diff -Nru clamav-0.99.2+dfsg/aclocal.m4 clamav-0.99.3~beta1+dfsg/aclocal.m4 --- clamav-0.99.2+dfsg/aclocal.m4 2016-04-22 16:19:42.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/aclocal.m4 2017-06-23 21:20:28.000000000 +0000 @@ -1331,6 +1331,7 @@ m4_include([m4/lib-ld.m4]) m4_include([m4/lib-link.m4]) m4_include([m4/lib-prefix.m4]) +m4_include([m4/lib-prelude.m4]) m4_include([m4/libtool.m4]) m4_include([m4/llvm.m4]) m4_include([m4/ltargz.m4]) diff -Nru clamav-0.99.2+dfsg/ChangeLog clamav-0.99.3~beta1+dfsg/ChangeLog --- clamav-0.99.2+dfsg/ChangeLog 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/ChangeLog 2017-07-20 21:05:27.000000000 +0000 @@ -1,3 +1,823 @@ +Thu, 20 Jul 2017 12:10:38 -0400 (Mickey Sola) +------------------------------------------ + * 11874 - fixing OOB read in cabd + +Wed, 19 Jul 2017 12:14:24 -0400 (Steven Morgan) +------------------------------------------ + * ClamAV 0.99.3-beta1 NEWS and README. + +Fri, 7 Jul 2017 17:28:14 +0000 (Sebastian Andrzej Siewior) +------------------------------------------ + * fts: use AC_COMPILE_IFELSE instead AC_TRY_RUN + +Thu, 29 Jun 2017 14:02:03 -0400 (Mickey Sola) +------------------------------------------ + * unrar - adding proposed changes to fix RAR VMSF_DELTA Filter Signedness error + +Mon, 26 Jun 2017 13:30:57 -0400 (Mickey Sola) +------------------------------------------ + * onas - changing sizelimit to unsigned int to allow for wider scan ranges + +Wed, 21 Jun 2017 15:53:14 -0400 (Mickey Sola) +------------------------------------------ + * bc - adding bc_idx sanity check when running bc lsigs + +Tue, 20 Jun 2017 17:15:15 -0400 (Steven Morgan) +------------------------------------------ + * fix cli_bcapi_extract_new() return code path virus reporting. + +Mon, 19 Jun 2017 15:41:17 -0400 (Mickey Sola) +------------------------------------------ + * bb11625 - adding heuristic check for XZ dictionary size evasion + +wMon, 12 Jun 2017 17:16:44 -0400 (Mickey Sola) +------------------------------------------ + * mspack - simplifying libclamav debug stamp and fixing errors when configuring the library with en + +Mon, 12 Jun 2017 14:43:13 -0400 (Mickey Sola) +------------------------------------------ + * mspack - adding custom clam debug output for internal mspack + +Wed, 31 May 2017 11:20:11 -0400 (Steven Morgan) +------------------------------------------ + * fix for 0.99.3 false negative of Andr.Trojan.SMSsend-2. + +Tue, 23 May 2017 15:56:41 -0400 (Steven Morgan) +------------------------------------------ + * fix 0.99.3 false negative of virus Pdf.Exploit.CVE_2016_1046-1. + +Fri, 19 May 2017 13:38:51 -0400 (Steven Morgan) +------------------------------------------ + * re-split/regenerate make check's test files. + +Wed, 10 May 2017 16:51:16 -0400 (Steven Morgan) +------------------------------------------ + * fix for amp allmatch. + +Wed, 26 Apr 2017 18:10:57 -0400 (Steven Morgan) +------------------------------------------ + * Fix for regression FN's. + +Fri, 21 Apr 2017 11:50:47 -0400 (Mickey Sola) +------------------------------------------ + * pe - correcting memory loss caused by double string allocation + +Tue, 18 Apr 2017 12:03:36 -0400 (Steven Morgan) +------------------------------------------ + * bb11805 fix multiple results. Refactor false positive and heuristic precedence logic. + +Mon, 16 Nov 2015 22:19:16 +0100 (Sebastian Andrzej Siewior) +------------------------------------------ + * clamav: add private fts() implementation + +Wed, 1 Feb 2017 16:59:54 -0500 (Mickey Sola) +------------------------------------------ + * Configure with largefile size when using internal mspack + +Wed, 29 Mar 2017 14:55:26 -0400 (Mickey Sola) +------------------------------------------ + * fixing potential OOB window write when unpacking chm files + +Thu, 16 Mar 2017 15:06:09 -0400 (Steven Morgan) +------------------------------------------ + * bb11803 - Fix pdf out of bound reference. + +Thu, 9 Mar 2017 15:11:56 -0500 (Steven Morgan) +------------------------------------------ + * fix imphash 'thunk' processing due to unit test check1_clamscan fail. + +Wed, 8 Mar 2017 08:58:28 -0500 (Steven Morgan) +------------------------------------------ + * bb11798 - fix unit tests. + +Fri, 3 Mar 2017 13:56:28 -0500 (Steven Morgan) +------------------------------------------ + * bb19798 - fix out of bound memory access for crafted wwunpack file. + +Thu, 2 Mar 2017 14:41:20 -0500 (Steven Morgan) +------------------------------------------ + * bb11797 - fix invalid read in fuzzed mail file. + +Thu, 2 Mar 2017 09:44:09 -0500 (Steven Morgan) +------------------------------------------ + * Autotool fixes for libiconv. + +Wed, 1 Mar 2017 16:18:27 -0500 (Mickey Sola) +------------------------------------------ + * increasing size of pcre match limit + +Wed, 15 Feb 2017 14:25:29 -0500 (Steven Morgan) +------------------------------------------ + * bb11751 fix compile error in entconv.c. + +Wed, 15 Feb 2017 14:07:50 -0500 (Steven Morgan) +------------------------------------------ + * bb11742 fix compile error in bytecode_api.c on Mac OS X. + +Tue, 14 Feb 2017 15:06:12 -0500 (Steven Morgan) +------------------------------------------ + * bb11750 Fix compile warning in special.c. + +Tue, 14 Feb 2017 14:53:33 -0500 (Steven Morgan) +------------------------------------------ + * bb11749 Fix compile warning in hfsplus.c on Mac OS X. Patch supplied by Ruga. + +Tue, 14 Feb 2017 14:31:23 -0500 (Steven Morgan) +------------------------------------------ + * bb11748 Fix compile warning is regex_pcre.c on Mac OS X. + +Tue, 14 Feb 2017 14:16:18 -0500 (Steven Morgan) +------------------------------------------ + * bb11746 Fix compile warning in spin.c. Patch by Ruga. + +Tue, 14 Feb 2017 14:04:52 -0500 (Steven Morgan) +------------------------------------------ + * bb11745 Fix compile warning. Patch by Ruga. + +Fri, 10 Feb 2017 13:52:16 -0500 (Steven Morgan) +------------------------------------------ + * bb11744 - fix compiler warnings on Mac OS X. + +Fri, 10 Feb 2017 12:59:23 -0500 (Steven Morgan) +------------------------------------------ + * bb11743 - fix compiler warning. Patch contributed by Ruga. + +Fri, 10 Feb 2017 12:53:24 -0500 (Steven Morgan) +------------------------------------------ + * bb11742 - fix compiler warnings. Patch contributed by Ruga. + +Wed, 8 Feb 2017 15:00:54 -0500 (Steven Morgan) +------------------------------------------ + * bb11741 - fix compiler warnings due to STAT64_BLACKLIST. Patch supplied by Ruga. + +Tue, 7 Feb 2017 13:27:15 -0500 (Steven Morgan) +------------------------------------------ + * bb11548 fix clamsubmit. + +Thu, 2 Feb 2017 12:40:08 -0500 (klin) +------------------------------------------ + * updated documentation for 'Intermediates' TDB option (#5) + +Wed, 1 Feb 2017 17:29:27 -0500 (Mickey Sola) +------------------------------------------ + * Fixes and updates to intermediate container sig rules based on code review + +on, 23 Jan 2017 13:11:03 -0500 (Kevin Lin) +------------------------------------------ + * add 'Intermediates' field to target description block (allows specification of any number of intermediate containers) + +Tue, 17 Jan 2017 12:27:07 -0500 (Steven Morgan) +------------------------------------------ + * fix file descriptor leak for msxml documents - patch from Chris Miserva. + +Thu, 5 Jan 2017 17:23:46 -0500 (Steven Morgan) +------------------------------------------ + * bb11703 - compile pcre with NO_RECURSE on windows. + +Thu, 5 Jan 2017 12:30:35 -0500 (Steven Morgan) +------------------------------------------ + * bb111711 - fix zlib version check - patch by Daniel J. Luke. + +Wed, 4 Jan 2017 13:20:29 -0500 (Steven Morgan) +------------------------------------------ + * Fix uninitialized variable issue when scanning file properties with libjson not configured. + +Thu, 22 Dec 2016 17:53:40 -0500 (Steven Morgan) +------------------------------------------ + * Add missing OS identifier os_generic. + +Wed, 21 Dec 2016 17:16:39 -0500 (Steven Morgan) +------------------------------------------ + * Change Windows build to use OpenSSL 1.1.0.c + +Thu, 15 Dec 2016 11:46:40 -0500 (Steven Morgan) +------------------------------------------ + * clamdscan - add an error message when local socket connection fails. + +Wed, 14 Dec 2016 18:12:37 -0500 (Steven Morgan) +------------------------------------------ + * clamdscan - check that the TCPAddr parameter is enabled before using. + +Wed, 14 Dec 2016 13:29:00 -0500 (Steven Morgan) +------------------------------------------ + * bb11601 - revise buffer limit check due. + +Wed, 16 Nov 2016 11:45:03 -0500 (Mickey Sola) +------------------------------------------ + * bb11062 - updated libmspack missing script to warn only and included more prescient advice + +Tue, 15 Nov 2016 11:54:25 -0500 (Mickey Sola) +------------------------------------------ + * bb11062 - loosening libmspack automake strictness and enabling maintainer mode to mitigate timestamp mangling + +Wed, 9 Nov 2016 13:12:19 -0500 (Steven Morgan) +------------------------------------------ + * Whitespace commit to prevent ClamAV build from invoking yacc/bison. + +Tue, 8 Nov 2016 11:57:16 -0500 (Mickey Sola) +------------------------------------------ + * bb11062 - link against libmspack libtool objects + +Tue, 8 Nov 2016 11:38:57 -0500 (Steven Morgan) +------------------------------------------ + * bb11684 - consistently set file size for yara condition handling. + +Thu, 3 Nov 2016 16:58:11 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - add autom4te cache to repo + +Thu, 3 Nov 2016 14:23:37 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - defaulting build to internal libmspack and creating configure option to specify use of external library + +Fri, 21 Oct 2016 17:05:45 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - require internal libmspack for make distcheck + +Fri, 28 Oct 2016 16:14:31 -0400 (Steven Morgan) +------------------------------------------ + * bb11677 - release mpool memory with mpool_free(), not free(). + +Mon, 24 Oct 2016 18:03:36 -0400 (Steven Morgan) +------------------------------------------ + * bb11639 - for VBA, run bytecodes and lsigs against decompressed VBA objects rather than the raw VBA project. + +Wed, 19 Oct 2016 16:33:48 -0400 (Steven Morgan) +------------------------------------------ + * pull request #53(4/4): Spelling fix by klemens(ka7). + +Wed, 19 Oct 2016 16:04:25 -0400 (Steven Morgan) +------------------------------------------ + * pull request #53(3/4): Spelling fix by klemens(ka7). + +Wed, 19 Oct 2016 15:57:45 -0400 (Steven Morgan) +------------------------------------------ + * pull request #53(2/4): Spelling fix by klemens(ka7). + +Wed, 19 Oct 2016 12:26:33 -0400 (Steven Morgan) +------------------------------------------ + * pull request #53(1/4): Spelling fix by klemens(ka7). + +Wed, 19 Oct 2016 11:19:08 -0400 (Steven Morgan) +------------------------------------------ + * pull request #62: Fix typos in log messages from Matthew Boedicker. + +Mon, 17 Oct 2016 11:10:31 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - remove libmspack artifacts from upstream + +Mon, 17 Oct 2016 11:07:18 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - make make distcheck work with internal libmspack + +Wed, 12 Oct 2016 18:16:51 -0400 (Steven Morgan) +------------------------------------------ + * bb17595 (FireAmp) - add sigtool support for building fp-only virus databases. + +Tue, 11 Oct 2016 17:48:58 -0400 (Steven Morgan) +------------------------------------------ + * bb17169 - compute MD5 file hashsums when using wildcard hdb signatures with caching disabled. + +Mon, 10 Oct 2016 16:50:38 -0400 (Steven Morgan) +------------------------------------------ + * bb11349 - patch from Michael Pelletier to fix compilation on HP-UX 11.11. + +Mon, 19 Sep 2016 11:50:43 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - removing configure option print-multi-os-directory + +Thu, 15 Sep 2016 16:04:21 -0400 (Mickey Sola) +------------------------------------------ + * bb1062 - simplifying configuration and compilation of internal libmspack + +Mon, 12 Sep 2016 14:54:27 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - including new dlls in setup redistributables + +Mon, 12 Sep 2016 14:34:52 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - adding compilation batch script to allow for proper windows env configuration + +Thu, 8 Sep 2016 13:52:34 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - updating libclamav.vcxproj to properly include 64bit mspack dlls + +Thu, 8 Sep 2016 13:04:43 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - updating libmspack windows installer to automate clamdep setup + +Mon, 22 Aug 2016 17:50:35 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - removing unnecessary include of mspack's system.h + +Mon, 22 Aug 2016 15:43:17 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - convert use of fseeko and ftello functions to meet vs2015 compatibility + +Mon, 22 Aug 2016 15:41:02 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - provide libmspack .lib path to vs2015 linker + +Mon, 22 Aug 2016 15:39:06 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - link libmspack dll + +Wed, 17 Aug 2016 18:06:11 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - modifying libmspack.c macros and casts for VS 2015 compatibility + +Wed, 20 Jul 2016 14:21:01 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - adding idmef_logging references to clamd vs2015 proj + +Thu, 14 Jul 2016 14:43:12 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - add libmspack.c to vs2015 libclamav solution + +Thu, 7 Jul 2016 14:59:47 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - removing old mspack references from VS2015 vcxproj files + +Wed, 6 Jul 2016 17:28:17 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - adding mspack.def file + +Tue, 5 Jul 2016 14:10:40 -0400 (Mickey Sola) +------------------------------------------ + * bb-11062 - adding winbuild script + +Tue, 5 Jul 2016 11:20:55 -0400 (Mickey Sola) +------------------------------------------ + * bb-11062 - cleanup scanners.c conflict + +Tue, 5 Jul 2016 11:13:38 -0400 (Mickey Sola) +------------------------------------------ + * bb-11062 - cleanup makefile conflicts + +Tue, 5 Jul 2016 10:39:02 -0400 (Mickey Sola) +------------------------------------------ + * bb-11062 - removing custom mspack.c + +Thu, 24 Mar 2016 12:26:04 -0400 (Mickey Sola) +------------------------------------------ + * bb11062 - adding support for external libmspack + +Wed, 24 Aug 2016 17:39:20 -0400 (Steven Morgan) +------------------------------------------ + * bb11522 - enable clamscan option --blockmax to flag files as virus Heuristic.Limits.Exceeded when --max-filesize, --max-scansize, or --max-recursion is exceeded. + +Thu, 14 Jul 2016 17:31:04 -0400 (Kevin Lin) +------------------------------------------ + * sigtool: patch hybrid cvd generation + +Sat, 13 Aug 2016 02:14:00 +0200 (tomime) +------------------------------------------ + * fixing NULL pointer dereference + +Thu, 11 Aug 2016 13:16:04 -0400 (Steven Morgan) +------------------------------------------ + * bb11618 - indicate virus Heuristic.Broken.Executable for an ELF file with a corrupted header. + +Wed, 10 Aug 2016 14:17:18 -0400 (Steven Morgan) +------------------------------------------ + * FireAMP bb17724: fix for CVE-2016-3189 for Windows build (win32/3rdparty/bzip2/bzip2recover.c). + +Tue, 9 Aug 2016 15:48:31 -0400 (Mickey Sola) +------------------------------------------ + * bb11594 - allow for compilation against openssl 1.1.0 + +Mon, 8 Aug 2016 17:26:38 -0400 (Mickey Sola) +------------------------------------------ + * bb11602 - correcting and simplifying fts_info check + +Mon, 8 Aug 2016 15:55:49 -0400 (Steven Morgan) +------------------------------------------ + * Apply patch from Craig Davidson to fix compilation on RHEL5/CentOS 5.11 with g++ 4.1.2. + +Fri, 5 Aug 2016 10:58:51 -0400 (Mickey Sola) +------------------------------------------ + * systemd - removing generated files from repository + +Tue, 26 Jul 2016 16:36:44 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: reduced stream dumping conditions to just leave-temps + fix warnings + +Tue, 26 Jul 2016 16:06:18 -0400 (Kevin Lin) +------------------------------------------ + * bb#11613 - dump vba project data to file with leave-temps + +Thu, 21 Jul 2016 15:36:11 -0400 (Mickey Sola) +------------------------------------------ + * bb11602 - fixing case where on access scanning would erroneously classify sockets and other objects as directories + +Thu, 14 Jul 2016 16:26:16 -0700 (Matthew Boedicker) +------------------------------------------ + * bb11605 - Update the error code to CL_ETMPFILE + +Wed, 13 Jul 2016 16:26:58 -0400 (Kevin Lin) +------------------------------------------ + * win32: fixes for sigtool imphash linking + +Wed, 13 Jul 2016 15:52:17 -0400 (Kevin Lin) +------------------------------------------ + * implement cli_strndup and cli_mpool_strndup + +Tue, 12 Jul 2016 11:53:59 -0400 (Kevin Lin) +------------------------------------------ + * imphash: code review and clean up + +Mon, 11 Jul 2016 16:25:37 -0400 (Kevin Lin) +------------------------------------------ + * imphash: yara copyright for pe_ordinal function + +Thu, 30 Jun 2016 17:29:49 -0400 (Kevin Lin) +------------------------------------------ + * imphash: refactor code for scanning and sigtool usage + +Thu, 30 Jun 2016 11:11:03 -0400 (Kevin Lin) +------------------------------------------ + * sig: convert .ith to .imp; add .imp to sigtool + +Wed, 29 Jun 2016 18:21:39 -0400 (Kevin Lin) +------------------------------------------ + * sigtool: properly generates and reports pe section hashes (mdb) + +Mon, 27 Jun 2016 17:55:16 -0400 (Kevin Lin) +------------------------------------------ + * imphash: dll and func name validation + +Mon, 27 Jun 2016 12:03:45 -0400 (Kevin Lin) +------------------------------------------ + * imptbl: macroize similar code; add size based on hashed data + +Wed, 22 Jun 2016 17:35:30 -0400 (Kevin Lin) +------------------------------------------ + * imptbl: general code clean-up and fixes + +Wed, 22 Jun 2016 16:39:42 -0400 (Kevin Lin) +------------------------------------------ + * dconf: support added for imptbl and imphash + +Wed, 22 Jun 2016 16:28:02 -0400 (Kevin Lin) +------------------------------------------ + * imphash: signature file support + +Wed, 22 Jun 2016 15:03:14 -0400 (Kevin Lin) +------------------------------------------ + * imptbl: add data collection for preclass + +Tue, 21 Jun 2016 17:17:40 -0400 (Kevin Lin) +------------------------------------------ + * imphash: add parsing of import table and calculate imphash + +Tue, 12 Jul 2016 12:46:16 -0400 (Kevin Lin) +------------------------------------------ + * matcher-ac: fix error case handling + +Wed, 13 Jul 2016 14:27:10 -0400 (Steven Morgan) +------------------------------------------ + * bb11601 - check array boundaries in unrarvm rarvm_getbits(). + +Tue, 12 Jul 2016 14:31:38 -0400 (Steven Morgan) +------------------------------------------ + * fix possible out of bounds stack read. + +Tue, 12 Jul 2016 12:36:29 -0400 (Steven Morgan) +------------------------------------------ + * bb11600 - fix out of bounds stack read. + +Fri, 8 Jul 2016 12:15:12 -0400 (Steven Morgan) +------------------------------------------ + * clean up file/memory in error case. + +Thu, 7 Jul 2016 16:27:47 -0600 (Anthony Chan) +------------------------------------------ + * Fix bug in msxml_parse_element which may leave behind empty temp file and leak a little memory + +Wed, 6 Jul 2016 18:00:29 -0400 (Kevin Lin) +------------------------------------------ + * win32: add missing libxml2 html source files + +Wed, 6 Jul 2016 17:27:25 -0400 (Kevin Lin) +------------------------------------------ + * mhtml: checks for html parsing support in libxml2 + +Tue, 5 Jul 2016 15:32:03 -0400 (Steven Morgan) +------------------------------------------ + * Additional documentation on using yara in ClamAV. + +Tue, 28 Jun 2016 17:39:06 -0400 (Steven Morgan) +------------------------------------------ + * bb11586 - change CL_TYPE_EPS to CL_TYPE_PS. + +Tue, 28 Jun 2016 15:18:30 -0400 (Kevin Lin) +------------------------------------------ + * bb#11587 - track linked bcs on matchers for target 7 normalization + +Tue, 28 Jun 2016 11:59:48 -0400 (Kevin Lin) +------------------------------------------ + * ole2: added debug message handler_otf stream -> tempfile + +Tue, 28 Jun 2016 11:37:31 -0400 (Steven Morgan) +------------------------------------------ + * bb11586 - add file type CL_TYPE_EPS for raw scan matching of PostScript files. + +Tue, 21 Jun 2016 17:22:52 -0400 (Steven Morgan) +------------------------------------------ + * bb11588 - fix out of bounds read. + +Tue, 21 Jun 2016 12:11:23 -0400 (Mickey Sola) +------------------------------------------ + * adding libltdl valgrind supression for newer distros + +Thu, 16 Jun 2016 11:02:21 -0400 (Mickey Sola) +------------------------------------------ + * fixing mbox parsing buffer reading issues + +Tue, 14 Jun 2016 17:11:41 -0400 (Kevin Lin) +------------------------------------------ + * bb#8239 - added offset check to prevent integer wrap + +Mon, 13 Jun 2016 14:44:36 -0400 (Mickey Sola) +------------------------------------------ + * bb11557 - prefer using opt value for userpwname + +Mon, 13 Jun 2016 12:42:01 -0400 (Steven Morgan) +------------------------------------------ + * pull request #56: Allow freshclam downloadmanager to return FC_UPTODATE if no update was required. + +Mon, 13 Jun 2016 11:16:39 -0400 (Mickey Sola) +------------------------------------------ + * bb11557 - freeing opts on exit after failed initgroups check + +Thu, 9 Jun 2016 14:06:23 -0400 (Steven Morgan) +------------------------------------------ + * bb11549 - fix temp file cleanup issue. + +Thu, 2 Jun 2016 11:54:01 -0400 (Mickey Sola) +------------------------------------------ + * bb11557 - drop AllowSupplementaryGroups option and make it default, patch by Sebastian A. Siewior + +Tue, 24 May 2016 15:04:51 -0400 (Mickey Sola) +------------------------------------------ + * updating prelude hook to work with allmatch + +Thu, 18 Jun 2015 09:33:04 +0200 (Ningirsu) +------------------------------------------ + * Adds a module to use Prelude and connect to a prelude manager + +Wed, 8 Jun 2016 16:25:34 -0400 (Steven Morgan) +------------------------------------------ + * bb11580 - make cli_matchmeta() respect allmatch. + +Thu, 2 Jun 2016 18:08:36 -0400 (Steven Morgan) +------------------------------------------ + * bb11471 - add clamscan parameter --normalize=no for yara compatibility. + +Thu, 2 Jun 2016 17:49:56 -0400 (Steven Morgan) +------------------------------------------ + * phishcheck: include trailing '/' in path names per safebrowsing url canonicalization spec. + +Thu, 2 Jun 2016 17:31:56 -0400 (Kevin Lin) +------------------------------------------ + * bb#11578 - adjustments to pointer last argument check (exclude hidden ctx) + +Thu, 2 Jun 2016 11:09:55 -0400 (Kevin Lin) +------------------------------------------ + * bb#11129 - applied unencoded '@' patch + +Fri, 27 May 2016 10:46:17 -0400 (Kevin Lin) +------------------------------------------ + * json_api: fix function redeclararations + +Thu, 26 May 2016 16:30:27 -0400 (Kevin Lin) +------------------------------------------ + * mhtml: reader memory fixes + +Thu, 26 May 2016 16:06:39 -0400 (Kevin Lin) +------------------------------------------ + * mhtml: add comment xml parser and general code clean up + +Tue, 24 May 2016 16:32:02 -0400 (Kevin Lin) +------------------------------------------ + * msxml_parser: suppress xml2 parser error and warnings to clamav debug + +Mon, 23 May 2016 16:08:05 -0400 (Kevin Lin) +------------------------------------------ + * msxml_parser: add custom callback data slot + +Fri, 20 May 2016 13:47:35 -0400 (Kevin Lin) +------------------------------------------ + * msxml_parser: change method of setting callback system; add comment_cb + +Thu, 19 May 2016 17:54:56 -0400 (Kevin Lin) +------------------------------------------ + * msxml_parser: flags for modifying reader usage (json, walk) + +Thu, 19 May 2016 17:24:53 -0400 (Kevin Lin) +------------------------------------------ + * mhtml: wrapper for xml parsing using libxml2 htmlparser + +Tue, 10 May 2016 18:53:59 -0400 (Kevin Lin) +------------------------------------------ + * mhtml: add preclass tracking for document body (attachments) + +Tue, 10 May 2016 18:46:32 -0400 (Kevin Lin) +------------------------------------------ + * message: add preclass tracking object to message structure + +Tue, 10 May 2016 18:43:42 -0400 (Kevin Lin) +------------------------------------------ + * jsonapi: add object ownership manipulation and deletion + +Tue, 3 May 2016 12:57:13 -0400 (Kevin Lin) +------------------------------------------ + * add mhtml files to preclass set + +Mon, 2 May 2016 17:32:03 -0400 (Kevin Lin) +------------------------------------------ + * MHTML: added filetype and switch case + +Thu, 26 May 2016 15:25:54 -0400 (Kevin Lin) +------------------------------------------ + * lzwdec: modify dictionary max code points and change state flags + +Wed, 25 May 2016 17:32:04 -0400 (Kevin Lin) +------------------------------------------ + * matcher: fix issue where filetyping may be lost + +Wed, 18 May 2016 16:59:48 -0400 (Kevin Lin) +------------------------------------------ + * bumped flevel to 83 + +Wed, 18 May 2016 14:16:43 -0400 (Mickey Sola) +------------------------------------------ + * bb11566 - added additional checks and more verbose error messages + +Tue, 17 May 2016 16:44:21 -0400 (Kevin Lin) +------------------------------------------ + * preclass: scanning condition includes ac_patterns and pcre_metas + +Tue, 17 May 2016 11:54:07 -0400 (Mickey Sola) +------------------------------------------ + * bb11566 - adding support for clamd socket directory creation at load time + +Wed, 11 May 2016 14:48:58 -0400 (Kevin Lin) +------------------------------------------ + * unzip: check for ctx value as requests do not supply a ctx + +Wed, 11 May 2016 11:28:01 -0400 (Kevin Lin) +------------------------------------------ + * autoreconf + +Wed, 11 May 2016 11:27:25 -0400 (Kevin Lin) +------------------------------------------ + * config: change bash-specific string manipulation + +Tue, 10 May 2016 16:44:36 -0400 (Steven Morgan) +------------------------------------------ + * bb11565 - return error for bad file type in cdb sigs & fix cab file name sanitizing. + +Mon, 9 May 2016 18:30:30 -0400 (Steven Morgan) +------------------------------------------ + * bb11561 - don't copy unmodified file-scheme custom databases. Patch by Stephen Welker. + +Mon, 9 May 2016 14:00:00 -0400 (Steven Morgan) +------------------------------------------ + * bb11564 - change CL_TYPE_CAB -> CL_TYPE_MSCAB in signatures manual. + +Mon, 9 May 2016 13:53:27 -0400 (Steven Morgan) +------------------------------------------ + * bb11560 - make cdb signatures also operate on central directory file names because they can differ from the file names in the local headers. + +Mon, 9 May 2016 13:43:45 -0400 (Steven Morgan) +------------------------------------------ + * bytecode_vm.c: fix compiler warning and reduce debug verbosity. + +Fri, 6 May 2016 16:00:04 -0400 (Kevin Lin) +------------------------------------------ + * config: fixed pcre version check bug + +Fri, 6 May 2016 12:35:13 -0400 (Kevin Lin) +------------------------------------------ + * make: change options for make distcheck + +Fri, 6 May 2016 11:53:43 -0400 (Kevin Lin) +------------------------------------------ + * config: non-sed method for verison string manipulation + +Wed, 4 May 2016 12:09:00 -0400 (Kevin Lin) +------------------------------------------ + * additional change of PCREMaxFileSize from MATCH_NUMBER to MATCH_SIZE + +Mon, 2 May 2016 15:45:01 -0400 (Kevin Lin) +------------------------------------------ + * config: unified llvm-opts handling, changed llvm defaults + +Wed, 20 Apr 2016 13:03:43 -0400 (Kevin Lin) +------------------------------------------ + * unit_tests: valgrind suppression for freebsd 11 dlopen invalid read + +Tue, 19 Apr 2016 12:49:57 -0400 (Kevin Lin) +------------------------------------------ + * bb#6451 - docs: add notes on cl_init macro + +Tue, 19 Apr 2016 11:22:38 -0400 (Kevin Lin) +------------------------------------------ + * win32: add lzw/lzwdec.c to source list + +Mon, 18 Apr 2016 17:11:59 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: return raw stream if no non-forced filters succeed + +Mon, 18 Apr 2016 17:11:12 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: do not apply forced decryption to /XRef streams + +Wed, 6 Apr 2016 16:47:26 -0400 (Mickey Sola) +------------------------------------------ + * bb11378 - updating ClamAV to support VS 2015, patch based on pull request by Keith Jones + +Mon, 18 Apr 2016 10:28:32 -0400 (Mickey Sola) +------------------------------------------ + * bb11553 - allowing sigtool to ignore comments in signature files + +Fri, 15 Apr 2016 11:28:40 -0400 (Kevin Lin) +------------------------------------------ + * pdf: add filter count heuristic + +Thu, 14 Apr 2016 17:09:27 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: reduce errmsg to dbgmsg for log reduction + +Thu, 14 Apr 2016 16:52:48 -0400 (Kevin Lin) +------------------------------------------ + * lzw: increase variable name consistency + +Thu, 14 Apr 2016 16:42:51 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: add dictionary heuristic and all-match support + +Thu, 14 Apr 2016 15:17:02 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: lzw dconf + +Wed, 13 Apr 2016 18:46:50 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: integrate lzw decompression + +Wed, 13 Apr 2016 18:45:34 -0400 (Kevin Lin) +------------------------------------------ + * implement lzw decompression, derived from tiff + +Wed, 13 Apr 2016 18:29:55 -0400 (Kevin Lin) +------------------------------------------ + * pdf: fix for locate DecodeParms for filters + +Tue, 5 Apr 2016 17:04:10 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: change various debug messages for clarity + +Tue, 5 Apr 2016 11:34:17 -0400 (Kevin Lin) +------------------------------------------ + * win32: add pdfdecode to source lists + +Fri, 1 Apr 2016 15:20:36 -0400 (Kevin Lin) +------------------------------------------ + * pdf: fix for '\r' in obj dictionary debug + +Wed, 30 Mar 2016 16:39:37 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: implement crypt filter handler + +Tue, 29 Mar 2016 12:52:08 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: implement rldecode filter handler + +Mon, 28 Mar 2016 13:16:17 -0400 (Kevin Lin) +------------------------------------------ + * pdf: filter order tracking implementation (max:64) + +Mon, 28 Mar 2016 11:53:40 -0400 (Kevin Lin) +------------------------------------------ + * pdfdecode: add new source for stream decoding (ascii85, asciihex, flate) + +Fri, 15 Apr 2016 12:02:36 -0400 (Kevin Lin) +------------------------------------------ + * bb#11551 - remove excess memory used by events + +Wed, 13 Apr 2016 13:16:24 -0400 (Kevin Lin) +------------------------------------------ + * matcher: perform regex match if ac has filetype detected + +Fri, 8 Apr 2016 14:15:00 -0400 (Steven Morgan) +------------------------------------------ + * fix clamsubmit autoconf. + +Wed, 30 Mar 2016 19:30:08 -0400 (Steven Morgan) +------------------------------------------ + * Add sigtool support for decoding *.ftm signatures (version 1). + Thu, 22 Apr 2016 12:45:00 -0500 (Steven Morgan) ------------------------------------------ * ClamAV 0.99.2 release. diff -Nru clamav-0.99.2+dfsg/clamav-config.h.in clamav-0.99.3~beta1+dfsg/clamav-config.h.in --- clamav-0.99.2+dfsg/clamav-config.h.in 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamav-config.h.in 2017-04-20 22:19:13.000000000 +0000 @@ -390,6 +390,9 @@ /* systemd is supported */ #undef HAVE_SYSTEMD +/* Use private fts() implementation which is LFS safe */ +#undef HAVE_SYSTEM_LFS_FTS + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_CDEFS_H @@ -520,6 +523,12 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION +/* Libprelude support enabled */ +#undef PRELUDE + +/* Define whether application use libtool >= 2.0 */ +#undef PRELUDE_APPLICATION_USE_LIBTOOL2 + /* scan buffer size */ #undef SCANBUFF @@ -600,9 +609,20 @@ `char[]'. */ #undef YYTEXT_POINTER +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ #undef _LARGEFILE_SOURCE +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + /* Define to 1 if on MINIX. */ #undef _MINIX diff -Nru clamav-0.99.2+dfsg/clamav-milter/clamav-milter.c clamav-0.99.3~beta1+dfsg/clamav-milter/clamav-milter.c --- clamav-0.99.2+dfsg/clamav-milter/clamav-milter.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamav-milter/clamav-milter.c 2016-10-13 15:45:43.000000000 +0000 @@ -298,28 +298,19 @@ return 1; } - if(optget(opts, "AllowSupplementaryGroups")->enabled) { #ifdef HAVE_INITGROUPS - if(initgroups(opt->strarg, user->pw_gid)) { - fprintf(stderr, "ERROR: initgroups() failed.\n"); - optfree(opts); - return 1; - } -#else - mprintf("!AllowSupplementaryGroups: initgroups() is not available, please disable AllowSupplementaryGroups\n"); + if(initgroups(opt->strarg, user->pw_gid)) { + fprintf(stderr, "ERROR: initgroups() failed.\n"); optfree(opts); return 1; -#endif - } else { -#ifdef HAVE_SETGROUPS - if(setgroups(1, &user->pw_gid)) { - fprintf(stderr, "ERROR: setgroups() failed.\n"); - optfree(opts); - return 1; - } -#endif } - +#elif HAVE_SETGROUPS + if(setgroups(1, &user->pw_gid)) { + fprintf(stderr, "ERROR: setgroups() failed.\n"); + optfree(opts); + return 1; + } +#endif if(setgid(user->pw_gid)) { fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid); optfree(opts); diff -Nru clamav-0.99.2+dfsg/clamav-milter/Makefile.in clamav-0.99.3~beta1+dfsg/clamav-milter/Makefile.in --- clamav-0.99.2+dfsg/clamav-milter/Makefile.in 2016-04-22 16:19:51.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamav-milter/Makefile.in 2017-06-23 21:20:54.000000000 +0000 @@ -107,10 +107,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -165,12 +166,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -355,6 +361,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -382,7 +390,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = $(top_builddir)/libclamav/libclamav_internal_utils.la @CLAMAV_MILTER_LIBS@ @THREAD_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -476,6 +493,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/clamav-milter/netcode.c clamav-0.99.3~beta1+dfsg/clamav-milter/netcode.c --- clamav-0.99.2+dfsg/clamav-milter/netcode.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamav-milter/netcode.c 2016-10-13 15:45:43.000000000 +0000 @@ -37,7 +37,9 @@ #include #include #include +#ifdef HAVE_SYS_SELECT_H #include +#endif #include #include #include diff -Nru clamav-0.99.2+dfsg/clambc/Makefile.in clamav-0.99.3~beta1+dfsg/clambc/Makefile.in --- clamav-0.99.2+dfsg/clambc/Makefile.in 2016-04-22 16:19:51.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clambc/Makefile.in 2017-06-23 21:20:54.000000000 +0000 @@ -88,10 +88,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -146,12 +147,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -291,6 +297,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -318,7 +326,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -412,6 +429,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/clamconf/Makefile.in clamav-0.99.3~beta1+dfsg/clamconf/Makefile.in --- clamav-0.99.2+dfsg/clamconf/Makefile.in 2016-04-22 16:19:51.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamconf/Makefile.in 2017-06-23 21:20:55.000000000 +0000 @@ -106,10 +106,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -164,12 +165,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -309,6 +315,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -336,7 +344,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMCONF_LIBS@ @CLAMD_LIBS@ @THREAD_LIBS@ @LIBCLAMAV_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -430,6 +447,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/clamd/clamd.c clamav-0.99.3~beta1+dfsg/clamd/clamd.c --- clamav-0.99.2+dfsg/clamd/clamd.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/clamd.c 2017-07-19 19:03:40.000000000 +0000 @@ -84,7 +84,7 @@ printf("\n"); printf(" Clam AntiVirus Daemon %s\n", get_version()); printf(" By The ClamAV Team: http://www.clamav.net/about.html#credits\n"); - printf(" (C) 2007-2015 Cisco Systems, Inc.\n\n"); + printf(" (C) 2007-2017 Cisco Systems, Inc.\n\n"); printf(" --help -h Show this help.\n"); printf(" --version -V Show version number.\n"); @@ -216,27 +216,19 @@ return 1; } - if(optget(opts, "AllowSupplementaryGroups")->enabled) { #ifdef HAVE_INITGROUPS - if(initgroups(opt->strarg, user->pw_gid)) { - fprintf(stderr, "ERROR: initgroups() failed.\n"); + if(initgroups(opt->strarg, user->pw_gid)) { + fprintf(stderr, "ERROR: initgroups() failed.\n"); optfree(opts); - return 1; - } -#else - mprintf("!AllowSupplementaryGroups: initgroups() is not available, please disable AllowSupplementaryGroups in %s\n", cfgfile); - optfree(opts); - return 1; -#endif - } else { -#ifdef HAVE_SETGROUPS - if(setgroups(1, &user->pw_gid)) { - fprintf(stderr, "ERROR: setgroups() failed.\n"); + return 1; + } +#elif HAVE_SETGROUPS + if(setgroups(1, &user->pw_gid)) { + fprintf(stderr, "ERROR: setgroups() failed.\n"); optfree(opts); return 1; - } + } #endif - } if(setgid(user->pw_gid)) { fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid); diff -Nru clamav-0.99.2+dfsg/clamd/fts.c clamav-0.99.3~beta1+dfsg/clamd/fts.c --- clamav-0.99.2+dfsg/clamd/fts.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/fts.c 2017-04-20 22:19:13.000000000 +0000 @@ -0,0 +1,1165 @@ +/* File tree traversal functions. + Copyright (C) 1994-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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; +#endif /* LIBC_SCCS and not lint */ + +#if HAVE_CONFIG_H +#include "clamav-config.h" +#endif + +#if defined(FANOTIFY) && defined(C_LINUX) + +#include +#include +#include +#include +#include +#include "priv_fts.h" +#include +#include +#include + +#define FTS_OPEN _priv_fts_open +#define FTS_CLOSE _priv_fts_close +#define FTS_READ _priv_fts_read +#define FTS_SET _priv_fts_set +#define FTS_CHILDREN _priv_fts_children +#define FTSOBJ FTS +#define FTSENTRY FTSENT +#define INO_T ino_t +#define STAT stat +#define LSTAT lstat + +#define internal_function +# define __set_errno(val) (errno = (val)) + +/* Largest alignment size needed, minus one. + Usually long double is the worst case. */ +#ifndef ALIGNBYTES +#define ALIGNBYTES (__alignof__ (long double) - 1) +#endif +/* Align P to that size. */ +#ifndef ALIGN +#define ALIGN(p) (((unsigned long int) (p) + ALIGNBYTES) & ~ALIGNBYTES) +#endif + +/* Support for the LFS API version. */ +#ifndef FTS_OPEN +#define FTS_OPEN fts_open +#define FTS_CLOSE fts_close +#define FTS_READ fts_read +#define FTS_SET fts_set +#define FTS_CHILDREN fts_children +# define FTSOBJ FTS +# define FTSENTRY FTSENT +# define INO_T ino_t +# define STAT stat +# define LSTAT lstat +#endif + +static FTSENTRY *fts_alloc (FTSOBJ *, const char *, size_t) internal_function; +static FTSENTRY *fts_build (FTSOBJ *, int) internal_function; +static void fts_lfree (FTSENTRY *) internal_function; +static void fts_load (FTSOBJ *, FTSENTRY *) internal_function; +static size_t fts_maxarglen (char * const *) internal_function; +static void fts_padjust (FTSOBJ *, FTSENTRY *) internal_function; +static int fts_palloc (FTSOBJ *, size_t) internal_function; +static FTSENTRY *fts_sort (FTSOBJ *, FTSENTRY *, int) internal_function; +static u_short fts_stat (FTSOBJ *, FTSENTRY *, int) internal_function; +static int fts_safe_changedir (FTSOBJ *, FTSENTRY *, int, const char *) + internal_function; + +#ifndef MAX +#define MAX(a, b) ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) +#endif + +#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) + +#define CLR(opt) (sp->fts_options &= ~(opt)) +#define ISSET(opt) (sp->fts_options & (opt)) +#define SET(opt) (sp->fts_options |= (opt)) + +#define FCHDIR(sp, fd) (!ISSET(FTS_NOCHDIR) && fchdir(fd)) + +/* fts_build flags */ +#define BCHILD 1 /* fts_children */ +#define BNAMES 2 /* fts_children, names only */ +#define BREAD 3 /* fts_read */ + +FTSOBJ * +FTS_OPEN (char * const *argv, int options, + int (*compar) (const FTSENTRY **, const FTSENTRY **)) +{ + FTSOBJ *sp; + FTSENTRY *p, *root; + int nitems; + FTSENTRY *parent = NULL; + FTSENTRY *tmp; + + /* Options check. */ + if (options & ~FTS_OPTIONMASK) { + __set_errno (EINVAL); + return (NULL); + } + + /* Allocate/initialize the stream */ + if ((sp = malloc((u_int)sizeof(FTSOBJ))) == NULL) + return (NULL); + memset(sp, 0, sizeof(FTSOBJ)); + sp->fts_compar = (int (*) (const void *, const void *)) compar; + sp->fts_options = options; + + /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ + if (ISSET(FTS_LOGICAL)) + SET(FTS_NOCHDIR); + + /* + * Start out with 1K of path space, and enough, in any case, + * to hold the user's paths. + */ +#ifndef MAXPATHLEN +#define MAXPATHLEN 1024 +#endif + size_t maxarglen = fts_maxarglen(argv); + if (fts_palloc(sp, MAX(maxarglen, MAXPATHLEN))) + goto mem1; + + /* Allocate/initialize root's parent. */ + if (*argv != NULL) { + if ((parent = fts_alloc(sp, "", 0)) == NULL) + goto mem2; + parent->fts_level = FTS_ROOTPARENTLEVEL; + } + + /* Allocate/initialize root(s). */ + for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) { + /* Don't allow zero-length paths. */ + size_t len = strlen(*argv); + if (len == 0) { + __set_errno (ENOENT); + goto mem3; + } + + p = fts_alloc(sp, *argv, len); + p->fts_level = FTS_ROOTLEVEL; + p->fts_parent = parent; + p->fts_accpath = p->fts_name; + p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW)); + + /* Command-line "." and ".." are real directories. */ + if (p->fts_info == FTS_DOT) + p->fts_info = FTS_D; + + /* + * If comparison routine supplied, traverse in sorted + * order; otherwise traverse in the order specified. + */ + if (compar) { + p->fts_link = root; + root = p; + } else { + p->fts_link = NULL; + if (root == NULL) + tmp = root = p; + else { + tmp->fts_link = p; + tmp = p; + } + } + } + if (compar && nitems > 1) + root = fts_sort(sp, root, nitems); + + /* + * Allocate a dummy pointer and make fts_read think that we've just + * finished the node before the root(s); set p->fts_info to FTS_INIT + * so that everything about the "current" node is ignored. + */ + if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL) + goto mem3; + sp->fts_cur->fts_link = root; + sp->fts_cur->fts_info = FTS_INIT; + + /* + * If using chdir(2), grab a file descriptor pointing to dot to ensure + * that we can get back here; this could be avoided for some paths, + * but almost certainly not worth the effort. Slashes, symbolic links, + * and ".." are all fairly nasty problems. Note, if we can't get the + * descriptor we run anyway, just more slowly. + */ + if (!ISSET(FTS_NOCHDIR) + && (sp->fts_rfd = open(".", O_RDONLY, 0)) < 0) + SET(FTS_NOCHDIR); + + return (sp); + +mem3: fts_lfree(root); + free(parent); +mem2: free(sp->fts_path); +mem1: free(sp); + return (NULL); +} + +static void +internal_function +fts_load (FTSOBJ *sp, FTSENTRY *p) +{ + int len; + char *cp; + + /* + * Load the stream structure for the next traversal. Since we don't + * actually enter the directory until after the preorder visit, set + * the fts_accpath field specially so the chdir gets done to the right + * place and the user can access the first node. From fts_open it's + * known that the path will fit. + */ + len = p->fts_pathlen = p->fts_namelen; + memmove(sp->fts_path, p->fts_name, len + 1); + if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { + len = strlen(++cp); + memmove(p->fts_name, cp, len + 1); + p->fts_namelen = len; + } + p->fts_accpath = p->fts_path = sp->fts_path; + sp->fts_dev = p->fts_dev; +} + +int +FTS_CLOSE (FTSOBJ *sp) +{ + FTSENTRY *freep, *p; + int saved_errno; + + /* + * This still works if we haven't read anything -- the dummy structure + * points to the root list, so we step through to the end of the root + * list which has a valid parent pointer. + */ + if (sp->fts_cur) { + for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { + freep = p; + p = p->fts_link != NULL ? p->fts_link : p->fts_parent; + free(freep); + } + free(p); + } + + /* Free up child linked list, sort array, path buffer. */ + if (sp->fts_child) + fts_lfree(sp->fts_child); + free(sp->fts_array); + free(sp->fts_path); + + /* Return to original directory, save errno if necessary. */ + if (!ISSET(FTS_NOCHDIR)) { + saved_errno = fchdir(sp->fts_rfd) ? errno : 0; + (void)close(sp->fts_rfd); + + /* Set errno and return. */ + if (saved_errno != 0) { + /* Free up the stream pointer. */ + free(sp); + __set_errno (saved_errno); + return (-1); + } + } + + /* Free up the stream pointer. */ + free(sp); + return (0); +} + +/* + * Special case of "/" at the end of the path so that slashes aren't + * appended which would cause paths to be written as "....//foo". + */ +#define NAPPEND(p) \ + (p->fts_path[p->fts_pathlen - 1] == '/' \ + ? p->fts_pathlen - 1 : p->fts_pathlen) + +FTSENTRY * +FTS_READ (FTSOBJ *sp) +{ + FTSENTRY *p, *tmp; + int instr; + char *t; + int saved_errno; + + /* If finished or unrecoverable error, return NULL. */ + if (sp->fts_cur == NULL || ISSET(FTS_STOP)) + return (NULL); + + /* Set current node pointer. */ + p = sp->fts_cur; + + /* Save and zero out user instructions. */ + instr = p->fts_instr; + p->fts_instr = FTS_NOINSTR; + + /* Any type of file may be re-visited; re-stat and re-turn. */ + if (instr == FTS_AGAIN) { + p->fts_info = fts_stat(sp, p, 0); + return (p); + } + + /* + * Following a symlink -- SLNONE test allows application to see + * SLNONE and recover. If indirecting through a symlink, have + * keep a pointer to current location. If unable to get that + * pointer, follow fails. + */ + if (instr == FTS_FOLLOW && + (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { + p->fts_info = fts_stat(sp, p, 1); + if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { + if ((p->fts_symfd = open(".", O_RDONLY, 0)) < 0) { + p->fts_errno = errno; + p->fts_info = FTS_ERR; + } else + p->fts_flags |= FTS_SYMFOLLOW; + } + return (p); + } + + /* Directory in pre-order. */ + if (p->fts_info == FTS_D) { + /* If skipped or crossed mount point, do post-order visit. */ + if (instr == FTS_SKIP || + (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { + if (p->fts_flags & FTS_SYMFOLLOW) + (void)close(p->fts_symfd); + if (sp->fts_child) { + fts_lfree(sp->fts_child); + sp->fts_child = NULL; + } + p->fts_info = FTS_DP; + return (p); + } + + /* Rebuild if only read the names and now traversing. */ + if (sp->fts_child != NULL && ISSET(FTS_NAMEONLY)) { + CLR(FTS_NAMEONLY); + fts_lfree(sp->fts_child); + sp->fts_child = NULL; + } + + /* + * Cd to the subdirectory. + * + * If have already read and now fail to chdir, whack the list + * to make the names come out right, and set the parent errno + * so the application will eventually get an error condition. + * Set the FTS_DONTCHDIR flag so that when we logically change + * directories back to the parent we don't do a chdir. + * + * If haven't read do so. If the read fails, fts_build sets + * FTS_STOP or the fts_info field of the node. + */ + if (sp->fts_child != NULL) { + if (fts_safe_changedir(sp, p, -1, p->fts_accpath)) { + p->fts_errno = errno; + p->fts_flags |= FTS_DONTCHDIR; + for (p = sp->fts_child; p != NULL; + p = p->fts_link) + p->fts_accpath = + p->fts_parent->fts_accpath; + } + } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) { + if (ISSET(FTS_STOP)) + return (NULL); + return (p); + } + p = sp->fts_child; + sp->fts_child = NULL; + sp->fts_cur = p; + goto name; + } + + /* Move to the next node on this level. */ +next: tmp = p; + if ((p = p->fts_link) != NULL) { + sp->fts_cur = p; + free(tmp); + + /* + * If reached the top, return to the original directory (or + * the root of the tree), and load the paths for the next root. + */ + if (p->fts_level == FTS_ROOTLEVEL) { + if (FCHDIR(sp, sp->fts_rfd)) { + SET(FTS_STOP); + return (NULL); + } + fts_load(sp, p); + return p; + } + + /* + * User may have called fts_set on the node. If skipped, + * ignore. If followed, get a file descriptor so we can + * get back if necessary. + */ + if (p->fts_instr == FTS_SKIP) + goto next; + if (p->fts_instr == FTS_FOLLOW) { + p->fts_info = fts_stat(sp, p, 1); + if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { + if ((p->fts_symfd = + open(".", O_RDONLY, 0)) < 0) { + p->fts_errno = errno; + p->fts_info = FTS_ERR; + } else + p->fts_flags |= FTS_SYMFOLLOW; + } + p->fts_instr = FTS_NOINSTR; + } + +name: t = sp->fts_path + NAPPEND(p->fts_parent); + *t++ = '/'; + memmove(t, p->fts_name, p->fts_namelen + 1); + return p; + } + + /* Move up to the parent node. */ + p = tmp->fts_parent; + sp->fts_cur = p; + free(tmp); + + if (p->fts_level == FTS_ROOTPARENTLEVEL) { + /* + * Done; free everything up and set errno to 0 so the user + * can distinguish between error and EOF. + */ + free(p); + __set_errno (0); + return (sp->fts_cur = NULL); + } + + /* NUL terminate the pathname. */ + sp->fts_path[p->fts_pathlen] = '\0'; + + /* + * Return to the parent directory. If at a root node or came through + * a symlink, go back through the file descriptor. Otherwise, cd up + * one directory. + */ + if (p->fts_level == FTS_ROOTLEVEL) { + if (FCHDIR(sp, sp->fts_rfd)) { + SET(FTS_STOP); + return (NULL); + } + } else if (p->fts_flags & FTS_SYMFOLLOW) { + if (FCHDIR(sp, p->fts_symfd)) { + saved_errno = errno; + (void)close(p->fts_symfd); + __set_errno (saved_errno); + SET(FTS_STOP); + return (NULL); + } + (void)close(p->fts_symfd); + } else if (!(p->fts_flags & FTS_DONTCHDIR) && + fts_safe_changedir(sp, p->fts_parent, -1, "..")) { + SET(FTS_STOP); + return (NULL); + } + p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP; + return p; +} + +/* + * Fts_set takes the stream as an argument although it's not used in this + * implementation; it would be necessary if anyone wanted to add global + * semantics to fts using fts_set. An error return is allowed for similar + * reasons. + */ +/* ARGSUSED */ +int +FTS_SET (FTSOBJ *sp, FTSENTRY *p, int instr) +{ + if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW && + instr != FTS_NOINSTR && instr != FTS_SKIP) { + __set_errno (EINVAL); + return (1); + } + p->fts_instr = instr; + return (0); +} + +FTSENTRY * +FTS_CHILDREN(FTSOBJ *sp, int instr) +{ + FTSENTRY *p; + int fd; + + if (instr != 0 && instr != FTS_NAMEONLY) { + __set_errno (EINVAL); + return (NULL); + } + + /* Set current node pointer. */ + p = sp->fts_cur; + + /* + * Errno set to 0 so user can distinguish empty directory from + * an error. + */ + __set_errno (0); + + /* Fatal errors stop here. */ + if (ISSET(FTS_STOP)) + return (NULL); + + /* Return logical hierarchy of user's arguments. */ + if (p->fts_info == FTS_INIT) + return (p->fts_link); + + /* + * If not a directory being visited in pre-order, stop here. Could + * allow FTS_DNR, assuming the user has fixed the problem, but the + * same effect is available with FTS_AGAIN. + */ + if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) + return (NULL); + + /* Free up any previous child list. */ + if (sp->fts_child != NULL) + fts_lfree(sp->fts_child); + + if (instr == FTS_NAMEONLY) { + SET(FTS_NAMEONLY); + instr = BNAMES; + } else + instr = BCHILD; + + /* + * If using chdir on a relative path and called BEFORE fts_read does + * its chdir to the root of a traversal, we can lose -- we need to + * chdir into the subdirectory, and we don't know where the current + * directory is, so we can't get back so that the upcoming chdir by + * fts_read will work. + */ + if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' || + ISSET(FTS_NOCHDIR)) + return (sp->fts_child = fts_build(sp, instr)); + + if ((fd = open(".", O_RDONLY, 0)) < 0) + return (NULL); + sp->fts_child = fts_build(sp, instr); + if (fchdir(fd)) + return (NULL); + (void)close(fd); + return (sp->fts_child); +} + +static inline int +dirent_not_directory(const struct dirent *dp) +{ +#if defined DT_DIR && defined _DIRENT_HAVE_D_TYPE + return dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN; +#else + return 0; +#endif +} + +/* + * This is the tricky part -- do not casually change *anything* in here. The + * idea is to build the linked list of entries that are used by fts_children + * and fts_read. There are lots of special cases. + * + * The real slowdown in walking the tree is the stat calls. If FTS_NOSTAT is + * set and it's a physical walk (so that symbolic links can't be directories), + * we can do things quickly. First, if it's a 4.4BSD file system, the type + * of the file is in the directory entry. Otherwise, we assume that the number + * of subdirectories in a node is equal to the number of links to the parent. + * The former skips all stat calls. The latter skips stat calls in any leaf + * directories and for any files after the subdirectories in the directory have + * been found, cutting the stat calls by about 2/3. + */ +static FTSENTRY * +internal_function +fts_build (FTSOBJ *sp, int type) +{ + struct dirent *dp; + FTSENTRY *p, *head; + int nitems; + FTSENTRY *cur, *tail; + DIR *dirp; + void *oldaddr; + int cderrno, descend, len, level, nlinks, saved_errno, + nostat, doadjust; + size_t maxlen; + char *cp; + + /* Set current node pointer. */ + cur = sp->fts_cur; + + /* + * Open the directory for reading. If this fails, we're done. + * If being called from fts_read, set the fts_info field. + */ +#if defined FTS_WHITEOUT && 0 + if (ISSET(FTS_WHITEOUT)) + oflag = DTF_NODUP|DTF_REWIND; + else + oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND; +#else +# define __opendir2(path, flag) opendir(path) +#endif + if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) { + if (type == BREAD) { + cur->fts_info = FTS_DNR; + cur->fts_errno = errno; + } + return (NULL); + } + + /* + * Nlinks is the number of possible entries of type directory in the + * directory if we're cheating on stat calls, 0 if we're not doing + * any stat calls at all, -1 if we're doing stats on everything. + */ + if (type == BNAMES) { + nlinks = 0; + /* Be quiet about nostat, GCC. */ + nostat = 0; + } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) { + nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2); + nostat = 1; + } else { + nlinks = -1; + nostat = 0; + } + +#ifdef notdef + (void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink); + (void)printf("NOSTAT %d PHYSICAL %d SEEDOT %d\n", + ISSET(FTS_NOSTAT), ISSET(FTS_PHYSICAL), ISSET(FTS_SEEDOT)); +#endif + /* + * If we're going to need to stat anything or we want to descend + * and stay in the directory, chdir. If this fails we keep going, + * but set a flag so we don't chdir after the post-order visit. + * We won't be able to stat anything, but we can still return the + * names themselves. Note, that since fts_read won't be able to + * chdir into the directory, it will have to return different path + * names than before, i.e. "a/b" instead of "b". Since the node + * has already been visited in pre-order, have to wait until the + * post-order visit to return the error. There is a special case + * here, if there was nothing to stat then it's not an error to + * not be able to stat. This is all fairly nasty. If a program + * needed sorted entries or stat information, they had better be + * checking FTS_NS on the returned nodes. + */ + cderrno = 0; + if (nlinks || type == BREAD) { + if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) { + if (nlinks && type == BREAD) + cur->fts_errno = errno; + cur->fts_flags |= FTS_DONTCHDIR; + descend = 0; + cderrno = errno; + (void)closedir(dirp); + dirp = NULL; + } else + descend = 1; + } else + descend = 0; + + /* + * Figure out the max file name length that can be stored in the + * current path -- the inner loop allocates more path as necessary. + * We really wouldn't have to do the maxlen calculations here, we + * could do them in fts_read before returning the path, but it's a + * lot easier here since the length is part of the dirent structure. + * + * If not changing directories set a pointer so that can just append + * each new name into the path. + */ + len = NAPPEND(cur); + if (ISSET(FTS_NOCHDIR)) { + cp = sp->fts_path + len; + *cp++ = '/'; + } else { + /* GCC, you're too verbose. */ + cp = NULL; + } + len++; + maxlen = sp->fts_pathlen - len; + + level = cur->fts_level + 1; + + /* Read the directory, attaching each entry to the `link' pointer. */ + doadjust = 0; + for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) { + if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) + continue; + + if ((p = fts_alloc(sp, dp->d_name, _D_EXACT_NAMLEN (dp))) == NULL) + goto mem1; + if (_D_EXACT_NAMLEN (dp) >= maxlen) {/* include space for NUL */ + oldaddr = sp->fts_path; + if (fts_palloc(sp, _D_EXACT_NAMLEN (dp) + len + 1)) { + /* + * No more memory for path or structures. Save + * errno, free up the current structure and the + * structures already allocated. + */ +mem1: saved_errno = errno; + free(p); + fts_lfree(head); + (void)closedir(dirp); + cur->fts_info = FTS_ERR; + SET(FTS_STOP); + __set_errno (saved_errno); + return (NULL); + } + /* Did realloc() change the pointer? */ + if (oldaddr != sp->fts_path) { + doadjust = 1; + if (ISSET(FTS_NOCHDIR)) + cp = sp->fts_path + len; + } + maxlen = sp->fts_pathlen - len; + } + + if (len + _D_EXACT_NAMLEN (dp) >= USHRT_MAX) { + /* + * In an FTSENT, fts_pathlen is a u_short so it is + * possible to wraparound here. If we do, free up + * the current structure and the structures already + * allocated, then error out with ENAMETOOLONG. + */ + free(p); + fts_lfree(head); + (void)closedir(dirp); + cur->fts_info = FTS_ERR; + SET(FTS_STOP); + __set_errno (ENAMETOOLONG); + return (NULL); + } + p->fts_level = level; + p->fts_parent = sp->fts_cur; + p->fts_pathlen = len + _D_EXACT_NAMLEN (dp); + +#if defined FTS_WHITEOUT && 0 + if (dp->d_type == DT_WHT) + p->fts_flags |= FTS_ISW; +#endif + + /* Unreachable code. cderrno is only ever set to a nonnull + value if dirp is closed at the same time. But then we + cannot enter this loop. */ + if (0 && cderrno) { + if (nlinks) { + p->fts_info = FTS_NS; + p->fts_errno = cderrno; + } else + p->fts_info = FTS_NSOK; + p->fts_accpath = cur->fts_accpath; + } else if (nlinks == 0 + || (nostat && dirent_not_directory(dp))) { + p->fts_accpath = + ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name; + p->fts_info = FTS_NSOK; + } else { + /* Build a file name for fts_stat to stat. */ + if (ISSET(FTS_NOCHDIR)) { + p->fts_accpath = p->fts_path; + memmove(cp, p->fts_name, p->fts_namelen + 1); + } else + p->fts_accpath = p->fts_name; + /* Stat it. */ + p->fts_info = fts_stat(sp, p, 0); + + /* Decrement link count if applicable. */ + if (nlinks > 0 && (p->fts_info == FTS_D || + p->fts_info == FTS_DC || p->fts_info == FTS_DOT)) + --nlinks; + } + + /* We walk in directory order so "ls -f" doesn't get upset. */ + p->fts_link = NULL; + if (head == NULL) + head = tail = p; + else { + tail->fts_link = p; + tail = p; + } + ++nitems; + } + if (dirp) + (void)closedir(dirp); + + /* + * If realloc() changed the address of the path, adjust the + * addresses for the rest of the tree and the dir list. + */ + if (doadjust) + fts_padjust(sp, head); + + /* + * If not changing directories, reset the path back to original + * state. + */ + if (ISSET(FTS_NOCHDIR)) { + if (len == sp->fts_pathlen || nitems == 0) + --cp; + *cp = '\0'; + } + + /* + * If descended after called from fts_children or after called from + * fts_read and nothing found, get back. At the root level we use + * the saved fd; if one of fts_open()'s arguments is a relative path + * to an empty directory, we wind up here with no other way back. If + * can't get back, we're done. + */ + if (descend && (type == BCHILD || !nitems) && + (cur->fts_level == FTS_ROOTLEVEL ? + FCHDIR(sp, sp->fts_rfd) : + fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { + cur->fts_info = FTS_ERR; + SET(FTS_STOP); + fts_lfree(head); + return (NULL); + } + + /* If didn't find anything, return NULL. */ + if (!nitems) { + if (type == BREAD) + cur->fts_info = FTS_DP; + fts_lfree(head); + return (NULL); + } + + /* Sort the entries. */ + if (sp->fts_compar && nitems > 1) + head = fts_sort(sp, head, nitems); + return (head); +} + +static u_short +internal_function +fts_stat (FTSOBJ *sp, FTSENTRY *p, int follow) +{ + FTSENTRY *t; + dev_t dev; + INO_T ino; + struct STAT *sbp, sb; + int saved_errno; + + /* If user needs stat info, stat buffer already allocated. */ + sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp; + +#if defined FTS_WHITEOUT && 0 + /* check for whiteout */ + if (p->fts_flags & FTS_ISW) { + if (sbp != &sb) { + memset(sbp, '\0', sizeof (*sbp)); + sbp->st_mode = S_IFWHT; + } + return (FTS_W); + } +#endif + + /* + * If doing a logical walk, or application requested FTS_FOLLOW, do + * a stat(2). If that fails, check for a non-existent symlink. If + * fail, set the errno from the stat call. + */ + if (ISSET(FTS_LOGICAL) || follow) { + if (STAT(p->fts_accpath, sbp)) { + saved_errno = errno; + if (!LSTAT(p->fts_accpath, sbp)) { + __set_errno (0); + return (FTS_SLNONE); + } + p->fts_errno = saved_errno; + goto err; + } + } else if (LSTAT(p->fts_accpath, sbp)) { + p->fts_errno = errno; +err: memset(sbp, 0, sizeof(struct STAT)); + return (FTS_NS); + } + + if (S_ISDIR(sbp->st_mode)) { + /* + * Set the device/inode. Used to find cycles and check for + * crossing mount points. Also remember the link count, used + * in fts_build to limit the number of stat calls. It is + * understood that these fields are only referenced if fts_info + * is set to FTS_D. + */ + dev = p->fts_dev = sbp->st_dev; + ino = p->fts_ino = sbp->st_ino; + p->fts_nlink = sbp->st_nlink; + + if (ISDOT(p->fts_name)) + return (FTS_DOT); + + /* + * Cycle detection is done by brute force when the directory + * is first encountered. If the tree gets deep enough or the + * number of symbolic links to directories is high enough, + * something faster might be worthwhile. + */ + for (t = p->fts_parent; + t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent) + if (ino == t->fts_ino && dev == t->fts_dev) { + p->fts_cycle = t; + return (FTS_DC); + } + return (FTS_D); + } + if (S_ISLNK(sbp->st_mode)) + return (FTS_SL); + if (S_ISREG(sbp->st_mode)) + return (FTS_F); + return (FTS_DEFAULT); +} + +static FTSENTRY * +internal_function +fts_sort (FTSOBJ *sp, FTSENTRY *head, int nitems) +{ + FTSENTRY **ap, *p; + + /* + * Construct an array of pointers to the structures and call qsort(3). + * Reassemble the array in the order returned by qsort. If unable to + * sort for memory reasons, return the directory entries in their + * current order. Allocate enough space for the current needs plus + * 40 so don't realloc one entry at a time. + */ + if (nitems > sp->fts_nitems) { + FTSENTRY **a; + + sp->fts_nitems = nitems + 40; + if ((a = realloc(sp->fts_array, + (size_t)(sp->fts_nitems * sizeof(FTSENTRY *)))) == NULL) { + free(sp->fts_array); + sp->fts_array = NULL; + sp->fts_nitems = 0; + return (head); + } + sp->fts_array = a; + } + for (ap = sp->fts_array, p = head; p; p = p->fts_link) + *ap++ = p; + qsort((void *)sp->fts_array, nitems, sizeof(FTSENTRY *), sp->fts_compar); + for (head = *(ap = sp->fts_array); --nitems; ++ap) + ap[0]->fts_link = ap[1]; + ap[0]->fts_link = NULL; + return (head); +} + +static FTSENTRY * +internal_function +fts_alloc (FTSOBJ *sp, const char *name, size_t namelen) +{ + FTSENTRY *p; + size_t len; + + /* + * The file name is a variable length array and no stat structure is + * necessary if the user has set the nostat bit. Allocate the FTSENT + * structure, the file name and the stat structure in one chunk, but + * be careful that the stat structure is reasonably aligned. Since the + * fts_name field is declared to be of size 1, the fts_name pointer is + * namelen + 2 before the first possible address of the stat structure. + */ + len = sizeof(FTSENTRY) + namelen; + if (!ISSET(FTS_NOSTAT)) + len += sizeof(struct STAT) + ALIGNBYTES; + if ((p = malloc(len)) == NULL) + return (NULL); + + /* Copy the name and guarantee NUL termination. */ + memmove(p->fts_name, name, namelen); + p->fts_name[namelen] = '\0'; + + if (!ISSET(FTS_NOSTAT)) + p->fts_statp = (struct STAT *)ALIGN(p->fts_name + namelen + 2); + p->fts_namelen = namelen; + p->fts_path = sp->fts_path; + p->fts_errno = 0; + p->fts_flags = 0; + p->fts_instr = FTS_NOINSTR; + p->fts_number = 0; + p->fts_pointer = NULL; + return (p); +} + +static void +internal_function +fts_lfree (FTSENTRY *head) +{ + FTSENTRY *p; + + /* Free a linked list of structures. */ + while ((p = head)) { + head = head->fts_link; + free(p); + } +} + +/* + * Allow essentially unlimited paths; find, rm, ls should all work on any tree. + * Most systems will allow creation of paths much longer than MAXPATHLEN, even + * though the kernel won't resolve them. Add the size (not just what's needed) + * plus 256 bytes so don't realloc the path 2 bytes at a time. + */ +static int +internal_function +fts_palloc (FTSOBJ *sp, size_t more) +{ + char *p; + + sp->fts_pathlen += more + 256; + /* + * Check for possible wraparound. In an FTS, fts_pathlen is + * a signed int but in an FTSENT it is an unsigned short. + * We limit fts_pathlen to USHRT_MAX to be safe in both cases. + */ + if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) { + free(sp->fts_path); + sp->fts_path = NULL; + __set_errno (ENAMETOOLONG); + return (1); + } + p = realloc(sp->fts_path, sp->fts_pathlen); + if (p == NULL) { + free(sp->fts_path); + sp->fts_path = NULL; + return 1; + } + sp->fts_path = p; + return 0; +} + +/* + * When the path is realloc'd, have to fix all of the pointers in structures + * already returned. + */ +static void +internal_function +fts_padjust (FTSOBJ *sp, FTSENTRY *head) +{ + FTSENTRY *p; + char *addr = sp->fts_path; + +#define ADJUST(p) do { \ + if ((p)->fts_accpath != (p)->fts_name) { \ + (p)->fts_accpath = \ + (char *)addr + ((p)->fts_accpath - (p)->fts_path); \ + } \ + (p)->fts_path = addr; \ +} while (0) + /* Adjust the current set of children. */ + for (p = sp->fts_child; p; p = p->fts_link) + ADJUST(p); + + /* Adjust the rest of the tree, including the current level. */ + for (p = head; p->fts_level >= FTS_ROOTLEVEL;) { + ADJUST(p); + p = p->fts_link ? p->fts_link : p->fts_parent; + } +} + +static size_t +internal_function +fts_maxarglen (char * const *argv) +{ + size_t len, max; + + for (max = 0; *argv; ++argv) + if ((len = strlen(*argv)) > max) + max = len; + return (max + 1); +} + +/* + * Change to dir specified by fd or p->fts_accpath without getting + * tricked by someone changing the world out from underneath us. + * Assumes p->fts_dev and p->fts_ino are filled in. + */ +static int +internal_function +fts_safe_changedir (FTSOBJ *sp, FTSENTRY *p, int fd, const char *path) +{ + int ret, oerrno, newfd; + struct stat sb; + + newfd = fd; + if (ISSET(FTS_NOCHDIR)) + return (0); + if (fd < 0 && (newfd = open(path, O_RDONLY, 0)) < 0) + return (-1); + if (fstat(newfd, &sb)) { + ret = -1; + goto bail; + } + if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) { + __set_errno (ENOENT); /* disinformation */ + ret = -1; + goto bail; + } + ret = fchdir(newfd); +bail: + oerrno = errno; + if (fd < 0) + (void)close(newfd); + __set_errno (oerrno); + return (ret); +} +#endif diff -Nru clamav-0.99.2+dfsg/clamd/localserver.c clamav-0.99.3~beta1+dfsg/clamd/localserver.c --- clamav-0.99.2+dfsg/clamd/localserver.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/localserver.c 2017-07-31 18:34:32.000000000 +0000 @@ -25,6 +25,37 @@ #include #include +#if defined(C_SOLARIS) +size_t strnlen(const char *s, size_t n) __attribute__((weak)); +size_t strnlen(const char *s, size_t n) +{ + size_t i = 0; + for(; (i < n) && s[i] != '\0'; ++i); + return i; +} + +char *strndup(const char *s, size_t n) __attribute__((weak)); +char *strndup(const char *s, size_t n) +{ + char *alloc; + size_t len; + + if(!s) { + return NULL; + } + + len = strnlen(s, n); + alloc = malloc(len+1); + + if(!alloc) { + return NULL; + } else + memcpy(alloc, s, len); + + alloc[len] = '\0'; + return alloc; +} +#endif #include #ifndef _WIN32 #include @@ -61,6 +92,10 @@ int sockfd, backlog; STATBUF foo; char *estr; + char *sockdir; + char *pos; + struct stat sb; + int cnt; int num_fd = sd_listen_fds(0); if (num_fd > 2) @@ -100,6 +135,52 @@ strncpy(server.sun_path, optget(opts, "LocalSocket")->strarg, sizeof(server.sun_path)); server.sun_path[sizeof(server.sun_path)-1]='\0'; + pos = NULL; + if ((pos = strstr(server.sun_path, "/")) && (pos = strstr(((char*) pos + 1), "/"))) { + cnt = 0; + sockdir = NULL; + pos = server.sun_path + strlen(server.sun_path); + while (pos != server.sun_path) { + if (*pos == '/') { + sockdir = strndup(server.sun_path, strlen(server.sun_path) - cnt); + break; + } + else { + pos--; + cnt++; + } + } + + if (stat(sockdir, &sb)) { + if (errno == ENOENT) { + mode_t sock_mode; + if(optget(opts, "LocalSocketMode")->enabled) { + char *end; + sock_mode = strtol(optget(opts, "LocalSocketMode")->strarg, &end, 8); + + if(*end) { + logg("!Invalid LocalSocketMode %s\n", optget(opts, "LocalSocketMode")->strarg); + free(sockdir); + return -1; + } + } else { + sock_mode = 0777; + } + + if (mkdir(sockdir, sock_mode)) { + logg("!LOCAL: Could not create socket directory: %s: %s\n", sockdir, strerror(errno)); + if (errno == ENOENT) { + logg("!LOCAL: Ensure parent directory exists.\n"); + } + } + else { + logg("Localserver: Creating socket directory: %s\n", sockdir); + } + } + } + free(sockdir); + } + if((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { estr = strerror(errno); logg("!LOCAL: Socket allocation error: %s\n", estr); diff -Nru clamav-0.99.2+dfsg/clamd/Makefile.am clamav-0.99.3~beta1+dfsg/clamd/Makefile.am --- clamav-0.99.2+dfsg/clamd/Makefile.am 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/Makefile.am 2017-04-20 22:19:13.000000000 +0000 @@ -23,6 +23,8 @@ clamd_SOURCES = \ $(top_srcdir)/shared/output.c \ $(top_srcdir)/shared/output.h \ + $(top_srcdir)/shared/idmef_logging.c \ + $(top_srcdir)/shared/idmef_logging.h \ $(top_srcdir)/shared/optparser.c \ $(top_srcdir)/shared/optparser.h \ $(top_srcdir)/shared/getopt.c \ @@ -52,7 +54,12 @@ onaccess_hash.c \ onaccess_hash.h \ onaccess_scth.c \ - onaccess_scth.h + onaccess_scth.h \ + priv_fts.h + +if !SYSTEM_LFS_FTS +clamd_SOURCES += fts.c +endif AM_CFLAGS=@WERR_CFLAGS@ diff -Nru clamav-0.99.2+dfsg/clamd/Makefile.in clamav-0.99.3~beta1+dfsg/clamd/Makefile.in --- clamav-0.99.2+dfsg/clamd/Makefile.in 2016-04-22 16:19:51.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/Makefile.in 2017-06-23 21:20:55.000000000 +0000 @@ -99,6 +99,7 @@ host_triplet = @host@ target_triplet = @target@ @BUILD_CLAMD_TRUE@sbin_PROGRAMS = clamd$(EXEEXT) +@BUILD_CLAMD_TRUE@@SYSTEM_LFS_FTS_FALSE@am__append_1 = fts.c subdir = clamd DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(srcdir)/clamav-daemon.service.in \ @@ -108,10 +109,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -166,12 +168,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -183,7 +190,10 @@ "$(DESTDIR)$(systemdsystemunitdir)" PROGRAMS = $(sbin_PROGRAMS) am__clamd_SOURCES_DIST = $(top_srcdir)/shared/output.c \ - $(top_srcdir)/shared/output.h $(top_srcdir)/shared/optparser.c \ + $(top_srcdir)/shared/output.h \ + $(top_srcdir)/shared/idmef_logging.c \ + $(top_srcdir)/shared/idmef_logging.h \ + $(top_srcdir)/shared/optparser.c \ $(top_srcdir)/shared/optparser.h $(top_srcdir)/shared/getopt.c \ $(top_srcdir)/shared/getopt.h $(top_srcdir)/shared/misc.c \ $(top_srcdir)/shared/misc.h clamd.c tcpserver.c tcpserver.h \ @@ -191,17 +201,19 @@ thrmgr.h server-th.c server.h scanner.c scanner.h others.c \ others.h shared.h onaccess_fan.c onaccess_fan.h onaccess_ddd.c \ onaccess_ddd.h onaccess_hash.c onaccess_hash.h onaccess_scth.c \ - onaccess_scth.h + onaccess_scth.h priv_fts.h fts.c +@BUILD_CLAMD_TRUE@@SYSTEM_LFS_FTS_FALSE@am__objects_1 = fts.$(OBJEXT) @BUILD_CLAMD_TRUE@am_clamd_OBJECTS = output.$(OBJEXT) \ -@BUILD_CLAMD_TRUE@ optparser.$(OBJEXT) getopt.$(OBJEXT) \ -@BUILD_CLAMD_TRUE@ misc.$(OBJEXT) clamd.$(OBJEXT) \ -@BUILD_CLAMD_TRUE@ tcpserver.$(OBJEXT) localserver.$(OBJEXT) \ -@BUILD_CLAMD_TRUE@ session.$(OBJEXT) thrmgr.$(OBJEXT) \ -@BUILD_CLAMD_TRUE@ server-th.$(OBJEXT) scanner.$(OBJEXT) \ -@BUILD_CLAMD_TRUE@ others.$(OBJEXT) onaccess_fan.$(OBJEXT) \ +@BUILD_CLAMD_TRUE@ idmef_logging.$(OBJEXT) optparser.$(OBJEXT) \ +@BUILD_CLAMD_TRUE@ getopt.$(OBJEXT) misc.$(OBJEXT) \ +@BUILD_CLAMD_TRUE@ clamd.$(OBJEXT) tcpserver.$(OBJEXT) \ +@BUILD_CLAMD_TRUE@ localserver.$(OBJEXT) session.$(OBJEXT) \ +@BUILD_CLAMD_TRUE@ thrmgr.$(OBJEXT) server-th.$(OBJEXT) \ +@BUILD_CLAMD_TRUE@ scanner.$(OBJEXT) others.$(OBJEXT) \ +@BUILD_CLAMD_TRUE@ onaccess_fan.$(OBJEXT) \ @BUILD_CLAMD_TRUE@ onaccess_ddd.$(OBJEXT) \ @BUILD_CLAMD_TRUE@ onaccess_hash.$(OBJEXT) \ -@BUILD_CLAMD_TRUE@ onaccess_scth.$(OBJEXT) +@BUILD_CLAMD_TRUE@ onaccess_scth.$(OBJEXT) $(am__objects_1) clamd_OBJECTS = $(am_clamd_OBJECTS) clamd_LDADD = $(LDADD) AM_V_lt = $(am__v_lt_@AM_V@) @@ -358,6 +370,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -385,7 +399,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMD_LIBS@ @THREAD_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -479,6 +502,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ @@ -506,40 +530,24 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -@BUILD_CLAMD_TRUE@clamd_SOURCES = \ -@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/output.c \ -@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/output.h \ -@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/optparser.c \ -@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/optparser.h \ -@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/getopt.c \ -@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/getopt.h \ -@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/misc.c \ -@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/misc.h \ -@BUILD_CLAMD_TRUE@ clamd.c \ -@BUILD_CLAMD_TRUE@ tcpserver.c \ -@BUILD_CLAMD_TRUE@ tcpserver.h \ -@BUILD_CLAMD_TRUE@ localserver.c \ -@BUILD_CLAMD_TRUE@ localserver.h \ -@BUILD_CLAMD_TRUE@ session.c \ -@BUILD_CLAMD_TRUE@ session.h \ -@BUILD_CLAMD_TRUE@ thrmgr.c \ -@BUILD_CLAMD_TRUE@ thrmgr.h \ -@BUILD_CLAMD_TRUE@ server-th.c \ -@BUILD_CLAMD_TRUE@ server.h \ -@BUILD_CLAMD_TRUE@ scanner.c \ -@BUILD_CLAMD_TRUE@ scanner.h \ -@BUILD_CLAMD_TRUE@ others.c \ -@BUILD_CLAMD_TRUE@ others.h \ -@BUILD_CLAMD_TRUE@ shared.h \ -@BUILD_CLAMD_TRUE@ onaccess_fan.c \ -@BUILD_CLAMD_TRUE@ onaccess_fan.h \ -@BUILD_CLAMD_TRUE@ onaccess_ddd.c \ -@BUILD_CLAMD_TRUE@ onaccess_ddd.h \ -@BUILD_CLAMD_TRUE@ onaccess_hash.c \ -@BUILD_CLAMD_TRUE@ onaccess_hash.h \ -@BUILD_CLAMD_TRUE@ onaccess_scth.c \ -@BUILD_CLAMD_TRUE@ onaccess_scth.h - +@BUILD_CLAMD_TRUE@clamd_SOURCES = $(top_srcdir)/shared/output.c \ +@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/output.h \ +@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/idmef_logging.c \ +@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/idmef_logging.h \ +@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/optparser.c \ +@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/optparser.h \ +@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/getopt.c \ +@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/getopt.h \ +@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/misc.c \ +@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/misc.h clamd.c \ +@BUILD_CLAMD_TRUE@ tcpserver.c tcpserver.h localserver.c \ +@BUILD_CLAMD_TRUE@ localserver.h session.c session.h thrmgr.c \ +@BUILD_CLAMD_TRUE@ thrmgr.h server-th.c server.h scanner.c \ +@BUILD_CLAMD_TRUE@ scanner.h others.c others.h shared.h \ +@BUILD_CLAMD_TRUE@ onaccess_fan.c onaccess_fan.h onaccess_ddd.c \ +@BUILD_CLAMD_TRUE@ onaccess_ddd.h onaccess_hash.c \ +@BUILD_CLAMD_TRUE@ onaccess_hash.h onaccess_scth.c \ +@BUILD_CLAMD_TRUE@ onaccess_scth.h priv_fts.h $(am__append_1) @BUILD_CLAMD_TRUE@AM_CFLAGS = @WERR_CFLAGS@ @BUILD_CLAMD_TRUE@@INSTALL_SYSTEMD_UNITS_TRUE@systemdsystemunit_DATA = clamav-daemon.socket clamav-daemon.service AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@ @@ -663,7 +671,9 @@ -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idmef_logging.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localserver.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/onaccess_ddd.Po@am__quote@ @@ -714,6 +724,20 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o output.obj `if test -f '$(top_srcdir)/shared/output.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/output.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/output.c'; fi` +idmef_logging.o: $(top_srcdir)/shared/idmef_logging.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT idmef_logging.o -MD -MP -MF $(DEPDIR)/idmef_logging.Tpo -c -o idmef_logging.o `test -f '$(top_srcdir)/shared/idmef_logging.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/idmef_logging.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/idmef_logging.Tpo $(DEPDIR)/idmef_logging.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/shared/idmef_logging.c' object='idmef_logging.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o idmef_logging.o `test -f '$(top_srcdir)/shared/idmef_logging.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/idmef_logging.c + +idmef_logging.obj: $(top_srcdir)/shared/idmef_logging.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT idmef_logging.obj -MD -MP -MF $(DEPDIR)/idmef_logging.Tpo -c -o idmef_logging.obj `if test -f '$(top_srcdir)/shared/idmef_logging.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/idmef_logging.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/idmef_logging.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/idmef_logging.Tpo $(DEPDIR)/idmef_logging.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/shared/idmef_logging.c' object='idmef_logging.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o idmef_logging.obj `if test -f '$(top_srcdir)/shared/idmef_logging.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/idmef_logging.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/idmef_logging.c'; fi` + optparser.o: $(top_srcdir)/shared/optparser.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT optparser.o -MD -MP -MF $(DEPDIR)/optparser.Tpo -c -o optparser.o `test -f '$(top_srcdir)/shared/optparser.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/optparser.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/optparser.Tpo $(DEPDIR)/optparser.Po diff -Nru clamav-0.99.2+dfsg/clamd/onaccess_ddd.c clamav-0.99.3~beta1+dfsg/clamd/onaccess_ddd.c --- clamav-0.99.2+dfsg/clamd/onaccess_ddd.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/onaccess_ddd.c 2017-04-20 22:19:13.000000000 +0000 @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -331,8 +330,8 @@ if((pt = optget(tharg->opts, "OnAccessIncludePath"))->enabled) { while(pt) { if (!strcmp(pt->strarg, "/")) { - logg("!ScanOnAcess: Not inlcuding path '%s' while DDD is enabled\n", pt->strarg); - logg("!ScanOnAcess: Please use the OnAccessMountPath option to watch '%s'\n", pt->strarg); + logg("!ScanOnAccess: Not including path '%s' while DDD is enabled\n", pt->strarg); + logg("!ScanOnAccess: Please use the OnAccessMountPath option to watch '%s'\n", pt->strarg); pt = (struct optstruct *) pt->nextarg; continue; } diff -Nru clamav-0.99.2+dfsg/clamd/onaccess_fan.c clamav-0.99.3~beta1+dfsg/clamd/onaccess_fan.c --- clamav-0.99.2+dfsg/clamd/onaccess_fan.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/onaccess_fan.c 2017-07-13 16:18:13.000000000 +0000 @@ -108,7 +108,7 @@ struct sigaction act; const struct optstruct *pt; short int scan; - int sizelimit = 0, extinfo; + unsigned int sizelimit = 0, extinfo; STATBUF sb; uint64_t fan_mask = FAN_EVENT_ON_CHILD | FAN_CLOSE; fd_set rfds; @@ -214,7 +214,7 @@ /* Load other options. */ sizelimit = optget(tharg->opts, "OnAccessMaxFileSize")->numarg; if(sizelimit) - logg("ScanOnAccess: Max file size limited to %d bytes\n", sizelimit); + logg("ScanOnAccess: Max file size limited to %u bytes\n", sizelimit); else logg("ScanOnAccess: File size limit disabled\n"); diff -Nru clamav-0.99.2+dfsg/clamd/onaccess_hash.c clamav-0.99.3~beta1+dfsg/clamd/onaccess_hash.c --- clamav-0.99.2+dfsg/clamd/onaccess_hash.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/onaccess_hash.c 2017-04-20 22:19:13.000000000 +0000 @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -51,6 +50,7 @@ #include "server.h" #include "others.h" #include "scanner.h" +#include "priv_fts.h" static struct onas_bucket *onas_bucket_init(); static void onas_free_bucket(struct onas_bucket *bckt); @@ -580,12 +580,12 @@ free(prnt); char * const pathargv[] = { (char*) pathname, NULL }; - if (!(ftsp = fts_open(pathargv, ftspopts, NULL))) { + if (!(ftsp = _priv_fts_open(pathargv, ftspopts, NULL))) { logg("!ScanOnAccess: Could not open '%s'\n", pathname); return CL_EARG; } - while((curr = fts_read(ftsp))) { + while((curr = _priv_fts_read(ftsp))) { struct onas_hnode *hnode = NULL; @@ -608,11 +608,9 @@ continue; } - if((childlist = fts_children(ftsp, 0))) { + if((childlist = _priv_fts_children(ftsp, 0))) { do { - if (childlist->fts_info & FTS_D && - !(childlist->fts_info & FTS_DNR) && - !(childlist->fts_info & FTS_SL)) { + if (childlist->fts_info == FTS_D) { if(CL_EMEM == onas_add_hashnode_child(hnode, childlist->fts_name)) return CL_EMEM; } @@ -626,7 +624,7 @@ if (onas_ht_insert(ht, elem)) return -1; } - fts_close(ftsp); + _priv_fts_close(ftsp); return CL_SUCCESS; } diff -Nru clamav-0.99.2+dfsg/clamd/onaccess_scth.c clamav-0.99.3~beta1+dfsg/clamd/onaccess_scth.c --- clamav-0.99.2+dfsg/clamd/onaccess_scth.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/onaccess_scth.c 2017-04-20 22:19:13.000000000 +0000 @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -36,6 +35,7 @@ #include "shared/output.h" #include "others.h" +#include "priv_fts.h" #include "onaccess_scth.h" @@ -56,10 +56,10 @@ FTSENT *curr = NULL; char *const pathargv[] = { (char *) pathname, NULL }; - if (!(ftsp = fts_open(pathargv, ftspopts, NULL))) return; + if (!(ftsp = _priv_fts_open(pathargv, ftspopts, NULL))) return; /* Offload scanning work to fanotify thread to avoid potential deadlocks. */ - while ((curr = fts_read(ftsp))) { + while ((curr = _priv_fts_read(ftsp))) { if (curr->fts_info != FTS_D) { int fd = open(curr->fts_path, O_RDONLY); if (fd > 0) close(fd); diff -Nru clamav-0.99.2+dfsg/clamd/priv_fts.h clamav-0.99.3~beta1+dfsg/clamd/priv_fts.h --- clamav-0.99.2+dfsg/clamd/priv_fts.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/priv_fts.h 2017-04-20 22:19:13.000000000 +0000 @@ -0,0 +1,221 @@ +#include "clamav-config.h" + +#if HAVE_SYSTEM_LFS_FTS +#include + +static inline FTSENT *_priv_fts_children(FTS *ftsp, int options) +{ + return fts_children(ftsp, options); +} + +static inline int _priv_fts_close(FTS *ftsp) +{ + return fts_close(ftsp); +} + +static inline FTS *_priv_fts_open (char * const *path_argv, int options, + int (*compar)(const FTSENT **, const FTSENT **)) +{ + return fts_open(path_argv, options, compar); +} + +static inline FTSENT *_priv_fts_read (FTS *ftsp) +{ + return fts_read(ftsp); +} + +static inline int _priv_fts_set (FTS *ftsp, FTSENT *f, int options) +{ + return fts_set(ftsp, f, options); +} + +#else +/* File tree traversal functions declarations. + Copyright (C) 1994-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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)fts.h 8.3 (Berkeley) 8/14/94 + */ + +#ifndef _FTS_H +#define _FTS_H 1 + +#include + + +typedef struct { + struct _ftsent *fts_cur; /* current node */ + struct _ftsent *fts_child; /* linked list of children */ + struct _ftsent **fts_array; /* sort array */ + dev_t fts_dev; /* starting device # */ + char *fts_path; /* path for this descent */ + int fts_rfd; /* fd for root */ + int fts_pathlen; /* sizeof(path) */ + int fts_nitems; /* elements in the sort array */ + int (*fts_compar) (const void *, const void *); /* compare fn */ + +#define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */ +#define FTS_LOGICAL 0x0002 /* logical walk */ +#define FTS_NOCHDIR 0x0004 /* don't change directories */ +#define FTS_NOSTAT 0x0008 /* don't get stat info */ +#define FTS_PHYSICAL 0x0010 /* physical walk */ +#define FTS_SEEDOT 0x0020 /* return dot and dot-dot */ +#define FTS_XDEV 0x0040 /* don't cross devices */ +#define FTS_WHITEOUT 0x0080 /* return whiteout information */ +#define FTS_OPTIONMASK 0x00ff /* valid user option mask */ + +#define FTS_NAMEONLY 0x0100 /* (private) child names only */ +#define FTS_STOP 0x0200 /* (private) unrecoverable error */ + int fts_options; /* fts_open options, global flags */ +} FTS; + +#ifdef __USE_LARGEFILE64 +typedef struct { + struct _ftsent64 *fts_cur; /* current node */ + struct _ftsent64 *fts_child; /* linked list of children */ + struct _ftsent64 **fts_array; /* sort array */ + dev_t fts_dev; /* starting device # */ + char *fts_path; /* path for this descent */ + int fts_rfd; /* fd for root */ + int fts_pathlen; /* sizeof(path) */ + int fts_nitems; /* elements in the sort array */ + int (*fts_compar) (const void *, const void *); /* compare fn */ + int fts_options; /* fts_open options, global flags */ +} FTS64; +#endif + +typedef struct _ftsent { + struct _ftsent *fts_cycle; /* cycle node */ + struct _ftsent *fts_parent; /* parent directory */ + struct _ftsent *fts_link; /* next file in directory */ + long fts_number; /* local numeric value */ + void *fts_pointer; /* local address value */ + char *fts_accpath; /* access path */ + char *fts_path; /* root path */ + int fts_errno; /* errno for this node */ + int fts_symfd; /* fd for symlink */ + u_short fts_pathlen; /* strlen(fts_path) */ + u_short fts_namelen; /* strlen(fts_name) */ + + ino_t fts_ino; /* inode */ + dev_t fts_dev; /* device */ + nlink_t fts_nlink; /* link count */ + +#define FTS_ROOTPARENTLEVEL -1 +#define FTS_ROOTLEVEL 0 + short fts_level; /* depth (-1 to N) */ + +#define FTS_D 1 /* preorder directory */ +#define FTS_DC 2 /* directory that causes cycles */ +#define FTS_DEFAULT 3 /* none of the above */ +#define FTS_DNR 4 /* unreadable directory */ +#define FTS_DOT 5 /* dot or dot-dot */ +#define FTS_DP 6 /* postorder directory */ +#define FTS_ERR 7 /* error; errno is set */ +#define FTS_F 8 /* regular file */ +#define FTS_INIT 9 /* initialized only */ +#define FTS_NS 10 /* stat(2) failed */ +#define FTS_NSOK 11 /* no stat(2) requested */ +#define FTS_SL 12 /* symbolic link */ +#define FTS_SLNONE 13 /* symbolic link without target */ +#define FTS_W 14 /* whiteout object */ + u_short fts_info; /* user flags for FTSENT structure */ + +#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ +#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ + u_short fts_flags; /* private flags for FTSENT structure */ + +#define FTS_AGAIN 1 /* read node again */ +#define FTS_FOLLOW 2 /* follow symbolic link */ +#define FTS_NOINSTR 3 /* no instructions */ +#define FTS_SKIP 4 /* discard node */ + u_short fts_instr; /* fts_set() instructions */ + + struct stat *fts_statp; /* stat(2) information */ + char fts_name[1]; /* file name */ +} FTSENT; + +#ifdef __USE_LARGEFILE64 +typedef struct _ftsent64 { + struct _ftsent64 *fts_cycle; /* cycle node */ + struct _ftsent64 *fts_parent; /* parent directory */ + struct _ftsent64 *fts_link; /* next file in directory */ + long fts_number; /* local numeric value */ + void *fts_pointer; /* local address value */ + char *fts_accpath; /* access path */ + char *fts_path; /* root path */ + int fts_errno; /* errno for this node */ + int fts_symfd; /* fd for symlink */ + u_short fts_pathlen; /* strlen(fts_path) */ + u_short fts_namelen; /* strlen(fts_name) */ + + ino64_t fts_ino; /* inode */ + dev_t fts_dev; /* device */ + nlink_t fts_nlink; /* link count */ + + short fts_level; /* depth (-1 to N) */ + + u_short fts_info; /* user flags for FTSENT structure */ + + u_short fts_flags; /* private flags for FTSENT structure */ + + u_short fts_instr; /* fts_set() instructions */ + + struct stat64 *fts_statp; /* stat(2) information */ + char fts_name[1]; /* file name */ +} FTSENT64; +#endif + +__BEGIN_DECLS +FTSENT *_priv_fts_children (FTS *, int); +int _priv_fts_close (FTS *); +FTS *_priv_fts_open (char * const *, int, + int (*)(const FTSENT **, const FTSENT **)); +FTSENT *_priv_fts_read (FTS *); +int _priv_fts_set (FTS *, FTSENT *, int) __THROW; +__END_DECLS + +#endif /* fts.h */ +#endif diff -Nru clamav-0.99.2+dfsg/clamd/scanner.c clamav-0.99.3~beta1+dfsg/clamd/scanner.c --- clamav-0.99.2+dfsg/clamd/scanner.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/scanner.c 2017-04-20 22:19:13.000000000 +0000 @@ -116,7 +116,7 @@ if (d == NULL) return; - if (!(d->options & CL_SCAN_ALLMATCHES)) + if (!(d->options & CL_SCAN_ALLMATCHES) && !(d->options & CL_SCAN_HEURISTIC_PRECEDENCE)) return; if (virname == NULL) return; @@ -124,6 +124,7 @@ fname = (c && c->filename) ? c->filename : "(filename not set)"; if (virname) { + d->infected++; conn_reply_virus(d->conn, fname, virname); if(c->virsize > 0 && optget(d->opts, "ExtendedDetectionInfo")->enabled) logg("~%s: %s(%s:%llu) FOUND\n", fname, virname, c->virhash, c->virsize); @@ -274,14 +275,22 @@ } if (ret == CL_VIRUS) { - scandata->infected++; - if (scandata->options & CL_SCAN_ALLMATCHES) { + + if (scandata->options & CL_SCAN_ALLMATCHES || (scandata->infected && scandata->options & CL_SCAN_HEURISTIC_PRECEDENCE)) { + if(optget(scandata->opts, "PreludeEnable")->enabled){ + prelude_logging(filename, virname, context.virhash, context.virsize); + } virusaction(filename, virname, scandata->opts); } else { + scandata->infected++; if (conn_reply_virus(scandata->conn, filename, virname) == -1) { free(filename); return CL_ETIMEOUT; } + if(optget(scandata->opts, "PreludeEnable")->enabled){ + prelude_logging(filename, virname, context.virhash, context.virsize); + } + if(context.virsize && optget(scandata->opts, "ExtendedDetectionInfo")->enabled) logg("~%s: %s(%s:%llu) FOUND\n", filename, virname, context.virhash, context.virsize); else diff -Nru clamav-0.99.2+dfsg/clamd/server-th.c clamav-0.99.3~beta1+dfsg/clamd/server-th.c --- clamav-0.99.2+dfsg/clamd/server-th.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamd/server-th.c 2016-10-13 15:46:46.000000000 +0000 @@ -51,6 +51,8 @@ #include "shared/optparser.h" #include "shared/misc.h" +#include "shared/idmef_logging.h" + #include "onaccess_fan.h" #include "server.h" #include "thrmgr.h" diff -Nru clamav-0.99.2+dfsg/clamdscan/clamdscan.c clamav-0.99.3~beta1+dfsg/clamdscan/clamdscan.c --- clamav-0.99.2+dfsg/clamdscan/clamdscan.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamdscan/clamdscan.c 2017-07-19 19:03:40.000000000 +0000 @@ -185,7 +185,7 @@ mprintf("\n"); mprintf(" ClamAV Daemon Client %s\n", get_version()); printf(" By The ClamAV Team: http://www.clamav.net/about.html#credits\n"); - printf(" (C) 2007-2015 Cisco Systems, Inc.\n\n"); + printf(" (C) 2007-2017 Cisco Systems, Inc.\n\n"); mprintf(" --help -h Show help\n"); mprintf(" --version -V Print version number and exit\n"); diff -Nru clamav-0.99.2+dfsg/clamdscan/Makefile.in clamav-0.99.3~beta1+dfsg/clamdscan/Makefile.in --- clamav-0.99.2+dfsg/clamdscan/Makefile.in 2016-04-22 16:19:51.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamdscan/Makefile.in 2017-06-23 21:20:55.000000000 +0000 @@ -106,10 +106,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -164,12 +165,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -320,6 +326,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -347,7 +355,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = $(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la @CLAMDSCAN_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -441,6 +458,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/clamdscan/proto.c clamav-0.99.3~beta1+dfsg/clamdscan/proto.c --- clamav-0.99.2+dfsg/clamdscan/proto.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamdscan/proto.c 2017-01-13 18:12:34.000000000 +0000 @@ -86,8 +86,10 @@ if ((sockd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0) { if (connect(sockd, (struct sockaddr *)&nixsock, sizeof(nixsock)) == 0) return sockd; - else + else { + logg("!Could not connect to clamd on LocalSocket %s: %s\n", opt->strarg, strerror(errno)); close(sockd); + } } } #endif @@ -96,38 +98,39 @@ opt = optget(clamdopts, "TCPAddr"); while (opt) { - ipaddr = NULL; - if (opt->strarg) - ipaddr = (!strcmp(opt->strarg, "any") ? NULL : opt->strarg); - - memset(&hints, 0x00, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - - if ((res = getaddrinfo(ipaddr, port, &hints, &info))) { - logg("!Could not lookup %s: %s\n", ipaddr ? ipaddr : "", gai_strerror(res)); - opt = opt->nextarg; - continue; - } - - for (p = info; p != NULL; p = p->ai_next) { - if((sockd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) { - logg("!Can't create the socket: %s\n", strerror(errno)); + if (opt->enabled) { + ipaddr = NULL; + if (opt->strarg) + ipaddr = (!strcmp(opt->strarg, "any") ? NULL : opt->strarg); + + memset(&hints, 0x00, sizeof(struct addrinfo)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + if ((res = getaddrinfo(ipaddr, port, &hints, &info))) { + logg("!Could not lookup %s: %s\n", ipaddr ? ipaddr : "", gai_strerror(res)); + opt = opt->nextarg; continue; } - if(connect(sockd, p->ai_addr, p->ai_addrlen) < 0) { - logg("!Could not connect to clamd on %s: %s\n", opt->strarg, strerror(errno)); - closesocket(sockd); - continue; + for (p = info; p != NULL; p = p->ai_next) { + if((sockd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) { + logg("!Can't create the socket: %s\n", strerror(errno)); + continue; + } + + if(connect(sockd, p->ai_addr, p->ai_addrlen) < 0) { + logg("!Could not connect to clamd on %s: %s\n", opt->strarg, strerror(errno)); + closesocket(sockd); + continue; + } + + freeaddrinfo(info); + return sockd; } freeaddrinfo(info); - return sockd; } - - freeaddrinfo(info); - opt = opt->nextarg; } diff -Nru clamav-0.99.2+dfsg/clamdtop/clamdtop.c clamav-0.99.3~beta1+dfsg/clamdtop/clamdtop.c --- clamav-0.99.2+dfsg/clamdtop/clamdtop.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamdtop/clamdtop.c 2017-07-19 19:03:40.000000000 +0000 @@ -1235,7 +1235,7 @@ printf("\n"); printf(" Clam AntiVirus: Monitoring Tool %s\n", get_version()); printf(" By The ClamAV Team: http://www.clamav.net/about.html#credits\n"); - printf(" (C) 2008-2015 Cisco Systems, Inc.\n\n"); + printf(" (C) 2008-2017 Cisco Systems, Inc.\n\n"); printf("clamdtop [-hVc] [host[:port] /path/to/clamd.socket ...]\n\n"); printf(" --help -h Show help\n"); printf(" --version -V Show version\n"); diff -Nru clamav-0.99.2+dfsg/clamdtop/Makefile.in clamav-0.99.3~beta1+dfsg/clamdtop/Makefile.in --- clamav-0.99.2+dfsg/clamdtop/Makefile.in 2016-04-22 16:19:52.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamdtop/Makefile.in 2017-06-23 21:20:55.000000000 +0000 @@ -88,10 +88,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -146,12 +147,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -326,6 +332,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -353,7 +361,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -447,6 +464,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/clamscan/clamscan.c clamav-0.99.3~beta1+dfsg/clamscan/clamscan.c --- clamav-0.99.2+dfsg/clamscan/clamscan.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamscan/clamscan.c 2017-07-19 19:03:40.000000000 +0000 @@ -203,7 +203,7 @@ mprintf("\n"); mprintf(" Clam AntiVirus Scanner %s\n", get_version()); printf(" By The ClamAV Team: http://www.clamav.net/about.html#credits\n"); - printf(" (C) 2007-2015 Cisco Systems, Inc.\n\n"); + printf(" (C) 2007-2017 Cisco Systems, Inc.\n\n"); mprintf(" --help -h Print this help screen\n"); mprintf(" --version -V Print version number\n"); @@ -256,6 +256,7 @@ mprintf(" --phishing-cloak[=yes/no(*)] Always block cloaked URLs (phishing module)\n"); mprintf(" --partition-intersection[=yes/no(*)] Detect partition intersections in raw disk images using heuristics.\n"); mprintf(" --algorithmic-detection[=yes(*)/no] Algorithmic detection\n"); + mprintf(" --normalize[=yes(*)/no] Normalize html, script, and text files. Use normalize=no for yara compatibility.\n"); mprintf(" --scan-pe[=yes(*)/no] Scan PE files\n"); mprintf(" --scan-elf[=yes(*)/no] Scan ELF files\n"); mprintf(" --scan-ole2[=yes(*)/no] Scan OLE2 containers\n"); diff -Nru clamav-0.99.2+dfsg/clamscan/Makefile.in clamav-0.99.3~beta1+dfsg/clamscan/Makefile.in --- clamav-0.99.2+dfsg/clamscan/Makefile.in 2016-04-22 16:19:52.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamscan/Makefile.in 2017-06-23 21:20:55.000000000 +0000 @@ -107,10 +107,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -165,12 +166,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -311,6 +317,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -338,7 +346,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@ @CLAMSCAN_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -432,6 +449,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/clamscan/manager.c clamav-0.99.3~beta1+dfsg/clamscan/manager.c --- clamav-0.99.2+dfsg/clamscan/manager.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamscan/manager.c 2016-10-13 15:45:43.000000000 +0000 @@ -400,9 +400,6 @@ logg("~%s!(%llu): %s FOUND\n", filename, (long long unsigned)(chain.lastvir-1), virname); } } - if (!(options & CL_SCAN_ALLMATCHES)) - logg("~%s: %s FOUND\n", filename, virname); - info.files++; info.ifiles++; @@ -596,9 +593,6 @@ data.filename = "stdin"; data.chain = NULL; if((ret = cl_scanfile_callback(file, &virname, &info.blocks, engine, options, &data)) == CL_VIRUS) { - if (!(options & CL_SCAN_ALLMATCHES)) - logg("stdin: %s FOUND\n", virname); - info.ifiles++; if(bell) @@ -676,6 +670,8 @@ return 2; } + cl_engine_set_clcb_virus_found(engine, clamscan_virus_found_cb); + if (optget(opts, "disable-cache")->enabled) cl_engine_set_num(engine, CL_ENGINE_DISABLE_CACHE, 1); @@ -1038,7 +1034,6 @@ /* set scan options */ if(optget(opts, "allmatch")->enabled) { options |= CL_SCAN_ALLMATCHES; - cl_engine_set_clcb_virus_found(engine, clamscan_virus_found_cb); } if(optget(opts,"phishing-ssl")->enabled) @@ -1080,7 +1075,7 @@ if(optget(opts, "scan-swf")->enabled) options |= CL_SCAN_SWF; - if(optget(opts, "scan-html")->enabled) + if(optget(opts, "scan-html")->enabled && optget(opts, "normalize")->enabled) options |= CL_SCAN_HTML; if(optget(opts, "scan-mail")->enabled) @@ -1095,6 +1090,10 @@ if(optget(opts, "algorithmic-detection")->enabled) options |= CL_SCAN_ALGORITHMIC; + if(optget(opts, "block-max")->enabled) { + options |= CL_SCAN_BLOCKMAX; + } + #ifdef HAVE__INTERNAL__SHA_COLLECT if(optget(opts, "dev-collect-hashes")->enabled) options |= CL_SCAN_INTERNAL_COLLECT_SHA; diff -Nru clamav-0.99.2+dfsg/clamsubmit/clamsubmit.c clamav-0.99.3~beta1+dfsg/clamsubmit/clamsubmit.c --- clamav-0.99.2+dfsg/clamsubmit/clamsubmit.c 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamsubmit/clamsubmit.c 2017-02-20 18:36:39.000000000 +0000 @@ -10,21 +10,33 @@ #include "shared/misc.h" #include "shared/getopt.h" -#define OPTS "e:p:n:N:H:h?v" +#define OPTS "e:p:n:N:V:H:h?v" char *read_stream(void); void usage(char *name); void version(void); +typedef struct _header_data { + int len; + char * cfduid; + char * session; +} header_data; + +typedef struct _write_data { + int len; + char * str; +} write_data; + void usage(char *name) { - fprintf(stderr, "USAGE: %s -hHinp?\n", name); + fprintf(stderr, "USAGE: %s -hHinpVv?\n", name); fprintf(stderr, "OPTIONS:\n"); fprintf(stderr, " -e [EMAIL]\tYour email address (required)\n"); fprintf(stderr, " -h or -?\tShow the help text\n"); fprintf(stderr, " -n [FILE]\tSubmit a false negative (FN)\n"); - fprintf(stderr, " -N [NAME]\tYour name (required)\n"); - fprintf(stderr, " -p [FILE]\tSubmit a fase positive (FP)\n"); + fprintf(stderr, " -N [NAME]\tYour name contained in quotation marks (required)\n"); + fprintf(stderr, " -p [FILE]\tSubmit a false positive (FP)\n"); + fprintf(stderr, " -V [NAME] \tDetected virus name(required with -p)\n"); fprintf(stderr, " -v\t\tShow version number and exit\n"); fprintf(stderr, "You must specify -n or -p. Both are mutually exclusive. Pass in - as the filename for stdin.\n"); exit(0); @@ -36,21 +48,106 @@ exit(0); } +size_t header_cb(char *ptr, size_t size, size_t nmemb, void *userdata) +{ + int len = size*nmemb; + char *sp, *ep, *mem; + header_data *hd = (header_data *) userdata; + const char *set_cookie = "Set-Cookie:"; + int clen = strlen(set_cookie); + + if (len > clen) { + if (strncmp(ptr, set_cookie, clen)) + return len; + sp = ptr + clen + 1; + ep = strchr(sp, ';'); + if (ep == NULL) { + fprintf(stderr, "header_cb(): malformed cookie\n"); + return 0; + } + mem = malloc(ep-sp+1); + if (mem == NULL) { + fprintf(stderr, "header_cb(): malloc failed\n"); + return 0; + } + memcpy(mem, sp, ep-sp); + mem[ep-sp] = '\0'; + if (!strncmp(mem, "__cfduid", 8)) + hd->cfduid = mem; + else if (!strncmp(mem, "_clamav-net_session", strlen("_clamav-net_session"))) + hd->session = mem; + else + fprintf(stderr, "header_cb(): unrecognized cookie\n"); + } + return len; +} + +size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) +{ + int len = size*nmemb; + char * str; + write_data *wd = (write_data *) userdata; + + if (len) { + str = realloc(wd->str, wd->len + len + 1); + if (str == NULL) { + fprintf (stderr, "write_cb() realloc failure\n"); + return 0; + } + memcpy(str + wd->len, ptr, len); + str[wd->len + len] = '\0'; + wd->str = str; + wd->len += len; + } + return len; +} + +const char* presigned_get_string(json_object * ps_json_obj, char * key) +{ + json_object * json_obj = NULL; + const char * json_str = NULL; + + if (json_object_object_get_ex(ps_json_obj, key, &json_obj)) { + json_str = json_object_get_string(json_obj); + if (json_str == NULL) { + fprintf(stderr, "Error: json_object_get_string() for %s.\n", key); + exit(1); + } + } else { + fprintf(stderr, "Error: json_object_object_get_ex() for %s.\n", key); + exit(1); + } + return json_str; +} + int main(int argc, char *argv[]) { - CURL *curl; + CURL *clam_curl, *aws_curl; CURLcode res; int ch; struct curl_httppost *post=NULL, *last=NULL; struct curl_slist *slist = NULL; char *name=NULL, *email=NULL, *filename=NULL; int setURL=0, fromStream=0; + const char * json_str; + write_data wd = {0, NULL}; + header_data hd_malware = {0, NULL, NULL}; + header_data hd_presigned = {0, NULL, NULL}; + json_object * ps_json_obj = NULL; + json_object * json_obj = NULL; + int malware = 0; + int len = 0; + char * submissionID = NULL; + char * fpvname = NULL; + char *sp, *ep, *str; + char * authenticity_token; + char * urlp; curl_global_init(CURL_GLOBAL_ALL); - curl = curl_easy_init(); - if (!(curl)) { - fprintf(stderr, "ERROR: Could not initialize libcurl\n"); + clam_curl = curl_easy_init(); + if (clam_curl == NULL) { + fprintf(stderr, "ERROR: Could not initialize libcurl.\n"); exit(1); } @@ -58,6 +155,7 @@ switch (ch) { case 'v': version(); + break; case 'e': email = optarg; break; @@ -67,20 +165,16 @@ case 'p': if (setURL) usage(argv[0]); - filename = optarg; - - curl_easy_setopt(curl, CURLOPT_URL, "http://cgi.clamav.net/sendfp.cgi"); - setURL=1; break; case 'n': if (setURL) usage(argv[0]); - + malware = 1; filename = optarg; - - curl_easy_setopt(curl, CURLOPT_URL, "http://cgi.clamav.net/sendmalware.cgi"); - setURL=1; + break; + case 'V': + fpvname = optarg; break; case 'h': case '?': @@ -92,47 +186,258 @@ if (!(name) || !(email) || !(filename)) usage(argv[0]); + if (malware == 0 && fpvname == NULL) { + fprintf(stderr, "Detected virus name(-V) required for false positive submissions.\n"); + usage(argv[0]); + } if (strlen(filename) == 1 && filename[0] == '-') { filename = read_stream(); if (!(filename)) { fprintf(stderr, "ERROR: Unable to read stream\n"); exit(1); } - fromStream=1; } - slist = curl_slist_append(slist, "Expect:"); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); - if (curl_formadd(&post, &last, CURLFORM_COPYNAME, "sendername", CURLFORM_COPYCONTENTS, name, CURLFORM_END)) { - fprintf(stderr, "Unable to specify name in libcurl form for file %s\n", optarg); - goto end; + /*** The GET malware|fp ***/ + if (malware == 1) + urlp = "http://www.clamav.net/reports/malware"; + else + urlp = "http://www.clamav.net/reports/fp"; + curl_easy_setopt(clam_curl, CURLOPT_URL, urlp); + curl_easy_setopt(clam_curl, CURLOPT_HTTPGET, 1); + curl_easy_setopt(clam_curl, CURLOPT_WRITEDATA, &wd); + curl_easy_setopt(clam_curl, CURLOPT_WRITEFUNCTION, write_cb); + curl_easy_setopt(clam_curl, CURLOPT_HEADERDATA, &hd_malware); + curl_easy_setopt(clam_curl, CURLOPT_HEADERFUNCTION, header_cb); + res = curl_easy_perform(clam_curl); + if (res) { + fprintf(stderr, "Error in GET %s: %s\n", urlp , curl_easy_strerror(res)); + exit(1); } + if (wd.str != NULL) { + sp = strstr(wd.str, "name=\"authenticity_token\""); + if (sp == NULL) { + fprintf (stderr, "Authenticity token element not found.\n"); + exit(1); + } + sp = strstr(sp, "value="); + if (sp == NULL) { + fprintf (stderr, "Authenticity token value not found.\n"); + exit(1); + } + sp += 7; + ep = strchr(sp, '"'); + if (ep == NULL) { + fprintf (stderr, "Authenticity token malformed.\n"); + exit(1); + } + authenticity_token = malloc(ep-sp+1); + if (authenticity_token == NULL) { + fprintf (stderr, "no memory for authenticity token.\n"); + exit(1); + } + memcpy(authenticity_token, sp, ep-sp); + authenticity_token[ep-sp] = '\0'; + free (wd.str); + wd.str = NULL; + } + wd.len = 0; + urlp = NULL; + - if (curl_formadd(&post, &last, CURLFORM_COPYNAME, "email", CURLFORM_COPYCONTENTS, email, CURLFORM_END)) { - fprintf(stderr, "Unable to specify email in libcurl form for file %s\n", optarg); - goto end; + /*** The GET presigned ***/ + if (malware == 1) + curl_easy_setopt(clam_curl, CURLOPT_URL, "http://www.clamav.net/presigned?type=malware"); + else + curl_easy_setopt(clam_curl, CURLOPT_URL, "http://www.clamav.net/presigned?type=fp"); + curl_easy_setopt(clam_curl, CURLOPT_HTTPGET, 1); + len = strlen(hd_malware.cfduid) + strlen(hd_malware.session) + 3; + str = malloc(len); + if (str == NULL) { + fprintf(stderr, "No memory for GET presigned cookies\n"); + exit(1); + } + if (snprintf(str, len, "%s; %s;", hd_malware.cfduid, hd_malware.session) > len) { + fprintf(stderr, "snprintf() failed formatting GET presigned cookies\n"); + exit(1); + } + curl_easy_setopt(clam_curl, CURLOPT_COOKIE, str); + free(str); + len = strlen(authenticity_token) + 15; + str = malloc(len); + if (str == NULL) { + fprintf(stderr, "No memory for GET presigned X-CSRF-Token\n"); + exit(1); + } + if (snprintf(str, len, "X-CSRF-Token: %s", authenticity_token) > len) { + fprintf(stderr, "snprintf() failed for GET presigned X-CSRF-Token\n"); + exit(1); } + slist = curl_slist_append(slist, str); + free(str); + curl_easy_setopt(clam_curl, CURLOPT_HTTPHEADER, slist); + curl_easy_setopt(clam_curl, CURLOPT_HEADERDATA, &hd_presigned); + curl_easy_setopt(clam_curl, CURLOPT_HEADERFUNCTION, header_cb); + if (malware ==1) + curl_easy_setopt(clam_curl, CURLOPT_REFERER, "http://www.clamav.net/reports/malware"); + else + curl_easy_setopt(clam_curl, CURLOPT_REFERER, "http://www.clamav.net/reports/fp"); - if (curl_formadd(&post, &last, CURLFORM_COPYNAME, "file", CURLFORM_FILE, filename, CURLFORM_END)) { - fprintf(stderr, "Unable to specify file path in libcurl form for file %s\n", optarg); - goto end; + res = curl_easy_perform(clam_curl); + if (res) { + fprintf(stderr, "Error in GET presigned: %s\n", curl_easy_strerror(res)); + exit(1); } + curl_slist_free_all(slist); + slist = NULL; - curl_formadd(&post, &last, CURLFORM_COPYNAME, "action", CURLFORM_COPYCONTENTS, "submit", CURLFORM_END); - curl_formadd(&post, &last, CURLFORM_COPYNAME, "privacy", CURLFORM_COPYCONTENTS, "yes", CURLFORM_END); - curl_formadd(&post, &last, CURLFORM_COPYNAME, "notify", CURLFORM_COPYCONTENTS, "yes", CURLFORM_END); - curl_easy_setopt(curl, CURLOPT_HTTPPOST, post); - res = curl_easy_perform(curl); + /*** The POST to AWS ***/ + ps_json_obj = json_tokener_parse(wd.str); + if (ps_json_obj == NULL) { + fprintf(stderr, "Error in json_tokener_parse of %.*s\n", wd.len, wd.str); + exit(1); + } + json_str = presigned_get_string(ps_json_obj, "key"); + sp = strchr(json_str, '/'); + if (sp == NULL) { + fprintf(stderr, "Error: malformed 'key' string in GET presigned response (missing '/'.\n"); + exit (1); + } + sp++; + ep = strchr(sp, '-'); + if (ep == NULL) { + fprintf(stderr, "Error: malformed 'key' string in GET presigned response (missing '-'.\n"); + exit (1); + } + submissionID = malloc(ep-sp+1); + if (submissionID == NULL) { + fprintf(stderr, "Error: malloc submissionID.\n"); + exit (1); + } + memcpy(submissionID, sp, ep-sp); + submissionID[ep-sp] = '\0'; + aws_curl = curl_easy_init(); + if (!(aws_curl)) { + fprintf(stderr, "ERROR: Could not initialize libcurl POST presigned\n"); + exit(1); + } + submissionID[ep-sp] = '\0'; + curl_formadd(&post, &last, CURLFORM_COPYNAME, "key", CURLFORM_COPYCONTENTS, json_str, CURLFORM_END); + json_str = presigned_get_string(ps_json_obj, "acl"); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "acl", CURLFORM_COPYCONTENTS, json_str, CURLFORM_END); + json_str = presigned_get_string(ps_json_obj, "policy"); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "policy", CURLFORM_COPYCONTENTS, json_str, CURLFORM_END); + json_str = presigned_get_string(ps_json_obj, "x-amz-meta-original-filename"); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "x-amz-meta-original-filename", CURLFORM_COPYCONTENTS, json_str, CURLFORM_END); + json_str = presigned_get_string(ps_json_obj, "x-amz-credential"); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "x-amz-credential", CURLFORM_COPYCONTENTS, json_str, CURLFORM_END); + json_str = presigned_get_string(ps_json_obj, "x-amz-algorithm"); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "x-amz-algorithm", CURLFORM_COPYCONTENTS, json_str, CURLFORM_END); + json_str = presigned_get_string(ps_json_obj, "x-amz-date"); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "x-amz-date", CURLFORM_COPYCONTENTS, json_str, CURLFORM_END); + json_str = presigned_get_string(ps_json_obj, "x-amz-signature"); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "x-amz-signature", CURLFORM_COPYCONTENTS, json_str, CURLFORM_END); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "file", CURLFORM_FILE, filename, CURLFORM_END); + slist = curl_slist_append(slist, "Expect:"); + curl_easy_setopt(aws_curl, CURLOPT_HTTPHEADER, slist); + curl_easy_setopt(aws_curl, CURLOPT_URL, "http://clamav-site.s3.amazonaws.com/"); + curl_easy_setopt(aws_curl, CURLOPT_HTTPPOST, post); + res = curl_easy_perform(aws_curl); if (res) { - fprintf(stderr, "Error: %s\n", curl_easy_strerror(res)); + fprintf(stderr, "Error in POST AWS: %s\n", curl_easy_strerror(res)); + exit(1); } + curl_slist_free_all(slist); + slist = NULL; + curl_formfree(post); + post = NULL; + last = NULL; + curl_easy_cleanup(aws_curl); + json_object_put(ps_json_obj); + free(wd.str); + wd.str = NULL; + wd.len = 0; -end: - curl_easy_cleanup(curl); + + /*** The POST submit to clamav.net ***/ + slist = curl_slist_append(slist, "Expect:"); + len = strlen(hd_malware.cfduid) + strlen(hd_presigned.session) + 3; + str = malloc(len); + if (str == NULL) { + fprintf(stderr, "No memory for POST submit cookies.\n"); + exit(1); + } + if (snprintf(str, len, "%s; %s;", hd_malware.cfduid, hd_presigned.session) > len) { + fprintf(stderr, "snprintf() failed formatting POST submit cookies\n"); + exit(1); + } + curl_easy_setopt(clam_curl, CURLOPT_COOKIE, str); + free(str); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "utf8", CURLFORM_COPYCONTENTS, "\x27" "\x13", CURLFORM_END); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "authenticity_token", CURLFORM_COPYCONTENTS, authenticity_token, CURLFORM_END); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "submissionID", CURLFORM_COPYCONTENTS, submissionID, CURLFORM_END); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "type", CURLFORM_COPYCONTENTS, malware?"malware":"fp", CURLFORM_END); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "sendername", CURLFORM_COPYCONTENTS, name, CURLFORM_END); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "email", CURLFORM_COPYCONTENTS, email, CURLFORM_END); + if (malware == 0) { + curl_formadd(&post, &last, CURLFORM_COPYNAME, "virusname", CURLFORM_COPYCONTENTS, fpvname, CURLFORM_END); + } else { + if (malware == 1) + curl_formadd(&post, &last, CURLFORM_COPYNAME, "shareSample", CURLFORM_COPYCONTENTS, "on", CURLFORM_END); + } + curl_formadd(&post, &last, CURLFORM_COPYNAME, "description", CURLFORM_COPYCONTENTS, "clamsubmit", CURLFORM_END); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "notify", CURLFORM_COPYCONTENTS, "on", CURLFORM_END); + curl_formadd(&post, &last, CURLFORM_COPYNAME, "privacy", CURLFORM_COPYCONTENTS, "on", CURLFORM_END); + curl_easy_setopt(clam_curl, CURLOPT_HTTPHEADER, slist); + curl_easy_setopt(clam_curl, CURLOPT_URL, "http://www.clamav.net/reports/submit"); + curl_easy_setopt(clam_curl, CURLOPT_HTTPPOST, post); + curl_easy_setopt(clam_curl, CURLOPT_HEADERFUNCTION, NULL); + res = curl_easy_perform(clam_curl); + if (res) { + fprintf(stderr, "Error in POST submit: %s\n", curl_easy_strerror(res)); + exit(1); + } else { + long response_code; + curl_easy_getinfo(clam_curl, CURLINFO_RESPONSE_CODE, &response_code); + if (response_code/100 == 3) { + curl_easy_getinfo(clam_curl, CURLINFO_REDIRECT_URL, &urlp); + if (urlp == NULL) { + fprintf(stderr, "POST submit Location URL is NULL.\n"); + exit(1); + } + sp = strstr(urlp, "/reports/"); + if (sp == NULL) { + fprintf(stderr, "POST submit Location URL is malformed.\n"); + exit(1); + } + if (!strcmp(sp, "/reports/success")) + fprintf(stdout, "Submission success!\n"); + else if (!strcmp(sp, "/reports/failure")) + fprintf(stdout, "Submission failed\n"); + else + fprintf(stdout, "Unknown submission status %s\n", sp); + } + else + fprintf(stderr, "Unexpected POST submit response code: %li\n", response_code); + } + curl_slist_free_all(slist); + curl_formfree(post); + curl_easy_cleanup(clam_curl); + if (wd.str != NULL) { + free(wd.str); + wd.str = NULL; + wd.len = 0; + } + free(hd_malware.cfduid); + free(hd_malware.session); + free(hd_presigned.cfduid); + free(hd_presigned.session); + free(submissionID); + free(authenticity_token); if (fromStream) { remove(filename); free(filename); @@ -141,6 +446,7 @@ return 0; } + char *read_stream(void) { char *filename; diff -Nru clamav-0.99.2+dfsg/clamsubmit/Makefile.in clamav-0.99.3~beta1+dfsg/clamsubmit/Makefile.in --- clamav-0.99.2+dfsg/clamsubmit/Makefile.in 2016-04-22 16:19:52.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/clamsubmit/Makefile.in 2017-06-23 21:20:56.000000000 +0000 @@ -106,10 +106,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -164,12 +165,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -309,6 +315,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -336,7 +344,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMSUBMIT_LIBS@ @THREAD_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -430,6 +447,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/configure clamav-0.99.3~beta1+dfsg/configure --- clamav-0.99.2+dfsg/configure 2016-04-22 16:19:50.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/configure 2017-07-19 20:01:31.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for ClamAV 0.99.2. +# Generated by GNU Autoconf 2.69 for ClamAV 0.99.3-beta1. # # Report bugs to . # @@ -592,8 +592,8 @@ # Identity of this package. PACKAGE_NAME='ClamAV' PACKAGE_TARNAME='clamav' -PACKAGE_VERSION='0.99.2' -PACKAGE_STRING='ClamAV 0.99.2' +PACKAGE_VERSION='0.99.3-beta1' +PACKAGE_STRING='ClamAV 0.99.3-beta1' PACKAGE_BUGREPORT='http://bugs.clamav.net/' PACKAGE_URL='http://www.clamav.net/' @@ -645,8 +645,10 @@ am__EXEEXT_TRUE LTLIBOBJS LIBOBJS -ENABLE_CLAMSUBMIT_FALSE -ENABLE_CLAMSUBMIT_TRUE +LIBMSPACK_LIBS +LIBMSPACK_CFLAGS +USE_INTERNAL_MSPACK_FALSE +USE_INTERNAL_MSPACK_TRUE JSON_LDFLAGS JSON_LIBS SSL_LDFLAGS @@ -681,10 +683,20 @@ FRESHCLAM_CPPFLAGS CLAMSUBMIT_CFLAGS CLAMSUBMIT_LIBS +LIBPRELUDE_CONFIG_PREFIX +LIBPRELUDE_PREFIX +LIBPRELUDE_LIBS +LIBPRELUDE_LDFLAGS +LIBPRELUDE_PTHREAD_CFLAGS +LIBPRELUDE_CFLAGS +LIBPRELUDE_CONFIG ENABLE_LIBFRESHCLAM_FALSE ENABLE_LIBFRESHCLAM_TRUE +SYSTEM_LFS_FTS_FALSE +SYSTEM_LFS_FTS_TRUE HAVE_YARA subdirs +llvmconfig WERR_CFLAGS_MILTER WERR_CFLAGS HAVE_CURSES_FALSE @@ -700,6 +712,8 @@ BUILD_CLAMD_TRUE CFGDIR DBDIR +ICONV_CPPFLAGS +ICONV_LDFLAGS INSTALL_SYSTEMD_UNITS_FALSE INSTALL_SYSTEMD_UNITS_TRUE systemdsystemunitdir @@ -939,13 +953,17 @@ with_libncurses_prefix with_libpdcurses_prefix enable_distcheck_werror +enable_llvm with_system_llvm with_llvm_linking -enable_llvm enable_sha_collector_for_internal_use enable_yara enable_libfreshclam +enable_prelude +with_libprelude_prefix with_libcurl +with_system_libmspack +enable_largefile ' ac_precious_vars='build_alias host_alias @@ -965,9 +983,12 @@ CHECK_CFLAGS CHECK_LIBS SYSTEMD_CFLAGS -SYSTEMD_LIBS' +SYSTEMD_LIBS +LIBMSPACK_CFLAGS +LIBMSPACK_LIBS' ac_subdirs_all=' -libclamav/c++' +libclamav/c++ +libclamav/libmspack-0.5alpha' # Initialize some variables set by options. ac_init_help= @@ -1507,7 +1528,7 @@ # 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 ClamAV 0.99.2 to adapt to many kinds of systems. +\`configure' configures ClamAV 0.99.3-beta1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1578,7 +1599,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ClamAV 0.99.2:";; + short | recursive ) echo "Configuration of ClamAV 0.99.3-beta1:";; esac cat <<\_ACEOF @@ -1634,6 +1655,8 @@ --disable-yara do not include yara support --enable-libfreshclam enable building of libfreshclam + --enable-prelude Enable Prelude support for alerts. + --disable-largefile omit support for large files Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1680,14 +1703,19 @@ --without-libncurses-prefix don't search for libncurses in includedir and libdir --with-libpdcurses-prefix[=DIR] search for libpdcurses in DIR/include and DIR/lib --without-libpdcurses-prefix don't search for libpdcurses in includedir and libdir - --with-system-llvm use system llvm instead of built-in, uses full path - to llvm-config [default=/usr/local or /usr if not - found in /usr/local] + --with-system-llvm Specify system llvm location or to use old package, + uses full path to llvm-config or bin directory + (default=search PATH environment variable) --with-llvm-linking specifies method to linking llvm [static|dynamic], only valid with --with-system-llvm + --with-libprelude-prefix=PFX + Prefix where libprelude is installed (optional) --with-libcurl[=DIR] path to directory containing libcurl [default=/usr/local or /usr if not found in /usr/local] + --with-system-libmspack Specify system libmspack location or to use internal + package, uses full path to libmspack or bin + directory (default=search PATH environment variable) Some influential environment variables: CC C compiler command @@ -1718,6 +1746,10 @@ C compiler flags for SYSTEMD, overriding pkg-config SYSTEMD_LIBS linker flags for SYSTEMD, overriding pkg-config + LIBMSPACK_CFLAGS + C compiler flags for LIBMSPACK, overriding pkg-config + LIBMSPACK_LIBS + linker flags for LIBMSPACK, 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. @@ -1786,7 +1818,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ClamAV configure 0.99.2 +ClamAV configure 0.99.3-beta1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2255,7 +2287,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ClamAV $as_me 0.99.2, which was +It was created by ClamAV $as_me 0.99.3-beta1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3424,7 +3456,7 @@ # Define the identity of the package. PACKAGE='clamav' - VERSION='0.99.2' + VERSION='0.99.3-beta1' # Some tools Automake needs. @@ -5165,7 +5197,7 @@ -VERSION="0.99.2" +VERSION="0.99.3-beta1" LC_CURRENT=8 LC_REVISION=1 @@ -17920,12 +17952,13 @@ save_CFLAGS="$CFLAGS" save_LIBS="$LIBS" -SSL_LIBS="-lssl -lcrypto -lz" +SSL_LIBS="$LIBS -lssl -lcrypto -lz" +LIBS="$LIBS $SSL_LIBS" if test "$LIBSSL_HOME" != "/usr"; then SSL_LDFLAGS="-L$LIBSSL_HOME/lib" SSL_CPPFLAGS="-I$LIBSSL_HOME/include" - LDFLAGS="-L$LIBSSL_HOME/lib $SSL_LIBS" + LDFLAGS="-L$LIBSSL_HOME/lib" CFLAGS="$SSL_CPPFLAGS" else SSL_LDFLAGS="" @@ -17935,47 +17968,24 @@ have_ssl="no" have_crypto="no" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5 -$as_echo_n "checking for SSL_library_init in -lssl... " >&6; } -if ${ac_cv_lib_ssl_SSL_library_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lssl -lcrypto -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 SSL_library_init (); +#include int main () { -return SSL_library_init (); +SSL_library_init(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ssl_SSL_library_init=yes + have_ssl="yes"; else - ac_cv_lib_ssl_SSL_library_init=no + as_fn_error $? "Your OpenSSL installation is misconfigured or missing" "$LINENO" 5 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_ssl_SSL_library_init" >&5 -$as_echo "$ac_cv_lib_ssl_SSL_library_init" >&6; } -if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then : - have_ssl="yes" -else - as_fn_error $? "Your OpenSSL installation is misconfigured or missing" "$LINENO" 5 -fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_EncryptInit in -lcrypto" >&5 @@ -18498,16 +18508,12 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pcre_version" >&5 $as_echo "$pcre_version" >&6; } - case $host_os in - darwin* ) - pcrever_major=`echo "$pcre_version" | sed -Ee 's/([0-9]+).*/\1/'` - pcrever_minor=`echo "$pcre_version" | sed -Ee 's/[0-9]+\.([0-9]+).*/\1/'` - ;; - *) - pcrever_major=`echo "$pcre_version" | sed -re 's/([0-9]+).*/\1/'` - pcrever_minor=`echo "$pcre_version" | sed -re 's/[0-9]+\.([0-9]+).*/\1/'` - ;; - esac + pcrever_prefix=`expr "$pcre_version" : '\([^0-9]*\)'` + pcrever_frag=${pcre_version#$pcrever_prefix} + + pcrever_major=`expr "$pcrever_frag" : '\([0-9]*\)'` + pcrever_frag=${pcrever_frag#*\.} + pcrever_minor=`expr "$pcrever_frag" : '\([0-9]*\)'` if test "$pcrelib" = "pcre"; then if test $pcrever_major -lt 6; then @@ -18716,9 +18722,9 @@ as_fn_error $? "Please install zlib and zlib-devel packages" "$LINENO" 5 else - vuln=`grep "ZLIB_VERSION \"1.2.0" $ZLIB_HOME/include/zlib.h` + vuln=`grep "ZLIB_VERSION \"1.2.0\"" $ZLIB_HOME/include/zlib.h` if test -z "$vuln"; then - vuln=`grep "ZLIB_VERSION \"1.2.1" $ZLIB_HOME/include/zlib.h` + vuln=`grep "ZLIB_VERSION \"1.2.1\"" $ZLIB_HOME/include/zlib.h` fi if test -n "$vuln"; then @@ -20380,7 +20386,51 @@ fi if test "X$wiconv" != "Xno"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libiconv_open in -liconv" >&5 + save_LDFLAGS="$LDFLAGS" + LDFLAGS="-L/usr/local/lib -liconv" + ICONV_HOME="" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libiconv_open in -liconv" >&5 +$as_echo_n "checking for libiconv_open in -liconv... " >&6; } +if ${ac_cv_lib_iconv_libiconv_open+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-liconv $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 libiconv_open (); +int +main () +{ +return libiconv_open (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_iconv_libiconv_open=yes +else + ac_cv_lib_iconv_libiconv_open=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_iconv_libiconv_open" >&5 +$as_echo "$ac_cv_lib_iconv_libiconv_open" >&6; } +if test "x$ac_cv_lib_iconv_libiconv_open" = xyes; then : + ICONV_HOME="/usr/local" +else + + LDFLAGS="-L/usr/lib -liconv" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libiconv_open in -liconv" >&5 $as_echo_n "checking for libiconv_open in -liconv... " >&6; } if ${ac_cv_lib_iconv_libiconv_open+:} false; then : $as_echo_n "(cached) " >&6 @@ -20417,14 +20467,28 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iconv_libiconv_open" >&5 $as_echo "$ac_cv_lib_iconv_libiconv_open" >&6; } if test "x$ac_cv_lib_iconv_libiconv_open" = xyes; then : - LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -liconv" + ICONV_HOME="/usr" +else + LDFLAGS="$save_LDFLAGS" +fi + + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } - save_LIBS="$LIBS" - LIBS="$LIBCLAMAV_LIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + save_LIBS="$LIBS" + save_CPPFLAGS="$CPPFLAGS" + LIBS="$LIBCLAMAV_LIBS" + if test "X$ICONV_HOME" != "X"; then + ICONV_LDFLAGS="$LDFLAGS" + ICONV_CPPFLAGS="-I$ICONV_HOME/include" + else + ICONV_LDFLAGS="" + ICONV_CPPFLAGS="" + fi + CPPFLAGS="$ICONV_CPPFLAGS $LIBCLAMAV_CPPFLAGS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -20433,12 +20497,12 @@ main () { - char** xin,**xout; - unsigned long il,ol; - int rc; - iconv_t iconv_struct = iconv_open("UTF-16BE","UTF-8"); - rc = iconv(iconv_struct,xin,&il,xout,&ol); - iconv_close(iconv_struct); + char** xin,**xout; + unsigned long il,ol; + int rc; + iconv_t iconv_struct = iconv_open("UTF-16BE","UTF-8"); + rc = iconv(iconv_struct,xin,&il,xout,&ol); + iconv_close(iconv_struct); ; return 0; @@ -20446,21 +20510,25 @@ _ACEOF if ac_fn_c_try_link "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_ICONV 1" >>confdefs.h + + else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LIBS="$save_LIBS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + CPPFLAGS="$save_CPPFLAGS" fi have_pthreads=no @@ -21831,7 +21899,7 @@ $as_echo "#define HAVE_STAT64 1" >>confdefs.h -CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE" +CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_stat64" >&5 $as_echo "$enable_stat64" >&6; } @@ -23931,67 +23999,168 @@ +# Check whether --enable-llvm was given. +if test "${enable_llvm+set}" = set; then : + enableval=$enable_llvm; enable_llvm=$enableval +else + enable_llvm="auto" +fi + + +if test "$enable_llvm" != "no"; then + + # Check whether --with-system-llvm was given. if test "${with_system_llvm+set}" = set; then : - withval=$with_system_llvm; case "$withval" in + withval=$with_system_llvm; system_llvm=$withval; if test "$enable_llvm" = "auto"; then enable_llvm="yes"; fi +else + system_llvm="yes" +fi + + +case "$system_llvm" in yes) - system_llvm="default" - ;; - no) - system_llvm="built-in" - ;; + # Extract the first word of "llvm-config", so it can be a program name with args. +set dummy llvm-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_llvmconfig+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $llvmconfig in + [\\/]* | ?:[\\/]*) + ac_cv_path_llvmconfig="$llvmconfig" # Let the user override the test with a path. + ;; *) - system_llvm=$withval - esac + 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_llvmconfig="$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 +llvmconfig=$ac_cv_path_llvmconfig +if test -n "$llvmconfig"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $llvmconfig" >&5 +$as_echo "$llvmconfig" >&6; } else - system_llvm="built-in" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi - -# Check whether --with-llvm-linking was given. -if test "${with_llvm_linking+set}" = set; then : - withval=$with_llvm_linking; -if test "x$system_llvm" = "xbuilt-in"; then - as_fn_error $? "Failed to configure LLVM, and LLVM linking was specified without specifying system-llvm" "$LINENO" 5 -else -case "$withval" in - static) - llvm_linking="static" - ;; - dynamic) - llvm_linking="dynamic" - ;; + if test "x$llvmconfig" = "x"; then + llvmoptserrmsg="llvm-config cannot be found within PATH" + fi + ;; + no) ;; + *) + if test -d "$withval"; then + # Extract the first word of "llvm-config", so it can be a program name with args. +set dummy llvm-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_llvmconfig+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $llvmconfig in + [\\/]* | ?:[\\/]*) + ac_cv_path_llvmconfig="$llvmconfig" # Let the user override the test with a path. + ;; *) - as_fn_error $? "Invalid argument to --with-llvm-linking" "$LINENO" 5 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $withval/bin +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_llvmconfig="$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 - +llvmconfig=$ac_cv_path_llvmconfig +if test -n "$llvmconfig"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $llvmconfig" >&5 +$as_echo "$llvmconfig" >&6; } else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + else + llvmconfig=$withval + if test ! -x "$llvmconfig"; then + llvmconfig="" + fi + fi + + if test "x$llvmconfig" = "x"; then + llvmoptserrmsg="llvm-config does not exist at $withval" + fi + ;; +esac + +if test "x$llvmconfig" != "x"; then -if test "x$system_llvm" = "xbuilt-in"; then - llvm_linking="" + +# Check whether --with-llvm-linking was given. +if test "${with_llvm_linking+set}" = set; then : + withval=$with_llvm_linking; if test "x$llvmconfig" = "x"; then + as_fn_error $? "Failed to configure LLVM, and LLVM linking was specified without valid llvm-config" "$LINENO" 5 else - llvm_linking="auto" + case "$withval" in + static) + llvm_linking="static" + ;; + dynamic) + llvm_linking="dynamic" + ;; + *) + as_fn_error $? "Invalid argument to --with-llvm-linking" "$LINENO" 5 + esac fi +else + llvm_linking="" fi -# Check whether --enable-llvm was given. -if test "${enable_llvm+set}" = set; then : - enableval=$enable_llvm; enable_llvm=$enableval -else +llvmver=`$llvmconfig --version` -if test "x$system_llvm" != "xbuilt-in"; then - enable_llvm="yes" else - enable_llvm="auto" -fi +llvmver="2.8" +system_llvm="internal" fi +fi +if test "x$llvmoptserrmsg" != "x"; then + if test "$enable_llvm" = "auto"; then + enable_llvm="no" + else + as_fn_error $? "Failed to configure LLVM, and LLVM was explicitly requested" "$LINENO" 5 + fi +fi if test "$enable_llvm" != "no"; then @@ -24041,6 +24210,55 @@ +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking LFS safe fts implementation" >&5 +$as_echo_n "checking LFS safe fts implementation... " >&6; } +if test "$cross_compiling" = yes; then : + have_LFS_fts=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int main(void) { + fts_open((void *)0, FTS_PHYSICAL, (void *)0); + + return 0; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + have_LFS_fts=yes +else + have_LFS_fts=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: $have_LFS_fts" >&5 +$as_echo "$have_LFS_fts" >&6; } + if test "x$have_LFS_fts" = "xyes"; then + SYSTEM_LFS_FTS_TRUE= + SYSTEM_LFS_FTS_FALSE='#' +else + SYSTEM_LFS_FTS_TRUE='#' + SYSTEM_LFS_FTS_FALSE= +fi + +if test "x$have_LFS_fts" = "xyes"; then + +$as_echo "#define HAVE_SYSTEM_LFS_FTS 1" >>confdefs.h + + lfs_fts_msg="libc" +else + +$as_echo "#define HAVE_SYSTEM_LFS_FTS 0" >>confdefs.h + + lfs_fts_msg="internal, libc's is not LFS compatible" +fi + # Check whether --enable-libfreshclam was given. if test "${enable_libfreshclam+set}" = set; then : enableval=$enable_libfreshclam; enable_libfreshclam=$enableval @@ -24064,62 +24282,323 @@ -case "$host_os" in -freebsd*) -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for kinfo_getvmmap in -lutil" >&5 -$as_echo_n "checking for kinfo_getvmmap in -lutil... " >&6; } -if ${ac_cv_lib_util_kinfo_getvmmap+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lutil $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +# PRELUDE +# Check whether --enable-prelude was given. +if test "${enable_prelude+set}" = set; then : + enableval=$enable_prelude; + if test "$enableval" != "no"; then -/* 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 kinfo_getvmmap (); -int -main () -{ -return kinfo_getvmmap (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_util_kinfo_getvmmap=yes -else - ac_cv_lib_util_kinfo_getvmmap=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_util_kinfo_getvmmap" >&5 -$as_echo "$ac_cv_lib_util_kinfo_getvmmap" >&6; } -if test "x$ac_cv_lib_util_kinfo_getvmmap" = xyes; then : - LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lutil" +# Check whether --with-libprelude-prefix was given. +if test "${with_libprelude_prefix+set}" = set; then : + withval=$with_libprelude_prefix; libprelude_config_prefix="$withval" else - as_fn_error $? "You are running BSD but you don't have kinfo_getvmmap in the util library. Please fix manually." "$LINENO" 5 + libprelude_config_prefix="" fi -;; -esac - - -have_curl="no" -curl_msg="Please use the web interface for submitting FPs/FNs." -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libcurl installation" >&5 -$as_echo_n "checking for libcurl installation... " >&6; } + if test x$libprelude_config_prefix != x ; then + if test x${LIBPRELUDE_CONFIG+set} != xset ; then + LIBPRELUDE_CONFIG=$libprelude_config_prefix/bin/libprelude-config + fi + fi -# Check whether --with-libcurl was given. -if test "${with_libcurl+set}" = set; then : + # Extract the first word of "libprelude-config", so it can be a program name with args. +set dummy libprelude-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_LIBPRELUDE_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $LIBPRELUDE_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_LIBPRELUDE_CONFIG="$LIBPRELUDE_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_LIBPRELUDE_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 + + test -z "$ac_cv_path_LIBPRELUDE_CONFIG" && ac_cv_path_LIBPRELUDE_CONFIG="no" + ;; +esac +fi +LIBPRELUDE_CONFIG=$ac_cv_path_LIBPRELUDE_CONFIG +if test -n "$LIBPRELUDE_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBPRELUDE_CONFIG" >&5 +$as_echo "$LIBPRELUDE_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "$LIBPRELUDE_CONFIG" != "no"; then + if $($LIBPRELUDE_CONFIG --thread > /dev/null 2>&1); then + LIBPRELUDE_PTHREAD_CFLAGS=`$LIBPRELUDE_CONFIG --thread --cflags` + + if test xno = xtrue || test xno = xyes; then + libprelude_config_args="--thread" + else + libprelude_config_args="--no-thread" + fi + else + LIBPRELUDE_PTHREAD_CFLAGS=`$LIBPRELUDE_CONFIG --pthread-cflags` + fi + fi + + min_libprelude_version=0.9.9 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libprelude - version >= $min_libprelude_version" >&5 +$as_echo_n "checking for libprelude - version >= $min_libprelude_version... " >&6; } + no_libprelude="" + if test "$LIBPRELUDE_CONFIG" = "no" ; then + no_libprelude=yes + else + LIBPRELUDE_CFLAGS=`$LIBPRELUDE_CONFIG $libprelude_config_args --cflags` + LIBPRELUDE_LDFLAGS=`$LIBPRELUDE_CONFIG $libprelude_config_args --ldflags` + LIBPRELUDE_LIBS=`$LIBPRELUDE_CONFIG $libprelude_config_args --libs` + LIBPRELUDE_PREFIX=`$LIBPRELUDE_CONFIG $libprelude_config_args --prefix` + LIBPRELUDE_CONFIG_PREFIX=`$LIBPRELUDE_CONFIG $libprelude_config_args --config-prefix` + libprelude_config_version=`$LIBPRELUDE_CONFIG $libprelude_config_args --version` + + + ac_save_CFLAGS="$CFLAGS" + ac_save_LDFLAGS="$LDFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $LIBPRELUDE_CFLAGS" + LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS" + LIBS="$LIBS $LIBPRELUDE_LIBS" + rm -f conf.libpreludetest + if test "$cross_compiling" = yes; then : + echo $ac_n "cross compiling; assumed OK... $ac_c" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main () +{ + system ("touch conf.libpreludetest"); + + if( strcmp( prelude_check_version(NULL), "$libprelude_config_version" ) ) + { + printf("\n*** 'libprelude-config --version' returned %s, but LIBPRELUDE (%s)\n", + "$libprelude_config_version", prelude_check_version(NULL) ); + printf("*** was found! If libprelude-config was correct, then it is best\n"); + printf("*** to remove the old version of LIBPRELUDE. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If libprelude-config was wrong, set the environment variable LIBPRELUDE_CONFIG\n"); + printf("*** to point to the correct copy of libprelude-config, and remove the file config.cache\n"); + printf("*** before re-running configure\n"); + } + else if ( strcmp(prelude_check_version(NULL), LIBPRELUDE_VERSION ) ) { + printf("\n*** LIBPRELUDE header file (version %s) does not match\n", LIBPRELUDE_VERSION); + printf("*** library (version %s)\n", prelude_check_version(NULL) ); + } + else { + if ( prelude_check_version( "$min_libprelude_version" ) ) + return 0; + else { + printf("no\n*** An old version of LIBPRELUDE (%s) was found.\n", + prelude_check_version(NULL) ); + printf("*** You need a version of LIBPRELUDE newer than %s. The latest version of\n", + "$min_libprelude_version" ); + printf("*** LIBPRELUDE is always available from http://www.prelude-ids.com/development/download/\n"); + printf("*** \n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the libprelude-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of LIBPRELUDE, but you can also set the LIBPRELUDE_CONFIG environment to point to the\n"); + printf("*** correct copy of libprelude-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + no_libprelude=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + LDFLAGS="$ac_save_LDFLAGS" + fi + + if test "x$no_libprelude" = x ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + : + else + if test -f conf.libpreludetest ; then + : + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + if test "$LIBPRELUDE_CONFIG" = "no" ; then + echo "*** The libprelude-config script installed by LIBPRELUDE could not be found" + echo "*** If LIBPRELUDE was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the LIBPRELUDE_CONFIG environment variable to the" + echo "*** full path to libprelude-config." + else + if test -f conf.libpreludetest ; then + : + else + echo "*** Could not run libprelude test program, checking why..." + CFLAGS="$CFLAGS $LIBPRELUDE_CFLAGS" + LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS" + LIBS="$LIBS $LIBPRELUDE_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main () +{ + return !!prelude_check_version(NULL); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding LIBPRELUDE or finding the wrong" + echo "*** version of LIBPRELUDE. If it is not finding LIBPRELUDE, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" + echo "***" +else + echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means LIBPRELUDE was incorrectly installed" + echo "*** or that you have moved LIBPRELUDE since it was installed. In the latter case, you" + echo "*** may want to edit the libprelude-config script: $LIBPRELUDE_CONFIG" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$ac_save_CFLAGS" + LDFLAGS="$ac_save_LDFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + LIBPRELUDE_CFLAGS="" + LIBPRELUDE_LDFLAGS="" + LIBPRELUDE_LIBS="" + as_fn_error $? "Cannot find libprelude: Is libprelude-config in the path?" "$LINENO" 5 + fi + rm -f conf.libpreludetest + + + + + + + + +$as_echo "#define PRELUDE_APPLICATION_USE_LIBTOOL2 /**/" >>confdefs.h + + + + CPPFLAGS="${CPPFLAGS} ${LIBPRELUDE_CFLAGS}" + LDFLAGS="${LDFLAGS} ${LIBPRELUDE_LDFLAGS}" + LDFLAGS="${LDFLAGS} ${LIBPRELUDE_LIBS}" + +$as_echo "#define PRELUDE 1" >>confdefs.h + + fi + +fi + + + +case "$host_os" in +freebsd*) +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for kinfo_getvmmap in -lutil" >&5 +$as_echo_n "checking for kinfo_getvmmap in -lutil... " >&6; } +if ${ac_cv_lib_util_kinfo_getvmmap+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lutil $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 kinfo_getvmmap (); +int +main () +{ +return kinfo_getvmmap (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_util_kinfo_getvmmap=yes +else + ac_cv_lib_util_kinfo_getvmmap=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_util_kinfo_getvmmap" >&5 +$as_echo "$ac_cv_lib_util_kinfo_getvmmap" >&6; } +if test "x$ac_cv_lib_util_kinfo_getvmmap" = xyes; then : + LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lutil" +else + as_fn_error $? "You are running BSD but you don't have kinfo_getvmmap in the util library. Please fix manually." "$LINENO" 5 +fi + +;; +esac + + +have_curl="no" +curl_msg="Please use the web interface for submitting FPs/FNs." +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libcurl installation" >&5 +$as_echo_n "checking for libcurl installation... " >&6; } + + +# Check whether --with-libcurl was given. +if test "${with_libcurl+set}" = set; then : withval=$with_libcurl; if test "$withval"; then LIBCURL_HOME="$withval" @@ -24245,12 +24724,317 @@ - if test "$have_curl" = "yes"; then - ENABLE_CLAMSUBMIT_TRUE= - ENABLE_CLAMSUBMIT_FALSE='#' + + +# Check whether --with-system-libmspack was given. +if test "${with_system_libmspack+set}" = set; then : + withval=$with_system_libmspack; system_libmspack=$withval else - ENABLE_CLAMSUBMIT_TRUE='#' - ENABLE_CLAMSUBMIT_FALSE= + system_libmspack="no" +fi + + + +if test "x$system_libmspack" = "xno"; then + use_internal_mspack=yes + if test TRUE; then + USE_INTERNAL_MSPACK_TRUE= + USE_INTERNAL_MSPACK_FALSE='#' +else + USE_INTERNAL_MSPACK_TRUE='#' + USE_INTERNAL_MSPACK_FALSE= +fi + + CLFAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" +else + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBMSPACK" >&5 +$as_echo_n "checking for LIBMSPACK... " >&6; } + +if test -n "$LIBMSPACK_CFLAGS"; then + pkg_cv_LIBMSPACK_CFLAGS="$LIBMSPACK_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmspack\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libmspack") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBMSPACK_CFLAGS=`$PKG_CONFIG --cflags "libmspack" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBMSPACK_LIBS"; then + pkg_cv_LIBMSPACK_LIBS="$LIBMSPACK_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmspack\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libmspack") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBMSPACK_LIBS=`$PKG_CONFIG --libs "libmspack" 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 + LIBMSPACK_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libmspack" 2>&1` + else + LIBMSPACK_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libmspack" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBMSPACK_PKG_ERRORS" >&5 + + use_internal_mspack=yes +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + use_internal_mspack=yes +else + LIBMSPACK_CFLAGS=$pkg_cv_LIBMSPACK_CFLAGS + LIBMSPACK_LIBS=$pkg_cv_LIBMSPACK_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + use_internal_mspack=no +fi + if test "x$use_internal_mspack" = "xyes"; then + USE_INTERNAL_MSPACK_TRUE= + USE_INTERNAL_MSPACK_FALSE='#' +else + USE_INTERNAL_MSPACK_TRUE='#' + USE_INTERNAL_MSPACK_FALSE= +fi + +fi + + +if test "x$use_internal_mspack" = "xyes"; then + mspack_msg="Internal" + subdirs="$subdirs libclamav/libmspack-0.5alpha" + + # 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 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + 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 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + 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 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + 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 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + 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 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + 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 + + +fi + +else + mspack_msg="External, $LIBMSPACK_CFLAGS $LIBMSPACK_LIBS" fi @@ -24464,12 +25248,20 @@ as_fn_error $? "conditional \"HAVE_CURSES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${SYSTEM_LFS_FTS_TRUE}" && test -z "${SYSTEM_LFS_FTS_FALSE}"; then + as_fn_error $? "conditional \"SYSTEM_LFS_FTS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${ENABLE_LIBFRESHCLAM_TRUE}" && test -z "${ENABLE_LIBFRESHCLAM_FALSE}"; then as_fn_error $? "conditional \"ENABLE_LIBFRESHCLAM\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${ENABLE_CLAMSUBMIT_TRUE}" && test -z "${ENABLE_CLAMSUBMIT_FALSE}"; then - as_fn_error $? "conditional \"ENABLE_CLAMSUBMIT\" was never defined. +if test -z "${USE_INTERNAL_MSPACK_TRUE}" && test -z "${USE_INTERNAL_MSPACK_FALSE}"; then + as_fn_error $? "conditional \"USE_INTERNAL_MSPACK\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${USE_INTERNAL_MSPACK_TRUE}" && test -z "${USE_INTERNAL_MSPACK_FALSE}"; then + as_fn_error $? "conditional \"USE_INTERNAL_MSPACK\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -24869,7 +25661,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ClamAV $as_me 0.99.2, which was +This file was extended by ClamAV $as_me 0.99.3-beta1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -24936,7 +25728,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ClamAV config.status 0.99.2 +ClamAV config.status 0.99.3-beta1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -26830,6 +27622,14 @@ ENABLE_YARA_FALSE= fi + if test "X$have_curl" = "Xyes" && test "X$have_json" = "Xyes"; then + ENABLE_CLAMSUBMIT_TRUE= + ENABLE_CLAMSUBMIT_FALSE='#' +else + ENABLE_CLAMSUBMIT_TRUE='#' + ENABLE_CLAMSUBMIT_FALSE= +fi + no_recursion="yes"; ac_config_files="$ac_config_files libclamav/Makefile" @@ -27041,12 +27841,20 @@ as_fn_error $? "conditional \"HAVE_CURSES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${SYSTEM_LFS_FTS_TRUE}" && test -z "${SYSTEM_LFS_FTS_FALSE}"; then + as_fn_error $? "conditional \"SYSTEM_LFS_FTS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${ENABLE_LIBFRESHCLAM_TRUE}" && test -z "${ENABLE_LIBFRESHCLAM_FALSE}"; then as_fn_error $? "conditional \"ENABLE_LIBFRESHCLAM\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${ENABLE_CLAMSUBMIT_TRUE}" && test -z "${ENABLE_CLAMSUBMIT_FALSE}"; then - as_fn_error $? "conditional \"ENABLE_CLAMSUBMIT\" was never defined. +if test -z "${USE_INTERNAL_MSPACK_TRUE}" && test -z "${USE_INTERNAL_MSPACK_FALSE}"; then + as_fn_error $? "conditional \"USE_INTERNAL_MSPACK\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${USE_INTERNAL_MSPACK_TRUE}" && test -z "${USE_INTERNAL_MSPACK_FALSE}"; then + as_fn_error $? "conditional \"USE_INTERNAL_MSPACK\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__EXEEXT_TRUE}" && test -z "${am__EXEEXT_FALSE}"; then @@ -27061,6 +27869,10 @@ as_fn_error $? "conditional \"ENABLE_YARA\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${ENABLE_CLAMSUBMIT_TRUE}" && test -z "${ENABLE_CLAMSUBMIT_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_CLAMSUBMIT\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 @@ -27458,7 +28270,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ClamAV $as_me 0.99.2, which was +This file was extended by ClamAV $as_me 0.99.3-beta1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -27525,7 +28337,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ClamAV config.status 0.99.2 +ClamAV config.status 0.99.3-beta1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -29510,19 +30322,35 @@ $as_echo "yes ($have_milter)" fi +if test "X$have_curl" = "Xyes" && test "X$have_json" = "Xyes"; then $as_echo_n " clamsubmit : " - if test "x$curl_msg" = "xno"; then : - $as_echo "$have_curl (disabled)" -elif test "x$curl_msg" = "xyes"; then : - $as_echo "$have_curl" -elif test "x$curl_msg" = "x"; then : - $as_echo "$have_curl" + if test "xyes" = "xno"; then : + $as_echo "yes (disabled)" +elif test "xyes" = "xyes"; then : + $as_echo "yes" +elif test "xyes" = "x"; then : + $as_echo "yes" else - $as_echo "$have_curl ($curl_msg)" + $as_echo "yes (yes)" fi +else + + + $as_echo_n " clamsubmit : " + if test "xno" = "xno"; then : + $as_echo "no (disabled)" +elif test "xno" = "xyes"; then : + $as_echo "no" +elif test "xno" = "x"; then : + $as_echo "no" +else + $as_echo "no (no)" +fi + +fi { $as_echo "$as_me:${as_lineno-$LINENO}: Summary of engine performance features" >&5 $as_echo "$as_me: Summary of engine performance features" >&6;} @@ -29559,18 +30387,32 @@ if test "$subdirfailed" = "no"; then have_jit="yes" fi -if test "x$llvm_linking" = "x"; then +if test "$enable_llvm" = "no"; then $as_echo_n " llvm : " if test "x$enable_llvm" = "xno"; then : - $as_echo "$have_jit, from $system_llvm (disabled)" + $as_echo "$have_jit (disabled)" elif test "x$enable_llvm" = "xyes"; then : - $as_echo "$have_jit, from $system_llvm" + $as_echo "$have_jit" elif test "x$enable_llvm" = "x"; then : - $as_echo "$have_jit, from $system_llvm" + $as_echo "$have_jit" else - $as_echo "$have_jit, from $system_llvm ($enable_llvm)" + $as_echo "$have_jit ($enable_llvm)" +fi + +elif test "x$llvm_linking" = "x"; then + + + $as_echo_n " llvm : " + if test "x$enable_llvm" = "xno"; then : + $as_echo "$have_jit($llvmver), from $system_llvm (disabled)" +elif test "x$enable_llvm" = "xyes"; then : + $as_echo "$have_jit($llvmver), from $system_llvm" +elif test "x$enable_llvm" = "x"; then : + $as_echo "$have_jit($llvmver), from $system_llvm" +else + $as_echo "$have_jit($llvmver), from $system_llvm ($enable_llvm)" fi else @@ -29578,13 +30420,13 @@ $as_echo_n " llvm : " if test "x$enable_llvm" = "xno"; then : - $as_echo "$have_jit, from $system_llvm ($llvm_linking) (disabled)" + $as_echo "$have_jit($llvmver), from $system_llvm ($llvm_linking) (disabled)" elif test "x$enable_llvm" = "xyes"; then : - $as_echo "$have_jit, from $system_llvm ($llvm_linking)" + $as_echo "$have_jit($llvmver), from $system_llvm ($llvm_linking)" elif test "x$enable_llvm" = "x"; then : - $as_echo "$have_jit, from $system_llvm ($llvm_linking)" + $as_echo "$have_jit($llvmver), from $system_llvm ($llvm_linking)" else - $as_echo "$have_jit, from $system_llvm ($llvm_linking) ($enable_llvm)" + $as_echo "$have_jit($llvmver), from $system_llvm ($llvm_linking) ($enable_llvm)" fi fi @@ -29687,6 +30529,32 @@ fi fi + + + $as_echo_n " preclass : " + if test "x$have_json" = "xno"; then : + $as_echo "$LIBJSON_HOME (disabled)" +elif test "x$have_json" = "xyes"; then : + $as_echo "$LIBJSON_HOME" +elif test "x$have_json" = "x"; then : + $as_echo "$LIBJSON_HOME" +else + $as_echo "$LIBJSON_HOME ($have_json)" +fi + + + + $as_echo_n " libmspack : " + if test "x$mspack_msg" = "xno"; then : + $as_echo "yes (disabled)" +elif test "x$mspack_msg" = "xyes"; then : + $as_echo "yes" +elif test "x$mspack_msg" = "x"; then : + $as_echo "yes" +else + $as_echo "yes ($mspack_msg)" +fi + if test "x$XML_LIBS" = "x"; then @@ -29730,6 +30598,20 @@ fi + + $as_echo_n " fts : " + if test "x$lfs_fts_msg" = "xno"; then : + $as_echo "yes (disabled)" +elif test "x$lfs_fts_msg" = "xyes"; then : + $as_echo "yes" +elif test "x$lfs_fts_msg" = "x"; then : + $as_echo "yes" +else + $as_echo "yes ($lfs_fts_msg)" +fi + + + # Yep, downgrading the compiler avoids the bug too: # 4.0.x, and 4.1.0 are the known buggy versions # 3.4 doesn't have the bug diff -Nru clamav-0.99.2+dfsg/configure.ac clamav-0.99.3~beta1+dfsg/configure.ac --- clamav-0.99.2+dfsg/configure.ac 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/configure.ac 2017-07-19 19:55:45.000000000 +0000 @@ -20,7 +20,7 @@ AC_PREREQ([2.59]) dnl For a release change [devel] to the real version [0.xy] dnl also change VERSION below -AC_INIT([ClamAV], [0.99.2], [http://bugs.clamav.net/], [clamav], [http://www.clamav.net/]) +AC_INIT([ClamAV], [0.99.3-beta1], [http://bugs.clamav.net/], [clamav], [http://www.clamav.net/]) AH_BOTTOM([#include "platform.h"]) dnl put configure auxiliary into config @@ -125,8 +125,11 @@ m4_include([m4/reorganization/llvm.m4]) m4_include([m4/reorganization/sha_collect.m4]) m4_include([m4/reorganization/yara.m4]) +m4_include([m4/reorganization/code_checks/fts.m4]) m4_include([m4/reorganization/libfreshclam.m4]) +m4_include([m4/reorganization/prelude.m4]) + m4_include([m4/reorganization/bsd.m4]) dnl Freshclam dependencies @@ -134,7 +137,16 @@ m4_include([m4/reorganization/substitutions.m4]) -AM_CONDITIONAL([ENABLE_CLAMSUBMIT], [test "$have_curl" = "yes"]) +m4_include([m4/reorganization/libmspack.m4]) + +if test "x$use_internal_mspack" = "xyes"; then + mspack_msg="Internal" + AC_CONFIG_SUBDIRS([libclamav/libmspack-0.5alpha]) + AC_SYS_LARGEFILE +else + mspack_msg="External, $LIBMSPACK_CFLAGS $LIBMSPACK_LIBS" +fi + AC_CONFIG_FILES([ clamscan/Makefile @@ -189,6 +201,8 @@ [test "$subdirfailed" != "yes" && test "$enable_llvm" != "no"]) AM_CONDITIONAL([ENABLE_YARA], [test "$enable_yara" != "no"]) +AM_CONDITIONAL([ENABLE_CLAMSUBMIT], + [test "X$have_curl" = "Xyes" && test "X$have_json" = "Xyes"]) no_recursion="yes"; AC_OUTPUT([libclamav/Makefile]) @@ -219,7 +233,11 @@ AC_MSG_NOTICE([Summary of optional tools]) CL_MSG_STATUS([clamdtop ],[$CURSES_LIBS],[$enable_clamdtop]) CL_MSG_STATUS([milter ],[yes],[$have_milter]) -CL_MSG_STATUS([clamsubmit ],[$have_curl],[$curl_msg]) +if test "X$have_curl" = "Xyes" && test "X$have_json" = "Xyes"; then + CL_MSG_STATUS([clamsubmit ], [yes], [yes]) +else + CL_MSG_STATUS([clamsubmit ], [no], [no]) +fi AC_MSG_NOTICE([Summary of engine performance features]) if test "x$enable_debug" = "xyes"; then @@ -231,10 +249,12 @@ if test "$subdirfailed" = "no"; then have_jit="yes" fi -if test "x$llvm_linking" = "x"; then - CL_MSG_STATUS([llvm ],[$have_jit, from $system_llvm],[$enable_llvm]) +if test "$enable_llvm" = "no"; then + CL_MSG_STATUS([llvm ],[$have_jit],[$enable_llvm]) +elif test "x$llvm_linking" = "x"; then + CL_MSG_STATUS([llvm ],[$have_jit($llvmver), from $system_llvm],[$enable_llvm]) else - CL_MSG_STATUS([llvm ],[$have_jit, from $system_llvm ($llvm_linking)],[$enable_llvm]) + CL_MSG_STATUS([llvm ],[$have_jit($llvmver), from $system_llvm ($llvm_linking)],[$enable_llvm]) fi CL_MSG_STATUS([mempool ],[$have_mempool],[$enable_mempool]) @@ -250,12 +270,16 @@ else CL_MSG_STATUS([pcre ],[$PCRE_HOME],[$have_pcre]) fi +CL_MSG_STATUS([preclass ],[$LIBJSON_HOME],[$have_json]) +CL_MSG_STATUS([libmspack ],[yes],[$mspack_msg]) if test "x$XML_LIBS" = "x"; then CL_MSG_STATUS([libxml2 ],[no],[]) else CL_MSG_STATUS([libxml2 ],[yes, from $XML_HOME],[]) fi CL_MSG_STATUS([yara ],[$enable_yara],[$enable_yara]) +CL_MSG_STATUS([fts ],[yes],[$lfs_fts_msg]) + # Yep, downgrading the compiler avoids the bug too: # 4.0.x, and 4.1.0 are the known buggy versions diff -Nru clamav-0.99.2+dfsg/database/Makefile.in clamav-0.99.3~beta1+dfsg/database/Makefile.in --- clamav-0.99.2+dfsg/database/Makefile.in 2016-04-22 16:19:52.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/database/Makefile.in 2017-06-23 21:20:56.000000000 +0000 @@ -104,10 +104,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -162,12 +163,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -257,6 +263,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -284,7 +292,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -378,6 +395,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/debian/changelog clamav-0.99.3~beta1+dfsg/debian/changelog --- clamav-0.99.2+dfsg/debian/changelog 2017-08-15 20:04:46.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/changelog 2017-11-22 21:56:26.000000000 +0000 @@ -1,3 +1,72 @@ +clamav (0.99.3~beta1+dfsg-2ubuntu1) bionic; urgency=medium + + * Merge with Debian unstable (LP: #1732439). Remaining changes: + - Fix build by forcing llvm 3.9 + (testsuite seems to be failing) + - debian/patches/fix_newer_zlib.patch: fix compatibility with zlib + 1.2.9 and newer (LP #1692073). + [DEP3 header updated to indicate it was incorporated upstream] + * Drop: + * debian/patches/zlib-check.patch: + + cherry-pick upstream fix for wrong zlib version check + [Fixed upstream] + - SECURITY UPDATE: DoS via crafted e-mail message + + debian/patches/CVE-2017-6418.patch: fix invalid read in + libclamav/message.c. + + CVE-2017-6418 + [Fixed upstream] + - SECURITY UPDATE: DoS via WWPack compression + + debian/patches/CVE-2017-6420.patch: add bounds checks to + libclamav/wwunpack.c. + + debian/patches/CVE-2017-6420-2.patch: fix unit tests in + libclamav/wwunpack.c, unit_tests/check_jsnorm.c. + + CVE-2017-6420 + [Fixed upstream] + + -- Andreas Hasenack Wed, 22 Nov 2017 19:56:26 -0200 + +clamav (0.99.3~beta1+dfsg-2) unstable; urgency=medium + + * Build again against system's libmspack (dropped by accident) + (Closes: #872594). + * Don't replace config file with sample config after debconf gets disabled + (in milter and daemon (Closes: #870253). + * Update standards to 4.0.1 + - use invoke-rc.d instead of /etc/init.d. + - drop priority extra from clamav-milter. + * Add bytecode.c(l|v)d to log clamav-freshclam.logcheck.ignore.server. Patch + by Václav Ovsík (Closes: #868766). + + -- Sebastian Andrzej Siewior Sat, 02 Sep 2017 21:26:33 +0200 + +clamav (0.99.3~beta1+dfsg-1) unstable; urgency=medium + + * Upload to unstable + * update to official beta1 release: + - drop fts-no-use-AC_TRY_RUN.patch, applied upstream. + + -- Sebastian Andrzej Siewior Sun, 06 Aug 2017 22:13:23 +0200 + +clamav (0.99.3~snapshot20170704+dfsg-1) experimental; urgency=medium + + * Update to upstream snapshot (commit + 144ef69462427b63a650294257c892b047601aac): + - add config options + - boost symbol file + - drop applied patches: + - Allow-M-suffix-for-PCREMaxFileSize.patch + - bb11549-fix-temp-file-cleanup-issue.patch + - clamav_add_private_fts_implementation.patch + - drop-AllowSupplementaryGroups-option-and-make-it-def.patch + - fix-ssize_t-size_t-off_t-printf-modifier.patch + - libclamav-use-libmspack.patch + - make_it_compile_against_openssl_1_1_0.patch + - add new ones: + - fts-no-use-AC_TRY_RUN.patch + - clamsubmit-add-JSON-libs-to-clamsubmit.patch + + -- Sebastian Andrzej Siewior Mon, 10 Jul 2017 00:06:32 +0200 + clamav (0.99.2+dfsg-6ubuntu2) artful; urgency=medium * SECURITY UPDATE: DoS via crafted e-mail message diff -Nru clamav-0.99.2+dfsg/debian/clamav-daemon.init.in clamav-0.99.3~beta1+dfsg/debian/clamav-daemon.init.in --- clamav-0.99.2+dfsg/debian/clamav-daemon.init.in 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/clamav-daemon.init.in 2017-11-22 21:56:26.000000000 +0000 @@ -43,7 +43,7 @@ log_failure_msg "There is no configuration file for Clamav." log_failure_msg "Please either dpkg-reconfigure $DESC, or copy the example from" log_failure_msg "/usr/share/doc/clamav-base/examples/ to $CLAMAVCONF and run" - log_failure_msg "'/etc/init.d/clamav-daemon start'" + log_failure_msg "'invoke-rc.d clamav-daemon start'" if [ "$1" = "status" ]; then # program or service status is unknown exit 4; @@ -57,7 +57,7 @@ if [ -n "$Example" ]; then log_failure_msg "Clamav is not configured." - log_failure_msg "Please edit $CLAMAVCONF and run '/etc/init.d/clamav-daemon start'" + log_failure_msg "Please edit $CLAMAVCONF and run 'invoke-rc.d clamav-daemon start'" if [ "$1" = "status" ]; then # program or service status is unknown exit 4; @@ -115,7 +115,7 @@ if [ ! -e "$DATABASEDIR"/"$db".cvd ] && [ ! -d "$DATABASEDIR"/"$db".inc ] && [ ! -e "$DATABASEDIR"/"$db".cld ]; then log_failure_msg "Clamav signatures not found in $DATABASEDIR" log_failure_msg "Please retrieve them using freshclam" - log_failure_msg "Then run '/etc/init.d/clamav-daemon start'" + log_failure_msg "Then run 'invoke-rc.d clamav-daemon start'" # this is expected on a fresh installation exit 0 fi diff -Nru clamav-0.99.2+dfsg/debian/clamav-daemon.postinst.in clamav-0.99.3~beta1+dfsg/debian/clamav-daemon.postinst.in --- clamav-0.99.2+dfsg/debian/clamav-daemon.postinst.in 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/clamav-daemon.postinst.in 2017-11-22 21:56:26.000000000 +0000 @@ -229,6 +229,8 @@ [ -z "$ScanXMLDOCS" ] && ScanXMLDOCS=true [ -z "$ScanHWP3" ] && ScanHWP3=true [ -z "$MaxRecHWP3" ] && MaxRecHWP3=16 + [ -z "$PreludeEnable" ] && PreludeEnable=no + [ -z "$PreludeAnalyzerName" ] && PreludeAnalyzerName=ClamAV if `dpkg --compare-versions "$2" lt 0.98.7+dfsg-2~`; then # Update the MaxRecursion variable, if it is the previous default value. @@ -293,6 +295,8 @@ LogFacility $LogFacility LogClean $LogClean LogVerbose $LogVerbose +PreludeEnable $PreludeEnable +PreludeAnalyzerName $PreludeAnalyzerName DatabaseDirectory $DatabaseDirectory OfficialDatabaseOnly $OfficialDatabaseOnly SelfCheck $SelfCheck @@ -441,7 +445,7 @@ else # Let the configuration be handled manually. ucf_cleanup "$CLAMAVCONF" - ucf_upgrade_check "$CLAMAVCONF" /usr/share/doc/clamav-daemon/examples/clamd.conf.sample /var/lib/ucf/cache/:etc:clamav:clamd.conf + ucf -p "$CLAMAVCONF" if [ -e "$CLAMAVSYSTEMDCLAMDONF" ]; then echo "Disabling old systemd service override options for clamav-daemon" mv "$CLAMAVSYSTEMDCLAMDONF" "$CLAMAVSYSTEMDCLAMDONF".dpkg-old @@ -490,7 +494,7 @@ echo " if [ -d /run/systemd/system ]; then" >> $DEBROTATEFILE echo " systemctl -q is-active clamav-daemon && systemctl kill --signal=SIGHUP clamav-daemon || true" >> $DEBROTATEFILE echo " else" >> $DEBROTATEFILE - echo " /etc/init.d/clamav-daemon reload-log > /dev/null || true" >> $DEBROTATEFILE + echo " invoke-rc.d clamav-daemon reload-log > /dev/null || true" >> $DEBROTATEFILE echo " fi" >> $DEBROTATEFILE echo " endscript" >> $DEBROTATEFILE echo " }" >> $DEBROTATEFILE diff -Nru clamav-0.99.2+dfsg/debian/clamav-freshclam-ifupdown clamav-0.99.3~beta1+dfsg/debian/clamav-freshclam-ifupdown --- clamav-0.99.2+dfsg/debian/clamav-freshclam-ifupdown 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/clamav-freshclam-ifupdown 2017-11-22 21:56:26.000000000 +0000 @@ -6,7 +6,7 @@ [ -e /var/lib/clamav/interface ] || exit 0 -INIT=/etc/init.d/clamav-freshclam +INIT=invoke-rc.d clamav-freshclam CLAMAV_CONF_FILE=/etc/clamav/clamd.conf FRESHCLAM_CONF_FILE=/etc/clamav/freshclam.conf diff -Nru clamav-0.99.2+dfsg/debian/clamav-freshclam.logcheck.ignore.server clamav-0.99.3~beta1+dfsg/debian/clamav-freshclam.logcheck.ignore.server --- clamav-0.99.2+dfsg/debian/clamav-freshclam.logcheck.ignore.server 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/clamav-freshclam.logcheck.ignore.server 2017-11-22 21:56:26.000000000 +0000 @@ -1,6 +1,6 @@ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ freshclam\[[0-9]+\]: ClamAV update process started at .*$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ freshclam\[[0-9]+\]: Received signal: (wake up|re-opening log file)$ -^\w{3} [ :0-9]{11} [._[:alnum:]-]+ freshclam\[[0-9]+\]: (daily|main)\.c(l|v)d (is up to date|updated) \(version: [0-9]+, sigs: [0-9]+, f-level: [0-9]+, builder: \w+\)$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ freshclam\[[0-9]+\]: (bytecode|daily|main)\.c(l|v)d (is up to date|updated) \(version: [0-9]+, sigs: [0-9]+, f-level: [0-9]+, builder: \w+\)$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ freshclam\[[0-9]+\]: Clamd successfully notified about the update\.$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ freshclam\[[0-9]+\]: --------------------------------------$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ freshclam\[[0-9]+\]: Database updated \([0-9]+ signatures\) from .* \(IP: [0-9.]+\)$ diff -Nru clamav-0.99.2+dfsg/debian/clamav-freshclam.postinst.in clamav-0.99.3~beta1+dfsg/debian/clamav-freshclam.postinst.in --- clamav-0.99.2+dfsg/debian/clamav-freshclam.postinst.in 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/clamav-freshclam.postinst.in 2017-11-22 21:56:26.000000000 +0000 @@ -144,7 +144,7 @@ echo " if [ -d /run/systemd/system ]; then" >> $DEBROTFILE echo " systemctl -q is-active clamav-freshclam && systemctl kill --signal=SIGHUP clamav-freshclam || true" >> $DEBROTFILE echo " else" >> $DEBROTFILE - echo " /etc/init.d/clamav-freshclam reload-log > /dev/null || true" >> $DEBROTFILE + echo " invoke-rc.d clamav-freshclam reload-log > /dev/null || true" >> $DEBROTFILE echo " fi" >> $DEBROTFILE echo " endscript" >> $DEBROTFILE echo " }" >> $DEBROTFILE @@ -336,33 +336,19 @@ fi if [ "$runas" = 'daemon' ]; then - if [ -x "/etc/init.d/clamav-freshclam" ]; then - update-rc.d clamav-freshclam defaults >/dev/null - fi - if pathfind invoke-rc.d; then - invoke-rc.d clamav-freshclam start - else - /etc/init.d/clamav-freshclam start - fi + update-rc.d clamav-freshclam defaults >/dev/null + invoke-rc.d clamav-freshclam start elif [ "$runas" = 'ifup.d' ]; then for intrface in $iface; do if route | grep -q "$intrface"; then - if pathfind invoke-rc.d; then - IFACE="$intrface" invoke-rc.d clamav-freshclam start || true - else - IFACE="$intrface" /etc/init.d/clamav-freshclam start || true - fi + IFACE="$intrface" invoke-rc.d clamav-freshclam start || true break fi done update-rc.d -f clamav-freshclam remove > /dev/null 2>&1 else echo "Starting database update: " - if pathfind invoke-rc.d; then - invoke-rc.d clamav-freshclam no-daemon || true - else - /etc/init.d/clamav-freshclam no-daemon || true - fi + invoke-rc.d clamav-freshclam no-daemon || true update-rc.d -f clamav-freshclam remove > /dev/null 2>&1 fi ;; diff -Nru clamav-0.99.2+dfsg/debian/clamav-freshclam.prerm.in clamav-0.99.3~beta1+dfsg/debian/clamav-freshclam.prerm.in --- clamav-0.99.2+dfsg/debian/clamav-freshclam.prerm.in 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/clamav-freshclam.prerm.in 2017-11-22 21:56:26.000000000 +0000 @@ -4,12 +4,6 @@ #COMMON-FUNCTIONS# -if [ -x "/etc/init.d/clamav-freshclam" ]; then - if pathfind invoke-rc.d ; then - invoke-rc.d clamav-freshclam stop - else - /etc/init.d/clamav-freshclam stop - fi -fi +invoke-rc.d clamav-freshclam stop || true #DEBHELPER# exit 0 diff -Nru clamav-0.99.2+dfsg/debian/clamav-milter.init.in clamav-0.99.3~beta1+dfsg/debian/clamav-milter.init.in --- clamav-0.99.2+dfsg/debian/clamav-milter.init.in 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/clamav-milter.init.in 2017-11-22 21:56:26.000000000 +0000 @@ -35,7 +35,7 @@ log_failure_msg "There is no configuration file for clamav-milter." log_failure_msg "Please either dpkg-reconfigure $DESC, or copy the example from" log_failure_msg "/usr/share/doc/clamav-milter/examples/ to $CLAMAVCONF and run" - log_failure_msg "'/etc/init.d/clamav-milter start'" + log_failure_msg "'invoke-rc.d clamav-milter start'" if [ "$1" = "status" ]; then # program or service status is unknown exit 4; @@ -50,7 +50,7 @@ if [ -n "$Example" ]; then log_failure_msg "$DESC is not configured." - log_failure_msg "Please edit $CLAMAVCONF and run '/etc/init.d/clamav-milter start'" + log_failure_msg "Please edit $CLAMAVCONF and run 'invoke-rc.d clamav-milter start'" if [ "$1" = "status" ]; then # program or service status is unknown exit 4; diff -Nru clamav-0.99.2+dfsg/debian/clamav-milter.postinst.in clamav-0.99.3~beta1+dfsg/debian/clamav-milter.postinst.in --- clamav-0.99.2+dfsg/debian/clamav-milter.postinst.in 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/clamav-milter.postinst.in 2017-11-22 21:56:26.000000000 +0000 @@ -217,7 +217,7 @@ else ucf_cleanup "$CLAMAVMILTERCONF" - ucf_upgrade_check "$CLAMAVMILTERCONF" /usr/share/doc/clamav-milter/examples/clamav-milter.conf.sample /var/lib/ucf/cache/:etc:clamav:clamav-milter.conf + ucp -p "$CLAMAVMILTERCONF" fi if [ -f "$CLAMAVMILTERCONF" ] && [ ! -L "$CLAMAVMILTERCONF" ]; then @@ -243,7 +243,7 @@ echo " delaycompress" >> $DEBROTATEFILE echo " create 640 $User adm" >> $DEBROTATEFILE echo " postrotate" >> $DEBROTATEFILE - echo " /etc/init.d/clamav-milter restart > /dev/null || true" >> $DEBROTATEFILE + echo " invoke-rc.d clamav-milter restart > /dev/null || true" >> $DEBROTATEFILE echo " endscript" >> $DEBROTATEFILE echo " }" >> $DEBROTATEFILE touch "$LogFile" diff -Nru clamav-0.99.2+dfsg/debian/control clamav-0.99.3~beta1+dfsg/debian/control --- clamav-0.99.2+dfsg/debian/control 2017-08-15 20:04:46.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/control 2017-11-22 21:56:26.000000000 +0000 @@ -33,7 +33,7 @@ po-debconf, python:native, zlib1g-dev -Standards-Version: 3.9.8 +Standards-Version: 4.0.1 Vcs-Git: https://anonscm.debian.org/git/pkg-clamav/clamav.git Vcs-Browser: https://anonscm.debian.org/cgit/pkg-clamav/clamav.git Homepage: https://www.clamav.net/ @@ -247,7 +247,6 @@ Package: clamav-milter Architecture: any Suggests: clamav-docs, daemon [!hurd-any] -Priority: extra Recommends: clamav-daemon Depends: adduser, clamav-base (>= ${source:Version}), diff -Nru clamav-0.99.2+dfsg/debian/copyright clamav-0.99.3~beta1+dfsg/debian/copyright --- clamav-0.99.2+dfsg/debian/copyright 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/copyright 2017-11-22 21:56:26.000000000 +0000 @@ -279,7 +279,6 @@ Files: clamd/fts.c clamd/priv_fts.h - debian/patches/clamav_add_private_fts_implementation.patch Copyright: 1990, 1993-1994, The Regents of the University of California. 1994-2015, Free Software Foundation, Inc. @@ -538,6 +537,49 @@ Comment: See COPYING.lzma. +Files: libclamav/libmspack-0.5alpha/* +Copyright: + 2003-2013, Stuart Caie + 2003-2013, Matthew Russotto + 2013, Intel Corporation +License: LGPL-2.1 + +Files: libclamav/lzw/* +Copyright: + 1988-1997 Sam Leffler + 1991-1997 Silicon Graphics, Inc + 2016 Cisco and/or its affiliates. All rights reserved. +License: LZW + Permission to use, copy, modify, distribute, and sell this software and + its documentation for any purpose is hereby granted without fee, provided + that (i) the above copyright notices and this permission notice appear in + all copies of the software and related documentation, and (ii) the names of + Sam Leffler and Silicon Graphics may not be used in any advertising or + publicity relating to the software without the specific, prior written + permission of Sam Leffler and Silicon Graphics. + . + THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + . + IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + OF THIS SOFTWARE. + +Files: libclamav/tomsfastmath/* +Copyright: Public Domain +License: public-domain + TomsFastMath is public domain. + . + Note some ideas were borrowed from LibTomMath and OpenSSL. All of the code is original or ported + from LibTomMath [no code was ported from OpenSSL]. As such the origins and status of this code + are both public domain. + . + -- Tom St Denis + Files: libclamav/yara_* Copyright: diff -Nru clamav-0.99.2+dfsg/debian/.git-dpm clamav-0.99.3~beta1+dfsg/debian/.git-dpm --- clamav-0.99.2+dfsg/debian/.git-dpm 2017-01-30 20:27:33.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/.git-dpm 2017-11-22 21:56:26.000000000 +0000 @@ -1,8 +1,8 @@ # see git-dpm(1) from git-dpm package -4a07f7933aad6b3f3e533fa69e5401d82415b319 -4a07f7933aad6b3f3e533fa69e5401d82415b319 -48a96d2a3f0f4aca12f39f62a53fe1671a6e15a2 -48a96d2a3f0f4aca12f39f62a53fe1671a6e15a2 -clamav_0.99.2+dfsg.orig.tar.xz -b52737367372ddb80ed8d9b669540c3c6531baa2 -5772404 +cb77ce50d70350cd94253f15c1e8d414c0fd8191 +cb77ce50d70350cd94253f15c1e8d414c0fd8191 +68d2668d72ad51808dd0696e2ab591e0f48eabc4 +68d2668d72ad51808dd0696e2ab591e0f48eabc4 +clamav_0.99.3~beta1+dfsg.orig.tar.xz +b936f63d16b33e26c283985ffe8cf84c1ad33dc4 +5883052 diff -Nru clamav-0.99.2+dfsg/debian/libclamav7.symbols clamav-0.99.3~beta1+dfsg/debian/libclamav7.symbols --- clamav-0.99.2+dfsg/debian/libclamav7.symbols 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/libclamav7.symbols 2017-11-22 21:56:26.000000000 +0000 @@ -1,15 +1,15 @@ libclamav.so.7 libclamav7 #MINVER# - CLAMAV_PRIVATE@CLAMAV_PRIVATE 0.99.2 + CLAMAV_PRIVATE@CLAMAV_PRIVATE 0.99.3~beta1 CLAMAV_PUBLIC@CLAMAV_PUBLIC 0.99~rc1 - base64Flush@CLAMAV_PRIVATE 0.99.2 - blobAddData@CLAMAV_PRIVATE 0.99.2 - blobCreate@CLAMAV_PRIVATE 0.99.2 - blobDestroy@CLAMAV_PRIVATE 0.99.2 - cl_ASN1_GetTimeT@CLAMAV_PRIVATE 0.99.2 + base64Flush@CLAMAV_PRIVATE 0.99.3~beta1 + blobAddData@CLAMAV_PRIVATE 0.99.3~beta1 + blobCreate@CLAMAV_PRIVATE 0.99.3~beta1 + blobDestroy@CLAMAV_PRIVATE 0.99.3~beta1 + cl_ASN1_GetTimeT@CLAMAV_PRIVATE 0.99.3~beta1 cl_always_gen_section_hash@CLAMAV_PUBLIC 0.99~rc1 - cl_base64_decode@CLAMAV_PRIVATE 0.99.2 - cl_base64_encode@CLAMAV_PRIVATE 0.99.2 - cl_cleanup_crypto@CLAMAV_PRIVATE 0.99.2 + cl_base64_decode@CLAMAV_PRIVATE 0.99.3~beta1 + cl_base64_encode@CLAMAV_PRIVATE 0.99.3~beta1 + cl_cleanup_crypto@CLAMAV_PRIVATE 0.99.3~beta1 cl_countsigs@CLAMAV_PUBLIC 0.99~rc1 cl_cvdfree@CLAMAV_PUBLIC 0.99~rc1 cl_cvdhead@CLAMAV_PUBLIC 0.99~rc1 @@ -49,21 +49,21 @@ cl_fmap_close@CLAMAV_PUBLIC 0.99~rc1 cl_fmap_open_handle@CLAMAV_PUBLIC 0.99~rc1 cl_fmap_open_memory@CLAMAV_PUBLIC 0.99~rc1 - cl_get_pkey_file@CLAMAV_PRIVATE 0.99.2 - cl_get_x509_from_mem@CLAMAV_PRIVATE 0.99.2 - cl_hash_data@CLAMAV_PRIVATE 0.99.2 + cl_get_pkey_file@CLAMAV_PRIVATE 0.99.3~beta1 + cl_get_x509_from_mem@CLAMAV_PRIVATE 0.99.3~beta1 + cl_hash_data@CLAMAV_PRIVATE 0.99.3~beta1 cl_hash_destroy@CLAMAV_PUBLIC 0.99~rc1 - cl_hash_file_fd@CLAMAV_PRIVATE 0.99.2 - cl_hash_file_fd_ctx@CLAMAV_PRIVATE 0.99.2 - cl_hash_file_fp@CLAMAV_PRIVATE 0.99.2 + cl_hash_file_fd@CLAMAV_PRIVATE 0.99.3~beta1 + cl_hash_file_fd_ctx@CLAMAV_PRIVATE 0.99.3~beta1 + cl_hash_file_fp@CLAMAV_PRIVATE 0.99.3~beta1 cl_hash_init@CLAMAV_PUBLIC 0.99~rc1 cl_init@CLAMAV_PUBLIC 0.99~rc1 - cl_initialize_crypto@CLAMAV_PRIVATE 0.99.2 + cl_initialize_crypto@CLAMAV_PRIVATE 0.99.3~beta1 cl_load@CLAMAV_PUBLIC 0.99~rc1 - cl_load_cert@CLAMAV_PRIVATE 0.99.2 - cl_load_crl@CLAMAV_PRIVATE 0.99.2 + cl_load_cert@CLAMAV_PRIVATE 0.99.3~beta1 + cl_load_crl@CLAMAV_PRIVATE 0.99.3~beta1 cl_retdbdir@CLAMAV_PUBLIC 0.99~rc1 - cl_retflevel@CLAMAV_PUBLIC 0.99.1 + cl_retflevel@CLAMAV_PUBLIC 0.99.3~beta1 cl_retver@CLAMAV_PUBLIC 0.99~rc1 cl_scandesc@CLAMAV_PUBLIC 0.99~rc1 cl_scandesc_callback@CLAMAV_PUBLIC 0.99~rc1 @@ -71,181 +71,182 @@ cl_scanfile_callback@CLAMAV_PUBLIC 0.99~rc1 cl_scanmap_callback@CLAMAV_PUBLIC 0.99~rc1 cl_set_clcb_msg@CLAMAV_PUBLIC 0.99~rc1 - cl_sha1@CLAMAV_PRIVATE 0.99.2 - cl_sha256@CLAMAV_PRIVATE 0.99.2 - cl_sign_data@CLAMAV_PRIVATE 0.99.2 - cl_sign_data_keyfile@CLAMAV_PRIVATE 0.99.2 - cl_sign_file_fd@CLAMAV_PRIVATE 0.99.2 - cl_sign_file_fp@CLAMAV_PRIVATE 0.99.2 + cl_sha1@CLAMAV_PRIVATE 0.99.3~beta1 + cl_sha256@CLAMAV_PRIVATE 0.99.3~beta1 + cl_sign_data@CLAMAV_PRIVATE 0.99.3~beta1 + cl_sign_data_keyfile@CLAMAV_PRIVATE 0.99.3~beta1 + cl_sign_file_fd@CLAMAV_PRIVATE 0.99.3~beta1 + cl_sign_file_fp@CLAMAV_PRIVATE 0.99.3~beta1 cl_statchkdir@CLAMAV_PUBLIC 0.99~rc1 cl_statfree@CLAMAV_PUBLIC 0.99~rc1 cl_statinidir@CLAMAV_PUBLIC 0.99~rc1 cl_strerror@CLAMAV_PUBLIC 0.99~rc1 cl_update_hash@CLAMAV_PUBLIC 0.99~rc1 - cl_validate_certificate_chain@CLAMAV_PRIVATE 0.99.2 - cl_validate_certificate_chain_ts_dir@CLAMAV_PRIVATE 0.99.2 - cl_verify_signature@CLAMAV_PRIVATE 0.99.2 - cl_verify_signature_fd@CLAMAV_PRIVATE 0.99.2 - cl_verify_signature_fd_x509@CLAMAV_PRIVATE 0.99.2 - cl_verify_signature_fd_x509_keyfile@CLAMAV_PRIVATE 0.99.2 - cl_verify_signature_hash@CLAMAV_PRIVATE 0.99.2 - cl_verify_signature_hash_x509@CLAMAV_PRIVATE 0.99.2 - cl_verify_signature_hash_x509_keyfile@CLAMAV_PRIVATE 0.99.2 - cl_verify_signature_x509@CLAMAV_PRIVATE 0.99.2 - cl_verify_signature_x509_keyfile@CLAMAV_PRIVATE 0.99.2 - cli_ac_buildtrie@CLAMAV_PRIVATE 0.99.2 - cli_ac_chklsig@CLAMAV_PRIVATE 0.99.2 - cli_ac_free@CLAMAV_PRIVATE 0.99.2 - cli_ac_freedata@CLAMAV_PRIVATE 0.99.2 - cli_ac_init@CLAMAV_PRIVATE 0.99.2 - cli_ac_initdata@CLAMAV_PRIVATE 0.99.2 - cli_ac_scanbuff@CLAMAV_PRIVATE 0.99.2 - cli_bm_free@CLAMAV_PRIVATE 0.99.2 - cli_bm_init@CLAMAV_PRIVATE 0.99.2 - cli_bm_scanbuff@CLAMAV_PRIVATE 0.99.2 - cli_build_regex_list@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_context_alloc@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_context_clear@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_context_destroy@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_context_getresult_int@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_context_set_trace@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_context_setfile@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_context_setfuncid@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_context_setparam_int@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_context_setparam_ptr@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_debug@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_debug_printsrc@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_describe@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_destroy@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_done@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_init@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_load@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_prepare2@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_printversion@CLAMAV_PRIVATE 0.99.2 - cli_bytecode_run@CLAMAV_PRIVATE 0.99.2 - cli_bytefunc_describe@CLAMAV_PRIVATE 0.99.2 - cli_byteinst_describe@CLAMAV_PRIVATE 0.99.2 - cli_bytetype_describe@CLAMAV_PRIVATE 0.99.2 - cli_bytevalue_describe@CLAMAV_PRIVATE 0.99.2 - cli_calloc@CLAMAV_PRIVATE 0.99.2 - cli_checkfp_pe@CLAMAV_PRIVATE 0.99.2 - cli_chomp@CLAMAV_PRIVATE 0.99.2 - cli_ctime@CLAMAV_PRIVATE 0.99.2 - cli_cvdunpack@CLAMAV_PRIVATE 0.99.2 - cli_dbgmsg_internal@CLAMAV_PRIVATE 0.99.2 - cli_dconf_init@CLAMAV_PRIVATE 0.99.2 - cli_debug_flag@CLAMAV_PRIVATE 0.99.2 - cli_detect_environment@CLAMAV_PRIVATE 0.99.2 - cli_disasm_one@CLAMAV_PRIVATE 0.99.2 - cli_errmsg@CLAMAV_PRIVATE 0.99.2 - cli_filecopy@CLAMAV_PRIVATE 0.99.2 - cli_fmap_scandesc@CLAMAV_PRIVATE 0.99.2 - cli_ftw@CLAMAV_PRIVATE 0.99.2 - cli_gentemp@CLAMAV_PRIVATE 0.99.2 - cli_gentempfd@CLAMAV_PRIVATE 0.99.2 - cli_gettmpdir@CLAMAV_PRIVATE 0.99.2 - cli_hashfile@CLAMAV_PRIVATE 0.99.2 - cli_hashset_destroy@CLAMAV_PRIVATE 0.99.2 - cli_hashstream@CLAMAV_PRIVATE 0.99.2 - cli_hex2str@CLAMAV_PRIVATE 0.99.2 - cli_hex2ui@CLAMAV_PRIVATE 0.99.2 - cli_initroots@CLAMAV_PRIVATE 0.99.2 - cli_isnumber@CLAMAV_PRIVATE 0.99.2 - cli_js_destroy@CLAMAV_PRIVATE 0.99.2 - cli_js_init@CLAMAV_PRIVATE 0.99.2 - cli_js_output@CLAMAV_PRIVATE 0.99.2 - cli_js_parse_done@CLAMAV_PRIVATE 0.99.2 - cli_js_process_buffer@CLAMAV_PRIVATE 0.99.2 - cli_ldbtokenize@CLAMAV_PRIVATE 0.99.2 - cli_malloc@CLAMAV_PRIVATE 0.99.2 - cli_memstr@CLAMAV_PRIVATE 0.99.2 - cli_ole2_extract@CLAMAV_PRIVATE 0.99.2 - cli_parse_add@CLAMAV_PRIVATE 0.99.2 - cli_pcre_build@CLAMAV_PRIVATE 0.99.2 - cli_pcre_freeoff@CLAMAV_PRIVATE 0.99.2 - cli_pcre_init@CLAMAV_PRIVATE 0.99.2 - cli_pcre_perf_events_destroy@CLAMAV_PRIVATE 0.99.2 - cli_pcre_perf_print@CLAMAV_PRIVATE 0.99.2 - cli_pcre_recaloff@CLAMAV_PRIVATE 0.99.2 - cli_pcre_scanbuf@CLAMAV_PRIVATE 0.99.2 - cli_ppt_vba_read@CLAMAV_PRIVATE 0.99.2 - cli_printcxxver@CLAMAV_PRIVATE 0.99.2 - cli_readn@CLAMAV_PRIVATE 0.99.2 - cli_realloc@CLAMAV_PRIVATE 0.99.2 - cli_regcomp@CLAMAV_PRIVATE 0.99.2 - cli_regex2suffix@CLAMAV_PRIVATE 0.99.2 - cli_regexec@CLAMAV_PRIVATE 0.99.2 - cli_regfree@CLAMAV_PRIVATE 0.99.2 - cli_rmdirs@CLAMAV_PRIVATE 0.99.2 - cli_rndnum@CLAMAV_PRIVATE 0.99.2 - cli_scanbuff@CLAMAV_PRIVATE 0.99.2 - cli_sigopts_handler@CLAMAV_PRIVATE 0.99.2 - cli_sigperf_events_destroy@CLAMAV_PRIVATE 0.99.2 - cli_sigperf_print@CLAMAV_PRIVATE 0.99.2 - cli_str2hex@CLAMAV_PRIVATE 0.99.2 - cli_strbcasestr@CLAMAV_PRIVATE 0.99.2 - cli_strdup@CLAMAV_PRIVATE 0.99.2 - cli_strerror@CLAMAV_PRIVATE 0.99.2 - cli_strlcat@CLAMAV_PRIVATE 0.99.2 - cli_strlcpy@CLAMAV_PRIVATE 0.99.2 - cli_strrcpy@CLAMAV_PRIVATE 0.99.2 - cli_strtok@CLAMAV_PRIVATE 0.99.2 - cli_strtokbuf@CLAMAV_PRIVATE 0.99.2 - cli_strtokenize@CLAMAV_PRIVATE 0.99.2 - cli_textbuffer_append_normalize@CLAMAV_PRIVATE 0.99.2 - cli_unescape@CLAMAV_PRIVATE 0.99.2 - cli_unlink@CLAMAV_PRIVATE 0.99.2 - cli_url_canon@CLAMAV_PRIVATE 0.99.2 - cli_utf16_to_utf8@CLAMAV_PRIVATE 0.99.2 - cli_utf16toascii@CLAMAV_PRIVATE 0.99.2 - cli_vba_inflate@CLAMAV_PRIVATE 0.99.2 - cli_vba_readdir@CLAMAV_PRIVATE 0.99.2 - cli_versig2@CLAMAV_PRIVATE 0.99.2 - cli_versig@CLAMAV_PRIVATE 0.99.2 - cli_warnmsg@CLAMAV_PRIVATE 0.99.2 - cli_wm_decrypt_macro@CLAMAV_PRIVATE 0.99.2 - cli_wm_readdir@CLAMAV_PRIVATE 0.99.2 - cli_writen@CLAMAV_PRIVATE 0.99.2 - decodeLine@CLAMAV_PRIVATE 0.99.2 - disasmbuf@CLAMAV_PRIVATE 0.99.2 - fmap@CLAMAV_PRIVATE 0.99.2 - get_fpu_endian@CLAMAV_PRIVATE 0.99.2 - have_clamjit@CLAMAV_PRIVATE 0.99.2 - have_rar@CLAMAV_PRIVATE 0.99.2 - html_normalise_map@CLAMAV_PRIVATE 0.99.2 - html_normalise_mem@CLAMAV_PRIVATE 0.99.2 - html_screnc_decode@CLAMAV_PRIVATE 0.99.2 - html_tag_arg_free@CLAMAV_PRIVATE 0.99.2 - init_domainlist@CLAMAV_PRIVATE 0.99.2 - init_regex_list@CLAMAV_PRIVATE 0.99.2 - init_whitelist@CLAMAV_PRIVATE 0.99.2 - is_regex_ok@CLAMAV_PRIVATE 0.99.2 - load_regex_matcher@CLAMAV_PRIVATE 0.99.2 + cl_validate_certificate_chain@CLAMAV_PRIVATE 0.99.3~beta1 + cl_validate_certificate_chain_ts_dir@CLAMAV_PRIVATE 0.99.3~beta1 + cl_verify_signature@CLAMAV_PRIVATE 0.99.3~beta1 + cl_verify_signature_fd@CLAMAV_PRIVATE 0.99.3~beta1 + cl_verify_signature_fd_x509@CLAMAV_PRIVATE 0.99.3~beta1 + cl_verify_signature_fd_x509_keyfile@CLAMAV_PRIVATE 0.99.3~beta1 + cl_verify_signature_hash@CLAMAV_PRIVATE 0.99.3~beta1 + cl_verify_signature_hash_x509@CLAMAV_PRIVATE 0.99.3~beta1 + cl_verify_signature_hash_x509_keyfile@CLAMAV_PRIVATE 0.99.3~beta1 + cl_verify_signature_x509@CLAMAV_PRIVATE 0.99.3~beta1 + cl_verify_signature_x509_keyfile@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ac_buildtrie@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ac_chklsig@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ac_free@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ac_freedata@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ac_init@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ac_initdata@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ac_scanbuff@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bm_free@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bm_init@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bm_scanbuff@CLAMAV_PRIVATE 0.99.3~beta1 + cli_build_regex_list@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_context_alloc@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_context_clear@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_context_destroy@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_context_getresult_int@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_context_set_trace@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_context_setfile@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_context_setfuncid@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_context_setparam_int@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_context_setparam_ptr@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_debug@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_debug_printsrc@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_describe@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_destroy@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_done@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_init@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_load@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_prepare2@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_printversion@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytecode_run@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytefunc_describe@CLAMAV_PRIVATE 0.99.3~beta1 + cli_byteinst_describe@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytetype_describe@CLAMAV_PRIVATE 0.99.3~beta1 + cli_bytevalue_describe@CLAMAV_PRIVATE 0.99.3~beta1 + cli_calloc@CLAMAV_PRIVATE 0.99.3~beta1 + cli_checkfp_pe@CLAMAV_PRIVATE 0.99.3~beta1 + cli_chomp@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ctime@CLAMAV_PRIVATE 0.99.3~beta1 + cli_cvdunpack@CLAMAV_PRIVATE 0.99.3~beta1 + cli_dbgmsg_internal@CLAMAV_PRIVATE 0.99.3~beta1 + cli_dconf_init@CLAMAV_PRIVATE 0.99.3~beta1 + cli_debug_flag@CLAMAV_PRIVATE 0.99.3~beta1 + cli_detect_environment@CLAMAV_PRIVATE 0.99.3~beta1 + cli_disasm_one@CLAMAV_PRIVATE 0.99.3~beta1 + cli_errmsg@CLAMAV_PRIVATE 0.99.3~beta1 + cli_filecopy@CLAMAV_PRIVATE 0.99.3~beta1 + cli_fmap_scandesc@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ftw@CLAMAV_PRIVATE 0.99.3~beta1 + cli_genhash_pe@CLAMAV_PRIVATE 0.99.3~beta1 + cli_gentemp@CLAMAV_PRIVATE 0.99.3~beta1 + cli_gentempfd@CLAMAV_PRIVATE 0.99.3~beta1 + cli_gettmpdir@CLAMAV_PRIVATE 0.99.3~beta1 + cli_hashfile@CLAMAV_PRIVATE 0.99.3~beta1 + cli_hashset_destroy@CLAMAV_PRIVATE 0.99.3~beta1 + cli_hashstream@CLAMAV_PRIVATE 0.99.3~beta1 + cli_hex2str@CLAMAV_PRIVATE 0.99.3~beta1 + cli_hex2ui@CLAMAV_PRIVATE 0.99.3~beta1 + cli_initroots@CLAMAV_PRIVATE 0.99.3~beta1 + cli_isnumber@CLAMAV_PRIVATE 0.99.3~beta1 + cli_js_destroy@CLAMAV_PRIVATE 0.99.3~beta1 + cli_js_init@CLAMAV_PRIVATE 0.99.3~beta1 + cli_js_output@CLAMAV_PRIVATE 0.99.3~beta1 + cli_js_parse_done@CLAMAV_PRIVATE 0.99.3~beta1 + cli_js_process_buffer@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ldbtokenize@CLAMAV_PRIVATE 0.99.3~beta1 + cli_malloc@CLAMAV_PRIVATE 0.99.3~beta1 + cli_memstr@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ole2_extract@CLAMAV_PRIVATE 0.99.3~beta1 + cli_parse_add@CLAMAV_PRIVATE 0.99.3~beta1 + cli_pcre_build@CLAMAV_PRIVATE 0.99.3~beta1 + cli_pcre_freeoff@CLAMAV_PRIVATE 0.99.3~beta1 + cli_pcre_init@CLAMAV_PRIVATE 0.99.3~beta1 + cli_pcre_perf_events_destroy@CLAMAV_PRIVATE 0.99.3~beta1 + cli_pcre_perf_print@CLAMAV_PRIVATE 0.99.3~beta1 + cli_pcre_recaloff@CLAMAV_PRIVATE 0.99.3~beta1 + cli_pcre_scanbuf@CLAMAV_PRIVATE 0.99.3~beta1 + cli_ppt_vba_read@CLAMAV_PRIVATE 0.99.3~beta1 + cli_printcxxver@CLAMAV_PRIVATE 0.99.3~beta1 + cli_readn@CLAMAV_PRIVATE 0.99.3~beta1 + cli_realloc@CLAMAV_PRIVATE 0.99.3~beta1 + cli_regcomp@CLAMAV_PRIVATE 0.99.3~beta1 + cli_regex2suffix@CLAMAV_PRIVATE 0.99.3~beta1 + cli_regexec@CLAMAV_PRIVATE 0.99.3~beta1 + cli_regfree@CLAMAV_PRIVATE 0.99.3~beta1 + cli_rmdirs@CLAMAV_PRIVATE 0.99.3~beta1 + cli_rndnum@CLAMAV_PRIVATE 0.99.3~beta1 + cli_scanbuff@CLAMAV_PRIVATE 0.99.3~beta1 + cli_sigopts_handler@CLAMAV_PRIVATE 0.99.3~beta1 + cli_sigperf_events_destroy@CLAMAV_PRIVATE 0.99.3~beta1 + cli_sigperf_print@CLAMAV_PRIVATE 0.99.3~beta1 + cli_str2hex@CLAMAV_PRIVATE 0.99.3~beta1 + cli_strbcasestr@CLAMAV_PRIVATE 0.99.3~beta1 + cli_strdup@CLAMAV_PRIVATE 0.99.3~beta1 + cli_strerror@CLAMAV_PRIVATE 0.99.3~beta1 + cli_strlcat@CLAMAV_PRIVATE 0.99.3~beta1 + cli_strlcpy@CLAMAV_PRIVATE 0.99.3~beta1 + cli_strrcpy@CLAMAV_PRIVATE 0.99.3~beta1 + cli_strtok@CLAMAV_PRIVATE 0.99.3~beta1 + cli_strtokbuf@CLAMAV_PRIVATE 0.99.3~beta1 + cli_strtokenize@CLAMAV_PRIVATE 0.99.3~beta1 + cli_textbuffer_append_normalize@CLAMAV_PRIVATE 0.99.3~beta1 + cli_unescape@CLAMAV_PRIVATE 0.99.3~beta1 + cli_unlink@CLAMAV_PRIVATE 0.99.3~beta1 + cli_url_canon@CLAMAV_PRIVATE 0.99.3~beta1 + cli_utf16_to_utf8@CLAMAV_PRIVATE 0.99.3~beta1 + cli_utf16toascii@CLAMAV_PRIVATE 0.99.3~beta1 + cli_vba_inflate@CLAMAV_PRIVATE 0.99.3~beta1 + cli_vba_readdir@CLAMAV_PRIVATE 0.99.3~beta1 + cli_versig2@CLAMAV_PRIVATE 0.99.3~beta1 + cli_versig@CLAMAV_PRIVATE 0.99.3~beta1 + cli_warnmsg@CLAMAV_PRIVATE 0.99.3~beta1 + cli_wm_decrypt_macro@CLAMAV_PRIVATE 0.99.3~beta1 + cli_wm_readdir@CLAMAV_PRIVATE 0.99.3~beta1 + cli_writen@CLAMAV_PRIVATE 0.99.3~beta1 + decodeLine@CLAMAV_PRIVATE 0.99.3~beta1 + disasmbuf@CLAMAV_PRIVATE 0.99.3~beta1 + fmap@CLAMAV_PRIVATE 0.99.3~beta1 + get_fpu_endian@CLAMAV_PRIVATE 0.99.3~beta1 + have_clamjit@CLAMAV_PRIVATE 0.99.3~beta1 + have_rar@CLAMAV_PRIVATE 0.99.3~beta1 + html_normalise_map@CLAMAV_PRIVATE 0.99.3~beta1 + html_normalise_mem@CLAMAV_PRIVATE 0.99.3~beta1 + html_screnc_decode@CLAMAV_PRIVATE 0.99.3~beta1 + html_tag_arg_free@CLAMAV_PRIVATE 0.99.3~beta1 + init_domainlist@CLAMAV_PRIVATE 0.99.3~beta1 + init_regex_list@CLAMAV_PRIVATE 0.99.3~beta1 + init_whitelist@CLAMAV_PRIVATE 0.99.3~beta1 + is_regex_ok@CLAMAV_PRIVATE 0.99.3~beta1 + load_regex_matcher@CLAMAV_PRIVATE 0.99.3~beta1 lsig_sub_matched@CLAMAV_PUBLIC 0.99~rc1 - messageCreate@CLAMAV_PRIVATE 0.99.2 - messageDestroy@CLAMAV_PRIVATE 0.99.2 - mpool_calloc@CLAMAV_PRIVATE 0.99.2 - mpool_create@CLAMAV_PRIVATE 0.99.2 - mpool_destroy@CLAMAV_PRIVATE 0.99.2 - mpool_free@CLAMAV_PRIVATE 0.99.2 - mpool_getstats@CLAMAV_PRIVATE 0.99.2 - phishingScan@CLAMAV_PRIVATE 0.99.2 - phishing_done@CLAMAV_PRIVATE 0.99.2 - phishing_init@CLAMAV_PRIVATE 0.99.2 - regex_list_add_pattern@CLAMAV_PRIVATE 0.99.2 - regex_list_done@CLAMAV_PRIVATE 0.99.2 - regex_list_match@CLAMAV_PRIVATE 0.99.2 - tableCreate@CLAMAV_PRIVATE 0.99.2 - tableDestroy@CLAMAV_PRIVATE 0.99.2 - tableFind@CLAMAV_PRIVATE 0.99.2 - tableInsert@CLAMAV_PRIVATE 0.99.2 - tableIterate@CLAMAV_PRIVATE 0.99.2 - tableRemove@CLAMAV_PRIVATE 0.99.2 - tableUpdate@CLAMAV_PRIVATE 0.99.2 - text_normalize_init@CLAMAV_PRIVATE 0.99.2 - text_normalize_map@CLAMAV_PRIVATE 0.99.2 - text_normalize_reset@CLAMAV_PRIVATE 0.99.2 - uniq_add@CLAMAV_PRIVATE 0.99.2 - uniq_free@CLAMAV_PRIVATE 0.99.2 - uniq_get@CLAMAV_PRIVATE 0.99.2 - uniq_init@CLAMAV_PRIVATE 0.99.2 + messageCreate@CLAMAV_PRIVATE 0.99.3~beta1 + messageDestroy@CLAMAV_PRIVATE 0.99.3~beta1 + mpool_calloc@CLAMAV_PRIVATE 0.99.3~beta1 + mpool_create@CLAMAV_PRIVATE 0.99.3~beta1 + mpool_destroy@CLAMAV_PRIVATE 0.99.3~beta1 + mpool_free@CLAMAV_PRIVATE 0.99.3~beta1 + mpool_getstats@CLAMAV_PRIVATE 0.99.3~beta1 + phishingScan@CLAMAV_PRIVATE 0.99.3~beta1 + phishing_done@CLAMAV_PRIVATE 0.99.3~beta1 + phishing_init@CLAMAV_PRIVATE 0.99.3~beta1 + regex_list_add_pattern@CLAMAV_PRIVATE 0.99.3~beta1 + regex_list_done@CLAMAV_PRIVATE 0.99.3~beta1 + regex_list_match@CLAMAV_PRIVATE 0.99.3~beta1 + tableCreate@CLAMAV_PRIVATE 0.99.3~beta1 + tableDestroy@CLAMAV_PRIVATE 0.99.3~beta1 + tableFind@CLAMAV_PRIVATE 0.99.3~beta1 + tableInsert@CLAMAV_PRIVATE 0.99.3~beta1 + tableIterate@CLAMAV_PRIVATE 0.99.3~beta1 + tableRemove@CLAMAV_PRIVATE 0.99.3~beta1 + tableUpdate@CLAMAV_PRIVATE 0.99.3~beta1 + text_normalize_init@CLAMAV_PRIVATE 0.99.3~beta1 + text_normalize_map@CLAMAV_PRIVATE 0.99.3~beta1 + text_normalize_reset@CLAMAV_PRIVATE 0.99.3~beta1 + uniq_add@CLAMAV_PRIVATE 0.99.3~beta1 + uniq_free@CLAMAV_PRIVATE 0.99.3~beta1 + uniq_get@CLAMAV_PRIVATE 0.99.3~beta1 + uniq_init@CLAMAV_PRIVATE 0.99.3~beta1 diff -Nru clamav-0.99.2+dfsg/debian/patches/Add-support-for-LLVM-3.7.patch clamav-0.99.3~beta1+dfsg/debian/patches/Add-support-for-LLVM-3.7.patch --- clamav-0.99.2+dfsg/debian/patches/Add-support-for-LLVM-3.7.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/Add-support-for-LLVM-3.7.patch 2017-11-22 21:56:26.000000000 +0000 @@ -1,4 +1,4 @@ -From 3b1b2e757d0d1f13a3f234abf05d6e5015f52744 Mon Sep 17 00:00:00 2001 +From 0d9501557bac2797b03ca63881003db9469adbf9 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Fri, 14 Oct 2016 20:24:39 +0200 Subject: Add support for LLVM 3.7 @@ -20,11 +20,11 @@ libclamav/c++/ClamBCRTChecks.cpp | 34 ++++++- libclamav/c++/PointerTracking.cpp | 44 ++++++++- libclamav/c++/bytecode2llvm.cpp | 181 +++++++++++++++++++++++++++++++++++--- - libclamav/c++/m4/llvm-flags.m4 | 4 +- + libclamav/c++/configure.ac | 4 +- 4 files changed, 244 insertions(+), 19 deletions(-) diff --git a/libclamav/c++/ClamBCRTChecks.cpp b/libclamav/c++/ClamBCRTChecks.cpp -index 97099b2..35f7272 100644 +index 07176f6..5db4845 100644 --- a/libclamav/c++/ClamBCRTChecks.cpp +++ b/libclamav/c++/ClamBCRTChecks.cpp @@ -201,9 +201,11 @@ namespace llvm { @@ -76,7 +76,7 @@ if (P2 != P) { Value *V = getPointerBase(P2); return BaseMap[Ptr] = V; -@@ -524,7 +536,11 @@ namespace llvm { +@@ -520,7 +532,11 @@ namespace llvm { } } if (LoadInst *LI = dyn_cast(Base)) { @@ -88,7 +88,7 @@ if (Argument *A = dyn_cast(V)) { if (A->getArgNo() == 0) { // pointers from hidden ctx are trusted to be at least the -@@ -651,7 +667,11 @@ namespace llvm { +@@ -674,7 +690,11 @@ namespace llvm { } BasicBlock *BB = I->getParent(); BasicBlock::iterator It = I; @@ -100,7 +100,7 @@ PHINode *PN; unsigned MDDbgKind = I->getContext().getMDKindID("dbg"); //verifyFunction(*BB->getParent()); -@@ -696,9 +716,15 @@ namespace llvm { +@@ -719,9 +739,15 @@ namespace llvm { unsigned locationid = 0; bool Approximate; if (MDNode *Dbg = getLocation(I, Approximate, MDDbgKind)) { @@ -116,7 +116,7 @@ if (col > 254) col = 254; if (Approximate) -@@ -912,7 +938,11 @@ INITIALIZE_PASS_DEPENDENCY(TargetData) +@@ -935,7 +961,11 @@ INITIALIZE_PASS_DEPENDENCY(TargetData) #elif LLVM_VERSION < 35 INITIALIZE_PASS_DEPENDENCY(DataLayout) #else @@ -129,7 +129,7 @@ #if LLVM_VERSION < 35 INITIALIZE_PASS_DEPENDENCY(DominatorTree) diff --git a/libclamav/c++/PointerTracking.cpp b/libclamav/c++/PointerTracking.cpp -index 8e17a4a..67340e8 100644 +index d5841a1..5567894 100644 --- a/libclamav/c++/PointerTracking.cpp +++ b/libclamav/c++/PointerTracking.cpp @@ -30,7 +30,11 @@ @@ -247,7 +247,7 @@ if (isa(Limit)) { Base = 0; diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp -index e5aea03..2171993 100644 +index 69e7d65..02c0a95 100644 --- a/libclamav/c++/bytecode2llvm.cpp +++ b/libclamav/c++/bytecode2llvm.cpp @@ -63,7 +63,11 @@ @@ -717,11 +717,11 @@ errs() << ":" << Col; } errs() << ": "; -diff --git a/libclamav/c++/m4/llvm-flags.m4 b/libclamav/c++/m4/llvm-flags.m4 -index dce4e10..04d6833 100644 ---- a/libclamav/c++/m4/llvm-flags.m4 -+++ b/libclamav/c++/m4/llvm-flags.m4 -@@ -98,14 +98,14 @@ elif test $llvmver_test -lt 290; then +diff --git a/libclamav/c++/configure.ac b/libclamav/c++/configure.ac +index 0a51664..6b10dd4 100644 +--- a/libclamav/c++/configure.ac ++++ b/libclamav/c++/configure.ac +@@ -89,14 +89,14 @@ elif test $llvmver_test -lt 290; then elif test $llvmver_test -lt 360; then llvmcomp="jit nativecodegen scalaropts ipo" AC_MSG_RESULT([ok ($llvmver)]) @@ -737,4 +737,4 @@ + AC_MSG_ERROR([LLVM < 3.8 required, but "$llvmver"($llvmver_test) found]) fi - dnl aquire the required flags to properly link in external LLVM + dnl acquire the required flags to properly link in external LLVM diff -Nru clamav-0.99.2+dfsg/debian/patches/Add-support-for-LLVM-3.8.patch clamav-0.99.3~beta1+dfsg/debian/patches/Add-support-for-LLVM-3.8.patch --- clamav-0.99.2+dfsg/debian/patches/Add-support-for-LLVM-3.8.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/Add-support-for-LLVM-3.8.patch 2017-11-22 21:56:26.000000000 +0000 @@ -1,4 +1,4 @@ -From 3111db3d1a3f2b20a007673f69a53ad69afec2f8 Mon Sep 17 00:00:00 2001 +From 19726041ebdb75fa9fd0f17d7e23713db6e116ff Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Fri, 14 Oct 2016 20:24:48 +0200 Subject: Add support for LLVM 3.8 @@ -17,12 +17,12 @@ libclamav/c++/ClamBCRTChecks.cpp | 50 ++++++++++++++++++++++++++++++ libclamav/c++/PointerTracking.cpp | 12 ++++++++ libclamav/c++/bytecode2llvm.cpp | 65 +++++++++++++++++++++++++++++++-------- + libclamav/c++/configure.ac | 4 +-- libclamav/c++/detect.cpp | 2 ++ - libclamav/c++/m4/llvm-flags.m4 | 4 +-- 5 files changed, 119 insertions(+), 14 deletions(-) diff --git a/libclamav/c++/ClamBCRTChecks.cpp b/libclamav/c++/ClamBCRTChecks.cpp -index 35f7272..a254c40 100644 +index 5db4845..d4f5859 100644 --- a/libclamav/c++/ClamBCRTChecks.cpp +++ b/libclamav/c++/ClamBCRTChecks.cpp @@ -54,7 +54,9 @@ @@ -113,7 +113,7 @@ ++It; Value *TrueB = getPointerBase(SI->getTrueValue()); Value *FalseB = getPointerBase(SI->getFalseValue()); -@@ -552,7 +582,11 @@ namespace llvm { +@@ -575,7 +605,11 @@ namespace llvm { } #endif if (PHINode *PN = dyn_cast(Base)) { @@ -125,7 +125,7 @@ ++It; PHINode *newPN = PHINode::Create(I64Ty, HINT(PN->getNumIncomingValues()) ".verif.bounds", &*It); Changed = true; -@@ -575,7 +609,11 @@ namespace llvm { +@@ -598,7 +632,11 @@ namespace llvm { return BoundsMap[Base] = newPN; } if (SelectInst *SI = dyn_cast(Base)) { @@ -137,7 +137,7 @@ ++It; Value *TrueB = getPointerBounds(SI->getTrueValue()); Value *FalseB = getPointerBounds(SI->getFalseValue()); -@@ -632,7 +670,11 @@ namespace llvm { +@@ -655,7 +693,11 @@ namespace llvm { if (!MDDbgKind) return 0; Approximate = true; @@ -149,7 +149,7 @@ while (It != I->getParent()->begin()) { --It; if (MDNode *Dbg = It->getMetadata(MDDbgKind)) -@@ -666,7 +708,11 @@ namespace llvm { +@@ -689,7 +731,11 @@ namespace llvm { return false; } BasicBlock *BB = I->getParent(); @@ -161,7 +161,7 @@ #if LLVM_VERSION < 37 BasicBlock *newBB = SplitBlock(BB, &*It, this); #else -@@ -949,7 +995,11 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTree) +@@ -972,7 +1018,11 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTree) #else INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) #endif @@ -174,7 +174,7 @@ INITIALIZE_AG_DEPENDENCY(CallGraph) #elif LLVM_VERSION < 35 diff --git a/libclamav/c++/PointerTracking.cpp b/libclamav/c++/PointerTracking.cpp -index 67340e8..ad5b93f 100644 +index 5567894..147ad48 100644 --- a/libclamav/c++/PointerTracking.cpp +++ b/libclamav/c++/PointerTracking.cpp @@ -79,7 +79,11 @@ INITIALIZE_PASS_DEPENDENCY(LoopInfo) @@ -214,7 +214,7 @@ } diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp -index 2171993..213847c 100644 +index 02c0a95..daf11dd 100644 --- a/libclamav/c++/bytecode2llvm.cpp +++ b/libclamav/c++/bytecode2llvm.cpp @@ -170,7 +170,9 @@ void LLVMInitializePowerPCAsmPrinter(); @@ -420,25 +420,11 @@ return DIG; #endif } -diff --git a/libclamav/c++/detect.cpp b/libclamav/c++/detect.cpp -index 17348af..95ba2f7 100644 ---- a/libclamav/c++/detect.cpp -+++ b/libclamav/c++/detect.cpp -@@ -22,7 +22,9 @@ - */ - - #include "llvm/ADT/Triple.h" -+#if LLVM_VERSION < 38 - #include "llvm/Config/config.h" -+#endif - #include "llvm/Support/raw_ostream.h" - #if LLVM_VERSION < 29 - #include "llvm/System/DataTypes.h" -diff --git a/libclamav/c++/m4/llvm-flags.m4 b/libclamav/c++/m4/llvm-flags.m4 -index 04d6833..345c7ae 100644 ---- a/libclamav/c++/m4/llvm-flags.m4 -+++ b/libclamav/c++/m4/llvm-flags.m4 -@@ -98,14 +98,14 @@ elif test $llvmver_test -lt 290; then +diff --git a/libclamav/c++/configure.ac b/libclamav/c++/configure.ac +index 6b10dd4..bf0be59 100644 +--- a/libclamav/c++/configure.ac ++++ b/libclamav/c++/configure.ac +@@ -89,14 +89,14 @@ elif test $llvmver_test -lt 290; then elif test $llvmver_test -lt 360; then llvmcomp="jit nativecodegen scalaropts ipo" AC_MSG_RESULT([ok ($llvmver)]) @@ -454,4 +440,18 @@ + AC_MSG_ERROR([LLVM < 3.9 required, but "$llvmver"($llvmver_test) found]) fi - dnl aquire the required flags to properly link in external LLVM + dnl acquire the required flags to properly link in external LLVM +diff --git a/libclamav/c++/detect.cpp b/libclamav/c++/detect.cpp +index 17348af..95ba2f7 100644 +--- a/libclamav/c++/detect.cpp ++++ b/libclamav/c++/detect.cpp +@@ -22,7 +22,9 @@ + */ + + #include "llvm/ADT/Triple.h" ++#if LLVM_VERSION < 38 + #include "llvm/Config/config.h" ++#endif + #include "llvm/Support/raw_ostream.h" + #if LLVM_VERSION < 29 + #include "llvm/System/DataTypes.h" diff -Nru clamav-0.99.2+dfsg/debian/patches/Add-support-for-LLVM-3.9.patch clamav-0.99.3~beta1+dfsg/debian/patches/Add-support-for-LLVM-3.9.patch --- clamav-0.99.2+dfsg/debian/patches/Add-support-for-LLVM-3.9.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/Add-support-for-LLVM-3.9.patch 2017-11-22 21:56:26.000000000 +0000 @@ -1,4 +1,4 @@ -From fef1bbc259bca9cfaac65a85de877f9b7ed27773 Mon Sep 17 00:00:00 2001 +From 32a3c979ae480c5ba2a388add0558e36e1ff9626 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Fri, 14 Oct 2016 20:24:56 +0200 Subject: Add support for LLVM 3.9 @@ -10,11 +10,11 @@ Patch-Name: Add-support-for-LLVM-3.9.patch --- libclamav/c++/bytecode2llvm.cpp | 12 +++++++++++- - libclamav/c++/m4/llvm-flags.m4 | 4 ++-- + libclamav/c++/configure.ac | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp -index 213847c..252f8f6 100644 +index daf11dd..9ef0477 100644 --- a/libclamav/c++/bytecode2llvm.cpp +++ b/libclamav/c++/bytecode2llvm.cpp @@ -787,7 +787,11 @@ class RuntimeLimits : public FunctionPass { @@ -53,11 +53,11 @@ std::vector globals; DenseMap GVoffsetMap; -diff --git a/libclamav/c++/m4/llvm-flags.m4 b/libclamav/c++/m4/llvm-flags.m4 -index 345c7ae..9631d5d 100644 ---- a/libclamav/c++/m4/llvm-flags.m4 -+++ b/libclamav/c++/m4/llvm-flags.m4 -@@ -98,14 +98,14 @@ elif test $llvmver_test -lt 290; then +diff --git a/libclamav/c++/configure.ac b/libclamav/c++/configure.ac +index bf0be59..8393cf2 100644 +--- a/libclamav/c++/configure.ac ++++ b/libclamav/c++/configure.ac +@@ -89,14 +89,14 @@ elif test $llvmver_test -lt 290; then elif test $llvmver_test -lt 360; then llvmcomp="jit nativecodegen scalaropts ipo" AC_MSG_RESULT([ok ($llvmver)]) @@ -73,4 +73,4 @@ + AC_MSG_ERROR([LLVM < 4.0 required, but "$llvmver"($llvmver_test) found]) fi - dnl aquire the required flags to properly link in external LLVM + dnl acquire the required flags to properly link in external LLVM diff -Nru clamav-0.99.2+dfsg/debian/patches/add-support-for-system-tomsfastmath.patch clamav-0.99.3~beta1+dfsg/debian/patches/add-support-for-system-tomsfastmath.patch --- clamav-0.99.2+dfsg/debian/patches/add-support-for-system-tomsfastmath.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/add-support-for-system-tomsfastmath.patch 2017-11-22 21:56:26.000000000 +0000 @@ -1,4 +1,4 @@ -From 756ff89526b5ffaa7a4f49b1bbecf2ecbd6f85f9 Mon Sep 17 00:00:00 2001 +From 4bc66d7e4060f5b1805b60e15c4e0ca88a9f1f48 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Wed, 11 Mar 2015 20:03:15 +0100 Subject: add support for system tomsfastmath @@ -14,7 +14,7 @@ create mode 100644 m4/reorganization/libs/tomsfastmath.m4 diff --git a/configure.ac b/configure.ac -index a685eed..6d7d666 100644 +index ce26071..216bfe3 100644 --- a/configure.ac +++ b/configure.ac @@ -82,6 +82,7 @@ m4_include([m4/reorganization/libs/xml.m4]) @@ -25,19 +25,19 @@ AM_MAINTAINER_MODE m4_include([m4/reorganization/libs/libz.m4]) -@@ -256,6 +257,7 @@ else - CL_MSG_STATUS([libxml2 ],[yes, from $XML_HOME],[]) - fi +@@ -280,6 +281,7 @@ fi CL_MSG_STATUS([yara ],[$enable_yara],[$enable_yara]) + CL_MSG_STATUS([fts ],[yes],[$lfs_fts_msg]) + +CL_MSG_STATUS([tomsfastmath],[yes],[$tomsfastmath_msg]) # Yep, downgrading the compiler avoids the bug too: # 4.0.x, and 4.1.0 are the known buggy versions diff --git a/libclamav/Makefile.am b/libclamav/Makefile.am -index e033248..0a6d2ad 100644 +index 1c4c007..fb9744d 100644 --- a/libclamav/Makefile.am +++ b/libclamav/Makefile.am -@@ -481,8 +481,10 @@ libclamav_la_SOURCES += yara_arena.c \ +@@ -520,8 +520,10 @@ libclamav_la_SOURCES += yara_arena.c \ yara_clam.h endif @@ -50,7 +50,7 @@ tomsfastmath/addsub/fp_add.c\ tomsfastmath/addsub/fp_add_d.c\ tomsfastmath/addsub/fp_addmod.c\ -@@ -564,6 +566,10 @@ libclamav_la_SOURCES += bignum.h\ +@@ -603,6 +605,10 @@ libclamav_la_SOURCES += bignum.h\ tomsfastmath/sqr/fp_sqr_comba_generic.c\ tomsfastmath/sqr/fp_sqr_comba_small_set.c\ tomsfastmath/sqr/fp_sqrmod.c diff -Nru clamav-0.99.2+dfsg/debian/patches/Allow-M-suffix-for-PCREMaxFileSize.patch clamav-0.99.3~beta1+dfsg/debian/patches/Allow-M-suffix-for-PCREMaxFileSize.patch --- clamav-0.99.2+dfsg/debian/patches/Allow-M-suffix-for-PCREMaxFileSize.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/Allow-M-suffix-for-PCREMaxFileSize.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -From 5a2747e6ae8a1021e5400d6ff53fa9684403bd9f Mon Sep 17 00:00:00 2001 -From: Sebastian Andrzej Siewior -Date: Tue, 16 Jun 2015 23:39:41 +0200 -Subject: Allow M suffix for PCREMaxFileSize - -the config file suggest that this should be possible - -Patch-Name: Allow-M-suffix-for-PCREMaxFileSize.patch -Signed-off-by: Sebastian Andrzej Siewior ---- - shared/optparser.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/shared/optparser.c b/shared/optparser.c -index ad22f21..f8911ea 100644 ---- a/shared/optparser.c -+++ b/shared/optparser.c -@@ -395,7 +395,7 @@ const struct clam_option __clam_options[] = { - - { "PCRERecMatchLimit", "pcre-recmatch-limit", 0, CLOPT_TYPE_NUMBER, MATCH_NUMBER, CLI_DEFAULT_PCRE_RECMATCH_LIMIT, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option sets the maximum recursive calls to the PCRE match function during an instance of regex matching.\nInstances using more than this limit will be terminated and alert the user but the scan will continue.\nFor more information on match_limit_recursion, see the PCRE documentation.\nNegative values are not allowed and values > PCREMatchLimit are superfluous.\nWARNING: setting this limit too high may severely impact performance.", "5000" }, - -- { "PCREMaxFileSize", "pcre-max-filesize", 0, CLOPT_TYPE_NUMBER, MATCH_SIZE, CLI_DEFAULT_PCRE_MAX_FILESIZE, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option sets the maximum filesize for which PCRE subsigs will be executed.\nFiles exceeding this limit will not have PCRE subsigs executed unless a subsig is encompassed to a smaller buffer.\nNegative values are not allowed.\nSetting this value to zero disables the limit.\nWARNING: setting this limit too high or disabling it may severely impact performance.", "25M" }, -+ { "PCREMaxFileSize", "pcre-max-filesize", 0, CLOPT_TYPE_SIZE, MATCH_SIZE, CLI_DEFAULT_PCRE_MAX_FILESIZE, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option sets the maximum filesize for which PCRE subsigs will be executed.\nFiles exceeding this limit will not have PCRE subsigs executed unless a subsig is encompassed to a smaller buffer.\nNegative values are not allowed.\nSetting this value to zero disables the limit.\nWARNING: setting this limit too high or disabling it may severely impact performance.", "25M" }, - - /* OnAccess settings */ - { "ScanOnAccess", NULL, 0, CLOPT_TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_CLAMD, "This option enables on-access scanning (Linux only)", "no" }, diff -Nru clamav-0.99.2+dfsg/debian/patches/bb11549-fix-temp-file-cleanup-issue.patch clamav-0.99.3~beta1+dfsg/debian/patches/bb11549-fix-temp-file-cleanup-issue.patch --- clamav-0.99.2+dfsg/debian/patches/bb11549-fix-temp-file-cleanup-issue.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/bb11549-fix-temp-file-cleanup-issue.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ -From d7ea9385baefece1a1c2ff29c3c57853fa8011cb Mon Sep 17 00:00:00 2001 -From: Steven Morgan -Date: Thu, 9 Jun 2016 14:06:23 -0400 -Subject: bb11549 - fix temp file cleanup issue. - -Patch-Name: bb11549-fix-temp-file-cleanup-issue.patch ---- - libclamav/scanners.c | 86 +++++++++++++++++++++++----------------------------- - 1 file changed, 38 insertions(+), 48 deletions(-) - -diff --git a/libclamav/scanners.c b/libclamav/scanners.c -index e104d2f..9536e3c 100644 ---- a/libclamav/scanners.c -+++ b/libclamav/scanners.c -@@ -1265,37 +1265,33 @@ static int cli_scanscript(cli_ctx *ctx) - return CL_CLEAN; - } - -+ if(!(normalized = cli_malloc(SCANBUFF + maxpatlen))) { -+ cli_dbgmsg("cli_scanscript: Unable to malloc %u bytes\n", SCANBUFF); -+ return CL_EMEM; -+ } -+ text_normalize_init(&state, normalized, SCANBUFF + maxpatlen); -+ -+ if ((ret = cli_ac_initdata(&tmdata, troot?troot->ac_partsigs:0, troot?troot->ac_lsigs:0, troot?troot->ac_reloff_num:0, CLI_DEFAULT_AC_TRACKLEN))) { -+ free(normalized); -+ return ret; -+ } -+ -+ if ((ret = cli_ac_initdata(&gmdata, groot->ac_partsigs, groot->ac_lsigs, groot->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN))) { -+ cli_ac_freedata(&tmdata); -+ free(normalized); -+ return ret; -+ } -+ - /* dump to disk only if explicitly asked to - * or if necessary to check relative offsets, - * otherwise we can process just in-memory */ - if(ctx->engine->keeptmp || (troot && troot->ac_reloff_num > 0)) { -- if((ret = cli_gentempfd(ctx->engine->tmpdir, &tmpname, &ofd))) { -- cli_dbgmsg("cli_scanscript: Can't generate temporary file/descriptor\n"); -- return ret; -- } -- if (ctx->engine->keeptmp) -- cli_dbgmsg("cli_scanscript: saving normalized file to %s\n", tmpname); -- } -- -- if(!(normalized = cli_malloc(SCANBUFF + maxpatlen))) { -- cli_dbgmsg("cli_scanscript: Unable to malloc %u bytes\n", SCANBUFF); -- free(tmpname); -- return CL_EMEM; -- } -- -- text_normalize_init(&state, normalized, SCANBUFF + maxpatlen); -- ret = CL_CLEAN; -- -- -- if ((ret = cli_ac_initdata(&tmdata, troot?troot->ac_partsigs:0, troot?troot->ac_lsigs:0, troot?troot->ac_reloff_num:0, CLI_DEFAULT_AC_TRACKLEN))) { -- free(tmpname); -- return ret; -- } -- -- if ((ret = cli_ac_initdata(&gmdata, groot->ac_partsigs, groot->ac_lsigs, groot->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN))) { -- cli_ac_freedata(&tmdata); -- free(tmpname); -- return ret; -+ if((ret = cli_gentempfd(ctx->engine->tmpdir, &tmpname, &ofd))) { -+ cli_dbgmsg("cli_scanscript: Can't generate temporary file/descriptor\n"); -+ goto done; -+ } -+ if (ctx->engine->keeptmp) -+ cli_dbgmsg("cli_scanscript: saving normalized file to %s\n", tmpname); - } - - mdata[0] = &tmdata; -@@ -1310,10 +1306,9 @@ static int cli_scanscript(cli_ctx *ctx) - map_off += written; - - if (write(ofd, state.out, state.out_pos) == -1) { -- cli_errmsg("cli_scanscript: can't write to file %s\n",tmpname); -- close(ofd); -- free(tmpname); -- return CL_EWRITE; -+ cli_errmsg("cli_scanscript: can't write to file %s\n",tmpname); -+ ret = CL_EWRITE; -+ goto done; - } - text_normalize_reset(&state); - } -@@ -1332,11 +1327,6 @@ static int cli_scanscript(cli_ctx *ctx) - funmap(*ctx->fmap); - } - *ctx->fmap = map; -- -- /* If we aren't keeping temps, delete the normalized file after scan. */ -- if(!(ctx->engine->keeptmp)) -- if (cli_unlink(tmpname)) ret = CL_EUNLINK; -- - } else { - /* Since the above is moderately costly all in all, - * do the old stuff if there's no relative offsets. */ -@@ -1344,11 +1334,8 @@ static int cli_scanscript(cli_ctx *ctx) - if (troot) { - cli_targetinfo(&info, 7, map); - ret = cli_ac_caloff(troot, &tmdata, &info); -- if (ret) { -- cli_ac_freedata(&tmdata); -- free(tmpname); -- return ret; -- } -+ if (ret) -+ goto done; - } - - while(1) { -@@ -1389,13 +1376,6 @@ static int cli_scanscript(cli_ctx *ctx) - - } - -- if(ctx->engine->keeptmp) { -- free(tmpname); -- if (ofd >= 0) -- close(ofd); -- } -- free(normalized); -- - if(ret != CL_VIRUS || SCAN_ALL) { - if ((ret = cli_exp_eval(ctx, troot, &tmdata, NULL, NULL)) == CL_VIRUS) - viruses_found++; -@@ -1404,9 +1384,19 @@ static int cli_scanscript(cli_ctx *ctx) - viruses_found++; - } - -+done: -+ free(normalized); - cli_ac_freedata(&tmdata); - cli_ac_freedata(&gmdata); - -+ if (ofd != -1) -+ close(ofd); -+ if (tmpname != NULL) { -+ if (!ctx->engine->keeptmp) -+ cli_unlink(tmpname); -+ free(tmpname); -+ } -+ - if (SCAN_ALL && viruses_found) - return CL_VIRUS; - diff -Nru clamav-0.99.2+dfsg/debian/patches/Change-paths-in-sample-conf-file-to-match-Debian.patch clamav-0.99.3~beta1+dfsg/debian/patches/Change-paths-in-sample-conf-file-to-match-Debian.patch --- clamav-0.99.2+dfsg/debian/patches/Change-paths-in-sample-conf-file-to-match-Debian.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/Change-paths-in-sample-conf-file-to-match-Debian.patch 2017-11-22 21:56:26.000000000 +0000 @@ -1,4 +1,4 @@ -From d126df7c1dad42913be43d51e416c70b2ff4ff77 Mon Sep 17 00:00:00 2001 +From 2cc6b850ef2055a03c40a8f1d8557eee6f224871 Mon Sep 17 00:00:00 2001 From: Scott Kitterman Date: Mon, 10 Mar 2014 19:20:18 -0400 Subject: Change paths in sample conf file to match Debian @@ -9,10 +9,10 @@ 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/clamav-milter.conf.sample b/etc/clamav-milter.conf.sample -index b7d66a4..ed0d519 100644 +index c81af48..d24a8d3 100644 --- a/etc/clamav-milter.conf.sample +++ b/etc/clamav-milter.conf.sample -@@ -64,7 +64,7 @@ Example +@@ -59,7 +59,7 @@ Example # daemon (main thread). # # Default: disabled @@ -21,7 +21,7 @@ # Optional path to the global temporary directory. # Default: system specific (usually /tmp or /var/tmp). -@@ -90,7 +90,7 @@ Example +@@ -85,7 +85,7 @@ Example # with the same socket: clamd servers will be selected in a round-robin fashion. # # Default: no default @@ -30,7 +30,7 @@ ## -@@ -212,7 +212,7 @@ Example +@@ -207,7 +207,7 @@ Example # A full path is required. # # Default: disabled diff -Nru clamav-0.99.2+dfsg/debian/patches/clamav_add_private_fts_implementation.patch clamav-0.99.3~beta1+dfsg/debian/patches/clamav_add_private_fts_implementation.patch --- clamav-0.99.2+dfsg/debian/patches/clamav_add_private_fts_implementation.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/clamav_add_private_fts_implementation.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,1506 +0,0 @@ -From 6f9ad907818901edbf9b0cb69a94cc0b60d44150 Mon Sep 17 00:00:00 2001 -From: Sebastian Andrzej Siewior -Date: Mon, 16 Nov 2015 22:19:16 +0100 -Subject: clamav: add private fts() implementation - -This file has been copied out of glibc and slightly modified. - -The fts() implementation in current libc does not support LFS which -looks like a glibc (only) restriction. The code has been copied out of -glibc and the used functions (like fstat()) have been modified to use the -public exported libc function instead of the internal one. The libc -functions are are using the LFS version. -The fts() functions gained the _priv_ prefix so they do not clash with -glibc's functions. - -This patch will be dropped once glibc's fts() implementations is LFS -safe which is glibc 2.23+, the bug is tracked in glibc's bugzilla as -11460 => https://sourceware.org/bugzilla/show_bug.cgi?id=11460 - -Patch-Name: clamav_add_private_fts_implementation.patch -Signed-off-by: Sebastian Andrzej Siewior ---- - clamd/Makefile.am | 1 + - clamd/fts.c | 1163 +++++++++++++++++++++++++++++++++++++++++++++++++ - clamd/onaccess_ddd.c | 1 - - clamd/onaccess_hash.c | 10 +- - clamd/onaccess_scth.c | 6 +- - clamd/priv_fts.h | 189 ++++++++ - 6 files changed, 1361 insertions(+), 9 deletions(-) - create mode 100644 clamd/fts.c - create mode 100644 clamd/priv_fts.h - -diff --git a/clamd/Makefile.am b/clamd/Makefile.am -index 96a62ef..d390801 100644 ---- a/clamd/Makefile.am -+++ b/clamd/Makefile.am -@@ -49,6 +49,7 @@ clamd_SOURCES = \ - onaccess_fan.h \ - onaccess_ddd.c \ - onaccess_ddd.h \ -+ fts.c priv_fts.h \ - onaccess_hash.c \ - onaccess_hash.h \ - onaccess_scth.c \ -diff --git a/clamd/fts.c b/clamd/fts.c -new file mode 100644 -index 0000000..0ad8074 ---- /dev/null -+++ b/clamd/fts.c -@@ -0,0 +1,1163 @@ -+/* File tree traversal functions. -+ Copyright (C) 1994-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 Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+/*- -+ * Copyright (c) 1990, 1993, 1994 -+ * The Regents of the University of California. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in the -+ * documentation and/or other materials provided with the distribution. -+ * 4. Neither the name of the University nor the names of its contributors -+ * may be used to endorse or promote products derived from this software -+ * without specific prior written permission. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ */ -+ -+#if defined(LIBC_SCCS) && !defined(lint) -+static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; -+#endif /* LIBC_SCCS and not lint */ -+ -+#include -+#include -+#include -+#include -+#include -+#include "priv_fts.h" -+#include -+#include -+#include -+ -+#if !defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64 -+#error need _FILE_OFFSET_BITS=64 -+#else -+ -+#define FTS_OPEN _priv_fts_open -+#define FTS_CLOSE _priv_fts_close -+#define FTS_READ _priv_fts_read -+#define FTS_SET _priv_fts_set -+#define FTS_CHILDREN _priv_fts_children -+#define FTSOBJ FTS -+#define FTSENTRY FTSENT -+#define INO_T ino_t -+#define STAT stat -+#define LSTAT lstat -+#endif -+ -+#define internal_function -+# define __set_errno(val) (errno = (val)) -+ -+/* Largest alignment size needed, minus one. -+ Usually long double is the worst case. */ -+#ifndef ALIGNBYTES -+#define ALIGNBYTES (__alignof__ (long double) - 1) -+#endif -+/* Align P to that size. */ -+#ifndef ALIGN -+#define ALIGN(p) (((unsigned long int) (p) + ALIGNBYTES) & ~ALIGNBYTES) -+#endif -+ -+/* Support for the LFS API version. */ -+#ifndef FTS_OPEN -+#define FTS_OPEN fts_open -+#define FTS_CLOSE fts_close -+#define FTS_READ fts_read -+#define FTS_SET fts_set -+#define FTS_CHILDREN fts_children -+# define FTSOBJ FTS -+# define FTSENTRY FTSENT -+# define INO_T ino_t -+# define STAT stat -+# define LSTAT lstat -+#endif -+ -+static FTSENTRY *fts_alloc (FTSOBJ *, const char *, size_t) internal_function; -+static FTSENTRY *fts_build (FTSOBJ *, int) internal_function; -+static void fts_lfree (FTSENTRY *) internal_function; -+static void fts_load (FTSOBJ *, FTSENTRY *) internal_function; -+static size_t fts_maxarglen (char * const *) internal_function; -+static void fts_padjust (FTSOBJ *, FTSENTRY *) internal_function; -+static int fts_palloc (FTSOBJ *, size_t) internal_function; -+static FTSENTRY *fts_sort (FTSOBJ *, FTSENTRY *, int) internal_function; -+static u_short fts_stat (FTSOBJ *, FTSENTRY *, int) internal_function; -+static int fts_safe_changedir (FTSOBJ *, FTSENTRY *, int, const char *) -+ internal_function; -+ -+#ifndef MAX -+#define MAX(a, b) ({ __typeof__ (a) _a = (a); \ -+ __typeof__ (b) _b = (b); \ -+ _a > _b ? _a : _b; }) -+#endif -+ -+#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) -+ -+#define CLR(opt) (sp->fts_options &= ~(opt)) -+#define ISSET(opt) (sp->fts_options & (opt)) -+#define SET(opt) (sp->fts_options |= (opt)) -+ -+#define FCHDIR(sp, fd) (!ISSET(FTS_NOCHDIR) && fchdir(fd)) -+ -+/* fts_build flags */ -+#define BCHILD 1 /* fts_children */ -+#define BNAMES 2 /* fts_children, names only */ -+#define BREAD 3 /* fts_read */ -+ -+FTSOBJ * -+FTS_OPEN (char * const *argv, int options, -+ int (*compar) (const FTSENTRY **, const FTSENTRY **)) -+{ -+ FTSOBJ *sp; -+ FTSENTRY *p, *root; -+ int nitems; -+ FTSENTRY *parent = NULL; -+ FTSENTRY *tmp; -+ -+ /* Options check. */ -+ if (options & ~FTS_OPTIONMASK) { -+ __set_errno (EINVAL); -+ return (NULL); -+ } -+ -+ /* Allocate/initialize the stream */ -+ if ((sp = malloc((u_int)sizeof(FTSOBJ))) == NULL) -+ return (NULL); -+ memset(sp, 0, sizeof(FTSOBJ)); -+ sp->fts_compar = (int (*) (const void *, const void *)) compar; -+ sp->fts_options = options; -+ -+ /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ -+ if (ISSET(FTS_LOGICAL)) -+ SET(FTS_NOCHDIR); -+ -+ /* -+ * Start out with 1K of path space, and enough, in any case, -+ * to hold the user's paths. -+ */ -+#ifndef MAXPATHLEN -+#define MAXPATHLEN 1024 -+#endif -+ size_t maxarglen = fts_maxarglen(argv); -+ if (fts_palloc(sp, MAX(maxarglen, MAXPATHLEN))) -+ goto mem1; -+ -+ /* Allocate/initialize root's parent. */ -+ if (*argv != NULL) { -+ if ((parent = fts_alloc(sp, "", 0)) == NULL) -+ goto mem2; -+ parent->fts_level = FTS_ROOTPARENTLEVEL; -+ } -+ -+ /* Allocate/initialize root(s). */ -+ for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) { -+ /* Don't allow zero-length paths. */ -+ size_t len = strlen(*argv); -+ if (len == 0) { -+ __set_errno (ENOENT); -+ goto mem3; -+ } -+ -+ p = fts_alloc(sp, *argv, len); -+ p->fts_level = FTS_ROOTLEVEL; -+ p->fts_parent = parent; -+ p->fts_accpath = p->fts_name; -+ p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW)); -+ -+ /* Command-line "." and ".." are real directories. */ -+ if (p->fts_info == FTS_DOT) -+ p->fts_info = FTS_D; -+ -+ /* -+ * If comparison routine supplied, traverse in sorted -+ * order; otherwise traverse in the order specified. -+ */ -+ if (compar) { -+ p->fts_link = root; -+ root = p; -+ } else { -+ p->fts_link = NULL; -+ if (root == NULL) -+ tmp = root = p; -+ else { -+ tmp->fts_link = p; -+ tmp = p; -+ } -+ } -+ } -+ if (compar && nitems > 1) -+ root = fts_sort(sp, root, nitems); -+ -+ /* -+ * Allocate a dummy pointer and make fts_read think that we've just -+ * finished the node before the root(s); set p->fts_info to FTS_INIT -+ * so that everything about the "current" node is ignored. -+ */ -+ if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL) -+ goto mem3; -+ sp->fts_cur->fts_link = root; -+ sp->fts_cur->fts_info = FTS_INIT; -+ -+ /* -+ * If using chdir(2), grab a file descriptor pointing to dot to ensure -+ * that we can get back here; this could be avoided for some paths, -+ * but almost certainly not worth the effort. Slashes, symbolic links, -+ * and ".." are all fairly nasty problems. Note, if we can't get the -+ * descriptor we run anyway, just more slowly. -+ */ -+ if (!ISSET(FTS_NOCHDIR) -+ && (sp->fts_rfd = open(".", O_RDONLY, 0)) < 0) -+ SET(FTS_NOCHDIR); -+ -+ return (sp); -+ -+mem3: fts_lfree(root); -+ free(parent); -+mem2: free(sp->fts_path); -+mem1: free(sp); -+ return (NULL); -+} -+ -+static void -+internal_function -+fts_load (FTSOBJ *sp, FTSENTRY *p) -+{ -+ int len; -+ char *cp; -+ -+ /* -+ * Load the stream structure for the next traversal. Since we don't -+ * actually enter the directory until after the preorder visit, set -+ * the fts_accpath field specially so the chdir gets done to the right -+ * place and the user can access the first node. From fts_open it's -+ * known that the path will fit. -+ */ -+ len = p->fts_pathlen = p->fts_namelen; -+ memmove(sp->fts_path, p->fts_name, len + 1); -+ if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { -+ len = strlen(++cp); -+ memmove(p->fts_name, cp, len + 1); -+ p->fts_namelen = len; -+ } -+ p->fts_accpath = p->fts_path = sp->fts_path; -+ sp->fts_dev = p->fts_dev; -+} -+ -+int -+FTS_CLOSE (FTSOBJ *sp) -+{ -+ FTSENTRY *freep, *p; -+ int saved_errno; -+ -+ /* -+ * This still works if we haven't read anything -- the dummy structure -+ * points to the root list, so we step through to the end of the root -+ * list which has a valid parent pointer. -+ */ -+ if (sp->fts_cur) { -+ for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { -+ freep = p; -+ p = p->fts_link != NULL ? p->fts_link : p->fts_parent; -+ free(freep); -+ } -+ free(p); -+ } -+ -+ /* Free up child linked list, sort array, path buffer. */ -+ if (sp->fts_child) -+ fts_lfree(sp->fts_child); -+ free(sp->fts_array); -+ free(sp->fts_path); -+ -+ /* Return to original directory, save errno if necessary. */ -+ if (!ISSET(FTS_NOCHDIR)) { -+ saved_errno = fchdir(sp->fts_rfd) ? errno : 0; -+ (void)close(sp->fts_rfd); -+ -+ /* Set errno and return. */ -+ if (saved_errno != 0) { -+ /* Free up the stream pointer. */ -+ free(sp); -+ __set_errno (saved_errno); -+ return (-1); -+ } -+ } -+ -+ /* Free up the stream pointer. */ -+ free(sp); -+ return (0); -+} -+ -+/* -+ * Special case of "/" at the end of the path so that slashes aren't -+ * appended which would cause paths to be written as "....//foo". -+ */ -+#define NAPPEND(p) \ -+ (p->fts_path[p->fts_pathlen - 1] == '/' \ -+ ? p->fts_pathlen - 1 : p->fts_pathlen) -+ -+FTSENTRY * -+FTS_READ (FTSOBJ *sp) -+{ -+ FTSENTRY *p, *tmp; -+ int instr; -+ char *t; -+ int saved_errno; -+ -+ /* If finished or unrecoverable error, return NULL. */ -+ if (sp->fts_cur == NULL || ISSET(FTS_STOP)) -+ return (NULL); -+ -+ /* Set current node pointer. */ -+ p = sp->fts_cur; -+ -+ /* Save and zero out user instructions. */ -+ instr = p->fts_instr; -+ p->fts_instr = FTS_NOINSTR; -+ -+ /* Any type of file may be re-visited; re-stat and re-turn. */ -+ if (instr == FTS_AGAIN) { -+ p->fts_info = fts_stat(sp, p, 0); -+ return (p); -+ } -+ -+ /* -+ * Following a symlink -- SLNONE test allows application to see -+ * SLNONE and recover. If indirecting through a symlink, have -+ * keep a pointer to current location. If unable to get that -+ * pointer, follow fails. -+ */ -+ if (instr == FTS_FOLLOW && -+ (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { -+ p->fts_info = fts_stat(sp, p, 1); -+ if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { -+ if ((p->fts_symfd = open(".", O_RDONLY, 0)) < 0) { -+ p->fts_errno = errno; -+ p->fts_info = FTS_ERR; -+ } else -+ p->fts_flags |= FTS_SYMFOLLOW; -+ } -+ return (p); -+ } -+ -+ /* Directory in pre-order. */ -+ if (p->fts_info == FTS_D) { -+ /* If skipped or crossed mount point, do post-order visit. */ -+ if (instr == FTS_SKIP || -+ (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { -+ if (p->fts_flags & FTS_SYMFOLLOW) -+ (void)close(p->fts_symfd); -+ if (sp->fts_child) { -+ fts_lfree(sp->fts_child); -+ sp->fts_child = NULL; -+ } -+ p->fts_info = FTS_DP; -+ return (p); -+ } -+ -+ /* Rebuild if only read the names and now traversing. */ -+ if (sp->fts_child != NULL && ISSET(FTS_NAMEONLY)) { -+ CLR(FTS_NAMEONLY); -+ fts_lfree(sp->fts_child); -+ sp->fts_child = NULL; -+ } -+ -+ /* -+ * Cd to the subdirectory. -+ * -+ * If have already read and now fail to chdir, whack the list -+ * to make the names come out right, and set the parent errno -+ * so the application will eventually get an error condition. -+ * Set the FTS_DONTCHDIR flag so that when we logically change -+ * directories back to the parent we don't do a chdir. -+ * -+ * If haven't read do so. If the read fails, fts_build sets -+ * FTS_STOP or the fts_info field of the node. -+ */ -+ if (sp->fts_child != NULL) { -+ if (fts_safe_changedir(sp, p, -1, p->fts_accpath)) { -+ p->fts_errno = errno; -+ p->fts_flags |= FTS_DONTCHDIR; -+ for (p = sp->fts_child; p != NULL; -+ p = p->fts_link) -+ p->fts_accpath = -+ p->fts_parent->fts_accpath; -+ } -+ } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) { -+ if (ISSET(FTS_STOP)) -+ return (NULL); -+ return (p); -+ } -+ p = sp->fts_child; -+ sp->fts_child = NULL; -+ sp->fts_cur = p; -+ goto name; -+ } -+ -+ /* Move to the next node on this level. */ -+next: tmp = p; -+ if ((p = p->fts_link) != NULL) { -+ sp->fts_cur = p; -+ free(tmp); -+ -+ /* -+ * If reached the top, return to the original directory (or -+ * the root of the tree), and load the paths for the next root. -+ */ -+ if (p->fts_level == FTS_ROOTLEVEL) { -+ if (FCHDIR(sp, sp->fts_rfd)) { -+ SET(FTS_STOP); -+ return (NULL); -+ } -+ fts_load(sp, p); -+ return p; -+ } -+ -+ /* -+ * User may have called fts_set on the node. If skipped, -+ * ignore. If followed, get a file descriptor so we can -+ * get back if necessary. -+ */ -+ if (p->fts_instr == FTS_SKIP) -+ goto next; -+ if (p->fts_instr == FTS_FOLLOW) { -+ p->fts_info = fts_stat(sp, p, 1); -+ if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { -+ if ((p->fts_symfd = -+ open(".", O_RDONLY, 0)) < 0) { -+ p->fts_errno = errno; -+ p->fts_info = FTS_ERR; -+ } else -+ p->fts_flags |= FTS_SYMFOLLOW; -+ } -+ p->fts_instr = FTS_NOINSTR; -+ } -+ -+name: t = sp->fts_path + NAPPEND(p->fts_parent); -+ *t++ = '/'; -+ memmove(t, p->fts_name, p->fts_namelen + 1); -+ return p; -+ } -+ -+ /* Move up to the parent node. */ -+ p = tmp->fts_parent; -+ sp->fts_cur = p; -+ free(tmp); -+ -+ if (p->fts_level == FTS_ROOTPARENTLEVEL) { -+ /* -+ * Done; free everything up and set errno to 0 so the user -+ * can distinguish between error and EOF. -+ */ -+ free(p); -+ __set_errno (0); -+ return (sp->fts_cur = NULL); -+ } -+ -+ /* NUL terminate the pathname. */ -+ sp->fts_path[p->fts_pathlen] = '\0'; -+ -+ /* -+ * Return to the parent directory. If at a root node or came through -+ * a symlink, go back through the file descriptor. Otherwise, cd up -+ * one directory. -+ */ -+ if (p->fts_level == FTS_ROOTLEVEL) { -+ if (FCHDIR(sp, sp->fts_rfd)) { -+ SET(FTS_STOP); -+ return (NULL); -+ } -+ } else if (p->fts_flags & FTS_SYMFOLLOW) { -+ if (FCHDIR(sp, p->fts_symfd)) { -+ saved_errno = errno; -+ (void)close(p->fts_symfd); -+ __set_errno (saved_errno); -+ SET(FTS_STOP); -+ return (NULL); -+ } -+ (void)close(p->fts_symfd); -+ } else if (!(p->fts_flags & FTS_DONTCHDIR) && -+ fts_safe_changedir(sp, p->fts_parent, -1, "..")) { -+ SET(FTS_STOP); -+ return (NULL); -+ } -+ p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP; -+ return p; -+} -+ -+/* -+ * Fts_set takes the stream as an argument although it's not used in this -+ * implementation; it would be necessary if anyone wanted to add global -+ * semantics to fts using fts_set. An error return is allowed for similar -+ * reasons. -+ */ -+/* ARGSUSED */ -+int -+FTS_SET (FTSOBJ *sp, FTSENTRY *p, int instr) -+{ -+ if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW && -+ instr != FTS_NOINSTR && instr != FTS_SKIP) { -+ __set_errno (EINVAL); -+ return (1); -+ } -+ p->fts_instr = instr; -+ return (0); -+} -+ -+FTSENTRY * -+FTS_CHILDREN(FTSOBJ *sp, int instr) -+{ -+ FTSENTRY *p; -+ int fd; -+ -+ if (instr != 0 && instr != FTS_NAMEONLY) { -+ __set_errno (EINVAL); -+ return (NULL); -+ } -+ -+ /* Set current node pointer. */ -+ p = sp->fts_cur; -+ -+ /* -+ * Errno set to 0 so user can distinguish empty directory from -+ * an error. -+ */ -+ __set_errno (0); -+ -+ /* Fatal errors stop here. */ -+ if (ISSET(FTS_STOP)) -+ return (NULL); -+ -+ /* Return logical hierarchy of user's arguments. */ -+ if (p->fts_info == FTS_INIT) -+ return (p->fts_link); -+ -+ /* -+ * If not a directory being visited in pre-order, stop here. Could -+ * allow FTS_DNR, assuming the user has fixed the problem, but the -+ * same effect is available with FTS_AGAIN. -+ */ -+ if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) -+ return (NULL); -+ -+ /* Free up any previous child list. */ -+ if (sp->fts_child != NULL) -+ fts_lfree(sp->fts_child); -+ -+ if (instr == FTS_NAMEONLY) { -+ SET(FTS_NAMEONLY); -+ instr = BNAMES; -+ } else -+ instr = BCHILD; -+ -+ /* -+ * If using chdir on a relative path and called BEFORE fts_read does -+ * its chdir to the root of a traversal, we can lose -- we need to -+ * chdir into the subdirectory, and we don't know where the current -+ * directory is, so we can't get back so that the upcoming chdir by -+ * fts_read will work. -+ */ -+ if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' || -+ ISSET(FTS_NOCHDIR)) -+ return (sp->fts_child = fts_build(sp, instr)); -+ -+ if ((fd = open(".", O_RDONLY, 0)) < 0) -+ return (NULL); -+ sp->fts_child = fts_build(sp, instr); -+ if (fchdir(fd)) -+ return (NULL); -+ (void)close(fd); -+ return (sp->fts_child); -+} -+ -+static inline int -+dirent_not_directory(const struct dirent *dp) -+{ -+#if defined DT_DIR && defined _DIRENT_HAVE_D_TYPE -+ return dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN; -+#else -+ return 0; -+#endif -+} -+ -+/* -+ * This is the tricky part -- do not casually change *anything* in here. The -+ * idea is to build the linked list of entries that are used by fts_children -+ * and fts_read. There are lots of special cases. -+ * -+ * The real slowdown in walking the tree is the stat calls. If FTS_NOSTAT is -+ * set and it's a physical walk (so that symbolic links can't be directories), -+ * we can do things quickly. First, if it's a 4.4BSD file system, the type -+ * of the file is in the directory entry. Otherwise, we assume that the number -+ * of subdirectories in a node is equal to the number of links to the parent. -+ * The former skips all stat calls. The latter skips stat calls in any leaf -+ * directories and for any files after the subdirectories in the directory have -+ * been found, cutting the stat calls by about 2/3. -+ */ -+static FTSENTRY * -+internal_function -+fts_build (FTSOBJ *sp, int type) -+{ -+ struct dirent *dp; -+ FTSENTRY *p, *head; -+ int nitems; -+ FTSENTRY *cur, *tail; -+ DIR *dirp; -+ void *oldaddr; -+ int cderrno, descend, len, level, nlinks, saved_errno, -+ nostat, doadjust; -+ size_t maxlen; -+ char *cp; -+ -+ /* Set current node pointer. */ -+ cur = sp->fts_cur; -+ -+ /* -+ * Open the directory for reading. If this fails, we're done. -+ * If being called from fts_read, set the fts_info field. -+ */ -+#if defined FTS_WHITEOUT && 0 -+ if (ISSET(FTS_WHITEOUT)) -+ oflag = DTF_NODUP|DTF_REWIND; -+ else -+ oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND; -+#else -+# define __opendir2(path, flag) opendir(path) -+#endif -+ if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) { -+ if (type == BREAD) { -+ cur->fts_info = FTS_DNR; -+ cur->fts_errno = errno; -+ } -+ return (NULL); -+ } -+ -+ /* -+ * Nlinks is the number of possible entries of type directory in the -+ * directory if we're cheating on stat calls, 0 if we're not doing -+ * any stat calls at all, -1 if we're doing stats on everything. -+ */ -+ if (type == BNAMES) { -+ nlinks = 0; -+ /* Be quiet about nostat, GCC. */ -+ nostat = 0; -+ } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) { -+ nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2); -+ nostat = 1; -+ } else { -+ nlinks = -1; -+ nostat = 0; -+ } -+ -+#ifdef notdef -+ (void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink); -+ (void)printf("NOSTAT %d PHYSICAL %d SEEDOT %d\n", -+ ISSET(FTS_NOSTAT), ISSET(FTS_PHYSICAL), ISSET(FTS_SEEDOT)); -+#endif -+ /* -+ * If we're going to need to stat anything or we want to descend -+ * and stay in the directory, chdir. If this fails we keep going, -+ * but set a flag so we don't chdir after the post-order visit. -+ * We won't be able to stat anything, but we can still return the -+ * names themselves. Note, that since fts_read won't be able to -+ * chdir into the directory, it will have to return different path -+ * names than before, i.e. "a/b" instead of "b". Since the node -+ * has already been visited in pre-order, have to wait until the -+ * post-order visit to return the error. There is a special case -+ * here, if there was nothing to stat then it's not an error to -+ * not be able to stat. This is all fairly nasty. If a program -+ * needed sorted entries or stat information, they had better be -+ * checking FTS_NS on the returned nodes. -+ */ -+ cderrno = 0; -+ if (nlinks || type == BREAD) { -+ if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) { -+ if (nlinks && type == BREAD) -+ cur->fts_errno = errno; -+ cur->fts_flags |= FTS_DONTCHDIR; -+ descend = 0; -+ cderrno = errno; -+ (void)closedir(dirp); -+ dirp = NULL; -+ } else -+ descend = 1; -+ } else -+ descend = 0; -+ -+ /* -+ * Figure out the max file name length that can be stored in the -+ * current path -- the inner loop allocates more path as necessary. -+ * We really wouldn't have to do the maxlen calculations here, we -+ * could do them in fts_read before returning the path, but it's a -+ * lot easier here since the length is part of the dirent structure. -+ * -+ * If not changing directories set a pointer so that can just append -+ * each new name into the path. -+ */ -+ len = NAPPEND(cur); -+ if (ISSET(FTS_NOCHDIR)) { -+ cp = sp->fts_path + len; -+ *cp++ = '/'; -+ } else { -+ /* GCC, you're too verbose. */ -+ cp = NULL; -+ } -+ len++; -+ maxlen = sp->fts_pathlen - len; -+ -+ level = cur->fts_level + 1; -+ -+ /* Read the directory, attaching each entry to the `link' pointer. */ -+ doadjust = 0; -+ for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) { -+ if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) -+ continue; -+ -+ if ((p = fts_alloc(sp, dp->d_name, _D_EXACT_NAMLEN (dp))) == NULL) -+ goto mem1; -+ if (_D_EXACT_NAMLEN (dp) >= maxlen) {/* include space for NUL */ -+ oldaddr = sp->fts_path; -+ if (fts_palloc(sp, _D_EXACT_NAMLEN (dp) + len + 1)) { -+ /* -+ * No more memory for path or structures. Save -+ * errno, free up the current structure and the -+ * structures already allocated. -+ */ -+mem1: saved_errno = errno; -+ free(p); -+ fts_lfree(head); -+ (void)closedir(dirp); -+ cur->fts_info = FTS_ERR; -+ SET(FTS_STOP); -+ __set_errno (saved_errno); -+ return (NULL); -+ } -+ /* Did realloc() change the pointer? */ -+ if (oldaddr != sp->fts_path) { -+ doadjust = 1; -+ if (ISSET(FTS_NOCHDIR)) -+ cp = sp->fts_path + len; -+ } -+ maxlen = sp->fts_pathlen - len; -+ } -+ -+ if (len + _D_EXACT_NAMLEN (dp) >= USHRT_MAX) { -+ /* -+ * In an FTSENT, fts_pathlen is a u_short so it is -+ * possible to wraparound here. If we do, free up -+ * the current structure and the structures already -+ * allocated, then error out with ENAMETOOLONG. -+ */ -+ free(p); -+ fts_lfree(head); -+ (void)closedir(dirp); -+ cur->fts_info = FTS_ERR; -+ SET(FTS_STOP); -+ __set_errno (ENAMETOOLONG); -+ return (NULL); -+ } -+ p->fts_level = level; -+ p->fts_parent = sp->fts_cur; -+ p->fts_pathlen = len + _D_EXACT_NAMLEN (dp); -+ -+#if defined FTS_WHITEOUT && 0 -+ if (dp->d_type == DT_WHT) -+ p->fts_flags |= FTS_ISW; -+#endif -+ -+ /* Unreachable code. cderrno is only ever set to a nonnull -+ value if dirp is closed at the same time. But then we -+ cannot enter this loop. */ -+ if (0 && cderrno) { -+ if (nlinks) { -+ p->fts_info = FTS_NS; -+ p->fts_errno = cderrno; -+ } else -+ p->fts_info = FTS_NSOK; -+ p->fts_accpath = cur->fts_accpath; -+ } else if (nlinks == 0 -+ || (nostat && dirent_not_directory(dp))) { -+ p->fts_accpath = -+ ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name; -+ p->fts_info = FTS_NSOK; -+ } else { -+ /* Build a file name for fts_stat to stat. */ -+ if (ISSET(FTS_NOCHDIR)) { -+ p->fts_accpath = p->fts_path; -+ memmove(cp, p->fts_name, p->fts_namelen + 1); -+ } else -+ p->fts_accpath = p->fts_name; -+ /* Stat it. */ -+ p->fts_info = fts_stat(sp, p, 0); -+ -+ /* Decrement link count if applicable. */ -+ if (nlinks > 0 && (p->fts_info == FTS_D || -+ p->fts_info == FTS_DC || p->fts_info == FTS_DOT)) -+ --nlinks; -+ } -+ -+ /* We walk in directory order so "ls -f" doesn't get upset. */ -+ p->fts_link = NULL; -+ if (head == NULL) -+ head = tail = p; -+ else { -+ tail->fts_link = p; -+ tail = p; -+ } -+ ++nitems; -+ } -+ if (dirp) -+ (void)closedir(dirp); -+ -+ /* -+ * If realloc() changed the address of the path, adjust the -+ * addresses for the rest of the tree and the dir list. -+ */ -+ if (doadjust) -+ fts_padjust(sp, head); -+ -+ /* -+ * If not changing directories, reset the path back to original -+ * state. -+ */ -+ if (ISSET(FTS_NOCHDIR)) { -+ if (len == sp->fts_pathlen || nitems == 0) -+ --cp; -+ *cp = '\0'; -+ } -+ -+ /* -+ * If descended after called from fts_children or after called from -+ * fts_read and nothing found, get back. At the root level we use -+ * the saved fd; if one of fts_open()'s arguments is a relative path -+ * to an empty directory, we wind up here with no other way back. If -+ * can't get back, we're done. -+ */ -+ if (descend && (type == BCHILD || !nitems) && -+ (cur->fts_level == FTS_ROOTLEVEL ? -+ FCHDIR(sp, sp->fts_rfd) : -+ fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { -+ cur->fts_info = FTS_ERR; -+ SET(FTS_STOP); -+ fts_lfree(head); -+ return (NULL); -+ } -+ -+ /* If didn't find anything, return NULL. */ -+ if (!nitems) { -+ if (type == BREAD) -+ cur->fts_info = FTS_DP; -+ fts_lfree(head); -+ return (NULL); -+ } -+ -+ /* Sort the entries. */ -+ if (sp->fts_compar && nitems > 1) -+ head = fts_sort(sp, head, nitems); -+ return (head); -+} -+ -+static u_short -+internal_function -+fts_stat (FTSOBJ *sp, FTSENTRY *p, int follow) -+{ -+ FTSENTRY *t; -+ dev_t dev; -+ INO_T ino; -+ struct STAT *sbp, sb; -+ int saved_errno; -+ -+ /* If user needs stat info, stat buffer already allocated. */ -+ sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp; -+ -+#if defined FTS_WHITEOUT && 0 -+ /* check for whiteout */ -+ if (p->fts_flags & FTS_ISW) { -+ if (sbp != &sb) { -+ memset(sbp, '\0', sizeof (*sbp)); -+ sbp->st_mode = S_IFWHT; -+ } -+ return (FTS_W); -+ } -+#endif -+ -+ /* -+ * If doing a logical walk, or application requested FTS_FOLLOW, do -+ * a stat(2). If that fails, check for a non-existent symlink. If -+ * fail, set the errno from the stat call. -+ */ -+ if (ISSET(FTS_LOGICAL) || follow) { -+ if (STAT(p->fts_accpath, sbp)) { -+ saved_errno = errno; -+ if (!LSTAT(p->fts_accpath, sbp)) { -+ __set_errno (0); -+ return (FTS_SLNONE); -+ } -+ p->fts_errno = saved_errno; -+ goto err; -+ } -+ } else if (LSTAT(p->fts_accpath, sbp)) { -+ p->fts_errno = errno; -+err: memset(sbp, 0, sizeof(struct STAT)); -+ return (FTS_NS); -+ } -+ -+ if (S_ISDIR(sbp->st_mode)) { -+ /* -+ * Set the device/inode. Used to find cycles and check for -+ * crossing mount points. Also remember the link count, used -+ * in fts_build to limit the number of stat calls. It is -+ * understood that these fields are only referenced if fts_info -+ * is set to FTS_D. -+ */ -+ dev = p->fts_dev = sbp->st_dev; -+ ino = p->fts_ino = sbp->st_ino; -+ p->fts_nlink = sbp->st_nlink; -+ -+ if (ISDOT(p->fts_name)) -+ return (FTS_DOT); -+ -+ /* -+ * Cycle detection is done by brute force when the directory -+ * is first encountered. If the tree gets deep enough or the -+ * number of symbolic links to directories is high enough, -+ * something faster might be worthwhile. -+ */ -+ for (t = p->fts_parent; -+ t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent) -+ if (ino == t->fts_ino && dev == t->fts_dev) { -+ p->fts_cycle = t; -+ return (FTS_DC); -+ } -+ return (FTS_D); -+ } -+ if (S_ISLNK(sbp->st_mode)) -+ return (FTS_SL); -+ if (S_ISREG(sbp->st_mode)) -+ return (FTS_F); -+ return (FTS_DEFAULT); -+} -+ -+static FTSENTRY * -+internal_function -+fts_sort (FTSOBJ *sp, FTSENTRY *head, int nitems) -+{ -+ FTSENTRY **ap, *p; -+ -+ /* -+ * Construct an array of pointers to the structures and call qsort(3). -+ * Reassemble the array in the order returned by qsort. If unable to -+ * sort for memory reasons, return the directory entries in their -+ * current order. Allocate enough space for the current needs plus -+ * 40 so don't realloc one entry at a time. -+ */ -+ if (nitems > sp->fts_nitems) { -+ FTSENTRY **a; -+ -+ sp->fts_nitems = nitems + 40; -+ if ((a = realloc(sp->fts_array, -+ (size_t)(sp->fts_nitems * sizeof(FTSENTRY *)))) == NULL) { -+ free(sp->fts_array); -+ sp->fts_array = NULL; -+ sp->fts_nitems = 0; -+ return (head); -+ } -+ sp->fts_array = a; -+ } -+ for (ap = sp->fts_array, p = head; p; p = p->fts_link) -+ *ap++ = p; -+ qsort((void *)sp->fts_array, nitems, sizeof(FTSENTRY *), sp->fts_compar); -+ for (head = *(ap = sp->fts_array); --nitems; ++ap) -+ ap[0]->fts_link = ap[1]; -+ ap[0]->fts_link = NULL; -+ return (head); -+} -+ -+static FTSENTRY * -+internal_function -+fts_alloc (FTSOBJ *sp, const char *name, size_t namelen) -+{ -+ FTSENTRY *p; -+ size_t len; -+ -+ /* -+ * The file name is a variable length array and no stat structure is -+ * necessary if the user has set the nostat bit. Allocate the FTSENT -+ * structure, the file name and the stat structure in one chunk, but -+ * be careful that the stat structure is reasonably aligned. Since the -+ * fts_name field is declared to be of size 1, the fts_name pointer is -+ * namelen + 2 before the first possible address of the stat structure. -+ */ -+ len = sizeof(FTSENTRY) + namelen; -+ if (!ISSET(FTS_NOSTAT)) -+ len += sizeof(struct STAT) + ALIGNBYTES; -+ if ((p = malloc(len)) == NULL) -+ return (NULL); -+ -+ /* Copy the name and guarantee NUL termination. */ -+ memmove(p->fts_name, name, namelen); -+ p->fts_name[namelen] = '\0'; -+ -+ if (!ISSET(FTS_NOSTAT)) -+ p->fts_statp = (struct STAT *)ALIGN(p->fts_name + namelen + 2); -+ p->fts_namelen = namelen; -+ p->fts_path = sp->fts_path; -+ p->fts_errno = 0; -+ p->fts_flags = 0; -+ p->fts_instr = FTS_NOINSTR; -+ p->fts_number = 0; -+ p->fts_pointer = NULL; -+ return (p); -+} -+ -+static void -+internal_function -+fts_lfree (FTSENTRY *head) -+{ -+ FTSENTRY *p; -+ -+ /* Free a linked list of structures. */ -+ while ((p = head)) { -+ head = head->fts_link; -+ free(p); -+ } -+} -+ -+/* -+ * Allow essentially unlimited paths; find, rm, ls should all work on any tree. -+ * Most systems will allow creation of paths much longer than MAXPATHLEN, even -+ * though the kernel won't resolve them. Add the size (not just what's needed) -+ * plus 256 bytes so don't realloc the path 2 bytes at a time. -+ */ -+static int -+internal_function -+fts_palloc (FTSOBJ *sp, size_t more) -+{ -+ char *p; -+ -+ sp->fts_pathlen += more + 256; -+ /* -+ * Check for possible wraparound. In an FTS, fts_pathlen is -+ * a signed int but in an FTSENT it is an unsigned short. -+ * We limit fts_pathlen to USHRT_MAX to be safe in both cases. -+ */ -+ if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) { -+ free(sp->fts_path); -+ sp->fts_path = NULL; -+ __set_errno (ENAMETOOLONG); -+ return (1); -+ } -+ p = realloc(sp->fts_path, sp->fts_pathlen); -+ if (p == NULL) { -+ free(sp->fts_path); -+ sp->fts_path = NULL; -+ return 1; -+ } -+ sp->fts_path = p; -+ return 0; -+} -+ -+/* -+ * When the path is realloc'd, have to fix all of the pointers in structures -+ * already returned. -+ */ -+static void -+internal_function -+fts_padjust (FTSOBJ *sp, FTSENTRY *head) -+{ -+ FTSENTRY *p; -+ char *addr = sp->fts_path; -+ -+#define ADJUST(p) do { \ -+ if ((p)->fts_accpath != (p)->fts_name) { \ -+ (p)->fts_accpath = \ -+ (char *)addr + ((p)->fts_accpath - (p)->fts_path); \ -+ } \ -+ (p)->fts_path = addr; \ -+} while (0) -+ /* Adjust the current set of children. */ -+ for (p = sp->fts_child; p; p = p->fts_link) -+ ADJUST(p); -+ -+ /* Adjust the rest of the tree, including the current level. */ -+ for (p = head; p->fts_level >= FTS_ROOTLEVEL;) { -+ ADJUST(p); -+ p = p->fts_link ? p->fts_link : p->fts_parent; -+ } -+} -+ -+static size_t -+internal_function -+fts_maxarglen (char * const *argv) -+{ -+ size_t len, max; -+ -+ for (max = 0; *argv; ++argv) -+ if ((len = strlen(*argv)) > max) -+ max = len; -+ return (max + 1); -+} -+ -+/* -+ * Change to dir specified by fd or p->fts_accpath without getting -+ * tricked by someone changing the world out from underneath us. -+ * Assumes p->fts_dev and p->fts_ino are filled in. -+ */ -+static int -+internal_function -+fts_safe_changedir (FTSOBJ *sp, FTSENTRY *p, int fd, const char *path) -+{ -+ int ret, oerrno, newfd; -+ struct stat sb; -+ -+ newfd = fd; -+ if (ISSET(FTS_NOCHDIR)) -+ return (0); -+ if (fd < 0 && (newfd = open(path, O_RDONLY, 0)) < 0) -+ return (-1); -+ if (fstat(newfd, &sb)) { -+ ret = -1; -+ goto bail; -+ } -+ if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) { -+ __set_errno (ENOENT); /* disinformation */ -+ ret = -1; -+ goto bail; -+ } -+ ret = fchdir(newfd); -+bail: -+ oerrno = errno; -+ if (fd < 0) -+ (void)close(newfd); -+ __set_errno (oerrno); -+ return (ret); -+} -diff --git a/clamd/onaccess_ddd.c b/clamd/onaccess_ddd.c -index 37b25ee..1e1af1a 100644 ---- a/clamd/onaccess_ddd.c -+++ b/clamd/onaccess_ddd.c -@@ -30,7 +30,6 @@ - #include - #include - #include --#include - #include - #include - #include -diff --git a/clamd/onaccess_hash.c b/clamd/onaccess_hash.c -index 9bbfd76..fd7e891 100644 ---- a/clamd/onaccess_hash.c -+++ b/clamd/onaccess_hash.c -@@ -28,7 +28,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -56,6 +55,7 @@ static struct onas_bucket *onas_bucket_init(); - static void onas_free_bucket(struct onas_bucket *bckt); - static int onas_bucket_insert(struct onas_bucket *bckt, struct onas_element *elem); - static int onas_bucket_remove(struct onas_bucket *bckt, struct onas_element *elem); -+#include "priv_fts.h" - - static int onas_add_hashnode_child(struct onas_hnode *node, const char* dirname); - -@@ -580,12 +580,12 @@ int onas_ht_add_hierarchy(struct onas_ht *ht, const char *pathname) { - free(prnt); - - char * const pathargv[] = { (char*) pathname, NULL }; -- if (!(ftsp = fts_open(pathargv, ftspopts, NULL))) { -+ if (!(ftsp = _priv_fts_open(pathargv, ftspopts, NULL))) { - logg("!ScanOnAccess: Could not open '%s'\n", pathname); - return CL_EARG; - } - -- while((curr = fts_read(ftsp))) { -+ while((curr = _priv_fts_read(ftsp))) { - - struct onas_hnode *hnode = NULL; - -@@ -608,7 +608,7 @@ int onas_ht_add_hierarchy(struct onas_ht *ht, const char *pathname) { - continue; - } - -- if((childlist = fts_children(ftsp, 0))) { -+ if((childlist = _priv_fts_children(ftsp, 0))) { - do { - if (childlist->fts_info & FTS_D && - !(childlist->fts_info & FTS_DNR) && -@@ -626,7 +626,7 @@ int onas_ht_add_hierarchy(struct onas_ht *ht, const char *pathname) { - if (onas_ht_insert(ht, elem)) return -1; - } - -- fts_close(ftsp); -+ _priv_fts_close(ftsp); - return CL_SUCCESS; - } - -diff --git a/clamd/onaccess_scth.c b/clamd/onaccess_scth.c -index c28e155..8378160 100644 ---- a/clamd/onaccess_scth.c -+++ b/clamd/onaccess_scth.c -@@ -28,7 +28,6 @@ - #include - #include - #include --#include - #include - #include - -@@ -36,6 +35,7 @@ - #include "shared/output.h" - - #include "others.h" -+#include "priv_fts.h" - - #include "onaccess_scth.h" - -@@ -56,10 +56,10 @@ static void onas_scth_handle_dir(const char *pathname) { - FTSENT *curr = NULL; - - char *const pathargv[] = { (char *) pathname, NULL }; -- if (!(ftsp = fts_open(pathargv, ftspopts, NULL))) return; -+ if (!(ftsp = _priv_fts_open(pathargv, ftspopts, NULL))) return; - - /* Offload scanning work to fanotify thread to avoid potential deadlocks. */ -- while ((curr = fts_read(ftsp))) { -+ while ((curr = _priv_fts_read(ftsp))) { - if (curr->fts_info != FTS_D) { - int fd = open(curr->fts_path, O_RDONLY); - if (fd > 0) close(fd); -diff --git a/clamd/priv_fts.h b/clamd/priv_fts.h -new file mode 100644 -index 0000000..3eadd76 ---- /dev/null -+++ b/clamd/priv_fts.h -@@ -0,0 +1,189 @@ -+/* File tree traversal functions declarations. -+ Copyright (C) 1994-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 Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+/* -+ * Copyright (c) 1989, 1993 -+ * The Regents of the University of California. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in the -+ * documentation and/or other materials provided with the distribution. -+ * 4. Neither the name of the University nor the names of its contributors -+ * may be used to endorse or promote products derived from this software -+ * without specific prior written permission. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ * -+ * @(#)fts.h 8.3 (Berkeley) 8/14/94 -+ */ -+ -+#ifndef _FTS_H -+#define _FTS_H 1 -+ -+#include -+#include -+ -+ -+typedef struct { -+ struct _ftsent *fts_cur; /* current node */ -+ struct _ftsent *fts_child; /* linked list of children */ -+ struct _ftsent **fts_array; /* sort array */ -+ dev_t fts_dev; /* starting device # */ -+ char *fts_path; /* path for this descent */ -+ int fts_rfd; /* fd for root */ -+ int fts_pathlen; /* sizeof(path) */ -+ int fts_nitems; /* elements in the sort array */ -+ int (*fts_compar) (const void *, const void *); /* compare fn */ -+ -+#define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */ -+#define FTS_LOGICAL 0x0002 /* logical walk */ -+#define FTS_NOCHDIR 0x0004 /* don't change directories */ -+#define FTS_NOSTAT 0x0008 /* don't get stat info */ -+#define FTS_PHYSICAL 0x0010 /* physical walk */ -+#define FTS_SEEDOT 0x0020 /* return dot and dot-dot */ -+#define FTS_XDEV 0x0040 /* don't cross devices */ -+#define FTS_WHITEOUT 0x0080 /* return whiteout information */ -+#define FTS_OPTIONMASK 0x00ff /* valid user option mask */ -+ -+#define FTS_NAMEONLY 0x0100 /* (private) child names only */ -+#define FTS_STOP 0x0200 /* (private) unrecoverable error */ -+ int fts_options; /* fts_open options, global flags */ -+} FTS; -+ -+#ifdef __USE_LARGEFILE64 -+typedef struct { -+ struct _ftsent64 *fts_cur; /* current node */ -+ struct _ftsent64 *fts_child; /* linked list of children */ -+ struct _ftsent64 **fts_array; /* sort array */ -+ dev_t fts_dev; /* starting device # */ -+ char *fts_path; /* path for this descent */ -+ int fts_rfd; /* fd for root */ -+ int fts_pathlen; /* sizeof(path) */ -+ int fts_nitems; /* elements in the sort array */ -+ int (*fts_compar) (const void *, const void *); /* compare fn */ -+ int fts_options; /* fts_open options, global flags */ -+} FTS64; -+#endif -+ -+typedef struct _ftsent { -+ struct _ftsent *fts_cycle; /* cycle node */ -+ struct _ftsent *fts_parent; /* parent directory */ -+ struct _ftsent *fts_link; /* next file in directory */ -+ long fts_number; /* local numeric value */ -+ void *fts_pointer; /* local address value */ -+ char *fts_accpath; /* access path */ -+ char *fts_path; /* root path */ -+ int fts_errno; /* errno for this node */ -+ int fts_symfd; /* fd for symlink */ -+ u_short fts_pathlen; /* strlen(fts_path) */ -+ u_short fts_namelen; /* strlen(fts_name) */ -+ -+ ino_t fts_ino; /* inode */ -+ dev_t fts_dev; /* device */ -+ nlink_t fts_nlink; /* link count */ -+ -+#define FTS_ROOTPARENTLEVEL -1 -+#define FTS_ROOTLEVEL 0 -+ short fts_level; /* depth (-1 to N) */ -+ -+#define FTS_D 1 /* preorder directory */ -+#define FTS_DC 2 /* directory that causes cycles */ -+#define FTS_DEFAULT 3 /* none of the above */ -+#define FTS_DNR 4 /* unreadable directory */ -+#define FTS_DOT 5 /* dot or dot-dot */ -+#define FTS_DP 6 /* postorder directory */ -+#define FTS_ERR 7 /* error; errno is set */ -+#define FTS_F 8 /* regular file */ -+#define FTS_INIT 9 /* initialized only */ -+#define FTS_NS 10 /* stat(2) failed */ -+#define FTS_NSOK 11 /* no stat(2) requested */ -+#define FTS_SL 12 /* symbolic link */ -+#define FTS_SLNONE 13 /* symbolic link without target */ -+#define FTS_W 14 /* whiteout object */ -+ u_short fts_info; /* user flags for FTSENT structure */ -+ -+#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ -+#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ -+ u_short fts_flags; /* private flags for FTSENT structure */ -+ -+#define FTS_AGAIN 1 /* read node again */ -+#define FTS_FOLLOW 2 /* follow symbolic link */ -+#define FTS_NOINSTR 3 /* no instructions */ -+#define FTS_SKIP 4 /* discard node */ -+ u_short fts_instr; /* fts_set() instructions */ -+ -+ struct stat *fts_statp; /* stat(2) information */ -+ char fts_name[1]; /* file name */ -+} FTSENT; -+ -+#ifdef __USE_LARGEFILE64 -+typedef struct _ftsent64 { -+ struct _ftsent64 *fts_cycle; /* cycle node */ -+ struct _ftsent64 *fts_parent; /* parent directory */ -+ struct _ftsent64 *fts_link; /* next file in directory */ -+ long fts_number; /* local numeric value */ -+ void *fts_pointer; /* local address value */ -+ char *fts_accpath; /* access path */ -+ char *fts_path; /* root path */ -+ int fts_errno; /* errno for this node */ -+ int fts_symfd; /* fd for symlink */ -+ u_short fts_pathlen; /* strlen(fts_path) */ -+ u_short fts_namelen; /* strlen(fts_name) */ -+ -+ ino64_t fts_ino; /* inode */ -+ dev_t fts_dev; /* device */ -+ nlink_t fts_nlink; /* link count */ -+ -+ short fts_level; /* depth (-1 to N) */ -+ -+ u_short fts_info; /* user flags for FTSENT structure */ -+ -+ u_short fts_flags; /* private flags for FTSENT structure */ -+ -+ u_short fts_instr; /* fts_set() instructions */ -+ -+ struct stat64 *fts_statp; /* stat(2) information */ -+ char fts_name[1]; /* file name */ -+} FTSENT64; -+#endif -+ -+__BEGIN_DECLS -+FTSENT *_priv_fts_children (FTS *, int); -+int _priv_fts_close (FTS *); -+FTS *_priv_fts_open (char * const *, int, -+ int (*)(const FTSENT **, const FTSENT **)); -+FTSENT *_priv_fts_read (FTS *); -+int _priv_fts_set (FTS *, FTSENT *, int) __THROW; -+__END_DECLS -+ -+#endif /* fts.h */ diff -Nru clamav-0.99.2+dfsg/debian/patches/clamd_dont_depend_on_clamav_demon_socket.patch clamav-0.99.3~beta1+dfsg/debian/patches/clamd_dont_depend_on_clamav_demon_socket.patch --- clamav-0.99.2+dfsg/debian/patches/clamd_dont_depend_on_clamav_demon_socket.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/clamd_dont_depend_on_clamav_demon_socket.patch 2017-11-22 21:56:26.000000000 +0000 @@ -1,4 +1,4 @@ -From 3bdb184f87270d6f5053b1382e1ab0637e9fd74c Mon Sep 17 00:00:00 2001 +From c4a2f566da7f567a4f0bdfb4492ae06dd8241f57 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Thu, 11 Aug 2016 21:54:10 +0200 Subject: clamd: don't depend on clamav-demon.socket diff -Nru clamav-0.99.2+dfsg/debian/patches/clamsubmit-add-JSON-libs-to-clamsubmit.patch clamav-0.99.3~beta1+dfsg/debian/patches/clamsubmit-add-JSON-libs-to-clamsubmit.patch --- clamav-0.99.2+dfsg/debian/patches/clamsubmit-add-JSON-libs-to-clamsubmit.patch 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/clamsubmit-add-JSON-libs-to-clamsubmit.patch 2017-11-22 21:56:26.000000000 +0000 @@ -0,0 +1,27 @@ +From cb77ce50d70350cd94253f15c1e8d414c0fd8191 Mon Sep 17 00:00:00 2001 +From: Sebastian Andrzej Siewior +Date: Fri, 7 Jul 2017 18:49:32 +0000 +Subject: clamsubmit: add JSON libs to clamsubmit + +It uses those, newer gcc aborts if not specified. + +https://bugzilla.clamav.net/show_bug.cgi?id=11867 +Patch-Name: clamsubmit-add-JSON-libs-to-clamsubmit.patch +Signed-off-by: Sebastian Andrzej Siewior +--- + clamsubmit/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/clamsubmit/Makefile.am b/clamsubmit/Makefile.am +index aa1952f..c1db392 100644 +--- a/clamsubmit/Makefile.am ++++ b/clamsubmit/Makefile.am +@@ -32,7 +32,7 @@ clamsubmit_SOURCES = \ + AM_CFLAGS=@WERR_CFLAGS@ @CLAMSUBMIT_CFLAGS@ + DEFS = @DEFS@ -DCL_NOTHREADS + AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@ +-LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMSUBMIT_LIBS@ @THREAD_LIBS@ ++LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMSUBMIT_LIBS@ @THREAD_LIBS@ @JSON_LIBS@ + + AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamsubmit$(EXEEXT) + CLEANFILES=*.gcda *.gcno diff -Nru clamav-0.99.2+dfsg/debian/patches/CVE-2017-6418.patch clamav-0.99.3~beta1+dfsg/debian/patches/CVE-2017-6418.patch --- clamav-0.99.2+dfsg/debian/patches/CVE-2017-6418.patch 2017-08-08 16:54:57.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/CVE-2017-6418.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -From 586a5180287262070637c8943f2f7efd652e4a2c Mon Sep 17 00:00:00 2001 -From: Steven Morgan -Date: Thu, 2 Mar 2017 14:41:20 -0500 -Subject: [PATCH] bb11797 - fix invalid read in fuzzed mail file. - ---- - libclamav/message.c | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -Index: clamav-0.99.2+dfsg/libclamav/message.c -=================================================================== ---- clamav-0.99.2+dfsg.orig/libclamav/message.c 2017-08-08 12:54:55.404004746 -0400 -+++ clamav-0.99.2+dfsg/libclamav/message.c 2017-08-08 12:54:55.400004746 -0400 -@@ -439,8 +439,12 @@ messageAddArgument(message *m, const cha - * FIXME: Bounce message handling is corrupting the in - * core copies of headers - */ -- cli_dbgmsg("Possible data corruption fixed\n"); -- p[8] = '='; -+ if (strlen(p) > 8) { -+ cli_dbgmsg("Possible data corruption fixed\n"); -+ p[8] = '='; -+ } else { -+ cli_dbgmsg("Possible data corruption not fixed\n"); -+ } - } else { - if(*p) - cli_dbgmsg("messageAddArgument, '%s' contains no '='\n", p); -@@ -676,7 +680,7 @@ messageFindArgument(const message *m, co - cli_dbgmsg("messageFindArgument: no '=' sign found in MIME header '%s' (%s)\n", variable, messageGetArgument(m, i)); - return NULL; - } -- if((*++ptr == '"') && (strchr(&ptr[1], '"') != NULL)) { -+ if((strlen(ptr) > 2) && (*++ptr == '"') && (strchr(&ptr[1], '"') != NULL)) { - /* Remove any quote characters */ - char *ret = cli_strdup(++ptr); - char *p; diff -Nru clamav-0.99.2+dfsg/debian/patches/CVE-2017-6420-2.patch clamav-0.99.3~beta1+dfsg/debian/patches/CVE-2017-6420-2.patch --- clamav-0.99.2+dfsg/debian/patches/CVE-2017-6420-2.patch 2017-08-08 19:20:14.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/CVE-2017-6420-2.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -From 60671e3deb1df6c626e5c7e13752c2eec1649f98 Mon Sep 17 00:00:00 2001 -From: Steven Morgan -Date: Wed, 8 Mar 2017 08:58:28 -0500 -Subject: [PATCH] bb11798 - fix unit tests. - ---- - libclamav/wwunpack.c | 9 +++------ - unit_tests/check_jsnorm.c | 2 +- - 2 files changed, 4 insertions(+), 7 deletions(-) - -diff --git a/libclamav/wwunpack.c b/libclamav/wwunpack.c -index 38c18081c..a13550e8f 100644 ---- a/libclamav/wwunpack.c -+++ b/libclamav/wwunpack.c -@@ -226,13 +226,10 @@ int wwunpack(uint8_t *exe, uint32_t exesz, uint8_t *wwsect, struct cli_exe_secti - return CL_EFORMAT; - exe[pe+6]=(uint8_t)scount; - exe[pe+7]=(uint8_t)(scount>>8); -- if (!CLI_ISCONTAINED(wwsect, sects[scount].rsz, wwsect+0x295, 4) || -- !CLI_ISCONTAINED(wwsect, sects[scount].rsz, wwsect+0x295+sects[scount].rva, 4) || -- !CLI_ISCONTAINED(wwsect, sects[scount].rsz, wwsect+0x295+sects[scount].rva+0x299, 4)) { -+ if (!CLI_ISCONTAINED(wwsect, sects[scount].rsz, wwsect+0x295, 4)) - cli_dbgmsg("WWPack: unpack memory address out of bounds.\n"); -- return CL_EFORMAT; -- } -- cli_writeint32(&exe[pe+0x28], cli_readint32(wwsect+0x295)+sects[scount].rva+0x299); -+ else -+ cli_writeint32(&exe[pe+0x28], cli_readint32(wwsect+0x295)+sects[scount].rva+0x299); - cli_writeint32(&exe[pe+0x50], cli_readint32(&exe[pe+0x50])-sects[scount].vsz); - - structs = &exe[(0xffff&cli_readint32(&exe[pe+0x14]))+pe+0x18]; -diff --git a/unit_tests/check_jsnorm.c b/unit_tests/check_jsnorm.c -index 7515a0c18..9587ea469 100644 ---- a/unit_tests/check_jsnorm.c -+++ b/unit_tests/check_jsnorm.c -@@ -145,7 +145,7 @@ END_TEST - - START_TEST (test_token_dval) - { -- int val = 0.12345; -+ double val = 0.12345; - yystype tok; - memset(&tok, 0, sizeof(tok)); - diff -Nru clamav-0.99.2+dfsg/debian/patches/CVE-2017-6420.patch clamav-0.99.3~beta1+dfsg/debian/patches/CVE-2017-6420.patch --- clamav-0.99.2+dfsg/debian/patches/CVE-2017-6420.patch 2017-08-08 16:55:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/CVE-2017-6420.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -From dfc00cd3301a42b571454b51a6102eecf58407bc Mon Sep 17 00:00:00 2001 -From: Steven Morgan -Date: Fri, 3 Mar 2017 13:56:28 -0500 -Subject: [PATCH] bb19798 - fix out of bound memory access for crafted wwunpack - file. - ---- - libclamav/wwunpack.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/libclamav/wwunpack.c b/libclamav/wwunpack.c -index 8611cb604..38c18081c 100644 ---- a/libclamav/wwunpack.c -+++ b/libclamav/wwunpack.c -@@ -226,6 +226,12 @@ int wwunpack(uint8_t *exe, uint32_t exesz, uint8_t *wwsect, struct cli_exe_secti - return CL_EFORMAT; - exe[pe+6]=(uint8_t)scount; - exe[pe+7]=(uint8_t)(scount>>8); -+ if (!CLI_ISCONTAINED(wwsect, sects[scount].rsz, wwsect+0x295, 4) || -+ !CLI_ISCONTAINED(wwsect, sects[scount].rsz, wwsect+0x295+sects[scount].rva, 4) || -+ !CLI_ISCONTAINED(wwsect, sects[scount].rsz, wwsect+0x295+sects[scount].rva+0x299, 4)) { -+ cli_dbgmsg("WWPack: unpack memory address out of bounds.\n"); -+ return CL_EFORMAT; -+ } - cli_writeint32(&exe[pe+0x28], cli_readint32(wwsect+0x295)+sects[scount].rva+0x299); - cli_writeint32(&exe[pe+0x50], cli_readint32(&exe[pe+0x50])-sects[scount].vsz); - diff -Nru clamav-0.99.2+dfsg/debian/patches/drop-AllowSupplementaryGroups-option-and-make-it-def.patch clamav-0.99.3~beta1+dfsg/debian/patches/drop-AllowSupplementaryGroups-option-and-make-it-def.patch --- clamav-0.99.2+dfsg/debian/patches/drop-AllowSupplementaryGroups-option-and-make-it-def.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/drop-AllowSupplementaryGroups-option-and-make-it-def.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,262 +0,0 @@ -From 57201a2c4a6a58ad786bf7e9d729701c70cc4a01 Mon Sep 17 00:00:00 2001 -From: Sebastian Andrzej Siewior -Date: Mon, 2 May 2016 22:01:26 +0200 -Subject: drop AllowSupplementaryGroups option and make it default - -AllowSupplementaryGroups set enables the use of additional groups which -are part of the user configured. I don't see a reason why this should be -optional. If this is not wanted there is no reason to add the additional -groups in the first place. -This option enabled is the default behaviour of `start-stop-deamon' and -systemd's "User=" directive. Therefore make it default if available and -give the user one option less that can be set wrong. - -BTS: https://bugs.debian.org/822444 -clamav: https://bugzilla.clamav.net/show_bug.cgi?id=11557 - -Patch-Name: drop-AllowSupplementaryGroups-option-and-make-it-def.patch -Signed-off-by: Sebastian Andrzej Siewior ---- - clamav-milter/clamav-milter.c | 27 ++++++++------------------- - clamd/clamd.c | 28 +++++++++------------------- - docs/man/clamav-milter.conf.5.in | 5 ----- - docs/man/clamd.conf.5.in | 5 ----- - docs/man/freshclam.conf.5.in | 5 ----- - etc/clamav-milter.conf.sample | 5 ----- - etc/clamd.conf.sample | 4 ---- - etc/freshclam.conf.sample | 4 ---- - freshclam/freshclam.c | 29 +++++++++-------------------- - shared/optparser.c | 2 -- - 10 files changed, 26 insertions(+), 88 deletions(-) - -diff --git a/clamav-milter/clamav-milter.c b/clamav-milter/clamav-milter.c -index 48a9044..8c7bf6d 100644 ---- a/clamav-milter/clamav-milter.c -+++ b/clamav-milter/clamav-milter.c -@@ -298,28 +298,17 @@ int main(int argc, char **argv) { - return 1; - } - -- if(optget(opts, "AllowSupplementaryGroups")->enabled) { - #ifdef HAVE_INITGROUPS -- if(initgroups(opt->strarg, user->pw_gid)) { -- fprintf(stderr, "ERROR: initgroups() failed.\n"); -- optfree(opts); -- return 1; -- } --#else -- mprintf("!AllowSupplementaryGroups: initgroups() is not available, please disable AllowSupplementaryGroups\n"); -- optfree(opts); -+ if(initgroups(user->pw_name, user->pw_gid)) { -+ fprintf(stderr, "ERROR: initgroups() failed.\n"); - return 1; --#endif -- } else { --#ifdef HAVE_SETGROUPS -- if(setgroups(1, &user->pw_gid)) { -- fprintf(stderr, "ERROR: setgroups() failed.\n"); -- optfree(opts); -- return 1; -- } --#endif - } -- -+#elif HAVE_SETGROUPS -+ if(setgroups(1, &user->pw_gid)) { -+ fprintf(stderr, "ERROR: setgroups() failed.\n"); -+ return 1; -+ } -+#endif - if(setgid(user->pw_gid)) { - fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid); - optfree(opts); -diff --git a/clamd/clamd.c b/clamd/clamd.c -index 5793bec..191d68c 100644 ---- a/clamd/clamd.c -+++ b/clamd/clamd.c -@@ -216,27 +216,17 @@ int main(int argc, char **argv) - return 1; - } - -- if(optget(opts, "AllowSupplementaryGroups")->enabled) { - #ifdef HAVE_INITGROUPS -- if(initgroups(opt->strarg, user->pw_gid)) { -- fprintf(stderr, "ERROR: initgroups() failed.\n"); -- optfree(opts); -- return 1; -- } --#else -- mprintf("!AllowSupplementaryGroups: initgroups() is not available, please disable AllowSupplementaryGroups in %s\n", cfgfile); -- optfree(opts); -- return 1; -+ if(initgroups(user->pw_name, user->pw_gid)) { -+ fprintf(stderr, "ERROR: initgroups() failed.\n"); -+ return 1; -+ } -+#elif HAVE_SETGROUPS -+ if(setgroups(1, &user->pw_gid)) { -+ fprintf(stderr, "ERROR: setgroups() failed.\n"); -+ return 1; -+ } - #endif -- } else { --#ifdef HAVE_SETGROUPS -- if(setgroups(1, &user->pw_gid)) { -- fprintf(stderr, "ERROR: setgroups() failed.\n"); -- optfree(opts); -- return 1; -- } --#endif -- } - - if(setgid(user->pw_gid)) { - fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid); -diff --git a/docs/man/clamav-milter.conf.5.in b/docs/man/clamav-milter.conf.5.in -index ae9d92f..c3d9e29 100644 ---- a/docs/man/clamav-milter.conf.5.in -+++ b/docs/man/clamav-milter.conf.5.in -@@ -57,11 +57,6 @@ Run as another user (clamav-milter must be started by root for this option to wo - .br - Default: unset (don\'t drop privileges) - .TP --\fBAllowSupplementaryGroups BOOL\fR --Initialize supplementary group access (clamav-milter must be started by root). --.br --Default: no --.TP - \fBReadTimeout NUMBER\fR - Waiting for data from clamd will timeout after this time (seconds). - .br -diff --git a/docs/man/clamd.conf.5.in b/docs/man/clamd.conf.5.in -index 8908e45..cd96854 100644 ---- a/docs/man/clamd.conf.5.in -+++ b/docs/man/clamd.conf.5.in -@@ -270,11 +270,6 @@ Run the daemon as a specified user (the process must be started by root). - .br - Default: disabled - .TP --\fBAllowSupplementaryGroups BOOL\fR --Initialize a supplementary group access (the process must be started by root). --.br --Default: no --.TP - \fBBytecode BOOL\fR - With this option enabled ClamAV will load bytecode from the database. It is highly recommended you keep this option turned on, otherwise you may miss detections for many new viruses. - .br -diff --git a/docs/man/freshclam.conf.5.in b/docs/man/freshclam.conf.5.in -index 9960ec2..a2e21b0 100644 ---- a/docs/man/freshclam.conf.5.in -+++ b/docs/man/freshclam.conf.5.in -@@ -76,11 +76,6 @@ Enable debug messages in libclamav. - .br - Default: no - .TP --\fBAllowSupplementaryGroups BOOL\fR --Initialize supplementary group access (freshclam must be started by root). --.br --Default: disabled --.TP - \fBUpdateLogFile STRING\fR - Enable logging to a specified file. Highly recommended. - .br -diff --git a/etc/clamav-milter.conf.sample b/etc/clamav-milter.conf.sample -index ed0d519..d24a8d3 100644 ---- a/etc/clamav-milter.conf.sample -+++ b/etc/clamav-milter.conf.sample -@@ -38,11 +38,6 @@ Example - # Default: unset (don't drop privileges) - #User clamav - --# Initialize supplementary group access (clamav-milter must be started by root). --# --# Default: no --#AllowSupplementaryGroups no -- - # Waiting for data from clamd will timeout after this time (seconds). - # Value of 0 disables the timeout. - # -diff --git a/etc/clamd.conf.sample b/etc/clamd.conf.sample -index 6a3ec45..8d2af63 100644 ---- a/etc/clamd.conf.sample -+++ b/etc/clamd.conf.sample -@@ -194,10 +194,6 @@ Example - # Default: don't drop privileges - #User clamav - --# Initialize supplementary group access (clamd must be started by root). --# Default: no --#AllowSupplementaryGroups no -- - # Stop daemon when libclamav reports out of memory condition. - #ExitOnOOM yes - -diff --git a/etc/freshclam.conf.sample b/etc/freshclam.conf.sample -index 1cc4a81..1839116 100644 ---- a/etc/freshclam.conf.sample -+++ b/etc/freshclam.conf.sample -@@ -55,10 +55,6 @@ Example - # Default: clamav (may depend on installation options) - #DatabaseOwner clamav - --# Initialize supplementary group access (freshclam must be started by root). --# Default: no --#AllowSupplementaryGroups yes -- - # Use DNS to verify virus database version. Freshclam uses DNS TXT records - # to verify database and software versions. With this directive you can change - # the database verification domain. -diff --git a/freshclam/freshclam.c b/freshclam/freshclam.c -index 08f1250..8bc90ef 100644 ---- a/freshclam/freshclam.c -+++ b/freshclam/freshclam.c -@@ -419,28 +419,17 @@ main (int argc, char **argv) - return FCE_USERINFO; - } - -- if (optget (opts, "AllowSupplementaryGroups")->enabled) -- { - #ifdef HAVE_INITGROUPS -- if (initgroups (dbowner, user->pw_gid)) -- { -- logg ("^initgroups() failed.\n"); -- optfree (opts); -- return FCE_USERORGROUP; -- } -+ if (initgroups(dbowner, user->pw_gid)) { -+ logg ("^initgroups() failed.\n"); -+ return FCE_USERORGROUP; -+ } -+#elif HAVE_SETGROUPS -+ if (setgroups(1, &user->pw_gid)) { -+ logg ("^setgroups() failed.\n"); -+ return FCE_USERORGROUP; -+ } - #endif -- } -- else -- { --#ifdef HAVE_SETGROUPS -- if (setgroups (1, &user->pw_gid)) -- { -- logg ("^setgroups() failed.\n"); -- optfree (opts); -- return FCE_USERORGROUP; -- } --#endif -- } - - if (setgid (user->pw_gid)) - { -diff --git a/shared/optparser.c b/shared/optparser.c -index f8911ea..e2b28cc 100644 ---- a/shared/optparser.c -+++ b/shared/optparser.c -@@ -285,8 +285,6 @@ const struct clam_option __clam_options[] = { - - { "User", NULL, 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMD | OPT_MILTER, "Run the daemon as a specified user (the process must be started by root).", "clamav" }, - -- { "AllowSupplementaryGroups", NULL, 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_MILTER, "Initialize a supplementary group access (the process must be started by root).", "no" }, -- - /* Scan options */ - { "Bytecode", "bytecode", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 1, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "With this option enabled ClamAV will load bytecode from the database. It is highly recommended you keep this option on, otherwise you'll miss detections for many new viruses.", "yes" }, - diff -Nru clamav-0.99.2+dfsg/debian/patches/Fix_detection_of_libcurl.patch clamav-0.99.3~beta1+dfsg/debian/patches/Fix_detection_of_libcurl.patch --- clamav-0.99.2+dfsg/debian/patches/Fix_detection_of_libcurl.patch 2017-01-30 20:41:46.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/Fix_detection_of_libcurl.patch 2017-11-22 21:56:26.000000000 +0000 @@ -1,4 +1,4 @@ -From 4a07f7933aad6b3f3e533fa69e5401d82415b319 Mon Sep 17 00:00:00 2001 +From 18ae673764fd15bed5b17678be1f753348d17735 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Mon, 30 Jan 2017 21:27:16 +0100 Subject: Fix detection of libcurl @@ -8,7 +8,6 @@ -dev package as the headers. Bug-Debian: https://bugs.debian.org/852894 -Bug-Upstream: https://bugzilla.clamav.net/show_bug.cgi?id=11739 Patch-Name: Fix_detection_of_libcurl.patch --- m4/reorganization/libs/curl.m4 | 2 +- diff -Nru clamav-0.99.2+dfsg/debian/patches/fix_newer_zlib.patch clamav-0.99.3~beta1+dfsg/debian/patches/fix_newer_zlib.patch --- clamav-0.99.2+dfsg/debian/patches/fix_newer_zlib.patch 2017-08-15 19:47:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/fix_newer_zlib.patch 2017-11-22 21:56:26.000000000 +0000 @@ -1,7 +1,8 @@ Description: fix compatibility with zlib 1.2.9 and newer Author: Marc Deslauriers Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/clamav/+bug/1692073 - +Applied-Upstream: https://github.com/vrtadmin/clamav-devel/commit/48fef7b8ec06dbfbf899986cdcbe05071a633eb4 +Last-Update: 2017-11-22 Index: clamav-0.99.2+dfsg/libclamav/bytecode_api.c =================================================================== --- clamav-0.99.2+dfsg.orig/libclamav/bytecode_api.c 2017-08-08 15:20:06.651685637 -0400 diff -Nru clamav-0.99.2+dfsg/debian/patches/fix-ssize_t-size_t-off_t-printf-modifier.patch clamav-0.99.3~beta1+dfsg/debian/patches/fix-ssize_t-size_t-off_t-printf-modifier.patch --- clamav-0.99.2+dfsg/debian/patches/fix-ssize_t-size_t-off_t-printf-modifier.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/fix-ssize_t-size_t-off_t-printf-modifier.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,299 +0,0 @@ -From 939ed793ad56d993b02173e6599fb9628fd5e7db Mon Sep 17 00:00:00 2001 -From: Sebastian Andrzej Siewior -Date: Sun, 17 Aug 2014 21:24:03 +0200 -Subject: fix ssize_t/size_t/off_t printf modifier -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This fixes a segfault on ARM, Sparc, … if 64bit off_t is used. Once LFS -is enabled then off_t becomes 64bit and there is no portable way to express -it except to cast the variable to signed long long. However with LFS -enabled we can spare that cast. -The 32bit Architectures may explode here because the earlier 64bit off_t -consumes two argument slots and the filename (on which glibc uses -strlen()) becomes invalid. - -In brief: -ssize_t -> %zd -size_t -> %zu -off_t -> %llu (with LFS enabled) - -https://bugzilla.clamav.net/show_bug.cgi?id=11092 - -Patch-Name: fix-ssize_t-size_t-off_t-printf-modifier.patch -Signed-off-by: Sebastian Andrzej Siewior ---- - clamd/server-th.c | 1 + - libclamav/adc.c | 1 + - libclamav/asn1.c | 1 + - libclamav/bytecode.c | 4 ++-- - libclamav/bytecode_api.c | 2 +- - libclamav/hashtab.c | 1 + - libclamav/jsparse/js-norm.c | 1 + - libclamav/matcher.c | 1 + - libclamav/mbox.c | 1 + - libclamav/others.c | 1 + - libclamav/pdf.c | 22 ++++++++++++++-------- - libclamav/regex_list.c | 1 + - libclamav/scanners.c | 5 +++-- - shared/misc.h | 4 ++++ - sigtool/sigtool.c | 3 ++- - 15 files changed, 35 insertions(+), 14 deletions(-) - -diff --git a/clamd/server-th.c b/clamd/server-th.c -index 5fd73fd..bb3b10e 100644 ---- a/clamd/server-th.c -+++ b/clamd/server-th.c -@@ -60,6 +60,7 @@ - #include "libclamav/others.h" - #include "libclamav/readdb.h" - #include "libclamav/cltypes.h" -+#include "misc.h" - - #define BUFFSIZE 1024 - -diff --git a/libclamav/adc.c b/libclamav/adc.c -index 0b91057..e718df3 100644 ---- a/libclamav/adc.c -+++ b/libclamav/adc.c -@@ -29,6 +29,7 @@ - #include - #endif - -+#include "shared/misc.h" - #include "clamav.h" - #include "cltypes.h" - #include "others.h" -diff --git a/libclamav/asn1.c b/libclamav/asn1.c -index 3cdd955..2075633 100644 ---- a/libclamav/asn1.c -+++ b/libclamav/asn1.c -@@ -25,6 +25,7 @@ - - #include - -+#include "shared/misc.h" - #include "clamav.h" - #include "asn1.h" - #include "bignum.h" -diff --git a/libclamav/bytecode.c b/libclamav/bytecode.c -index 4a0c920..c2d4193 100644 ---- a/libclamav/bytecode.c -+++ b/libclamav/bytecode.c -@@ -1497,8 +1497,8 @@ void cli_sigperf_print() - cli_infomsg (NULL, "%-*s %*s %*s %*s %*s\n", max_name_len, "=============", - 8, "=====", 8, "========", 12, "===========", 9, "========="); - while (elem->run_count) { -- cli_infomsg (NULL, "%-*s %*lu %*lu %*llu %*.2f\n", max_name_len, elem->bc_name, -- 8, elem->run_count, 8, elem->match_count, -+ cli_infomsg (NULL, "%-*s %*lu %*lu %*" PRIu64 " %*.2f\n", max_name_len, -+ elem->bc_name, 8, elem->run_count, 8, elem->match_count, - 12, elem->usecs, 9, (double)elem->usecs/elem->run_count); - elem++; - } -diff --git a/libclamav/bytecode_api.c b/libclamav/bytecode_api.c -index 41d7cac..a33e6da 100644 ---- a/libclamav/bytecode_api.c -+++ b/libclamav/bytecode_api.c -@@ -123,7 +123,7 @@ int32_t cli_bcapi_seek(struct cli_bc_ctx* ctx, int32_t pos, uint32_t whence) - return -1; - } - if (off < 0 || off > ctx->file_size) { -- cli_dbgmsg("bcapi_seek: out of file: %ld (max %d)\n", -+ cli_dbgmsg("bcapi_seek: out of file: %" PRId64 " (max %d)\n", - off, ctx->file_size); - return -1; - } -diff --git a/libclamav/hashtab.c b/libclamav/hashtab.c -index 03db980..4801c4f 100644 ---- a/libclamav/hashtab.c -+++ b/libclamav/hashtab.c -@@ -26,6 +26,7 @@ - #include - #include - -+#include "shared/misc.h" - #include "cltypes.h" - #include "clamav.h" - #include "others.h" -diff --git a/libclamav/jsparse/js-norm.c b/libclamav/jsparse/js-norm.c -index 486dea2..0014090 100644 ---- a/libclamav/jsparse/js-norm.c -+++ b/libclamav/jsparse/js-norm.c -@@ -35,6 +35,7 @@ - #include - #include - -+#include "shared/misc.h" - #include "clamav.h" - #include "cltypes.h" - #include "jsparse/lexglobal.h" -diff --git a/libclamav/matcher.c b/libclamav/matcher.c -index 88d2f27..afcc3a5 100644 ---- a/libclamav/matcher.c -+++ b/libclamav/matcher.c -@@ -59,6 +59,7 @@ - #include "yara_clam.h" - #include "yara_exec.h" - #endif -+#include "shared/misc.h" - - #ifdef CLI_PERF_LOGGING - -diff --git a/libclamav/mbox.c b/libclamav/mbox.c -index 8319992..96bdbd2 100644 ---- a/libclamav/mbox.c -+++ b/libclamav/mbox.c -@@ -70,6 +70,7 @@ - #include "mbox.h" - #include "dconf.h" - #include "fmap.h" -+#include "shared/misc.h" - - #define DCONF_PHISHING mctx->ctx->dconf->phishing - -diff --git a/libclamav/others.c b/libclamav/others.c -index fd67a5d..5da0b05 100644 ---- a/libclamav/others.c -+++ b/libclamav/others.c -@@ -80,6 +80,7 @@ - #include "cache.h" - #include "readdb.h" - #include "stats.h" -+#include "shared/misc.h" - - int (*cli_unrar_open)(int fd, const char *dirname, unrar_state_t *state); - int (*cli_unrar_extract_next_prepare)(unrar_state_t *state, const char *dirname); -diff --git a/libclamav/pdf.c b/libclamav/pdf.c -index 3d95319..4f7139e 100644 ---- a/libclamav/pdf.c -+++ b/libclamav/pdf.c -@@ -61,6 +61,7 @@ - #include "textnorm.h" - #include "conv.h" - #include "json_api.h" -+#include "shared/misc.h" - - #ifdef CL_DEBUG - /*#define SAVE_TMP -@@ -1024,10 +1025,12 @@ int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj, uint32_t flags) - - orig_length = length; - if (length > pdf->size || obj->start + p_stream + length > pdf->size) { -- cli_dbgmsg("cli_pdf: length out of file: %ld + %ld > %ld\n", -- p_stream, length, pdf->size); -- noisy_warnmsg("length out of file, truncated: %ld + %ld > %ld\n", -- p_stream, length, pdf->size); -+ cli_dbgmsg("cli_pdf: length out of file: %" PRId64 " + %" -+ PRId64 " > % " PRId64 "\n", p_stream, -+ length, pdf->size); -+ noisy_warnmsg("length out of file, truncated: %" PRId64 -+ " + %" PRId64 " > %" PRId64 "\n", -+ p_stream, length, pdf->size); - length = pdf->size - (obj->start + p_stream); - } - -@@ -1049,7 +1052,8 @@ int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj, uint32_t flags) - if (length < 0) - length = 0; - -- cli_dbgmsg("cli_pdf: calculated length %ld\n", length); -+ cli_dbgmsg("cli_pdf: calculated length %" PRId64 "\n", -+ length); - } else { - if (size > (size_t)length+2) { - cli_dbgmsg("cli_pdf: calculated length %llu < %llu\n", -@@ -1246,7 +1250,7 @@ int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj, uint32_t flags) - } - } while (0); - -- cli_dbgmsg("cli_pdf: extracted %ld bytes %u %u obj\n", sum, obj->id>>8, obj->id&0xff); -+ cli_dbgmsg("cli_pdf: extracted %" PRId64 " bytes %u %u obj\n", sum, obj->id>>8, obj->id&0xff); - cli_dbgmsg(" ... to %s\n", fullname); - - if (flags & PDF_EXTRACT_OBJ_SCAN && sum) { -@@ -2500,7 +2504,8 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) - - if (pdfver != start || offset) { - pdf.flags |= 1 << BAD_PDF_HEADERPOS; -- cli_dbgmsg("cli_pdf: PDF header is not at position 0: %ld\n",pdfver-start+offset); -+ cli_dbgmsg("cli_pdf: PDF header is not at position 0: %" PRId64 "\n", -+ pdfver - start + offset); - #if HAVE_JSON - if (pdfobj) - cli_jsonbool(pdfobj, "BadVersionLocation", 1); -@@ -2609,7 +2614,8 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) - while ((rc = pdf_findobj(&pdf)) > 0) { - struct pdf_obj *obj = &pdf.objs[pdf.nobjs-1]; - -- cli_dbgmsg("cli_pdf: found %d %d obj @%ld\n", obj->id >> 8, obj->id&0xff, obj->start + offset); -+ cli_dbgmsg("cli_pdf: found %d %d obj @%" PRId64 "\n", obj->id >> 8, -+ obj->id & 0xff, obj->start + offset); - } - - if (pdf.nobjs) -diff --git a/libclamav/regex_list.c b/libclamav/regex_list.c -index d956c85..d644d3b 100644 ---- a/libclamav/regex_list.c -+++ b/libclamav/regex_list.c -@@ -42,6 +42,7 @@ - #include - - #include "regex/regex.h" -+#include "shared/misc.h" - - #include "clamav.h" - #include "others.h" -diff --git a/libclamav/scanners.c b/libclamav/scanners.c -index d78dfdd..ed0bbf0 100644 ---- a/libclamav/scanners.c -+++ b/libclamav/scanners.c -@@ -49,6 +49,7 @@ - #define DCONF_MAIL ctx->dconf->mail - #define DCONF_OTHER ctx->dconf->other - -+#include "shared/misc.h" - #include "clamav.h" - #include "others.h" - #include "dconf.h" -@@ -3472,8 +3473,8 @@ int cli_map_scandesc(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx, - - if (!length) length = old_len - offset; - if (length > old_len - offset) { -- cli_dbgmsg("Data truncated: %lu -> %lu\n", -- (unsigned long)length, old_len - offset); -+ cli_dbgmsg("Data truncated: %" _sizet" -> %" PRIu64" \n", length, -+ old_len - offset); - length = old_len - offset; - } - -diff --git a/shared/misc.h b/shared/misc.h -index 84c288a..88e533b 100644 ---- a/shared/misc.h -+++ b/shared/misc.h -@@ -52,6 +52,10 @@ - #define PATH_MAX 1024 - #endif - -+#include -+#define _sizet "zu" -+#define _ssizet "zd" -+ - char *freshdbdir(void); - void print_version(const char *dbdir); - int check_flevel(void); -diff --git a/sigtool/sigtool.c b/sigtool/sigtool.c -index 76cbef5..9cbd044 100644 ---- a/sigtool/sigtool.c -+++ b/sigtool/sigtool.c -@@ -450,7 +450,8 @@ static char *getdsig(const char *host, const char *user, const unsigned char *da - closesocket(sockd); - return NULL; - } else { -- mprintf("Signature received (length = %lu)\n", (unsigned long)strlen(buff) - 10); -+ mprintf("Signature received (length = %" _sizet ")\n", -+ strlen(buff) - 10); - } - } else { - mprintf("!getdsig: Communication error with remote server\n"); diff -Nru clamav-0.99.2+dfsg/debian/patches/libclamav-use-libmspack.patch clamav-0.99.3~beta1+dfsg/debian/patches/libclamav-use-libmspack.patch --- clamav-0.99.2+dfsg/debian/patches/libclamav-use-libmspack.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/libclamav-use-libmspack.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,4046 +0,0 @@ -From 0202c98369a712b038ca5b5e464b8a1198fea7d0 Mon Sep 17 00:00:00 2001 -From: Sebastian Andrzej Siewior -Date: Wed, 30 Jul 2014 08:35:16 +0200 -Subject: libclamav: use libmspack - -This patch provides support for upstream / external libmspack version -libmspack 0.4 (current). The old in-tree version of libmspack is removed -while no loner used. - -BTS: #675558 -clamav: https://bugzilla.clamav.net/show_bug.cgi?id=11062 - -Patch-Name: libclamav-use-libmspack.patch -Signed-off-by: Sebastian Andrzej Siewior ---- - configure.ac | 3 + - libclamav/Makefile.am | 11 +- - libclamav/cab.c | 685 ----------------- - libclamav/cab.h | 82 -- - libclamav/chmunpack.h | 123 --- - libclamav/libmspack.c | 525 +++++++++++++ - libclamav/libmspack.h | 7 + - libclamav/mspack.c | 2026 ------------------------------------------------- - libclamav/mspack.h | 294 ------- - libclamav/scanners.c | 146 +--- - 10 files changed, 541 insertions(+), 3361 deletions(-) - delete mode 100644 libclamav/cab.c - delete mode 100644 libclamav/cab.h - delete mode 100644 libclamav/chmunpack.h - create mode 100644 libclamav/libmspack.c - create mode 100644 libclamav/libmspack.h - delete mode 100644 libclamav/mspack.c - delete mode 100644 libclamav/mspack.h - -diff --git a/configure.ac b/configure.ac -index 6d7d666..289a0b9 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -190,6 +190,9 @@ AM_CONDITIONAL([ENABLE_LLVM], - [test "$subdirfailed" != "yes" && test "$enable_llvm" != "no"]) - AM_CONDITIONAL([ENABLE_YARA], - [test "$enable_yara" != "no"]) -+ -+PKG_CHECK_MODULES([LIBMSPACK], [libmspack]) -+ - no_recursion="yes"; - - AC_OUTPUT([libclamav/Makefile]) -diff --git a/libclamav/Makefile.am b/libclamav/Makefile.am -index 0a6d2ad..f56fc46 100644 ---- a/libclamav/Makefile.am -+++ b/libclamav/Makefile.am -@@ -154,6 +154,9 @@ if VERSIONSCRIPT - libclamav_la_LDFLAGS += -Wl,@VERSIONSCRIPTFLAG@,@top_srcdir@/libclamav/libclamav.map - endif - -+libclamav_la_CFLAGS += $(LIBMSPACK_CFLAGS) -+libclamav_la_LDFLAGS += $(LIBMSPACK_LIBS) -+ - include_HEADERS = clamav.h - - libclamav_la_SOURCES = \ -@@ -211,8 +214,8 @@ libclamav_la_SOURCES = \ - upx.h \ - htmlnorm.c \ - htmlnorm.h \ -- chmunpack.c \ -- chmunpack.h \ -+ libmspack.c \ -+ libmspack.h \ - rebuildpe.c \ - rebuildpe.h \ - petite.c \ -@@ -290,10 +293,6 @@ libclamav_la_SOURCES = \ - regex_list.h \ - regex_suffix.c \ - regex_suffix.h \ -- mspack.c \ -- mspack.h \ -- cab.c \ -- cab.h \ - entconv.c \ - entconv.h \ - entitylist.h \ -diff --git a/libclamav/cab.c b/libclamav/cab.c -deleted file mode 100644 -index b0bd428..0000000 ---- a/libclamav/cab.c -+++ /dev/null -@@ -1,685 +0,0 @@ --/* -- * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. -- * Copyright (C) 2007-2008 Sourcefire, Inc. -- * -- * Authors: Tomasz Kojm -- * -- * This program is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License version 2 as -- * published by the Free Software Foundation. -- * -- * This program is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU 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., 51 Franklin Street, Fifth Floor, Boston, -- * MA 02110-1301, USA. -- */ -- --#if HAVE_CONFIG_H --#include "clamav-config.h" --#endif -- --#include --#include --#include --#include --#include --#ifdef HAVE_UNISTD_H --#include --#endif --#include -- --#include "clamav.h" --#include "cltypes.h" --#include "others.h" --#include "mspack.h" --#include "cab.h" -- --#define EC32(x) cli_readint32(&x) /* Convert little endian to host */ --#define EC16(x) cli_readint16(&x) -- --/* hard limits */ --#define CAB_FOLDER_LIMIT 5000 --#define CAB_FILE_LIMIT 5000 -- --/* Cabinet format data structures */ -- --struct cab_hdr { -- uint32_t signature; /* file signature */ -- uint32_t res1; /* reserved */ -- uint32_t cbCabinet; /* size of cabinet file */ -- uint32_t res2; /* reserved */ -- uint32_t coffFiles; /* offset of the first file entry */ -- uint32_t res3; /* reserved */ -- uint8_t versionMinor; /* file format version, minor */ -- uint8_t versionMajor; /* file format version, major */ -- uint16_t cFolders; /* number of folder entries */ -- uint16_t cFiles; /* number of file entries */ -- uint16_t flags; /* option flags */ -- uint16_t setID; /* multiple cabs related */ -- uint16_t iCabinet; /* multiple cabs related */ --}; -- --struct cab_hdr_opt { -- uint16_t cbCFHeader; /* size of reserved header area */ -- uint8_t cbCFFolder; /* size of reserved folder area */ -- uint8_t cbCFData; /* size of reserved block area */ --}; -- --struct cab_folder_hdr --{ -- uint32_t coffCabStart; /* offset of the first data block */ -- uint16_t cCFData; /* number of data blocks */ -- uint16_t typeCompress; /* compression type */ --}; -- --struct cab_file_hdr --{ -- uint32_t cbFile; /* uncompressed size */ -- uint32_t uoffFolderStart; /* uncompressed offset of file in folder */ -- uint16_t iFolder; /* folder index */ -- uint16_t date; /* date stamp */ -- uint16_t time; /* time stamp */ -- uint16_t attribs; /* attribute flags */ --}; -- --struct cab_block_hdr --{ -- uint32_t csum; /* data block checksum */ -- uint16_t cbData; /* number of compressed bytes */ -- uint16_t cbUncomp; /* number of uncompressed bytes */ --}; -- --static char *cab_readstr(fmap_t *map, off_t *offset, int *ret) --{ -- int i; -- const char *str; -- char *retstr; -- -- if(!(str = fmap_need_offstr(map, *offset, 256))) { -- *ret = CL_EFORMAT; -- return NULL; -- } -- -- i = strlen(str) + 1; -- if(i>=255) { -- fmap_unneed_ptr(map, str, i); -- *ret = CL_EFORMAT; -- return NULL; -- } -- -- *offset += i; -- if((retstr = cli_malloc(i))) -- memcpy(retstr, str, i); -- fmap_unneed_ptr(map, str, i); -- -- if(!retstr) { -- *ret = CL_EMEM; -- return NULL; -- } -- -- *ret = CL_SUCCESS; -- return retstr; --} -- --static int cab_chkname(char *name, int san) --{ -- size_t i, len = strlen(name); -- -- -- for(i = 0; i < len; i++) { -- if(!san && (strchr("%/*?|\\\"+=<>;:\t ", name[i]) || !isascii(name[i]))) { -- cli_dbgmsg("cab_chkname: File name contains disallowed characters\n"); -- return 1; -- } else if(san && !isalnum(name[i])) { -- name[i] = '*'; -- } -- } -- -- return 0; --} -- --void cab_free(struct cab_archive *cab) --{ -- struct cab_folder *folder; -- struct cab_file *file; -- -- -- if(cab->state) { -- if(cab->state->stream) { -- switch(cab->state->cmethod & 0x000f) { -- case 0x0001: -- mszip_free(cab->state->stream); -- break; -- case 0x0002: -- qtm_free(cab->state->stream); -- break; -- case 0x0003: -- lzx_free(cab->state->stream); -- } -- } -- free(cab->state); -- } -- -- while(cab->folders) { -- folder = cab->folders; -- cab->folders = cab->folders->next; -- free(folder); -- } -- -- while(cab->files) { -- file = cab->files; -- cab->files = cab->files->next; -- free(file->name); -- free(file); -- } --} -- --int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab) --{ -- unsigned int i, folders = 0; -- struct cab_file *file, *lfile = NULL; -- struct cab_folder *folder, *lfolder = NULL; -- const struct cab_hdr *hdr; -- const struct cab_hdr_opt *hdr_opt; -- uint16_t fidx; -- uint32_t coffFiles; -- char *pt; -- int ret; -- off_t resfold = 0, rsize, cur_offset = offset; -- -- if(!(hdr=fmap_need_off_once(map, cur_offset, sizeof(*hdr)))) { -- cli_dbgmsg("cab_open: Can't read cabinet header\n"); -- return CL_EFORMAT; /* most likely a corrupted file */ -- } -- cur_offset += sizeof(*hdr); -- -- if(EC32(hdr->signature) != 0x4643534d) { -- cli_dbgmsg("cab_open: Incorrect CAB signature\n"); -- return CL_EFORMAT; -- } else { -- cli_dbgmsg("CAB: -------------- Cabinet file ----------------\n"); -- } -- -- rsize = map->len; -- -- memset(cab, 0, sizeof(struct cab_archive)); -- -- cab->length = EC32(hdr->cbCabinet); -- cli_dbgmsg("CAB: Cabinet length: %u\n", cab->length); -- if((off_t) cab->length > rsize) { -- cli_dbgmsg("CAB: Truncating file size from %lu to %lu\n", (unsigned long int) cab->length, (unsigned long int) rsize); -- cab->length = (uint32_t) rsize; -- } -- -- cab->nfolders = EC16(hdr->cFolders); -- if(!cab->nfolders) { -- cli_dbgmsg("cab_open: No folders in cabinet (fake cab?)\n"); -- return CL_EFORMAT; -- } else { -- cli_dbgmsg("CAB: Folders: %u\n", cab->nfolders); -- if(cab->nfolders > CAB_FOLDER_LIMIT) { -- cab->nfolders = CAB_FOLDER_LIMIT; -- cli_dbgmsg("CAB: *** Number of folders limited to %u ***\n", cab->nfolders); -- } -- } -- -- cab->nfiles = EC16(hdr->cFiles); -- if(!cab->nfiles) { -- cli_dbgmsg("cab_open: No files in cabinet (fake cab?)\n"); -- return CL_EFORMAT; -- } else { -- cli_dbgmsg("CAB: Files: %u\n", cab->nfiles); -- if(cab->nfiles > CAB_FILE_LIMIT) { -- cab->nfiles = CAB_FILE_LIMIT; -- cli_dbgmsg("CAB: *** Number of files limited to %u ***\n", cab->nfiles); -- } -- } -- -- cli_dbgmsg("CAB: File format version: %u.%u\n", hdr->versionMajor, hdr->versionMinor); -- -- cab->flags = EC16(hdr->flags); -- coffFiles = EC16(hdr->coffFiles); -- -- if(cab->flags & 0x0004) { -- if(!(hdr_opt = fmap_need_off_once(map, cur_offset, sizeof(*hdr_opt)))) { -- cli_dbgmsg("cab_open: Can't read file header (fake cab?)\n"); -- return CL_EFORMAT; /* most likely a corrupted file */ -- } -- -- cab->reshdr = EC16(hdr_opt->cbCFHeader); -- resfold = hdr_opt->cbCFFolder; -- cab->resdata = hdr_opt->cbCFData; -- -- cur_offset += sizeof(*hdr_opt) + cab->reshdr; -- if(cab->reshdr) { -- if(cab->reshdr >= rsize) { -- cli_dbgmsg("cab_open: Can't lseek to %u (fake cab?)\n", cab->reshdr); -- return CL_EFORMAT; /* most likely a corrupted file */ -- } -- } -- } -- -- if(cab->flags & 0x0001) { /* preceding cabinet */ -- /* name */ -- pt = cab_readstr(map, &cur_offset, &ret); -- if(ret) -- return ret; -- if(cab_chkname(pt, 0)) -- cli_dbgmsg("CAB: Invalid name of preceding cabinet\n"); -- else -- cli_dbgmsg("CAB: Preceding cabinet name: %s\n", pt); -- free(pt); -- /* info */ -- pt = cab_readstr(map, &cur_offset, &ret); -- if(ret) -- return ret; -- if(cab_chkname(pt, 0)) -- cli_dbgmsg("CAB: Invalid info for preceding cabinet\n"); -- else -- cli_dbgmsg("CAB: Preceding cabinet info: %s\n", pt); -- free(pt); -- } -- -- if(cab->flags & 0x0002) { /* next cabinet */ -- /* name */ -- pt = cab_readstr(map, &cur_offset, &ret); -- if(ret) -- return ret; -- if(cab_chkname(pt, 0)) -- cli_dbgmsg("CAB: Invalid name of next cabinet\n"); -- else -- cli_dbgmsg("CAB: Next cabinet name: %s\n", pt); -- free(pt); -- /* info */ -- pt = cab_readstr(map, &cur_offset, &ret); -- if(ret) -- return ret; -- if(cab_chkname(pt, 0)) -- cli_dbgmsg("CAB: Invalid info for next cabinet\n"); -- else -- cli_dbgmsg("CAB: Next cabinet info: %s\n", pt); -- free(pt); -- } -- -- /* folders */ -- for(i = 0; i < cab->nfolders; i++) { -- const struct cab_folder_hdr *folder_hdr; -- -- if(!(folder_hdr = fmap_need_off_once(map, cur_offset, sizeof(*folder_hdr)))) { -- cli_dbgmsg("cab_open: Can't read header for folder %u\n", i); -- break; -- } -- -- cur_offset += sizeof(*folder_hdr) + resfold; -- -- if(EC32(folder_hdr->coffCabStart) + offset > rsize) { -- cli_dbgmsg("CAB: Folder out of file\n"); -- continue; -- } -- -- if((EC16(folder_hdr->typeCompress) & 0x000f) > 3) { -- cli_dbgmsg("CAB: Unknown compression method\n"); -- continue; -- } -- -- folder = (struct cab_folder *) cli_calloc(1, sizeof(struct cab_folder)); -- if(!folder) { -- cli_errmsg("cab_open: Can't allocate memory for folder\n"); -- cab_free(cab); -- return CL_EMEM; -- } -- -- folder->cab = (struct cab_archive *) cab; -- folder->offset = (off_t) EC32(folder_hdr->coffCabStart) + offset; -- folder->nblocks = EC16(folder_hdr->cCFData); -- folder->cmethod = EC16(folder_hdr->typeCompress); -- -- cli_dbgmsg("CAB: Folder record %u\n", i); -- cli_dbgmsg("CAB: Folder offset: %u\n", (unsigned int) folder->offset); -- cli_dbgmsg("CAB: Folder compression method: %d\n", folder->cmethod); -- -- if(!lfolder) -- cab->folders = folder; -- else -- lfolder->next = folder; -- -- lfolder = folder; -- folders++; -- } -- cli_dbgmsg("CAB: Recorded folders: %u\n", folders); -- -- /* files */ -- if(cab->nfolders != folders) { -- if(coffFiles >= rsize) { -- cli_dbgmsg("cab_open: Can't lseek to hdr.coffFiles\n"); -- cab_free(cab); -- return CL_EFORMAT; -- } -- cur_offset = coffFiles; -- } -- for(i = 0; i < cab->nfiles; i++) { -- const struct cab_file_hdr *file_hdr; -- -- if(!(file_hdr = fmap_need_off_once(map, cur_offset, sizeof(*file_hdr)))) { -- cli_dbgmsg("cab_open: Can't read file %u header\n", i); -- break; -- } -- cur_offset += sizeof(*file_hdr); -- -- file = (struct cab_file *) cli_calloc(1, sizeof(struct cab_file)); -- if(!file) { -- cli_errmsg("cab_open: Can't allocate memory for file\n"); -- cab_free(cab); -- return CL_EMEM; -- } -- -- file->cab = cab; -- cab->map = map; -- file->offset = EC32(file_hdr->uoffFolderStart); -- file->length = EC32(file_hdr->cbFile); -- file->attribs = EC16(file_hdr->attribs); -- fidx = EC16(file_hdr->iFolder); -- file->error = CL_SUCCESS; -- -- file->name = cab_readstr(map, &cur_offset, &ret); -- if(ret) { -- free(file); -- continue; -- } -- cab_chkname(file->name, 1); -- -- cli_dbgmsg("CAB: File record %u\n", i); -- cli_dbgmsg("CAB: File name: %s\n", file->name); -- cli_dbgmsg("CAB: File offset: %u\n", (unsigned int) file->offset); -- cli_dbgmsg("CAB: File folder index: %u\n", fidx); -- cli_dbgmsg("CAB: File attribs: 0x%x\n", file->attribs); -- if(file->attribs & 0x01) -- cli_dbgmsg("CAB: * file is read-only\n"); -- if(file->attribs & 0x02) -- cli_dbgmsg("CAB: * file is hidden\n"); -- if(file->attribs & 0x04) -- cli_dbgmsg("CAB: * file is a system file\n"); -- if(file->attribs & 0x20) -- cli_dbgmsg("CAB: * file modified since last backup\n"); -- if(file->attribs & 0x40) -- cli_dbgmsg("CAB: * file to be run after extraction\n"); -- if(file->attribs & 0x80) -- cli_dbgmsg("CAB: * file name contains UTF\n"); -- -- /* folder index */ -- if(fidx < 0xfffd) { -- if(fidx > cab->nfolders) { -- cli_dbgmsg("cab_open: File %s is not associated with any folder\n", file->name); -- free(file->name); -- free(file); -- continue; -- } -- -- file->folder = cab->folders; -- while(file->folder && fidx--) -- file->folder = file->folder->next; -- -- if(!file->folder) { -- cli_dbgmsg("cab_open: Folder not found for file %s\n", file->name); -- free(file->name); -- free(file); -- continue; -- } -- -- } else { -- cli_dbgmsg("CAB: File is split *skipping*\n"); -- free(file->name); -- free(file); -- continue; -- } -- -- if(!lfile) -- cab->files = file; -- else -- lfile->next = file; -- -- lfile = file; -- -- } -- -- return CL_SUCCESS; --} -- --static int cab_read_block(struct cab_file *file) --{ -- const struct cab_block_hdr *block_hdr; -- struct cab_state *state = file->cab->state; -- -- if(!(block_hdr = fmap_need_off_once(file->cab->map, file->cab->cur_offset, sizeof(*block_hdr)))) { -- cli_dbgmsg("cab_read_block: Can't read block header\n"); -- return CL_EFORMAT; /* most likely a corrupted file */ -- } -- -- file->cab->cur_offset += sizeof(*block_hdr) + file->cab->resdata; -- state->blklen = EC16(block_hdr->cbData); -- state->outlen = EC16(block_hdr->cbUncomp); -- -- if(fmap_readn(file->cab->map, state->block, file->cab->cur_offset, state->blklen) != state->blklen) { -- cli_dbgmsg("cab_read_block: Can't read block data\n"); -- return CL_EFORMAT; /* most likely a corrupted file */ -- } -- -- file->cab->cur_offset += state->blklen; -- state->pt = state->end = state->block; -- state->end += state->blklen; -- -- return CL_SUCCESS; --} -- --static int cab_read(struct cab_file *file, unsigned char *buffer, int bytes) --{ -- uint16_t todo, left; -- -- -- if((file->cab->state->blknum > file->folder->nblocks) && !file->lread) { -- file->error = CL_BREAK; -- return -1; -- } -- -- todo = bytes; -- while(todo > 0) { -- left = file->cab->state->end - file->cab->state->pt; -- -- if(left) { -- if(left > todo) -- left = todo; -- -- memcpy(buffer, file->cab->state->pt, left); -- file->cab->state->pt += left; -- buffer += left; -- todo -= left; -- -- } else { -- if(file->cab->state->blknum++ >= file->folder->nblocks) -- break; -- -- file->error = cab_read_block(file); -- if(file->error) -- return -1; -- -- if((file->folder->cmethod & 0x000f) == 0x0002) /* Quantum hack */ -- *file->cab->state->end++ = 0xff; -- -- if(file->cab->state->blknum >= file->folder->nblocks) { -- if((file->folder->cmethod & 0x000f) == 0x0003) { /* LZX hack */ -- lzx_set_output_length(file->cab->state->stream, (off_t) ((file->cab->state->blknum - 1) * 32768 + file->cab->state->outlen)); -- } -- } else { -- if(file->cab->state->outlen != 32768) { -- cli_dbgmsg("cab_read: WARNING: partial data block\n"); -- } -- } -- } -- } -- -- return file->lread = bytes - todo; --} -- --static int cab_unstore(struct cab_file *file) --{ -- int todo, bread, bytes = file->length; -- unsigned char buff[4096]; -- -- -- if(bytes < 0) { -- cli_dbgmsg("cab_unstore: bytes < 0\n"); -- return CL_EFORMAT; -- } -- -- todo = MIN((unsigned int) bytes, file->max_size); -- -- while(1) { -- -- if((unsigned int) todo <= sizeof(buff)) -- bread = todo; -- else -- bread = sizeof(buff); -- -- if((bread = cab_read(file, buff, bread)) == -1) { -- cli_dbgmsg("cab_unstore: cab_read failed\n"); -- return file->error; -- } else if(cli_writen(file->ofd, buff, bread) != bread) { -- cli_warnmsg("cab_unstore: Can't write %d bytes to descriptor %d\n", bread, file->ofd); -- return CL_EWRITE; -- } -- -- todo -= bread; -- -- if(!bread || todo <= 0) -- break; -- } -- -- return CL_SUCCESS; --} -- --#define CAB_CHGFOLDER \ -- if(!file->cab->actfol || (file->folder != file->cab->actfol) \ -- || (file->cab->state && file->cab->state->cmethod != file->folder->cmethod)) { \ -- if(file->cab->state) { \ -- if(file->cab->state->stream) { \ -- switch(file->cab->state->cmethod & 0x000f) { \ -- case 0x0001: \ -- mszip_free(file->cab->state->stream); \ -- break; \ -- case 0x0002: \ -- qtm_free(file->cab->state->stream); \ -- break; \ -- case 0x0003: \ -- lzx_free(file->cab->state->stream); \ -- } \ -- } \ -- free(file->cab->state); \ -- file->cab->state = NULL; \ -- } \ -- file->cab->cur_offset = file->folder->offset; \ -- file->cab->state = (struct cab_state *) cli_calloc(1, sizeof(struct cab_state)); \ -- if(!file->cab->state) { \ -- cli_errmsg("cab_extract: Can't allocate memory for internal state\n"); \ -- close(file->ofd); \ -- return CL_EMEM; \ -- } \ -- file->cab->state->cmethod = file->folder->cmethod; \ -- switch(file->folder->cmethod & 0x000f) { \ -- case 0x0001: \ -- file->cab->state->stream = (struct mszip_stream *) mszip_init(file->ofd, 4096, 1, file, &cab_read); \ -- break; \ -- case 0x0002: \ -- file->cab->state->stream = (struct qtm_stream *) qtm_init(file->ofd, (int) (file->folder->cmethod >> 8) & 0x1f, 4096, file, &cab_read); \ -- break; \ -- case 0x0003: \ -- file->cab->state->stream = (struct lzx_stream *) lzx_init(file->ofd, (int) (file->folder->cmethod >> 8) & 0x1f, 0, 4096, 0, file, &cab_read); \ -- } \ -- if((file->folder->cmethod & 0x000f) && !file->cab->state->stream) { \ -- close(file->ofd); \ -- return CL_EUNPACK; \ -- } \ -- file->cab->actfol = file->folder; \ -- } else { \ -- if(file->cab->state && file->cab->state->stream) { \ -- switch(file->cab->state->cmethod & 0x000f) { \ -- case 0x0001: \ -- ((struct mszip_stream *) file->cab->state->stream)->ofd = file->ofd; \ -- break; \ -- case 0x0002: \ -- ((struct qtm_stream *) file->cab->state->stream)->ofd = file->ofd; \ -- break; \ -- case 0x0003: \ -- ((struct lzx_stream *) file->cab->state->stream)->ofd = file->ofd; \ -- break; \ -- } \ -- } \ -- } -- -- --int cab_extract(struct cab_file *file, const char *name) --{ -- int ret; -- -- -- if(!file || !name) { -- cli_errmsg("cab_extract: !file || !name\n"); -- return CL_ENULLARG; -- } -- -- if(!file->folder) { -- cli_errmsg("cab_extract: file->folder == NULL\n"); -- return CL_ENULLARG; -- } -- -- file->ofd = open(name, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU); -- if(file->ofd == -1) { -- cli_errmsg("cab_extract: Can't open file %s in write mode\n", name); -- return CL_ECREAT; -- } -- -- switch(file->folder->cmethod & 0x000f) { -- case 0x0000: /* STORE */ -- cli_dbgmsg("CAB: Compression method: STORED\n"); -- CAB_CHGFOLDER; -- if(file->length > file->cab->length) { -- cli_dbgmsg("cab_extract: Stored file larger than archive itself, trimming down\n"); -- file->length = file->cab->length; -- } -- ret = cab_unstore(file); -- break; -- -- case 0x0001: /* MSZIP */ -- cli_dbgmsg("CAB: Compression method: MSZIP\n"); -- CAB_CHGFOLDER; -- ret = mszip_decompress(file->cab->state->stream, file->length); -- break; -- -- case 0x0002: /* QUANTUM */ -- cli_dbgmsg("CAB: Compression method: QUANTUM\n"); -- CAB_CHGFOLDER; -- ret = qtm_decompress(file->cab->state->stream, file->length); -- break; -- -- case 0x0003: /* LZX */ -- cli_dbgmsg("CAB: Compression method: LZX\n"); -- CAB_CHGFOLDER; -- ret = lzx_decompress(file->cab->state->stream, file->length); -- break; -- -- default: -- cli_dbgmsg("CAB: Not supported compression method: 0x%x\n", file->folder->cmethod & 0x000f); -- ret = CL_EFORMAT; -- } -- -- close(file->ofd); -- -- if(ret == CL_BREAK) -- ret = CL_SUCCESS; -- -- return ret; --} -diff --git a/libclamav/cab.h b/libclamav/cab.h -deleted file mode 100644 -index e2459b3..0000000 ---- a/libclamav/cab.h -+++ /dev/null -@@ -1,82 +0,0 @@ --/* -- * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. -- * Copyright (C) 2007-2008 Sourcefire, Inc. -- * -- * Authors: Tomasz Kojm -- * -- * This program is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License version 2 as -- * published by the Free Software Foundation. -- * -- * This program is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU 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., 51 Franklin Street, Fifth Floor, Boston, -- * MA 02110-1301, USA. -- */ -- --#ifndef __CAB_H --#define __CAB_H -- --#include --#include "cltypes.h" --#include "fmap.h" -- --#define CAB_BLOCKMAX 65535 --#define CAB_INPUTMAX (CAB_BLOCKMAX + 6144) -- --struct cab_archive { -- struct cab_folder *folders, *actfol; -- struct cab_file *files; -- struct cab_state *state; -- fmap_t *map; -- off_t cur_offset; -- uint32_t length; -- uint16_t nfolders; -- uint16_t nfiles; -- uint16_t flags; -- uint16_t reshdr; -- uint8_t resdata; --}; -- --struct cab_state { -- unsigned char *pt, *end; -- void *stream; -- unsigned char block[CAB_INPUTMAX]; -- uint16_t blklen; -- uint16_t outlen; -- uint16_t blknum; -- uint16_t cmethod; --}; -- --struct cab_file { -- off_t offset; -- char *name; -- uint32_t length; -- int error; -- int lread; -- int ofd; -- struct cab_folder *folder; -- struct cab_file *next; -- struct cab_archive *cab; -- uint16_t attribs; -- uint64_t max_size, written_size; --}; -- --struct cab_folder { -- struct cab_archive *cab; -- off_t offset; -- struct cab_folder *next; -- uint16_t cmethod; -- uint16_t nblocks; --}; -- --int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab); --int cab_extract(struct cab_file *file, const char *name); --void cab_free(struct cab_archive *cab); -- --#endif -diff --git a/libclamav/chmunpack.h b/libclamav/chmunpack.h -deleted file mode 100644 -index d075a39..0000000 ---- a/libclamav/chmunpack.h -+++ /dev/null -@@ -1,123 +0,0 @@ --/* -- * Extract component parts of MS CHM files -- * -- * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. -- * Copyright (C) 2007-2008 Sourcefire, Inc. -- * -- * Authors: Trog -- * -- * This program is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License version 2 as -- * published by the Free Software Foundation. -- * -- * This program is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU 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., 51 Franklin Street, Fifth Floor, Boston, -- * MA 02110-1301, USA. -- */ -- --#ifndef __CHM_UNPACK_H --#define __CHM_UNPACK_H -- --#if HAVE_CONFIG_H --#include "clamav-config.h" --#endif -- --#include "cltypes.h" --#include "others.h" --#include "fmap.h" -- --#ifndef HAVE_ATTRIB_PACKED --#define __attribute__(x) --#endif -- --#ifdef HAVE_PRAGMA_PACK --#pragma pack(1) --#endif -- --#ifdef HAVE_PRAGMA_PACK_HPPA --#pragma pack 1 --#endif -- --#define CHM_ITSF_MIN_LEN (0x60) --typedef struct chm_itsf_header_tag --{ -- unsigned char signature[4]; -- int32_t version __attribute__ ((packed)); -- int32_t header_len __attribute__ ((packed)); -- uint32_t unknown __attribute__ ((packed)); -- uint32_t last_modified __attribute__ ((packed)); -- uint32_t lang_id __attribute__ ((packed)); -- unsigned char dir_clsid[16]; -- unsigned char stream_clsid[16]; -- uint64_t sec0_offset __attribute__ ((packed)); -- uint64_t sec0_len __attribute__ ((packed)); -- uint64_t dir_offset __attribute__ ((packed)); -- uint64_t dir_len __attribute__ ((packed)); -- uint64_t data_offset __attribute__ ((packed)); --} chm_itsf_header_t; -- --#define CHM_ITSP_LEN (0x54) --typedef struct chm_itsp_header_tag --{ -- unsigned char signature[4]; -- int32_t version __attribute__ ((packed)); -- int32_t header_len __attribute__ ((packed)); -- int32_t unknown1 __attribute__ ((packed)); -- uint32_t block_len __attribute__ ((packed)); -- int32_t blockidx_intvl __attribute__ ((packed)); -- int32_t index_depth __attribute__ ((packed)); -- int32_t index_root __attribute__ ((packed)); -- int32_t index_head __attribute__ ((packed)); -- int32_t index_tail __attribute__ ((packed)); -- int32_t unknown2 __attribute__ ((packed)); -- uint32_t num_blocks __attribute__ ((packed)); -- uint32_t lang_id __attribute__ ((packed)); -- unsigned char system_clsid[16]; -- unsigned char unknown4[16]; --} chm_itsp_header_t; -- --#ifdef HAVE_PRAGMA_PACK --#pragma pack() --#endif -- --#ifdef HAVE_PRAGMA_PACK_HPPA --#pragma pack --#endif -- --typedef struct chm_sys_entry_tag --{ -- uint64_t offset; -- uint64_t length; --} chm_sys_entry_t; -- --typedef struct chm_metadata_tag { -- uint64_t file_length; -- uint64_t file_offset; -- chm_sys_entry_t sys_control; -- chm_sys_entry_t sys_content; -- chm_sys_entry_t sys_reset; -- off_t m_length; -- chm_itsf_header_t itsf_hdr; -- chm_itsp_header_t itsp_hdr; -- int ufd; -- int ofd; -- uint32_t num_chunks; -- off_t chunk_offset; -- const char *chunk_data; -- const char *chunk_current; -- const char *chunk_end; -- fmap_t *map; -- uint16_t chunk_entries; --} chm_metadata_t; -- --int cli_chm_open(const char *dirname, chm_metadata_t *metadata, cli_ctx *ctx); --int cli_chm_prepare_file(chm_metadata_t *metadata); --int cli_chm_extract_file(char *dirname, chm_metadata_t *metadata, cli_ctx *ctx); --void cli_chm_close(chm_metadata_t *metadata); --#endif -diff --git a/libclamav/libmspack.c b/libclamav/libmspack.c -new file mode 100644 -index 0000000..788ece0 ---- /dev/null -+++ b/libclamav/libmspack.c -@@ -0,0 +1,525 @@ -+/* -+ * Glue code for libmspack handling. -+ * Author: 웃 Sebastian Andrzej Siewior -+ * ✉ sebastian @ breakpoint ̣cc -+ */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+ -+#include "clamav.h" -+#include "fmap.h" -+#include "scanners.h" -+#include "others.h" -+ -+enum mspack_type { -+ FILETYPE_DUNNO, -+ FILETYPE_FMAP, -+ FILETYPE_FILENAME, -+}; -+ -+struct mspack_name { -+ fmap_t *fmap; -+ off_t org; -+}; -+ -+struct mspack_system_ex { -+ struct mspack_system ops; -+ off_t max_size; -+}; -+ -+struct mspack_handle { -+ enum mspack_type type; -+ -+ fmap_t *fmap; -+ off_t org; -+ off_t offset; -+ -+ FILE *f; -+ off_t max_size; -+}; -+ -+#define container_of(ptr, type, member) ({ \ -+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ -+ (type *)( (char *)__mptr - offsetof(type,member) );}) -+ -+#define min_t(type, x, y) ({ \ -+ type __min1 = (x); \ -+ type __min2 = (y); \ -+ __min1 < __min2 ? __min1: __min2; }) -+ -+static struct mspack_file *mspack_fmap_open(struct mspack_system *self, -+ const char *filename, int mode) -+{ -+ struct mspack_name *mspack_name; -+ struct mspack_handle *mspack_handle; -+ struct mspack_system_ex *self_ex; -+ const char *fmode; -+ -+ if (!filename) { -+ cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); -+ return NULL; -+ } -+ mspack_handle = malloc(sizeof(*mspack_handle)); -+ if (!mspack_handle) { -+ cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); -+ return NULL; -+ } -+ switch (mode) { -+ case MSPACK_SYS_OPEN_READ: -+ mspack_handle->type = FILETYPE_FMAP; -+ -+ mspack_name = (struct mspack_name *)filename; -+ mspack_handle->fmap = mspack_name->fmap; -+ mspack_handle->org = mspack_name->org; -+ mspack_handle->offset = 0; -+ -+ return (struct mspack_file *)mspack_handle; -+ -+ case MSPACK_SYS_OPEN_WRITE: -+ fmode = "wb"; -+ break; -+ case MSPACK_SYS_OPEN_UPDATE: -+ fmode = "r+b"; -+ break; -+ case MSPACK_SYS_OPEN_APPEND: -+ fmode = "ab"; -+ break; -+ default: -+ cli_dbgmsg("%s() wrong mode\n", __func__); -+ goto out_err; -+ } -+ -+ mspack_handle->type = FILETYPE_FILENAME; -+ -+ mspack_handle->f = fopen(filename, fmode); -+ if (!mspack_handle->f) { -+ cli_dbgmsg("%s() failed %d\n", __func__, __LINE__); -+ goto out_err; -+ } -+ self_ex = container_of(self, struct mspack_system_ex, ops); -+ mspack_handle->max_size = self_ex->max_size; -+ return (struct mspack_file *)mspack_handle; -+ -+out_err: -+ free(mspack_handle); -+ return NULL; -+} -+ -+static void mspack_fmap_close(struct mspack_file *file) -+{ -+ struct mspack_handle *mspack_handle = (struct mspack_handle *)file; -+ -+ if (!mspack_handle) -+ return; -+ -+ if (mspack_handle->type == FILETYPE_FILENAME) -+ fclose(mspack_handle->f); -+ free(mspack_handle); -+} -+ -+static int mspack_fmap_read(struct mspack_file *file, void *buffer, int bytes) -+{ -+ struct mspack_handle *mspack_handle = (struct mspack_handle *)file; -+ off_t offset; -+ size_t count; -+ int ret; -+ -+ if (bytes < 0) { -+ cli_dbgmsg("%s() %d\n", __func__, __LINE__); -+ return -1; -+ } -+ if (!mspack_handle) { -+ cli_dbgmsg("%s() %d\n", __func__, __LINE__); -+ return -1; -+ } -+ -+ if (mspack_handle->type == FILETYPE_FMAP) { -+ offset = mspack_handle->offset + mspack_handle->org; -+ -+ ret = fmap_readn(mspack_handle->fmap, buffer, offset, bytes); -+ if (ret != bytes) { -+ cli_dbgmsg("%s() %d %d, %d\n", __func__, __LINE__, bytes, ret); -+ return ret; -+ } -+ -+ mspack_handle->offset += bytes; -+ return bytes; -+ } -+ count = fread(buffer, bytes, 1, mspack_handle->f); -+ if (count < 1) { -+ cli_dbgmsg("%s() %d %d, %zd\n", __func__, __LINE__, bytes, count); -+ return -1; -+ } -+ return bytes; -+} -+ -+static int mspack_fmap_write(struct mspack_file *file, void *buffer, int bytes) -+{ -+ struct mspack_handle *mspack_handle = (struct mspack_handle *)file; -+ size_t count; -+ off_t max_size; -+ -+ if (bytes < 0 || !mspack_handle) { -+ cli_dbgmsg("%s() err %d\n", __func__, __LINE__); -+ return -1; -+ } -+ -+ if (mspack_handle->type == FILETYPE_FMAP) { -+ cli_dbgmsg("%s() err %d\n", __func__, __LINE__); -+ return -1; -+ } -+ -+ if (!bytes) -+ return 0; -+ -+ max_size = mspack_handle->max_size; -+ if (!max_size) -+ return bytes; -+ -+ max_size = min_t(off_t, max_size, bytes); -+ mspack_handle->max_size -= max_size; -+ -+ count = fwrite(buffer, max_size, 1, mspack_handle->f); -+ if (count < 1) { -+ cli_dbgmsg("%s() err %m <%zd %d>\n", __func__, count, bytes); -+ return -1; -+ } -+ -+ return bytes; -+} -+ -+static int mspack_fmap_seek(struct mspack_file *file, off_t offset, int mode) -+{ -+ struct mspack_handle *mspack_handle = (struct mspack_handle *)file; -+ -+ if (!mspack_handle) { -+ cli_dbgmsg("%s() err %d\n", __func__, __LINE__); -+ return -1; -+ } -+ -+ if (mspack_handle->type == FILETYPE_FMAP) { -+ off_t new_pos; -+ -+ switch (mode) { -+ case MSPACK_SYS_SEEK_START: -+ new_pos = offset; -+ break; -+ case MSPACK_SYS_SEEK_CUR: -+ new_pos = mspack_handle->offset + offset; -+ break; -+ case MSPACK_SYS_SEEK_END: -+ new_pos = mspack_handle->fmap->len + offset; -+ break; -+ default: -+ cli_dbgmsg("%s() err %d\n", __func__, __LINE__); -+ return -1; -+ } -+ if (new_pos < 0 || new_pos > mspack_handle->fmap->len) { -+ cli_dbgmsg("%s() err %d\n", __func__, __LINE__); -+ return -1; -+ } -+ -+ mspack_handle->offset = new_pos; -+ return 0; -+ } -+ -+ switch (mode) { -+ case MSPACK_SYS_SEEK_START: -+ mode = SEEK_SET; -+ break; -+ case MSPACK_SYS_SEEK_CUR: -+ mode = SEEK_CUR; -+ break; -+ case MSPACK_SYS_SEEK_END: -+ mode = SEEK_END; -+ break; -+ default: -+ cli_dbgmsg("%s() err %d\n", __func__, __LINE__); -+ return -1; -+ } -+ -+ return fseeko(mspack_handle->f, offset, mode); -+} -+ -+static off_t mspack_fmap_tell(struct mspack_file *file) -+{ -+ struct mspack_handle *mspack_handle = (struct mspack_handle *)file; -+ -+ if (!mspack_handle) -+ return -1; -+ -+ if (mspack_handle->type == FILETYPE_FMAP) -+ return mspack_handle->offset; -+ -+ return ftello(mspack_handle->f); -+} -+ -+static void mspack_fmap_message(struct mspack_file *file, const char *fmt, ...) -+{ -+ cli_dbgmsg("%s() %s\n", __func__, fmt); -+} -+static void *mspack_fmap_alloc(struct mspack_system *self, size_t num) -+{ -+ return malloc(num); -+} -+ -+static void mspack_fmap_free(void *mem) -+{ -+ free(mem); -+} -+ -+static void mspack_fmap_copy(void *src, void *dst, size_t num) -+{ -+ memcpy(dst, src, num); -+} -+ -+static struct mspack_system mspack_sys_fmap_ops = { -+ .open = mspack_fmap_open, -+ .close = mspack_fmap_close, -+ .read = mspack_fmap_read, -+ .write = mspack_fmap_write, -+ .seek = mspack_fmap_seek, -+ .tell = mspack_fmap_tell, -+ .message = mspack_fmap_message, -+ .alloc = mspack_fmap_alloc, -+ .free = mspack_fmap_free, -+ .copy = mspack_fmap_copy, -+}; -+ -+static int cli_scanfile(const char *filename, cli_ctx *ctx) -+{ -+ int fd, ret; -+ -+ /* internal version of cl_scanfile with arec/mrec preserved */ -+ fd = safe_open(filename, O_RDONLY|O_BINARY); -+ if (fd < 0) -+ return CL_EOPEN; -+ -+ ret = cli_magic_scandesc(fd, ctx); -+ -+ close(fd); -+ return ret; -+} -+ -+int cli_scanmscab(cli_ctx *ctx, off_t sfx_offset) -+{ -+ struct mscab_decompressor *cab_d; -+ struct mscabd_cabinet *cab_h; -+ struct mscabd_file *cab_f; -+ int ret; -+ int files; -+ int virus_num = 0; -+ struct mspack_name mspack_fmap = { -+ .fmap = *ctx->fmap, -+ .org = sfx_offset, -+ }; -+ struct mspack_system_ex ops_ex = { -+ .ops = mspack_sys_fmap_ops, -+ }; -+ -+ MSPACK_SYS_SELFTEST(ret); -+ if (ret) { -+ cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); -+ return CL_EUNPACK; -+ } -+ -+ cab_d = mspack_create_cab_decompressor(&ops_ex.ops); -+ if (!cab_d) { -+ cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); -+ return CL_EUNPACK; -+ } -+ -+ cab_h = cab_d->open(cab_d, (char *)&mspack_fmap); -+ if (!cab_h) { -+ ret = CL_EFORMAT; -+ cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); -+ goto out_dest; -+ } -+ files = 0; -+ for (cab_f = cab_h->files; cab_f; cab_f = cab_f->next) { -+ off_t max_size; -+ char *tmp_fname; -+ -+ ret = cli_matchmeta(ctx, cab_f->filename, 0, cab_f->length, 0, -+ files, 0, NULL); -+ if (ret) { -+ if (ret == CL_VIRUS) { -+ virus_num++; -+ if (!SCAN_ALL) -+ break; -+ } -+ goto out_close; -+ } -+ -+ if (ctx->engine->maxscansize) { -+ if (ctx->scansize >= ctx->engine->maxscansize) { -+ ret = CL_CLEAN; -+ break; -+ } -+ } -+ -+ if (ctx->engine->maxscansize && -+ ctx->scansize + ctx->engine->maxfilesize >= -+ ctx->engine->maxscansize) -+ max_size = ctx->engine->maxscansize - -+ ctx->scansize; -+ else -+ max_size = ctx->engine->maxfilesize ? -+ ctx->engine->maxfilesize : -+ 0xffffffff; -+ -+ tmp_fname = cli_gentemp(ctx->engine->tmpdir); -+ if (!tmp_fname) { -+ ret = CL_EMEM; -+ break; -+ } -+ -+ ops_ex.max_size = max_size; -+ /* scan */ -+ ret = cab_d->extract(cab_d, cab_f, tmp_fname); -+ if (ret) -+ /* Failed to extract. Try to scan what is there */ -+ cli_dbgmsg("%s() failed to extract %d\n", __func__, ret); -+ -+ ret = cli_scanfile(tmp_fname, ctx); -+ if (ret == CL_VIRUS) -+ virus_num++; -+ -+ if (!ctx->engine->keeptmp) { -+ if (!access(tmp_fname, R_OK) && cli_unlink(tmp_fname)) { -+ free(tmp_fname); -+ ret = CL_EUNLINK; -+ break; -+ } -+ } -+ free(tmp_fname); -+ files++; -+ if (ret == CL_VIRUS && SCAN_ALL) -+ continue; -+ if (ret) -+ break; -+ } -+ -+out_close: -+ cab_d->close(cab_d, cab_h); -+out_dest: -+ mspack_destroy_cab_decompressor(cab_d); -+ if (virus_num) -+ return CL_VIRUS; -+ return ret; -+} -+ -+int cli_scanmschm(cli_ctx *ctx) -+{ -+ struct mschm_decompressor *mschm_d; -+ struct mschmd_header *mschm_h; -+ struct mschmd_file *mschm_f; -+ int ret; -+ int files; -+ int virus_num = 0; -+ struct mspack_name mspack_fmap = { -+ .fmap = *ctx->fmap, -+ }; -+ struct mspack_system_ex ops_ex = { -+ .ops = mspack_sys_fmap_ops, -+ }; -+ -+ MSPACK_SYS_SELFTEST(ret); -+ if (ret) { -+ cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); -+ return CL_EUNPACK; -+ } -+ -+ mschm_d = mspack_create_chm_decompressor(&ops_ex.ops); -+ if (!mschm_d) { -+ cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); -+ return CL_EUNPACK; -+ } -+ -+ mschm_h = mschm_d->open(mschm_d, (char *)&mspack_fmap); -+ if (!mschm_h) { -+ ret = CL_EFORMAT; -+ cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); -+ goto out_dest; -+ } -+ files = 0; -+ for (mschm_f = mschm_h->files; mschm_f; mschm_f = mschm_f->next) { -+ off_t max_size; -+ char *tmp_fname; -+ -+ ret = cli_matchmeta(ctx, mschm_f->filename, 0, mschm_f->length, -+ 0, files, 0, NULL); -+ if (ret) { -+ if (ret == CL_VIRUS) { -+ virus_num++; -+ if (!SCAN_ALL) -+ break; -+ } -+ goto out_close; -+ } -+ -+ if (ctx->engine->maxscansize) { -+ if (ctx->scansize >= ctx->engine->maxscansize) { -+ ret = CL_CLEAN; -+ break; -+ } -+ } -+ -+ if (ctx->engine->maxscansize && -+ ctx->scansize + ctx->engine->maxfilesize >= -+ ctx->engine->maxscansize) -+ max_size = ctx->engine->maxscansize - -+ ctx->scansize; -+ else -+ max_size = ctx->engine->maxfilesize ? -+ ctx->engine->maxfilesize : -+ 0xffffffff; -+ -+ ops_ex.max_size = max_size; -+ -+ tmp_fname = cli_gentemp(ctx->engine->tmpdir); -+ if (!tmp_fname) { -+ ret = CL_EMEM; -+ break; -+ } -+ -+ /* scan */ -+ ret = mschm_d->extract(mschm_d, mschm_f, tmp_fname); -+ if (ret) -+ /* Failed to extract. Try to scan what is there */ -+ cli_dbgmsg("%s() failed to extract %d\n", __func__, ret); -+ -+ ret = cli_scanfile(tmp_fname, ctx); -+ if (ret == CL_VIRUS) -+ virus_num++; -+ -+ if (!ctx->engine->keeptmp) { -+ if (!access(tmp_fname, R_OK) && cli_unlink(tmp_fname)) { -+ free(tmp_fname); -+ ret = CL_EUNLINK; -+ break; -+ } -+ } -+ free(tmp_fname); -+ files++; -+ if (ret == CL_VIRUS && SCAN_ALL) -+ continue; -+ if (ret) -+ break; -+ } -+ -+out_close: -+ mschm_d->close(mschm_d, mschm_h); -+out_dest: -+ mspack_destroy_chm_decompressor(mschm_d); -+ if (virus_num) -+ return CL_VIRUS; -+ return ret; -+ -+ return 0; -+} -diff --git a/libclamav/libmspack.h b/libclamav/libmspack.h -new file mode 100644 -index 0000000..07a9442 ---- /dev/null -+++ b/libclamav/libmspack.h -@@ -0,0 +1,7 @@ -+#ifndef __LIBMSPACK_H__ -+#define __LIBMSPACK_H__ -+ -+int cli_scanmscab(cli_ctx *ctx, off_t sfx_offset); -+int cli_scanmschm(cli_ctx *ctx); -+ -+#endif -diff --git a/libclamav/mspack.c b/libclamav/mspack.c -deleted file mode 100644 -index b9da9c3..0000000 ---- a/libclamav/mspack.c -+++ /dev/null -@@ -1,2026 +0,0 @@ --/* -- * This file includes code from libmspack adapted for libclamav by -- * tkojm@clamav.net and draynor@sourcefire.com -- * -- * Copyright (C) 2003-2004 Stuart Caie -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Lesser General Public -- * License version 2.1 as published by the Free Software Foundation. -- * -- * 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 -- * Lesser General Public License for more details. -- * -- * You should have received a copy of the GNU Lesser General Public -- * License along with this library; if not, write to the Free Software -- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 -- * USA -- */ -- --#if HAVE_CONFIG_H --#include "clamav-config.h" --#endif -- --#include --#include -- --#include "others.h" --#include "clamav.h" --#include "mspack.h" -- --#if HAVE_LIMITS_H --# include --#endif --#ifndef CHAR_BIT --# define CHAR_BIT (8) --#endif -- -- --/*************************************************************************** -- * MS-ZIP decompression implementation -- *************************************************************************** -- * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted -- * by Microsoft Corporation. -- * -- * The deflate method was created by Phil Katz. MSZIP is equivalent to the -- * deflate method. -- * -- */ -- --/* match lengths for literal codes 257.. 285 */ --static const unsigned short mszip_lit_lengths[29] = { -- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, -- 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 --}; -- --/* match offsets for distance codes 0 .. 29 */ --static const unsigned short mszip_dist_offsets[30] = { -- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, -- 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 --}; -- --/* extra bits required for literal codes 257.. 285 */ --static const unsigned char mszip_lit_extrabits[29] = { -- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, -- 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 --}; -- --/* extra bits required for distance codes 0 .. 29 */ --static const unsigned char mszip_dist_extrabits[30] = { -- 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, -- 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 --}; -- --/* the order of the bit length Huffman code lengths */ --static const unsigned char mszip_bitlen_order[19] = { -- 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 --}; -- --/* ANDing with mszip_bit_mask[n] masks the lower n bits */ --static const unsigned short mszip_bit_mask_tab[17] = { -- 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, -- 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff --}; -- --#define MSZIP_STORE_BITS do { \ -- zip->i_ptr = i_ptr; \ -- zip->i_end = i_end; \ -- zip->bit_buffer = bit_buffer; \ -- zip->bits_left = bits_left; \ --} while (0) -- --#define MSZIP_RESTORE_BITS do { \ -- i_ptr = zip->i_ptr; \ -- i_end = zip->i_end; \ -- bit_buffer = zip->bit_buffer; \ -- bits_left = zip->bits_left; \ --} while (0) -- --#define MSZIP_ENSURE_BITS(nbits) do { \ -- while (bits_left < (nbits)) { \ -- if (i_ptr >= i_end) { \ -- if (mszip_read_input(zip)) return zip->error; \ -- i_ptr = zip->i_ptr; \ -- i_end = zip->i_end; \ -- if(i_ptr == i_end) break; \ -- } \ -- bit_buffer |= *i_ptr++ << bits_left; bits_left += 8; \ -- } \ --} while (0) -- --#define MSZIP_PEEK_BITS(nbits) (bit_buffer & ((1<<(nbits))-1)) --#define MSZIP_PEEK_BITS_T(nbits) (bit_buffer & mszip_bit_mask_tab[(nbits)]) -- --#define MSZIP_REMOVE_BITS(nbits) ((bit_buffer >>= (nbits)), (bits_left -= (nbits))) -- --#define MSZIP_READ_BITS(val, nbits) do { \ -- MSZIP_ENSURE_BITS(nbits); (val) = MSZIP_PEEK_BITS(nbits); MSZIP_REMOVE_BITS(nbits); \ --} while (0) -- --#define MSZIP_READ_BITS_T(val, nbits) do { \ -- MSZIP_ENSURE_BITS(nbits); (val) = MSZIP_PEEK_BITS_T(nbits); MSZIP_REMOVE_BITS(nbits); \ --} while (0) -- --static int mszip_read_input(struct mszip_stream *zip) { -- int nread = zip->read_cb(zip->file, zip->inbuf, (int)zip->inbuf_size); -- if (nread < 0) { -- if (zip->file->error == CL_BREAK) { -- if ((unsigned int)nread == zip->last) { -- cli_dbgmsg("mszip_read_input: Two consecutive CL_BREAKs reached.\n"); -- return CL_BREAK; -- } -- // Need short circuit to ensure scanning small files -- cli_dbgmsg("mszip_read_input: First CL_BREAK reached.\n"); -- zip->i_ptr = zip->i_end; -- zip->last = nread; -- return CL_SUCCESS; -- } -- else -- return zip->error = CL_EFORMAT; -- } -- -- zip->last = nread; -- zip->i_ptr = &zip->inbuf[0]; -- zip->i_end = &zip->inbuf[nread]; -- -- return CL_SUCCESS; --} -- --/* inflate() error codes */ --#define INF_ERR_BLOCKTYPE (-1) /* unknown block type */ --#define INF_ERR_COMPLEMENT (-2) /* block size complement mismatch */ --#define INF_ERR_FLUSH (-3) /* error from flush_window() callback */ --#define INF_ERR_BITBUF (-4) /* too many bits in bit buffer */ --#define INF_ERR_SYMLENS (-5) /* too many symbols in blocktype 2 header */ --#define INF_ERR_BITLENTBL (-6) /* failed to build bitlens huffman table */ --#define INF_ERR_LITERALTBL (-7) /* failed to build literals huffman table */ --#define INF_ERR_DISTANCETBL (-8) /* failed to build distance huffman table */ --#define INF_ERR_BITOVERRUN (-9) /* bitlen RLE code goes over table size */ --#define INF_ERR_BADBITLEN (-10) /* invalid bit-length code */ --#define INF_ERR_LITCODE (-11) /* out-of-range literal code */ --#define INF_ERR_DISTCODE (-12) /* out-of-range distance code */ --#define INF_ERR_DISTANCE (-13) /* somehow, distance is beyond 32k */ --#define INF_ERR_HUFFSYM (-14) /* out of bits decoding huffman symbol */ -- --/* mszip_make_decode_table(nsyms, nbits, length[], table[]) -- * -- * This function was coded by David Tritscher. It builds a fast huffman -- * decoding table out of just a canonical huffman code lengths table. -- * -- * NOTE: this is NOT identical to the mszip_make_decode_table() in lzxd.c. This -- * one reverses the quick-lookup bit pattern. Bits are read MSB to LSB in LZX, -- * but LSB to MSB in MSZIP. -- * -- * nsyms = total number of symbols in this huffman tree. -- * nbits = any symbols with a code length of nbits or less can be decoded -- * in one lookup of the table. -- * length = A table to get code lengths from [0 to nsyms-1] -- * table = The table to fill up with decoded symbols and pointers. -- * -- * Returns 0 for OK or 1 for error -- */ --static int mszip_make_decode_table(unsigned int nsyms, unsigned int nbits, -- unsigned char *length, unsigned short *table) --{ -- register unsigned int leaf, reverse, fill; -- register unsigned short sym, next_sym; -- register unsigned char bit_num; -- unsigned int pos = 0; /* the current position in the decode table */ -- unsigned int table_mask = 1 << nbits; -- unsigned int mszip_bit_mask = table_mask >> 1; /* don't do 0 length codes */ -- -- /* fill entries for codes short enough for a direct mapping */ -- for (bit_num = 1; bit_num <= nbits; bit_num++) { -- for (sym = 0; sym < nsyms; sym++) { -- if (length[sym] != bit_num) continue; -- -- /* reverse the significant bits */ -- fill = length[sym]; reverse = pos >> (nbits - fill); leaf = 0; -- do {leaf <<= 1; leaf |= reverse & 1; reverse >>= 1;} while (--fill); -- -- if((pos += mszip_bit_mask) > table_mask) return 1; /* table overrun */ -- -- /* fill all possible lookups of this symbol with the symbol itself */ -- fill = mszip_bit_mask; next_sym = 1 << bit_num; -- do { table[leaf] = sym; leaf += next_sym; } while (--fill); -- } -- mszip_bit_mask >>= 1; -- } -- -- /* exit with success if table is now complete */ -- if (pos == table_mask) return 0; -- -- /* mark all remaining table entries as unused */ -- for (sym = pos; sym < table_mask; sym++) { -- reverse = sym; leaf = 0; fill = nbits; -- do { leaf <<= 1; leaf |= reverse & 1; reverse >>= 1; } while (--fill); -- table[leaf] = 0xFFFF; -- } -- -- /* where should the longer codes be allocated from? */ -- next_sym = ((table_mask >> 1) < nsyms) ? nsyms : (table_mask >> 1); -- -- /* give ourselves room for codes to grow by up to 16 more bits. -- * codes now start at bit nbits+16 and end at (nbits+16-codelength) */ -- pos <<= 16; -- table_mask <<= 16; -- mszip_bit_mask = 1 << 15; -- -- for (bit_num = nbits+1; bit_num <= MSZIP_MAX_HUFFBITS; bit_num++) { -- for (sym = 0; sym < nsyms; sym++) { -- if (length[sym] != bit_num) continue; -- -- /* leaf = the first nbits of the code, reversed */ -- reverse = pos >> 16; leaf = 0; fill = nbits; -- do {leaf <<= 1; leaf |= reverse & 1; reverse >>= 1;} while (--fill); -- -- for (fill = 0; fill < (bit_num - nbits); fill++) { -- /* if this path hasn't been taken yet, 'allocate' two entries */ -- if (table[leaf] == 0xFFFF) { -- table[(next_sym << 1) ] = 0xFFFF; -- table[(next_sym << 1) + 1 ] = 0xFFFF; -- table[leaf] = next_sym++; -- } -- /* follow the path and select either left or right for next bit */ -- leaf = (table[leaf] << 1) | ((pos >> (15 - fill)) & 1); -- } -- table[leaf] = sym; -- -- if ((pos += mszip_bit_mask) > table_mask) return 1; /* table overflow */ -- } -- mszip_bit_mask >>= 1; -- } -- -- /* full table? */ -- return (pos != table_mask) ? 1 : 0; --} -- --/* MSZIP_READ_HUFFSYM(tablename, var) decodes one huffman symbol from the -- * bitstream using the stated table and puts it in var. -- */ --#define MSZIP_READ_HUFFSYM(tbl, var) do { \ -- /* huffman symbols can be up to 16 bits long */ \ -- MSZIP_ENSURE_BITS(MSZIP_MAX_HUFFBITS); \ -- /* immediate table lookup of [tablebits] bits of the code */ \ -- sym = zip->tbl##_table[MSZIP_PEEK_BITS(MSZIP_##tbl##_TABLEBITS)]; \ -- /* is the symbol is longer than [tablebits] bits? (i=node index) */ \ -- if (sym >= MSZIP_##tbl##_MAXSYMBOLS) { \ -- /* decode remaining bits by tree traversal */ \ -- i = MSZIP_##tbl##_TABLEBITS - 1; \ -- do { \ -- /* check next bit. error if we run out of bits before decode */ \ -- if (i++ > MSZIP_MAX_HUFFBITS) { \ -- cli_dbgmsg("zip_inflate: out of bits in huffman decode\n"); \ -- return INF_ERR_HUFFSYM; \ -- } \ -- sym = (sym << 1) | ((bit_buffer >> i) & 1); \ -- if(sym >= MSZIP_##tbl##_TABLESIZE) { \ -- cli_dbgmsg("zip_inflate: index out of table\n"); \ -- return INF_ERR_HUFFSYM; \ -- } \ -- /* double node index and add 0 (left branch) or 1 (right) */ \ -- sym = zip->tbl##_table[sym]; \ -- /* while we are still in node indicies, not decoded symbols */ \ -- } while (sym >= MSZIP_##tbl##_MAXSYMBOLS); \ -- } \ -- /* result */ \ -- (var) = sym; \ -- /* look up the code length of that symbol and discard those bits */ \ -- i = zip->tbl##_len[sym]; \ -- MSZIP_REMOVE_BITS(i); \ --} while (0) -- --static int mszip_read_lens(struct mszip_stream *zip) { -- /* for the bit buffer and huffman decoding */ -- register unsigned int bit_buffer; -- register int bits_left; -- unsigned char *i_ptr, *i_end; -- -- /* bitlen Huffman codes -- immediate lookup, 7 bit max code length */ -- unsigned short bl_table[(1 << 7)]; -- unsigned char bl_len[19]; -- -- unsigned char lens[MSZIP_LITERAL_MAXSYMBOLS + MSZIP_DISTANCE_MAXSYMBOLS]; -- unsigned int lit_codes, dist_codes, code, last_code=0, bitlen_codes, i, run; -- -- MSZIP_RESTORE_BITS; -- -- /* read the number of codes */ -- MSZIP_READ_BITS(lit_codes, 5); lit_codes += 257; -- MSZIP_READ_BITS(dist_codes, 5); dist_codes += 1; -- MSZIP_READ_BITS(bitlen_codes, 4); bitlen_codes += 4; -- if (lit_codes > MSZIP_LITERAL_MAXSYMBOLS) return INF_ERR_SYMLENS; -- if (dist_codes > MSZIP_DISTANCE_MAXSYMBOLS) return INF_ERR_SYMLENS; -- -- /* read in the bit lengths in their unusual order */ -- for (i = 0; i < bitlen_codes; i++) MSZIP_READ_BITS(bl_len[mszip_bitlen_order[i]], 3); -- while (i < 19) bl_len[mszip_bitlen_order[i++]] = 0; -- -- /* create decoding table with an immediate lookup */ -- if (mszip_make_decode_table(19, 7, &bl_len[0], &bl_table[0])) { -- return INF_ERR_BITLENTBL; -- } -- -- /* read literal / distance code lengths */ -- for (i = 0; i < (lit_codes + dist_codes); i++) { -- /* single-level huffman lookup */ -- MSZIP_ENSURE_BITS(7); -- code = bl_table[MSZIP_PEEK_BITS(7)]; -- MSZIP_REMOVE_BITS(bl_len[code]); -- -- if (code < 16) lens[i] = last_code = code; -- else { -- switch (code) { -- case 16: MSZIP_READ_BITS(run, 2); run += 3; code = last_code; break; -- case 17: MSZIP_READ_BITS(run, 3); run += 3; code = 0; break; -- case 18: MSZIP_READ_BITS(run, 7); run += 11; code = 0; break; -- default: cli_dbgmsg("zip_read_lens: bad code!: %u\n", code); return INF_ERR_BADBITLEN; -- } -- if ((i + run) > (lit_codes + dist_codes)) return INF_ERR_BITOVERRUN; -- while (run--) lens[i++] = code; -- i--; -- } -- } -- -- /* copy LITERAL code lengths and clear any remaining */ -- i = lit_codes; -- memcpy(&zip->LITERAL_len[0], &lens[0], i); -- while (i < MSZIP_LITERAL_MAXSYMBOLS) zip->LITERAL_len[i++] = 0; -- -- i = dist_codes; -- memcpy(&zip->DISTANCE_len[0], &lens[lit_codes], i); -- while (i < MSZIP_DISTANCE_MAXSYMBOLS) zip->DISTANCE_len[i++] = 0; -- -- MSZIP_STORE_BITS; -- return 0; --} -- --static int mspack_write(int fd, const void *buff, unsigned int count, struct cab_file *file) --{ -- int ret; -- -- if(file->max_size) { -- if(file->written_size >= file->max_size) -- return CL_BREAK; -- -- if(file->written_size + count > file->max_size) -- count = file->max_size - file->written_size; -- } -- if((ret = cli_writen(fd, buff, count)) > 0) -- file->written_size += ret; -- -- return (ret == -1) ? CL_EWRITE : CL_SUCCESS; --} -- --/* a clean implementation of RFC 1951 / inflate */ --static int mszip_inflate(struct mszip_stream *zip) { -- unsigned int last_block, block_type, distance, length, this_run, i; -- -- /* for the bit buffer and huffman decoding */ -- register unsigned int bit_buffer; -- register int bits_left; -- register unsigned short sym; -- unsigned char *i_ptr, *i_end; -- -- MSZIP_RESTORE_BITS; -- -- do { -- /* read in last block bit */ -- MSZIP_READ_BITS(last_block, 1); -- -- /* read in block type */ -- MSZIP_READ_BITS(block_type, 2); -- -- if (block_type == 0) { -- /* uncompressed block */ -- unsigned char lens_buf[4]; -- -- /* go to byte boundary */ -- i = bits_left & 7; MSZIP_REMOVE_BITS(i); -- -- /* read 4 bytes of data, emptying the bit-buffer if necessary */ -- for (i = 0; (bits_left >= 8); i++) { -- if (i == 4) return INF_ERR_BITBUF; -- lens_buf[i] = MSZIP_PEEK_BITS(8); -- MSZIP_REMOVE_BITS(8); -- } -- if (bits_left != 0) return INF_ERR_BITBUF; -- while (i < 4) { -- if (i_ptr >= i_end) { -- if (mszip_read_input(zip)) return zip->error; -- i_ptr = zip->i_ptr; -- i_end = zip->i_end; -- if(i_ptr == i_end) break; -- } -- lens_buf[i++] = *i_ptr++; -- } -- if (i < 4) return INF_ERR_BITBUF; -- -- /* get the length and its complement */ -- length = lens_buf[0] | (lens_buf[1] << 8); -- i = lens_buf[2] | (lens_buf[3] << 8); -- if (length != (~i & 0xFFFF)) return INF_ERR_COMPLEMENT; -- -- /* read and copy the uncompressed data into the window */ -- while (length > 0) { -- if (i_ptr >= i_end) { -- if (mszip_read_input(zip)) return zip->error; -- i_ptr = zip->i_ptr; -- i_end = zip->i_end; -- if(i_ptr == i_end) break; -- } -- -- this_run = length; -- if (this_run > (unsigned int)(i_end - i_ptr)) this_run = i_end - i_ptr; -- if (this_run > (MSZIP_FRAME_SIZE - zip->window_posn)) -- this_run = MSZIP_FRAME_SIZE - zip->window_posn; -- -- memcpy(&zip->window[zip->window_posn], i_ptr, this_run); -- zip->window_posn += this_run; -- i_ptr += this_run; -- length -= this_run; -- -- if (zip->window_posn == MSZIP_FRAME_SIZE) { -- if (zip->flush_window(zip, MSZIP_FRAME_SIZE)) return INF_ERR_FLUSH; -- zip->window_posn = 0; -- } -- } -- } -- else if ((block_type == 1) || (block_type == 2)) { -- /* Huffman-compressed LZ77 block */ -- unsigned int window_posn, match_posn, code; -- -- if (block_type == 1) { -- /* block with fixed Huffman codes */ -- i = 0; -- while (i < 144) zip->LITERAL_len[i++] = 8; -- while (i < 256) zip->LITERAL_len[i++] = 9; -- while (i < 280) zip->LITERAL_len[i++] = 7; -- while (i < 288) zip->LITERAL_len[i++] = 8; -- for (i = 0; i < 32; i++) zip->DISTANCE_len[i] = 5; -- } -- else { -- /* block with dynamic Huffman codes */ -- MSZIP_STORE_BITS; -- if ((i = mszip_read_lens(zip))) return i; -- MSZIP_RESTORE_BITS; -- } -- -- /* now huffman lengths are read for either kind of block, -- * create huffman decoding tables */ -- if (mszip_make_decode_table(MSZIP_LITERAL_MAXSYMBOLS, MSZIP_LITERAL_TABLEBITS, -- &zip->LITERAL_len[0], &zip->LITERAL_table[0])) -- { -- return INF_ERR_LITERALTBL; -- } -- -- if (mszip_make_decode_table(MSZIP_DISTANCE_MAXSYMBOLS,MSZIP_DISTANCE_TABLEBITS, -- &zip->DISTANCE_len[0], &zip->DISTANCE_table[0])) -- { -- return INF_ERR_DISTANCETBL; -- } -- -- /* decode forever until end of block code */ -- window_posn = zip->window_posn; -- while (1) { -- MSZIP_READ_HUFFSYM(LITERAL, code); -- if (code < 256) { -- zip->window[window_posn++] = (unsigned char) code; -- if (window_posn == MSZIP_FRAME_SIZE) { -- if (zip->flush_window(zip, MSZIP_FRAME_SIZE)) return INF_ERR_FLUSH; -- window_posn = 0; -- } -- } -- else if (code == 256) { -- /* END OF BLOCK CODE: loop break point */ -- break; -- } -- else { -- code -= 257; -- if (code >= 29) return INF_ERR_LITCODE; -- MSZIP_READ_BITS_T(length, mszip_lit_extrabits[code]); -- length += mszip_lit_lengths[code]; -- -- MSZIP_READ_HUFFSYM(DISTANCE, code); -- if (code >= 30) return INF_ERR_DISTCODE; -- MSZIP_READ_BITS_T(distance, mszip_dist_extrabits[code]); -- distance += mszip_dist_offsets[code]; -- -- /* match position is window position minus distance. If distance -- * is more than window position numerically, it must 'wrap -- * around' the frame size. */ -- match_posn = ((distance > window_posn) ? MSZIP_FRAME_SIZE : 0) -- + window_posn - distance; -- -- /* copy match */ -- if (length < 12) { -- /* short match, use slower loop but no loop setup code */ -- while (length--) { -- zip->window[window_posn++] = zip->window[match_posn++]; -- match_posn &= MSZIP_FRAME_SIZE - 1; -- -- if (window_posn == MSZIP_FRAME_SIZE) { -- if (zip->flush_window(zip, MSZIP_FRAME_SIZE)) -- return INF_ERR_FLUSH; -- window_posn = 0; -- } -- } -- } -- else { -- /* longer match, use faster loop but with setup expense */ -- unsigned char *runsrc, *rundest; -- do { -- this_run = length; -- if ((match_posn + this_run) > MSZIP_FRAME_SIZE) -- this_run = MSZIP_FRAME_SIZE - match_posn; -- if ((window_posn + this_run) > MSZIP_FRAME_SIZE) -- this_run = MSZIP_FRAME_SIZE - window_posn; -- -- rundest = &zip->window[window_posn]; window_posn += this_run; -- runsrc = &zip->window[match_posn]; match_posn += this_run; -- length -= this_run; -- while (this_run--) *rundest++ = *runsrc++; -- -- /* flush if necessary */ -- if (window_posn == MSZIP_FRAME_SIZE) { -- if (zip->flush_window(zip, MSZIP_FRAME_SIZE)) -- return INF_ERR_FLUSH; -- window_posn = 0; -- } -- if (match_posn == MSZIP_FRAME_SIZE) match_posn = 0; -- } while (length > 0); -- } -- -- } /* else (code >= 257) */ -- -- } /* while (forever) -- break point at 'code == 256' */ -- zip->window_posn = window_posn; -- } -- else { -- /* block_type == 3 -- bad block type */ -- return INF_ERR_BLOCKTYPE; -- } -- } while (!last_block); -- -- /* flush the remaining data */ -- if (zip->window_posn) { -- if (zip->flush_window(zip, zip->window_posn)) return INF_ERR_FLUSH; -- } -- MSZIP_STORE_BITS; -- -- /* return success */ -- return 0; --} -- --/* inflate() calls this whenever the window should be flushed. As -- * MSZIP only expands to the size of the window, the implementation used -- * simply keeps track of the amount of data flushed, and if more than 32k -- * is flushed, an error is raised. -- */ --static int mszip_flush_window(struct mszip_stream *zip, -- unsigned int data_flushed) --{ -- zip->bytes_output += data_flushed; -- if (zip->bytes_output > MSZIP_FRAME_SIZE) { -- cli_dbgmsg("mszip_flush_window: overflow: %u bytes flushed, total is now %u\n", data_flushed, zip->bytes_output); -- return 1; -- } -- return 0; --} -- --struct mszip_stream *mszip_init(int ofd, -- int input_buffer_size, -- int repair_mode, -- struct cab_file *file, -- int (*read_cb)(struct cab_file *, unsigned char *, int)) --{ -- struct mszip_stream *zip; -- -- input_buffer_size = (input_buffer_size + 1) & -2; -- if (!input_buffer_size) return NULL; -- -- /* allocate decompression state */ -- if (!(zip = cli_calloc(1, sizeof(struct mszip_stream)))) { -- cli_errmsg("mszip_stream: Unable to allocate zip buffer\n"); -- return NULL; -- } -- -- /* allocate input buffer */ -- zip->inbuf = cli_malloc((size_t) input_buffer_size); -- if (!zip->inbuf) { -- cli_errmsg("mszip_stream: Unable to allocate input buffer\n"); -- free(zip); -- return NULL; -- } -- -- /* initialise decompression state */ -- zip->ofd = ofd; -- zip->wflag = 1; -- zip->inbuf_size = input_buffer_size; -- zip->error = CL_SUCCESS; -- zip->repair_mode = repair_mode; -- zip->flush_window = &mszip_flush_window; -- zip->input_end = 0; -- -- zip->i_ptr = zip->i_end = &zip->inbuf[0]; -- zip->o_ptr = zip->o_end = NULL; -- zip->bit_buffer = 0; zip->bits_left = 0; -- -- zip->file = file; -- zip->read_cb = read_cb; -- -- return zip; --} -- --int mszip_decompress(struct mszip_stream *zip, uint32_t out_bytes) { -- /* for the bit buffer */ -- register unsigned int bit_buffer; -- register int bits_left; -- unsigned char *i_ptr, *i_end; -- -- int i, ret, state, error; -- -- /* easy answers */ -- if (!zip) return CL_ENULLARG; -- if (zip->error) return zip->error; -- -- /* flush out any stored-up bytes before we begin */ -- i = zip->o_end - zip->o_ptr; -- if (((off_t) i > out_bytes) && ((int) out_bytes >= 0)) i = (int) out_bytes; -- if (i) { -- if (zip->wflag && (ret = mspack_write(zip->ofd, zip->o_ptr, i, zip->file)) != CL_SUCCESS) { -- return zip->error = ret; -- } -- zip->o_ptr += i; -- out_bytes -= i; -- } -- if (out_bytes == 0) return CL_SUCCESS; -- -- while (out_bytes > 0) { -- /* unpack another block */ -- MSZIP_RESTORE_BITS; -- -- /* skip to next read 'CK' header */ -- i = bits_left & 7; MSZIP_REMOVE_BITS(i); /* align to bytestream */ -- state = 0; -- do { -- MSZIP_READ_BITS(i, 8); -- if (i == 'C') state = 1; -- else if ((state == 1) && (i == 'K')) state = 2; -- else state = 0; -- } while (state != 2); -- -- /* inflate a block, repair and realign if necessary */ -- zip->window_posn = 0; -- zip->bytes_output = 0; -- MSZIP_STORE_BITS; -- if ((error = mszip_inflate(zip))) { -- cli_dbgmsg("mszip_decompress: inflate error %d\n", error); -- if (zip->repair_mode) { -- cli_dbgmsg("mszip_decompress: MSZIP error, %u bytes of data lost\n", -- MSZIP_FRAME_SIZE - zip->bytes_output); -- for (i = zip->bytes_output; i < MSZIP_FRAME_SIZE; i++) { -- zip->window[i] = '\0'; -- } -- zip->bytes_output = MSZIP_FRAME_SIZE; -- } -- else { -- return zip->error = (error > 0) ? error : CL_EFORMAT; -- } -- } -- zip->o_ptr = &zip->window[0]; -- zip->o_end = &zip->o_ptr[zip->bytes_output]; -- -- /* write a frame */ -- i = (out_bytes < (off_t)zip->bytes_output) ? -- (int)out_bytes : zip->bytes_output; -- if (zip->wflag && (ret = mspack_write(zip->ofd, zip->o_ptr, i, zip->file)) != CL_SUCCESS) { -- return zip->error = ret; -- } -- -- /* mspack errors (i.e. read errors) are fatal and can't be recovered */ -- if ((error > 0) && zip->repair_mode) return error; -- -- zip->o_ptr += i; -- out_bytes -= i; -- } -- -- if (out_bytes) -- cli_dbgmsg("mszip_decompress: bytes left to output\n"); -- -- return CL_SUCCESS; --} -- --void mszip_free(struct mszip_stream *zip) { -- if (zip) { -- free(zip->inbuf); -- free(zip); -- } --} -- --/*************************************************************************** -- * LZX decompression implementation -- *************************************************************************** -- * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted -- * by Microsoft Corporation. -- * -- */ -- --/* LZX decompressor input macros -- * -- * LZX_STORE_BITS stores bitstream state in lzx_stream structure -- * LZX_RESTORE_BITS restores bitstream state from lzx_stream structure -- * LZX_READ_BITS(var,n) takes N bits from the buffer and puts them in var -- * LZX_ENSURE_BITS(n) ensures there are at least N bits in the bit buffer. -- * LZX_PEEK_BITS(n) extracts without removing N bits from the bit buffer -- * LZX_REMOVE_BITS(n) removes N bits from the bit buffer -- * -- */ -- --#define LZX_BITBUF_WIDTH (sizeof(bit_buffer) * CHAR_BIT) -- --#define LZX_STORE_BITS do { \ -- lzx->i_ptr = i_ptr; \ -- lzx->i_end = i_end; \ -- lzx->bit_buffer = bit_buffer; \ -- lzx->bits_left = bits_left; \ --} while (0) -- --#define LZX_RESTORE_BITS do { \ -- i_ptr = lzx->i_ptr; \ -- i_end = lzx->i_end; \ -- bit_buffer = lzx->bit_buffer; \ -- bits_left = lzx->bits_left; \ --} while (0) -- --#define LZX_ENSURE_BITS(nbits) \ -- while (bits_left < (nbits)) { \ -- if (i_ptr + 1 >= i_end) { \ -- if (lzx_read_input(lzx)) return lzx->error; \ -- i_ptr = lzx->i_ptr; \ -- i_end = lzx->i_end; \ -- } \ -- bit_buffer |= ((i_ptr[1] << 8) | i_ptr[0]) \ -- << (LZX_BITBUF_WIDTH - 16 - bits_left); \ -- bits_left += 16; \ -- i_ptr += 2; \ -- } -- --#define LZX_PEEK_BITS(nbits) (bit_buffer >> (LZX_BITBUF_WIDTH - (nbits))) -- --#define LZX_REMOVE_BITS(nbits) ((bit_buffer <<= (nbits)), (bits_left -= (nbits))) -- --#define LZX_READ_BITS(val, nbits) do { \ -- LZX_ENSURE_BITS(nbits); \ -- (val) = LZX_PEEK_BITS(nbits); \ -- LZX_REMOVE_BITS(nbits); \ --} while (0) -- --static int lzx_read_input(struct lzx_stream *lzx) { -- int bread = lzx->read_cb(lzx->file, &lzx->inbuf[0], (int)lzx->inbuf_size); -- if (bread < 0) { -- if (lzx->file->error == CL_BREAK) -- return lzx->error = CL_BREAK; -- else -- return lzx->error = CL_EFORMAT; -- } -- -- /* huff decode's ENSURE_BYTES(16) might overrun the input stream, even -- * if those bits aren't used, so fake 2 more bytes */ -- if (bread == 0) { -- if (lzx->input_end) { -- cli_dbgmsg("lzx_read_input: out of input bytes\n"); -- return lzx->error = CL_EREAD; -- } -- else { -- bread = 2; -- lzx->inbuf[0] = lzx->inbuf[1] = 0; -- lzx->input_end = 1; -- } -- } -- -- lzx->i_ptr = &lzx->inbuf[0]; -- lzx->i_end = &lzx->inbuf[bread]; -- -- return CL_SUCCESS; --} -- --/* Huffman decoding macros */ -- --/* LZX_READ_HUFFSYM(tablename, var) decodes one huffman symbol from the -- * bitstream using the stated table and puts it in var. -- */ --#define LZX_READ_HUFFSYM(tbl, var) do { \ -- /* huffman symbols can be up to 16 bits long */ \ -- LZX_ENSURE_BITS(16); \ -- /* immediate table lookup of [tablebits] bits of the code */ \ -- sym = lzx->tbl##_table[LZX_PEEK_BITS(LZX_##tbl##_TABLEBITS)]; \ -- /* is the symbol is longer than [tablebits] bits? (i=node index) */ \ -- if (sym >= LZX_##tbl##_MAXSYMBOLS) { \ -- /* decode remaining bits by tree traversal */ \ -- i = 1 << (LZX_BITBUF_WIDTH - LZX_##tbl##_TABLEBITS); \ -- do { \ -- /* one less bit. error if we run out of bits before decode */ \ -- i >>= 1; \ -- if (i == 0) { \ -- cli_dbgmsg("lzx: out of bits in huffman decode\n"); \ -- return lzx->error = CL_EFORMAT; \ -- } \ -- /* double node index and add 0 (left branch) or 1 (right) */ \ -- sym <<= 1; sym |= (bit_buffer & i) ? 1 : 0; \ -- /* hop to next node index / decoded symbol */ \ -- if(sym >= (1 << LZX_##tbl##_TABLEBITS) + (LZX_##tbl##_MAXSYMBOLS * 2)) { \ -- cli_dbgmsg("lzx: index out of table\n"); \ -- return lzx->error = CL_EFORMAT; \ -- } \ -- sym = lzx->tbl##_table[sym]; \ -- /* while we are still in node indicies, not decoded symbols */ \ -- } while (sym >= LZX_##tbl##_MAXSYMBOLS); \ -- } \ -- /* result */ \ -- (var) = sym; \ -- /* look up the code length of that symbol and discard those bits */ \ -- i = lzx->tbl##_len[sym]; \ -- LZX_REMOVE_BITS(i); \ --} while (0) -- --/* LZX_BUILD_TABLE(tbl) builds a huffman lookup table from code lengths */ --#define LZX_BUILD_TABLE(tbl) \ -- if (lzx_make_decode_table(LZX_##tbl##_MAXSYMBOLS, LZX_##tbl##_TABLEBITS, \ -- &lzx->tbl##_len[0], &lzx->tbl##_table[0])) \ -- { \ -- cli_dbgmsg("lzx: failed to build %s table\n", #tbl); \ -- return lzx->error = CL_EFORMAT; \ -- } -- --/* lzx_make_decode_table(nsyms, nbits, length[], table[]) -- * -- * This function was coded by David Tritscher. It builds a fast huffman -- * decoding table from a canonical huffman code lengths table. -- * -- * nsyms = total number of symbols in this huffman tree. -- * nbits = any symbols with a code length of nbits or less can be decoded -- * in one lookup of the table. -- * length = A table to get code lengths from [0 to syms-1] -- * table = The table to fill up with decoded symbols and pointers. -- * -- * Returns 0 for OK or 1 for error -- */ -- --static int lzx_make_decode_table(unsigned int nsyms, unsigned int nbits, -- unsigned char *length, unsigned short *table) --{ -- register unsigned short sym; -- register unsigned int leaf, fill; -- register unsigned char bit_num; -- unsigned int pos = 0; /* the current position in the decode table */ -- unsigned int table_mask = 1 << nbits; -- unsigned int bit_mask = table_mask >> 1; /* don't do 0 length codes */ -- unsigned int next_symbol = bit_mask; /* base of allocation for long codes */ -- -- /* fill entries for codes short enough for a direct mapping */ -- for (bit_num = 1; bit_num <= nbits; bit_num++) { -- for (sym = 0; sym < nsyms; sym++) { -- if (length[sym] != bit_num) continue; -- leaf = pos; -- if((pos += bit_mask) > table_mask) return 1; /* table overrun */ -- /* fill all possible lookups of this symbol with the symbol itself */ -- for (fill = bit_mask; fill-- > 0;) table[leaf++] = sym; -- } -- bit_mask >>= 1; -- } -- -- /* full table already? */ -- if (pos == table_mask) return 0; -- -- /* clear the remainder of the table */ -- for (sym = pos; sym < table_mask; sym++) table[sym] = 0xFFFF; -- -- /* allow codes to be up to nbits+16 long, instead of nbits */ -- pos <<= 16; -- table_mask <<= 16; -- bit_mask = 1 << 15; -- -- for (bit_num = nbits+1; bit_num <= 16; bit_num++) { -- for (sym = 0; sym < nsyms; sym++) { -- if (length[sym] != bit_num) continue; -- -- leaf = pos >> 16; -- for (fill = 0; fill < bit_num - nbits; fill++) { -- /* if this path hasn't been taken yet, 'allocate' two entries */ -- if (table[leaf] == 0xFFFF) { -- table[(next_symbol << 1)] = 0xFFFF; -- table[(next_symbol << 1) + 1] = 0xFFFF; -- table[leaf] = next_symbol++; -- } -- /* follow the path and select either left or right for next bit */ -- leaf = table[leaf] << 1; -- if ((pos >> (15-fill)) & 1) leaf++; -- } -- table[leaf] = sym; -- -- if ((pos += bit_mask) > table_mask) return 1; /* table overflow */ -- } -- bit_mask >>= 1; -- } -- -- /* full table? */ -- if (pos == table_mask) return 0; -- -- /* either erroneous table, or all elements are 0 - let's find out. */ -- for (sym = 0; sym < nsyms; sym++) if (length[sym]) return 1; -- return 0; --} -- --/* LZX_READ_LENGTHS(tablename, first, last) reads in code lengths for symbols -- * first to last in the given table. The code lengths are stored in their -- * own special LZX way. -- */ --#define LZX_READ_LENGTHS(tbl, first, last) do { \ -- LZX_STORE_BITS; \ -- if (lzx_read_lens(lzx, &lzx->tbl##_len[0], (first), \ -- (unsigned int)(last))) return lzx->error; \ -- LZX_RESTORE_BITS; \ --} while (0) -- --static int lzx_read_lens(struct lzx_stream *lzx, unsigned char *lens, -- unsigned int first, unsigned int last) --{ -- /* bit buffer and huffman symbol decode variables */ -- register unsigned int bit_buffer; -- register int bits_left, i; -- register unsigned short sym; -- unsigned char *i_ptr, *i_end; -- -- unsigned int x, y; -- int z; -- -- LZX_RESTORE_BITS; -- -- /* read lengths for pretree (20 symbols, lengths stored in fixed 4 bits) */ -- for (x = 0; x < 20; x++) { -- LZX_READ_BITS(y, 4); -- lzx->PRETREE_len[x] = y; -- } -- LZX_BUILD_TABLE(PRETREE); -- -- for (x = first; x < last; ) { -- LZX_READ_HUFFSYM(PRETREE, z); -- if (z == 17) { -- /* code = 17, run of ([read 4 bits]+4) zeros */ -- LZX_READ_BITS(y, 4); y += 4; -- while (y--) lens[x++] = 0; -- } -- else if (z == 18) { -- /* code = 18, run of ([read 5 bits]+20) zeros */ -- LZX_READ_BITS(y, 5); y += 20; -- while (y--) lens[x++] = 0; -- } -- else if (z == 19) { -- /* code = 19, run of ([read 1 bit]+4) [read huffman symbol] */ -- LZX_READ_BITS(y, 1); y += 4; -- LZX_READ_HUFFSYM(PRETREE, z); -- z = lens[x] - z; if (z < 0) z += 17; -- while (y--) lens[x++] = z; -- } -- else { -- /* code = 0 to 16, delta current length entry */ -- z = lens[x] - z; if (z < 0) z += 17; -- lens[x++] = z; -- } -- } -- -- LZX_STORE_BITS; -- -- return CL_SUCCESS; --} -- --static void lzx_reset_state(struct lzx_stream *lzx) { -- int i; -- -- lzx->R0 = 1; -- lzx->R1 = 1; -- lzx->R2 = 1; -- lzx->header_read = 0; -- lzx->block_remaining = 0; -- lzx->block_type = LZX_BLOCKTYPE_INVALID; -- -- /* initialise tables to 0 (because deltas will be applied to them) */ -- for (i = 0; i < LZX_MAINTREE_MAXSYMBOLS; i++) lzx->MAINTREE_len[i] = 0; -- for (i = 0; i < LZX_LENGTH_MAXSYMBOLS; i++) lzx->LENGTH_len[i] = 0; --} -- --/*-------- main LZX code --------*/ -- --struct lzx_stream *lzx_init(int ofd, -- int window_bits, -- int reset_interval, -- int input_buffer_size, -- off_t output_length, -- struct cab_file *file, -- int (*read_cb)(struct cab_file *, unsigned char *, int)) --{ -- unsigned int window_size = 1 << window_bits; -- struct lzx_stream *lzx; -- int i, j; -- -- /* LZX supports window sizes of 2^15 (32Kb) through 2^21 (2Mb) */ -- if (window_bits < 15 || window_bits > 21) return NULL; -- -- input_buffer_size = (input_buffer_size + 1) & -2; -- if (!input_buffer_size) return NULL; -- -- /* allocate decompression state */ -- if (!(lzx = cli_calloc(1, sizeof(struct lzx_stream)))) { -- return NULL; -- } -- -- for (i = 0, j = 0; i < 51; i += 2) { -- lzx->extra_bits[i] = j; /* 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7... */ -- if(i < 50) -- lzx->extra_bits[i+1] = j; -- if ((i != 0) && (j < 17)) j++; /* 0,0,1,2,3,4...15,16,17,17,17,17... */ -- } -- -- for (i = 0, j = 0; i < 51; i++) { -- lzx->position_base[i] = j; /* 0,1,2,3,4,6,8,12,16,24,32,... */ -- j += 1 << lzx->extra_bits[i]; /* 1,1,1,1,2,2,4,4,8,8,16,16,32,32,... */ -- } -- -- /* allocate decompression window and input buffer */ -- lzx->window = cli_calloc(1, (size_t) window_size); -- if(!lzx->window) { -- free(lzx); -- return NULL; -- } -- -- lzx->inbuf = cli_calloc(1, (size_t) input_buffer_size); -- if (!lzx->inbuf) { -- free(lzx->window); -- free(lzx); -- return NULL; -- } -- -- /* initialise decompression state */ -- lzx->ofd = ofd; -- lzx->wflag = 1; -- lzx->offset = 0; -- lzx->length = output_length; -- lzx->file = file; -- lzx->read_cb = read_cb; -- -- lzx->inbuf_size = input_buffer_size; -- lzx->window_size = 1 << window_bits; -- lzx->window_posn = 0; -- lzx->frame_posn = 0; -- lzx->frame = 0; -- lzx->reset_interval = reset_interval; -- lzx->intel_filesize = 0; -- lzx->intel_curpos = 0; -- -- /* window bits: 15 16 17 18 19 20 21 -- * position slots: 30 32 34 36 38 42 50 */ -- lzx->posn_slots = ((window_bits == 21) ? 50 : -- ((window_bits == 20) ? 42 : (window_bits << 1))); -- lzx->intel_started = 0; -- lzx->input_end = 0; -- -- lzx->error = CL_SUCCESS; -- -- lzx->i_ptr = lzx->i_end = &lzx->inbuf[0]; -- lzx->o_ptr = lzx->o_end = &lzx->e8_buf[0]; -- lzx->bit_buffer = lzx->bits_left = 0; -- -- lzx_reset_state(lzx); -- return lzx; --} -- --void lzx_set_output_length(struct lzx_stream *lzx, off_t out_bytes) { -- if (lzx) lzx->length = out_bytes; --} -- --int lzx_decompress(struct lzx_stream *lzx, uint32_t out_bytes) { -- /* bitstream reading and huffman variables */ -- register unsigned int bit_buffer; -- register int bits_left, i=0; -- register unsigned short sym; -- unsigned char *i_ptr, *i_end; -- -- int match_length, length_footer, extra, verbatim_bits, bytes_todo; -- int this_run, main_element, aligned_bits, j, ret, warned=0; -- unsigned char *window, *runsrc, *rundest, buf[12]; -- unsigned int frame_size=0, end_frame, match_offset, window_posn; -- unsigned int R0, R1, R2; -- -- /* easy answers */ -- if (!lzx) return CL_ENULLARG; -- if (lzx->error) return lzx->error; -- -- /* flush out any stored-up bytes before we begin */ -- i = lzx->o_end - lzx->o_ptr; -- if (((off_t) i > out_bytes) && ((int) out_bytes >= 0)) i = (int) out_bytes; -- if (i) { -- if (lzx->wflag && (ret = mspack_write(lzx->ofd, lzx->o_ptr, i, lzx->file)) != CL_SUCCESS) { -- return lzx->error = ret; -- } -- lzx->o_ptr += i; -- lzx->offset += i; -- out_bytes -= i; -- } -- if (out_bytes == 0) return CL_SUCCESS; -- -- /* restore local state */ -- LZX_RESTORE_BITS; -- window = lzx->window; -- window_posn = lzx->window_posn; -- R0 = lzx->R0; -- R1 = lzx->R1; -- R2 = lzx->R2; -- -- end_frame = (unsigned int)((lzx->offset + out_bytes) / LZX_FRAME_SIZE) + 1; -- cli_dbgmsg("lzx_decompress: end frame = %u\n", end_frame); -- -- while (lzx->frame < end_frame) { -- cli_dbgmsg("lzx_decompress: current frame = %u\n", lzx->frame); -- /* have we reached the reset interval? (if there is one?) */ -- if (lzx->reset_interval && ((lzx->frame % lzx->reset_interval) == 0)) { -- if (lzx->block_remaining) { -- /* this is a file format error, but we need to extract what we can and scan that */ -- cli_dbgmsg("lzx_decompress: %d bytes remaining at reset interval\n", lzx->block_remaining); -- if (!warned) { -- cli_dbgmsg("Detected an invalid reset interval during decompression.\n"); -- warned++; -- } -- if (!lzx->header_read) { -- /* cannot continue if no header at all */ -- return lzx->error = CL_EFORMAT; -- } -- } else { -- /* re-read the intel header and reset the huffman lengths */ -- lzx_reset_state(lzx); -- } -- } -- -- /* read header if necessary */ -- if (!lzx->header_read) { -- /* read 1 bit. if bit=0, intel filesize = 0. -- * if bit=1, read intel filesize (32 bits) */ -- j = 0; LZX_READ_BITS(i, 1); if (i) { LZX_READ_BITS(i, 16); LZX_READ_BITS(j, 16); } -- lzx->intel_filesize = (i << 16) | j; -- lzx->header_read = 1; -- } -- -- /* calculate size of frame: all frames are 32k except the final frame -- * which is 32kb or less. this can only be calculated when lzx->length -- * has been filled in. */ -- frame_size = LZX_FRAME_SIZE; -- if (lzx->length && (lzx->length - lzx->offset) < (off_t)frame_size) { -- frame_size = lzx->length - lzx->offset; -- } -- -- /* decode until one more frame is available */ -- bytes_todo = lzx->frame_posn + frame_size - window_posn; -- while (bytes_todo > 0) { -- /* initialise new block, if one is needed */ -- if (lzx->block_remaining == 0) { -- /* realign if previous block was an odd-sized UNCOMPRESSED block */ -- if ((lzx->block_type == LZX_BLOCKTYPE_UNCOMPRESSED) && -- (lzx->block_length & 1)) -- { -- if (i_ptr == i_end) { -- if (lzx_read_input(lzx)) return lzx->error; -- i_ptr = lzx->i_ptr; -- i_end = lzx->i_end; -- } -- i_ptr++; -- } -- -- /* read block type (3 bits) and block length (24 bits) */ -- LZX_READ_BITS(lzx->block_type, 3); -- LZX_READ_BITS(i, 16); LZX_READ_BITS(j, 8); -- lzx->block_remaining = lzx->block_length = (i << 8) | j; -- -- /* read individual block headers */ -- switch (lzx->block_type) { -- case LZX_BLOCKTYPE_ALIGNED: -- /* read lengths of and build aligned huffman decoding tree */ -- for (i = 0; i < 8; i++) { LZX_READ_BITS(j, 3); lzx->ALIGNED_len[i] = j; } -- LZX_BUILD_TABLE(ALIGNED); -- /* no break -- rest of aligned header is same as verbatim */ -- case LZX_BLOCKTYPE_VERBATIM: -- /* read lengths of and build main huffman decoding tree */ -- LZX_READ_LENGTHS(MAINTREE, 0, 256); -- LZX_READ_LENGTHS(MAINTREE, 256, LZX_NUM_CHARS + (lzx->posn_slots << 3)); -- LZX_BUILD_TABLE(MAINTREE); -- /* if the literal 0xE8 is anywhere in the block... */ -- if (lzx->MAINTREE_len[0xE8] != 0) lzx->intel_started = 1; -- /* read lengths of and build lengths huffman decoding tree */ -- LZX_READ_LENGTHS(LENGTH, 0, LZX_NUM_SECONDARY_LENGTHS); -- LZX_BUILD_TABLE(LENGTH); -- break; -- -- case LZX_BLOCKTYPE_UNCOMPRESSED: -- /* because we can't assume otherwise */ -- lzx->intel_started = 1; -- -- /* read 1-16 (not 0-15) bits to align to bytes */ -- LZX_ENSURE_BITS(16); -- if (bits_left > 16) i_ptr -= 2; -- bits_left = 0; bit_buffer = 0; -- -- /* read 12 bytes of stored R0 / R1 / R2 values */ -- for (rundest = &buf[0], i = 0; i < 12; i++) { -- if (i_ptr == i_end) { -- if (lzx_read_input(lzx)) return lzx->error; -- i_ptr = lzx->i_ptr; -- i_end = lzx->i_end; -- } -- *rundest++ = *i_ptr++; -- } -- R0 = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); -- R1 = buf[4] | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24); -- R2 = buf[8] | (buf[9] << 8) | (buf[10] << 16) | (buf[11] << 24); -- break; -- -- default: -- cli_dbgmsg("lzx_decompress: bad block type (0x%x)\n", lzx->block_type); -- return lzx->error = CL_EFORMAT; -- } -- } -- -- /* decode more of the block: -- * run = min(what's available, what's needed) */ -- this_run = lzx->block_remaining; -- if (this_run > bytes_todo) this_run = bytes_todo; -- -- /* assume we decode exactly this_run bytes, for now */ -- bytes_todo -= this_run; -- lzx->block_remaining -= this_run; -- -- /* decode at least this_run bytes */ -- switch (lzx->block_type) { -- case LZX_BLOCKTYPE_VERBATIM: -- while (this_run > 0) { -- LZX_READ_HUFFSYM(MAINTREE, main_element); -- if (main_element < LZX_NUM_CHARS) { -- /* literal: 0 to LZX_NUM_CHARS-1 */ -- window[window_posn++] = main_element; -- this_run--; -- } -- else { -- /* match: LZX_NUM_CHARS + ((slot<<3) | length_header (3 bits)) */ -- main_element -= LZX_NUM_CHARS; -- -- /* get match length */ -- match_length = main_element & LZX_NUM_PRIMARY_LENGTHS; -- if (match_length == LZX_NUM_PRIMARY_LENGTHS) { -- LZX_READ_HUFFSYM(LENGTH, length_footer); -- match_length += length_footer; -- } -- match_length += LZX_MIN_MATCH; -- -- /* get match offset */ -- switch ((match_offset = (main_element >> 3))) { -- case 0: match_offset = R0; break; -- case 1: match_offset = R1; R1=R0; R0 = match_offset; break; -- case 2: match_offset = R2; R2=R0; R0 = match_offset; break; -- case 3: match_offset = 1; R2=R1; R1=R0; R0 = match_offset; break; -- default: -- extra = lzx->extra_bits[match_offset]; -- LZX_READ_BITS(verbatim_bits, extra); -- match_offset = lzx->position_base[match_offset] - 2 + verbatim_bits; -- R2 = R1; R1 = R0; R0 = match_offset; -- } -- -- if ((window_posn + match_length) > lzx->window_size) { -- cli_dbgmsg("lzx_decompress: match ran over window wrap\n"); -- return lzx->error = CL_EFORMAT; -- } -- -- /* copy match */ -- rundest = &window[window_posn]; -- i = match_length; -- /* does match offset wrap the window? */ -- if (match_offset > window_posn) { -- /* j = length from match offset to end of window */ -- j = match_offset - window_posn; -- if (j > (int) lzx->window_size) { -- cli_dbgmsg("lzx_decompress: match offset beyond window boundaries\n"); -- return lzx->error = CL_EFORMAT; -- } -- runsrc = &window[lzx->window_size - j]; -- if (j < i) { -- /* if match goes over the window edge, do two copy runs */ -- i -= j; while (j-- > 0) *rundest++ = *runsrc++; -- runsrc = window; -- } -- while (i-- > 0) *rundest++ = *runsrc++; -- } -- else { -- runsrc = rundest - match_offset; -- if(i > (int) (lzx->window_size - window_posn)) -- i = lzx->window_size - window_posn; -- while (i-- > 0) *rundest++ = *runsrc++; -- } -- -- this_run -= match_length; -- window_posn += match_length; -- } -- } /* while (this_run > 0) */ -- break; -- -- case LZX_BLOCKTYPE_ALIGNED: -- while (this_run > 0) { -- LZX_READ_HUFFSYM(MAINTREE, main_element); -- if (main_element < LZX_NUM_CHARS) { -- /* literal: 0 to LZX_NUM_CHARS-1 */ -- window[window_posn++] = main_element; -- this_run--; -- } -- else { -- /* match: LZX_NUM_CHARS + ((slot<<3) | length_header (3 bits)) */ -- main_element -= LZX_NUM_CHARS; -- -- /* get match length */ -- match_length = main_element & LZX_NUM_PRIMARY_LENGTHS; -- if (match_length == LZX_NUM_PRIMARY_LENGTHS) { -- LZX_READ_HUFFSYM(LENGTH, length_footer); -- match_length += length_footer; -- } -- match_length += LZX_MIN_MATCH; -- -- /* get match offset */ -- switch ((match_offset = (main_element >> 3))) { -- case 0: match_offset = R0; break; -- case 1: match_offset = R1; R1 = R0; R0 = match_offset; break; -- case 2: match_offset = R2; R2 = R0; R0 = match_offset; break; -- default: -- extra = lzx->extra_bits[match_offset]; -- match_offset = lzx->position_base[match_offset] - 2; -- if (extra > 3) { -- /* verbatim and aligned bits */ -- extra -= 3; -- LZX_READ_BITS(verbatim_bits, extra); -- match_offset += (verbatim_bits << 3); -- LZX_READ_HUFFSYM(ALIGNED, aligned_bits); -- match_offset += aligned_bits; -- } -- else if (extra == 3) { -- /* aligned bits only */ -- LZX_READ_HUFFSYM(ALIGNED, aligned_bits); -- match_offset += aligned_bits; -- } -- else if (extra > 0) { /* extra==1, extra==2 */ -- /* verbatim bits only */ -- LZX_READ_BITS(verbatim_bits, extra); -- match_offset += verbatim_bits; -- } -- else /* extra == 0 */ { -- /* ??? not defined in LZX specification! */ -- match_offset = 1; -- } -- /* update repeated offset LRU queue */ -- R2 = R1; R1 = R0; R0 = match_offset; -- } -- -- if ((window_posn + match_length) > lzx->window_size) { -- cli_dbgmsg("lzx_decompress: match ran over window wrap\n"); -- return lzx->error = CL_EFORMAT; -- } -- -- /* copy match */ -- rundest = &window[window_posn]; -- i = match_length; -- /* does match offset wrap the window? */ -- if (match_offset > window_posn) { -- /* j = length from match offset to end of window */ -- j = match_offset - window_posn; -- if (j > (int) lzx->window_size) { -- cli_dbgmsg("lzx_decompress: match offset beyond window boundaries\n"); -- return lzx->error = CL_EFORMAT; -- } -- runsrc = &window[lzx->window_size - j]; -- if (j < i) { -- /* if match goes over the window edge, do two copy runs */ -- i -= j; while (j-- > 0) *rundest++ = *runsrc++; -- runsrc = window; -- } -- while (i-- > 0) *rundest++ = *runsrc++; -- } -- else { -- runsrc = rundest - match_offset; -- while (i-- > 0) *rundest++ = *runsrc++; -- } -- -- this_run -= match_length; -- window_posn += match_length; -- } -- } /* while (this_run > 0) */ -- break; -- -- case LZX_BLOCKTYPE_UNCOMPRESSED: -- /* as this_run is limited not to wrap a frame, this also means it -- * won't wrap the window (as the window is a multiple of 32k) */ -- rundest = &window[window_posn]; -- window_posn += this_run; -- while (this_run > 0) { -- if ((i = i_end - i_ptr)) { -- if (i > this_run) i = this_run; -- memcpy(rundest, i_ptr, (size_t) i); -- rundest += i; -- i_ptr += i; -- this_run -= i; -- } -- else { -- if (lzx_read_input(lzx)) return lzx->error; -- i_ptr = lzx->i_ptr; -- i_end = lzx->i_end; -- } -- } -- break; -- -- default: -- return lzx->error = CL_EFORMAT; /* might as well */ -- } -- -- /* did the final match overrun our desired this_run length? */ -- if (this_run < 0) { -- if ((unsigned int)(-this_run) > lzx->block_remaining) { -- cli_dbgmsg("lzx_decompress: overrun went past end of block by %d (%d remaining)\n", -this_run, lzx->block_remaining); -- return lzx->error = CL_EFORMAT; -- } -- lzx->block_remaining -= -this_run; -- } -- } /* while (bytes_todo > 0) */ -- -- /* streams don't extend over frame boundaries */ -- if ((window_posn - lzx->frame_posn) != frame_size) { -- cli_dbgmsg("lzx_decompress: decode beyond output frame limits! %d != %d\n", window_posn - lzx->frame_posn, frame_size); -- return lzx->error = CL_EFORMAT; -- } -- -- /* re-align input bitstream */ -- if (bits_left > 0) LZX_ENSURE_BITS(16); -- if (bits_left & 15) LZX_REMOVE_BITS(bits_left & 15); -- -- /* check that we've used all of the previous frame first */ -- if (lzx->o_ptr != lzx->o_end) { -- cli_dbgmsg("lzx_decompress: %d avail bytes, new %d frame\n", lzx->o_end-lzx->o_ptr, frame_size); -- return lzx->error = CL_EFORMAT; -- } -- -- /* does this intel block _really_ need decoding? */ -- if (lzx->intel_started && lzx->intel_filesize && -- (lzx->frame <= 32768) && (frame_size > 10)) -- { -- unsigned char *data = &lzx->e8_buf[0]; -- unsigned char *dataend = &lzx->e8_buf[frame_size - 10]; -- signed int curpos = lzx->intel_curpos; -- signed int filesize = lzx->intel_filesize; -- signed int abs_off, rel_off; -- -- /* copy e8 block to the e8 buffer and tweak if needed */ -- lzx->o_ptr = data; -- memcpy(data, &lzx->window[lzx->frame_posn], frame_size); -- -- while (data < dataend) { -- if (*data++ != 0xE8) { curpos++; continue; } -- abs_off = data[0] | (data[1]<<8) | (data[2]<<16) | (data[3]<<24); -- if ((abs_off >= -curpos) && (abs_off < filesize)) { -- rel_off = (abs_off >= 0) ? abs_off - curpos : abs_off + filesize; -- data[0] = (unsigned char) rel_off; -- data[1] = (unsigned char) (rel_off >> 8); -- data[2] = (unsigned char) (rel_off >> 16); -- data[3] = (unsigned char) (rel_off >> 24); -- } -- data += 4; -- curpos += 5; -- } -- lzx->intel_curpos += frame_size; -- } -- else { -- lzx->o_ptr = &lzx->window[lzx->frame_posn]; -- if (lzx->intel_filesize) lzx->intel_curpos += frame_size; -- } -- lzx->o_end = &lzx->o_ptr[frame_size]; -- -- /* write a frame */ -- i = (out_bytes < (off_t)frame_size) ? (unsigned int)out_bytes : frame_size; -- if (lzx->wflag && (ret = mspack_write(lzx->ofd, lzx->o_ptr, i, lzx->file)) != CL_SUCCESS) { -- return lzx->error = ret; -- } -- lzx->o_ptr += i; -- lzx->offset += i; -- out_bytes -= i; -- -- /* advance frame start position */ -- lzx->frame_posn += frame_size; -- lzx->frame++; -- -- /* wrap window / frame position pointers */ -- if (window_posn == lzx->window_size) window_posn = 0; -- if (lzx->frame_posn == lzx->window_size) lzx->frame_posn = 0; -- -- } /* while (lzx->frame < end_frame) */ -- -- if (out_bytes) -- cli_dbgmsg("lzx_decompress: bytes left to output\n"); -- -- /* store local state */ -- LZX_STORE_BITS; -- lzx->window_posn = window_posn; -- lzx->R0 = R0; -- lzx->R1 = R1; -- lzx->R2 = R2; -- -- return CL_SUCCESS; --} -- --void lzx_free(struct lzx_stream *lzx) { -- if (lzx) { -- free(lzx->inbuf); -- free(lzx->window); -- free(lzx); -- } --} -- --/*************************************************************************** -- * Quantum decompression implementation -- *************************************************************************** -- * The Quantum method was created by David Stafford, adapted by Microsoft -- * Corporation. -- * -- * This decompressor is based on an implementation by Matthew Russotto, used -- * with permission. -- * -- * This decompressor was researched and implemented by Matthew Russotto. It -- * has since been tidied up by Stuart Caie. More information can be found at -- * http://www.speakeasy.org/~russotto/quantumcomp.html -- */ -- --/* Quantum decompressor bitstream reading macros -- * -- * QTM_STORE_BITS stores bitstream state in qtm_stream structure -- * QTM_RESTORE_BITS restores bitstream state from qtm_stream structure -- * QTM_READ_BITS(var,n) takes N bits from the buffer and puts them in var -- * QTM_FILL_BUFFER if there is room for another 16 bits, reads another -- * 16 bits from the input stream. -- * QTM_PEEK_BITS(n) extracts without removing N bits from the bit buffer -- * QTM_REMOVE_BITS(n) removes N bits from the bit buffer -- * -- * These bit access routines work by using the area beyond the MSB and the -- * LSB as a free source of zeroes. This avoids having to mask any bits. -- * So we have to know the bit width of the bitbuffer variable. -- */ -- --#define QTM_BITBUF_WIDTH (sizeof(unsigned int) * CHAR_BIT) -- --#define QTM_STORE_BITS do { \ -- qtm->i_ptr = i_ptr; \ -- qtm->i_end = i_end; \ -- qtm->bit_buffer = bit_buffer; \ -- qtm->bits_left = bits_left; \ --} while (0) -- --#define QTM_RESTORE_BITS do { \ -- i_ptr = qtm->i_ptr; \ -- i_end = qtm->i_end; \ -- bit_buffer = qtm->bit_buffer; \ -- bits_left = qtm->bits_left; \ --} while (0) -- --/* adds 16 bits to bit buffer, if there's space for the new bits */ --#define QTM_FILL_BUFFER do { \ -- if (bits_left <= (QTM_BITBUF_WIDTH - 16)) { \ -- if (i_ptr >= i_end) { \ -- if (qtm_read_input(qtm)) return qtm->error; \ -- i_ptr = qtm->i_ptr; \ -- i_end = qtm->i_end; \ -- } \ -- bit_buffer |= ((i_ptr[0] << 8) | i_ptr[1]) \ -- << (QTM_BITBUF_WIDTH - 16 - bits_left); \ -- bits_left += 16; \ -- i_ptr += 2; \ -- } \ --} while (0) -- --#define QTM_PEEK_BITS(n) (bit_buffer >> (QTM_BITBUF_WIDTH - (n))) --#define QTM_REMOVE_BITS(n) ((bit_buffer <<= (n)), (bits_left -= (n))) -- --#define QTM_READ_BITS(val, bits) do { \ -- (val) = 0; \ -- for (bits_needed = (bits); bits_needed > 0; bits_needed -= bit_run) { \ -- QTM_FILL_BUFFER; \ -- bit_run = (bits_left < bits_needed) ? bits_left : bits_needed; \ -- (val) = ((val) << bit_run) | QTM_PEEK_BITS(bit_run); \ -- QTM_REMOVE_BITS(bit_run); \ -- } \ --} while (0) -- --static int qtm_read_input(struct qtm_stream *qtm) { -- int nread = qtm->read_cb(qtm->file, &qtm->inbuf[0], (int)qtm->inbuf_size); -- if (nread < 0) { -- if (qtm->file->error == CL_BREAK) -- return qtm->error = CL_BREAK; -- else -- return qtm->error = CL_EFORMAT; -- } -- -- if (nread == 0) { -- if (qtm->input_end) { -- cli_dbgmsg("qtm_read_input: out of input bytes\n"); -- return qtm->error = CL_EREAD; -- } -- else { -- nread = 2; -- qtm->inbuf[0] = qtm->inbuf[1] = 0; -- qtm->input_end = 1; -- } -- } -- -- qtm->i_ptr = &qtm->inbuf[0]; -- qtm->i_end = &qtm->inbuf[nread]; -- return CL_SUCCESS; --} -- --/* Arithmetic decoder: -- * -- * QTM_GET_SYMBOL(model, var) fetches the next symbol from the stated model -- * and puts it in var. -- * -- * If necessary, qtm_update_model() is called. -- */ --#define QTM_GET_SYMBOL(model, var) do { \ -- range = ((H - L) & 0xFFFF) + 1; \ -- symf = ((((C - L + 1) * model.syms[0].cumfreq)-1) / range) & 0xFFFF; \ -- \ -- for (i = 1; i < model.entries; i++) { \ -- if (model.syms[i].cumfreq <= symf) break; \ -- } \ -- (var) = model.syms[i-1].sym; \ -- \ -- range = (H - L) + 1; \ -- symf = model.syms[0].cumfreq; \ -- H = L + ((model.syms[i-1].cumfreq * range) / symf) - 1; \ -- L = L + ((model.syms[i].cumfreq * range) / symf); \ -- \ -- do { model.syms[--i].cumfreq += 8; } while (i > 0); \ -- if (model.syms[0].cumfreq > 3800) qtm_update_model(&model); \ -- \ -- while (1) { \ -- if ((L & 0x8000) != (H & 0x8000)) { \ -- if ((L & 0x4000) && !(H & 0x4000)) { \ -- /* underflow case */ \ -- C ^= 0x4000; L &= 0x3FFF; H |= 0x4000; \ -- } \ -- else break; \ -- } \ -- L <<= 1; H = (H << 1) | 1; \ -- QTM_FILL_BUFFER; \ -- C = (C << 1) | QTM_PEEK_BITS(1); \ -- QTM_REMOVE_BITS(1); \ -- } \ --} while (0) -- --static void qtm_update_model(struct qtm_model *model) { -- struct qtm_modelsym tmp; -- int i, j; -- -- if (--model->shiftsleft) { -- for (i = model->entries - 1; i >= 0; i--) { -- /* -1, not -2; the 0 entry saves this */ -- model->syms[i].cumfreq >>= 1; -- if (model->syms[i].cumfreq <= model->syms[i+1].cumfreq) { -- model->syms[i].cumfreq = model->syms[i+1].cumfreq + 1; -- } -- } -- } -- else { -- model->shiftsleft = 50; -- for (i = 0; i < model->entries; i++) { -- /* no -1, want to include the 0 entry */ -- /* this converts cumfreqs into frequencies, then shifts right */ -- model->syms[i].cumfreq -= model->syms[i+1].cumfreq; -- model->syms[i].cumfreq++; /* avoid losing things entirely */ -- model->syms[i].cumfreq >>= 1; -- } -- -- /* now sort by frequencies, decreasing order -- this must be an -- * inplace selection sort, or a sort with the same (in)stability -- * characteristics */ -- for (i = 0; i < model->entries - 1; i++) { -- for (j = i + 1; j < model->entries; j++) { -- if (model->syms[i].cumfreq < model->syms[j].cumfreq) { -- tmp = model->syms[i]; -- model->syms[i] = model->syms[j]; -- model->syms[j] = tmp; -- } -- } -- } -- -- /* then convert frequencies back to cumfreq */ -- for (i = model->entries - 1; i >= 0; i--) { -- model->syms[i].cumfreq += model->syms[i+1].cumfreq; -- } -- } --} -- --/* Initialises a model to decode symbols from [start] to [start]+[len]-1 */ --static void qtm_init_model(struct qtm_model *model, -- struct qtm_modelsym *syms, int start, int len) --{ -- int i; -- -- model->shiftsleft = 4; -- model->entries = len; -- model->syms = syms; -- -- for (i = 0; i <= len; i++) { -- syms[i].sym = start + i; /* actual symbol */ -- syms[i].cumfreq = len - i; /* current frequency of that symbol */ -- } --} -- -- --/*-------- main Quantum code --------*/ -- --struct qtm_stream *qtm_init(int ofd, -- int window_bits, int input_buffer_size, -- struct cab_file *file, -- int (*read_cb)(struct cab_file *, unsigned char *, int)) --{ -- unsigned int window_size = 1 << window_bits; -- struct qtm_stream *qtm; -- unsigned offset; -- int i; -- -- /* Quantum supports window sizes of 2^10 (1Kb) through 2^21 (2Mb) */ -- -- /* tk: temporary fix: only process 32KB+ window sizes */ -- if (window_bits < 15 || window_bits > 21) return NULL; -- -- input_buffer_size = (input_buffer_size + 1) & -2; -- if (input_buffer_size < 2) return NULL; -- -- /* allocate decompression state */ -- if (!(qtm = cli_calloc(1, sizeof(struct qtm_stream)))) { -- return NULL; -- } -- -- for (i = 0, offset = 0; i < 42; i++) { -- qtm->position_base[i] = offset; -- qtm->extra_bits[i] = ((i < 2) ? 0 : (i - 2)) >> 1; -- offset += 1 << qtm->extra_bits[i]; -- } -- -- for (i = 0, offset = 0; i < 26; i++) { -- qtm->length_base[i] = offset; -- qtm->length_extra[i] = (i < 2 ? 0 : i - 2) >> 2; -- offset += 1 << qtm->length_extra[i]; -- } -- qtm->length_base[26] = 254; qtm->length_extra[26] = 0; -- -- /* allocate decompression window and input buffer */ -- qtm->window = cli_calloc(1, (size_t) window_size); -- if (!qtm->window) { -- cli_errmsg("qtm_init: Unable to allocate decompression window\n"); -- free(qtm); -- return NULL; -- } -- -- qtm->inbuf = cli_calloc(1, (size_t) input_buffer_size); -- if (!qtm->inbuf) { -- cli_errmsg("qtm_init: Unable to allocate input buffer\n"); -- free(qtm->window); -- free(qtm); -- return NULL; -- } -- -- /* initialise decompression state */ -- qtm->ofd = ofd; -- qtm->wflag = 1; -- qtm->inbuf_size = input_buffer_size; -- qtm->window_size = window_size; -- qtm->window_posn = 0; -- qtm->frame_start = 0; -- qtm->header_read = 0; -- qtm->error = CL_SUCCESS; -- -- qtm->i_ptr = qtm->i_end = &qtm->inbuf[0]; -- qtm->o_ptr = qtm->o_end = &qtm->window[0]; -- qtm->bits_left = 0; -- qtm->bit_buffer = 0; -- -- /* initialise arithmetic coding models -- * - model 4 depends on window size, ranges from 20 to 24 -- * - model 5 depends on window size, ranges from 20 to 36 -- * - model 6pos depends on window size, ranges from 20 to 42 -- */ -- i = window_bits * 2; -- qtm_init_model(&qtm->model0, &qtm->m0sym[0], 0, 64); -- qtm_init_model(&qtm->model1, &qtm->m1sym[0], 64, 64); -- qtm_init_model(&qtm->model2, &qtm->m2sym[0], 128, 64); -- qtm_init_model(&qtm->model3, &qtm->m3sym[0], 192, 64); -- qtm_init_model(&qtm->model4, &qtm->m4sym[0], 0, (i > 24) ? 24 : i); -- qtm_init_model(&qtm->model5, &qtm->m5sym[0], 0, (i > 36) ? 36 : i); -- qtm_init_model(&qtm->model6, &qtm->m6sym[0], 0, i); -- qtm_init_model(&qtm->model6len, &qtm->m6lsym[0], 0, 27); -- qtm_init_model(&qtm->model7, &qtm->m7sym[0], 0, 7); -- -- qtm->file = file; -- qtm->read_cb = read_cb; -- -- /* all ok */ -- return qtm; --} -- --int qtm_decompress(struct qtm_stream *qtm, uint32_t out_bytes) { -- unsigned int frame_start, frame_end, window_posn, match_offset, range; -- unsigned char *window, *i_ptr, *i_end, *runsrc, *rundest; -- int i, j, selector, extra, sym, match_length, ret; -- unsigned short H, L, C, symf; -- -- register unsigned int bit_buffer; -- register unsigned char bits_left; -- unsigned char bits_needed, bit_run; -- -- /* easy answers */ -- if (!qtm) return CL_ENULLARG; -- if (qtm->error) return qtm->error; -- -- /* flush out any stored-up bytes before we begin */ -- i = qtm->o_end - qtm->o_ptr; -- if (((off_t) i > out_bytes) && ((int) out_bytes >= 0)) i = (int) out_bytes; -- if (i) { -- if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) { -- return qtm->error = ret; -- } -- qtm->o_ptr += i; -- out_bytes -= i; -- } -- if (out_bytes == 0) return CL_SUCCESS; -- -- /* restore local state */ -- QTM_RESTORE_BITS; -- window = qtm->window; -- window_posn = qtm->window_posn; -- frame_start = qtm->frame_start; -- H = qtm->H; -- L = qtm->L; -- C = qtm->C; -- -- /* while we do not have enough decoded bytes in reserve: */ -- while ((qtm->o_end - qtm->o_ptr) < out_bytes) { -- -- /* read header if necessary. Initialises H, L and C */ -- if (!qtm->header_read) { -- H = 0xFFFF; L = 0; QTM_READ_BITS(C, 16); -- qtm->header_read = 1; -- } -- -- /* decode more, at most up to to frame boundary */ -- frame_end = window_posn + (out_bytes - (qtm->o_end - qtm->o_ptr)); -- if ((frame_start + QTM_FRAME_SIZE) < frame_end) { -- frame_end = frame_start + QTM_FRAME_SIZE; -- } -- if (frame_end < window_posn) { -- cli_dbgmsg("qtm_decompress: window position beyond end of frame\n"); -- return qtm->error = CL_EFORMAT; -- } -- -- while (window_posn < frame_end) { -- QTM_GET_SYMBOL(qtm->model7, selector); -- if (selector < 4) { -- struct qtm_model *mdl = (selector == 0) ? &qtm->model0 : -- ((selector == 1) ? &qtm->model1 : -- ((selector == 2) ? &qtm->model2 : -- &qtm->model3)); -- QTM_GET_SYMBOL((*mdl), sym); -- window[window_posn++] = sym; -- } -- else { -- switch (selector) { -- case 4: /* selector 4 = fixed length match (3 bytes) */ -- QTM_GET_SYMBOL(qtm->model4, sym); -- QTM_READ_BITS(extra, qtm->extra_bits[sym]); -- match_offset = qtm->position_base[sym] + extra + 1; -- match_length = 3; -- break; -- -- case 5: /* selector 5 = fixed length match (4 bytes) */ -- QTM_GET_SYMBOL(qtm->model5, sym); -- QTM_READ_BITS(extra, qtm->extra_bits[sym]); -- match_offset = qtm->position_base[sym] + extra + 1; -- match_length = 4; -- break; -- -- case 6: /* selector 6 = variable length match */ -- QTM_GET_SYMBOL(qtm->model6len, sym); -- QTM_READ_BITS(extra, qtm->length_extra[sym]); -- match_length = qtm->length_base[sym] + extra + 5; -- -- QTM_GET_SYMBOL(qtm->model6, sym); -- QTM_READ_BITS(extra, qtm->extra_bits[sym]); -- match_offset = qtm->position_base[sym] + extra + 1; -- break; -- -- default: -- /* should be impossible, model7 can only return 0-6 */ -- return qtm->error = CL_EFORMAT; -- } -- -- if (window_posn + match_length > qtm->window_size) { -- cli_dbgmsg("qtm_decompress: match ran over window wrap\n"); -- return qtm->error = CL_EFORMAT; -- } -- -- rundest = &window[window_posn]; -- i = match_length; -- /* does match offset wrap the window? */ -- if (match_offset > window_posn) { -- /* j = length from match offset to end of window */ -- j = match_offset - window_posn; -- if (j > (int) qtm->window_size) { -- cli_dbgmsg("qtm_decompress: match offset beyond window boundaries\n"); -- return qtm->error = CL_EFORMAT; -- } -- runsrc = &window[qtm->window_size - j]; -- if (j < i) { -- /* if match goes over the window edge, do two copy runs */ -- i -= j; while (j-- > 0) *rundest++ = *runsrc++; -- runsrc = window; -- } -- while (i-- > 0) *rundest++ = *runsrc++; -- } -- else { -- runsrc = rundest - match_offset; -- if(i > (int) (qtm->window_size - window_posn)) -- i = qtm->window_size - window_posn; -- while (i-- > 0) *rundest++ = *runsrc++; -- } -- window_posn += match_length; -- } -- } /* while (window_posn < frame_end) */ -- -- qtm->o_end = &window[window_posn]; -- -- /* another frame completed? */ -- if ((window_posn - frame_start) >= QTM_FRAME_SIZE) { -- if ((window_posn - frame_start) != QTM_FRAME_SIZE) { -- cli_dbgmsg("qtm_decompress: overshot frame alignment\n"); -- return qtm->error = CL_EFORMAT; -- } -- -- /* re-align input */ -- if (bits_left & 7) QTM_REMOVE_BITS(bits_left & 7); -- do { QTM_READ_BITS(i, 8); } while (i != 0xFF); -- qtm->header_read = 0; -- -- /* window wrap? */ -- if (window_posn == qtm->window_size) { -- /* flush all currently stored data */ -- i = (qtm->o_end - qtm->o_ptr); -- if(i <= 0) -- break; -- if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) { -- return qtm->error = ret; -- } -- out_bytes -= i; -- qtm->o_ptr = &window[0]; -- qtm->o_end = &window[0]; -- window_posn = 0; -- } -- -- frame_start = window_posn; -- } -- -- } /* while (more bytes needed) */ -- -- if (out_bytes > 0) { -- i = (int) out_bytes; -- if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) { -- return qtm->error = ret; -- } -- qtm->o_ptr += i; -- } -- -- /* store local state */ -- QTM_STORE_BITS; -- qtm->window_posn = window_posn; -- qtm->frame_start = frame_start; -- qtm->H = H; -- qtm->L = L; -- qtm->C = C; -- -- return CL_SUCCESS; --} -- --void qtm_free(struct qtm_stream *qtm) { -- if (qtm) { -- free(qtm->window); -- free(qtm->inbuf); -- free(qtm); -- } --} -diff --git a/libclamav/mspack.h b/libclamav/mspack.h -deleted file mode 100644 -index 0ed472c..0000000 ---- a/libclamav/mspack.h -+++ /dev/null -@@ -1,294 +0,0 @@ --/* -- * This file includes code from libmspack adapted for libclamav by -- * tkojm@clamav.net -- * -- * Copyright (C) 2003-2004 Stuart Caie -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Lesser General Public -- * License version 2.1 as published by the Free Software Foundation. -- * -- * 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 -- * Lesser General Public License for more details. -- * -- * You should have received a copy of the GNU Lesser General Public -- * License along with this library; if not, write to the Free Software -- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 -- * USA -- */ -- --#ifndef __MSPACK_H --#define __MSPACK_H -- --#include --#include "cab.h" -- -- --/*************************************************************************** -- * MS-ZIP decompression definitions * -- ***************************************************************************/ -- --#define MSZIP_FRAME_SIZE (32768) /* size of LZ history window */ --#define MSZIP_MAX_HUFFBITS (16) /* maximum huffman code length */ --#define MSZIP_LITERAL_MAXSYMBOLS (288) /* literal/length huffman tree */ --#define MSZIP_LITERAL_TABLEBITS (9) --#define MSZIP_DISTANCE_MAXSYMBOLS (32) /* distance huffman tree */ --#define MSZIP_DISTANCE_TABLEBITS (6) -- --/* if there are less direct lookup entries than symbols, the longer -- * code pointers will be <= maxsymbols. This must not happen, or we -- * will decode entries badly */ --#if (1 << MSZIP_LITERAL_TABLEBITS) < (MSZIP_LITERAL_MAXSYMBOLS * 2) --# define MSZIP_LITERAL_TABLESIZE (MSZIP_LITERAL_MAXSYMBOLS * 4) --#else --# define MSZIP_LITERAL_TABLESIZE ((1 << MSZIP_LITERAL_TABLEBITS) + \ -- (MSZIP_LITERAL_MAXSYMBOLS * 2)) --#endif -- --#if (1 << MSZIP_DISTANCE_TABLEBITS) < (MSZIP_DISTANCE_MAXSYMBOLS * 2) --# define MSZIP_DISTANCE_TABLESIZE (MSZIP_DISTANCE_MAXSYMBOLS * 4) --#else --# define MSZIP_DISTANCE_TABLESIZE ((1 << MSZIP_DISTANCE_TABLEBITS) + \ -- (MSZIP_DISTANCE_MAXSYMBOLS * 2)) --#endif -- --struct mszip_stream { -- int ofd; /* output file descriptor */ -- -- /* inflate() will call this whenever the window should be emptied. */ -- int (*flush_window)(struct mszip_stream *, unsigned int); -- -- int error, repair_mode, bytes_output, input_end; -- -- /* I/O buffering */ -- unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end; -- unsigned int bit_buffer, bits_left, inbuf_size; -- -- unsigned int window_posn; /* offset within window */ -- -- /* huffman code lengths */ -- unsigned char LITERAL_len[MSZIP_LITERAL_MAXSYMBOLS]; -- unsigned char DISTANCE_len[MSZIP_DISTANCE_MAXSYMBOLS]; -- -- /* huffman decoding tables */ -- unsigned short LITERAL_table [MSZIP_LITERAL_TABLESIZE]; -- unsigned short DISTANCE_table[MSZIP_DISTANCE_TABLESIZE]; -- -- /* 32kb history window */ -- unsigned char window[MSZIP_FRAME_SIZE]; -- -- /* cabinet related stuff */ -- struct cab_file *file; -- int (*read_cb)(struct cab_file *, unsigned char *, int); -- -- unsigned char wflag; /* write flag */ -- unsigned int last; /* prior end of content buffer */ -- --}; -- --struct mszip_stream *mszip_init(int ofd, -- int input_buffer_size, -- int repair_mode, -- struct cab_file *file, -- int (*read_cb)(struct cab_file *, unsigned char *, int)); -- --extern int mszip_decompress(struct mszip_stream *zip, uint32_t out_bytes); -- --void mszip_free(struct mszip_stream *zip); -- -- --/*************************************************************************** -- * Quantum decompression definitions * -- ***************************************************************************/ -- --/* Quantum compression / decompression definitions */ -- --#define QTM_FRAME_SIZE (32768) -- --struct qtm_modelsym { -- unsigned short sym, cumfreq; --}; -- --struct qtm_model { -- int shiftsleft, entries; -- struct qtm_modelsym *syms; --}; -- --struct qtm_stream { -- int ofd; /* output file descriptor */ -- -- unsigned char *window; /* decoding window */ -- unsigned int window_size; /* window size */ -- unsigned int window_posn; /* decompression offset within window */ -- unsigned int frame_start; /* start of current frame within window */ -- -- unsigned short H, L, C; /* high/low/current: arith coding state */ -- unsigned char header_read; /* have we started decoding a new frame? */ -- unsigned char wflag; /* write flag */ -- -- int error, input_end; -- -- /* data tables */ -- unsigned int position_base[42]; -- unsigned char extra_bits[42], length_base[27], length_extra[27]; -- -- /* four literal models, each representing 64 symbols -- * model0 for literals from 0 to 63 (selector = 0) -- * model1 for literals from 64 to 127 (selector = 1) -- * model2 for literals from 128 to 191 (selector = 2) -- * model3 for literals from 129 to 255 (selector = 3) */ -- struct qtm_model model0, model1, model2, model3; -- -- /* three match models. -- * model4 for match with fixed length of 3 bytes -- * model5 for match with fixed length of 4 bytes -- * model6 for variable length match, encoded with model6len model */ -- struct qtm_model model4, model5, model6, model6len; -- -- /* selector model. 0-6 to say literal (0,1,2,3) or match (4,5,6) */ -- struct qtm_model model7; -- -- /* symbol arrays for all models */ -- struct qtm_modelsym m0sym[64 + 1]; -- struct qtm_modelsym m1sym[64 + 1]; -- struct qtm_modelsym m2sym[64 + 1]; -- struct qtm_modelsym m3sym[64 + 1]; -- struct qtm_modelsym m4sym[24 + 1]; -- struct qtm_modelsym m5sym[36 + 1]; -- struct qtm_modelsym m6sym[42 + 1], m6lsym[27 + 1]; -- struct qtm_modelsym m7sym[7 + 1]; -- -- /* I/O buffers - 1*/ -- unsigned int bit_buffer; -- -- /* cabinet related stuff */ -- struct cab_file *file; -- int (*read_cb)(struct cab_file *, unsigned char *, int); -- -- /* I/O buffers - 2*/ -- unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end; -- unsigned int inbuf_size; -- unsigned char bits_left; -- --}; -- --extern struct qtm_stream *qtm_init(int ofd, -- int window_bits, -- int input_buffer_size, -- struct cab_file *file, -- int (*read_cb)(struct cab_file *, unsigned char *, int)); -- --extern int qtm_decompress(struct qtm_stream *qtm, uint32_t out_bytes); -- --void qtm_free(struct qtm_stream *qtm); -- --/*************************************************************************** -- * LZX decompression definitions * -- ***************************************************************************/ -- --/* some constants defined by the LZX specification */ --#define LZX_MIN_MATCH (2) --#define LZX_MAX_MATCH (257) --#define LZX_NUM_CHARS (256) --#define LZX_BLOCKTYPE_INVALID (0) /* also blocktypes 4-7 invalid */ --#define LZX_BLOCKTYPE_VERBATIM (1) --#define LZX_BLOCKTYPE_ALIGNED (2) --#define LZX_BLOCKTYPE_UNCOMPRESSED (3) --#define LZX_PRETREE_NUM_ELEMENTS (20) --#define LZX_ALIGNED_NUM_ELEMENTS (8) /* aligned offset tree #elements */ --#define LZX_NUM_PRIMARY_LENGTHS (7) /* this one missing from spec! */ --#define LZX_NUM_SECONDARY_LENGTHS (249) /* length tree #elements */ -- --/* LZX huffman defines: tweak tablebits as desired */ --#define LZX_PRETREE_MAXSYMBOLS (LZX_PRETREE_NUM_ELEMENTS) --#define LZX_PRETREE_TABLEBITS (6) --#define LZX_MAINTREE_MAXSYMBOLS (LZX_NUM_CHARS + 50*8) --#define LZX_MAINTREE_TABLEBITS (12) --#define LZX_LENGTH_MAXSYMBOLS (LZX_NUM_SECONDARY_LENGTHS+1) --#define LZX_LENGTH_TABLEBITS (12) --#define LZX_ALIGNED_MAXSYMBOLS (LZX_ALIGNED_NUM_ELEMENTS) --#define LZX_ALIGNED_TABLEBITS (7) --#define LZX_LENTABLE_SAFETY (64) /* table decoding overruns are allowed */ -- --#define LZX_FRAME_SIZE (32768) /* the size of a frame in LZX */ -- --struct lzx_stream { -- int ofd; /* output file descriptor */ -- -- off_t offset; /* number of bytes actually output */ -- off_t length; /* overall decompressed length of stream */ -- -- unsigned char *window; /* decoding window */ -- unsigned int window_size; /* window size */ -- unsigned int window_posn; /* decompression offset within window */ -- unsigned int frame_posn; /* current frame offset within in window */ -- unsigned int frame; /* the number of 32kb frames processed */ -- unsigned int reset_interval; /* which frame do we reset the compressor? */ -- -- unsigned int R0, R1, R2; /* for the LRU offset system */ -- unsigned int block_length; /* uncompressed length of this LZX block */ -- unsigned int block_remaining; /* uncompressed bytes still left to decode */ -- -- signed int intel_filesize; /* magic header value used for transform */ -- signed int intel_curpos; /* current offset in transform space */ -- -- unsigned char intel_started; /* has intel E8 decoding started? */ -- unsigned char block_type; /* type of the current block */ -- unsigned char header_read; /* have we started decoding at all yet? */ -- unsigned char posn_slots; /* how many posn slots in stream? */ -- -- int error; -- -- /* I/O buffering */ -- unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end; -- unsigned int bit_buffer, bits_left, inbuf_size; -- -- /* huffman code lengths */ -- unsigned char PRETREE_len [LZX_PRETREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; -- unsigned char MAINTREE_len [LZX_MAINTREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; -- unsigned char LENGTH_len [LZX_LENGTH_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; -- unsigned char ALIGNED_len [LZX_ALIGNED_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; -- -- /* huffman decoding tables */ -- unsigned short PRETREE_table [(1 << LZX_PRETREE_TABLEBITS) + -- (LZX_PRETREE_MAXSYMBOLS * 2)]; -- unsigned short MAINTREE_table[(1 << LZX_MAINTREE_TABLEBITS) + -- (LZX_MAINTREE_MAXSYMBOLS * 2)]; -- unsigned short LENGTH_table [(1 << LZX_LENGTH_TABLEBITS) + -- (LZX_LENGTH_MAXSYMBOLS * 2)]; -- unsigned short ALIGNED_table [(1 << LZX_ALIGNED_TABLEBITS) + -- (LZX_ALIGNED_MAXSYMBOLS * 2)]; -- unsigned char input_end; /* have we reached the end of input? */ -- unsigned char wflag; /* write flag */ -- -- /* this is used purely for doing the intel E8 transform */ -- unsigned char e8_buf[LZX_FRAME_SIZE]; -- -- unsigned int position_base[51]; -- -- /* cabinet related stuff */ -- struct cab_file *file; -- int (*read_cb)(struct cab_file *, unsigned char *, int); -- -- unsigned char extra_bits[51]; -- --}; -- --struct lzx_stream *lzx_init(int ofd, -- int window_bits, -- int reset_interval, -- int input_buffer_size, -- off_t output_length, -- struct cab_file *file, -- int (*read_cb)(struct cab_file *, unsigned char *, int)); -- --extern void lzx_set_output_length(struct lzx_stream *lzx, -- off_t output_length); -- --extern int lzx_decompress(struct lzx_stream *lzx, uint32_t out_bytes); -- --void lzx_free(struct lzx_stream *lzx); -- --#endif -diff --git a/libclamav/scanners.c b/libclamav/scanners.c -index ed0bbf0..e104d2f 100644 ---- a/libclamav/scanners.c -+++ b/libclamav/scanners.c -@@ -61,7 +61,7 @@ - #include "vba_extract.h" - #include "msexpand.h" - #include "mbox.h" --#include "chmunpack.h" -+#include "libmspack.h" - #include "pe.h" - #include "elf.h" - #include "filetypes.h" -@@ -74,8 +74,6 @@ - #include "sis.h" - #include "pdf.h" - #include "str.h" --#include "mspack.h" --#include "cab.h" - #include "rtf.h" - #include "unarj.h" - #include "nsis/nulsft.h" -@@ -863,82 +861,6 @@ static int cli_scanszdd(cli_ctx *ctx) - return ret; - } - --static int cli_scanmscab(cli_ctx *ctx, off_t sfx_offset) --{ -- char *tempname; -- int ret; -- unsigned int files = 0; -- struct cab_archive cab; -- struct cab_file *file; -- unsigned int corrupted_input; -- unsigned int viruses_found = 0; -- -- cli_dbgmsg("in cli_scanmscab()\n"); -- -- if((ret = cab_open(*ctx->fmap, sfx_offset, &cab))) -- return ret; -- -- for(file = cab.files; file; file = file->next) { -- files++; -- -- if(cli_matchmeta(ctx, file->name, 0, file->length, 0, files, 0, NULL) == CL_VIRUS) { -- if (!SCAN_ALL) { -- ret = CL_VIRUS; -- break; -- } -- viruses_found++; -- } -- -- if(ctx->engine->maxscansize && ctx->scansize >= ctx->engine->maxscansize) { -- ret = CL_CLEAN; -- break; -- } -- -- if(!(tempname = cli_gentemp(ctx->engine->tmpdir))) { -- ret = CL_EMEM; -- break; -- } -- -- if(ctx->engine->maxscansize && ctx->scansize + ctx->engine->maxfilesize >= ctx->engine->maxscansize) -- file->max_size = ctx->engine->maxscansize - ctx->scansize; -- else -- file->max_size = ctx->engine->maxfilesize ? ctx->engine->maxfilesize : 0xffffffff; -- -- cli_dbgmsg("CAB: Extracting file %s to %s, size %u, max_size: %u\n", file->name, tempname, file->length, (unsigned int) file->max_size); -- file->written_size = 0; -- if((ret = cab_extract(file, tempname))) { -- cli_dbgmsg("CAB: Failed to extract file: %s\n", cl_strerror(ret)); -- } else { -- corrupted_input = ctx->corrupted_input; -- if(file->length != file->written_size) { -- cli_dbgmsg("CAB: Length from header %u but wrote %u bytes\n", (unsigned int) file->length, (unsigned int) file->written_size); -- ctx->corrupted_input = 1; -- } -- ret = cli_scanfile(tempname, ctx); -- ctx->corrupted_input = corrupted_input; -- } -- if(!ctx->engine->keeptmp) { -- if (!access(tempname, R_OK) && cli_unlink(tempname)) { -- free(tempname); -- ret = CL_EUNLINK; -- break; -- } -- } -- free(tempname); -- if(ret == CL_VIRUS) { -- if (SCAN_ALL) -- viruses_found++; -- else -- break; -- } -- } -- -- cab_free(&cab); -- if (viruses_found) -- return CL_VIRUS; -- return ret; --} -- - static int vba_scandata(const unsigned char *data, unsigned int len, cli_ctx *ctx) - { - struct cli_matcher *groot = ctx->engine->root[0]; -@@ -1628,72 +1550,6 @@ static int cli_scantar(cli_ctx *ctx, unsigned int posix) - return ret; - } - --static int cli_scanmschm(cli_ctx *ctx) --{ -- int ret = CL_CLEAN, rc; -- chm_metadata_t metadata; -- char *dir; -- unsigned int viruses_found = 0; -- -- cli_dbgmsg("in cli_scanmschm()\n"); -- -- /* generate the temporary directory */ -- if(!(dir = cli_gentemp(ctx->engine->tmpdir))) -- return CL_EMEM; -- -- if(mkdir(dir, 0700)) { -- cli_dbgmsg("CHM: Can't create temporary directory %s\n", dir); -- free(dir); -- return CL_ETMPDIR; -- } -- -- ret = cli_chm_open(dir, &metadata, ctx); -- if (ret != CL_SUCCESS) { -- if(!ctx->engine->keeptmp) -- cli_rmdirs(dir); -- free(dir); -- cli_dbgmsg("CHM: Error: %s\n", cl_strerror(ret)); -- return ret; -- } -- -- do { -- ret = cli_chm_prepare_file(&metadata); -- if (ret != CL_SUCCESS) { -- break; -- } -- ret = cli_chm_extract_file(dir, &metadata, ctx); -- if (ret == CL_SUCCESS) { -- rc = cli_magic_scandesc(metadata.ofd, ctx); -- close(metadata.ofd); -- if (rc == CL_VIRUS) { -- cli_dbgmsg("CHM: infected with %s\n", cli_get_last_virus(ctx)); -- if (SCAN_ALL) -- viruses_found++; -- else { -- ret = CL_VIRUS; -- break; -- } -- } -- } -- -- } while(ret == CL_SUCCESS); -- -- cli_chm_close(&metadata); -- -- if(!ctx->engine->keeptmp) -- cli_rmdirs(dir); -- -- free(dir); -- -- cli_dbgmsg("CHM: Exit code: %d\n", ret); -- if (ret == CL_BREAK) -- ret = CL_CLEAN; -- -- if (SCAN_ALL && viruses_found) -- return CL_VIRUS; -- return ret; --} -- - static int cli_scanscrenc(cli_ctx *ctx) - { - char *tempname; diff -Nru clamav-0.99.2+dfsg/debian/patches/make_it_compile_against_openssl_1_1_0.patch clamav-0.99.3~beta1+dfsg/debian/patches/make_it_compile_against_openssl_1_1_0.patch --- clamav-0.99.2+dfsg/debian/patches/make_it_compile_against_openssl_1_1_0.patch 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/make_it_compile_against_openssl_1_1_0.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -From 088af365ce4f715b9f1d41754651e01db6ebf39a Mon Sep 17 00:00:00 2001 -From: Sebastian Andrzej Siewior -Date: Sat, 2 Jul 2016 00:12:01 +0200 -Subject: make it compile against openssl 1.1.0 - -- SSL_library_init() is no longer a function but a define invoking - another function with parameters. Thus a link check against this - function will fail. As a fix AC_LINK_IFELSE is used so the header file - can be included. - -- X509_CRL is opaque and needs an accessor. X509_CRL_get_nextUpdate() is - around since OpenSSL 0.9.1c. X509_cmp_current_time() seems to be - around since SSLeay 0.8.1b. - -BTS: https://bugs.debian.org/828083 -clamav: https://bugzilla.clamav.net/show_bug.cgi?id=11594 -Patch-Name: make_it_compile_against_openssl_1_1_0.patch - -Signed-off-by: Sebastian Andrzej Siewior ---- - libclamav/crypto.c | 21 ++++++--------------- - m4/reorganization/libs/openssl.m4 | 12 +++++++++--- - 2 files changed, 15 insertions(+), 18 deletions(-) - -diff --git a/libclamav/crypto.c b/libclamav/crypto.c -index c62c65a..4be900f 100644 ---- a/libclamav/crypto.c -+++ b/libclamav/crypto.c -@@ -1096,7 +1096,6 @@ X509_CRL *cl_load_crl(const char *file) - { - X509_CRL *x=NULL; - FILE *fp; -- struct tm *tm; - - if (!(file)) - return NULL; -@@ -1110,21 +1109,13 @@ X509_CRL *cl_load_crl(const char *file) - fclose(fp); - - if ((x)) { -- tm = cl_ASN1_GetTimeT(x->crl->nextUpdate); -- if (!(tm)) { -- X509_CRL_free(x); -- return NULL; -- } -+ ASN1_TIME *tme; - --#if !defined(_WIN32) -- if (timegm(tm) < time(NULL)) { -- X509_CRL_free(x); -- free(tm); -- return NULL; -- } --#endif -- -- free(tm); -+ tme = X509_CRL_get_nextUpdate(x); -+ if (!tme || X509_cmp_current_time(tme) < 0) { -+ X509_CRL_free(x); -+ return NULL; -+ } - } - - return x; -diff --git a/m4/reorganization/libs/openssl.m4 b/m4/reorganization/libs/openssl.m4 -index 78e2c23..45ee02d 100644 ---- a/m4/reorganization/libs/openssl.m4 -+++ b/m4/reorganization/libs/openssl.m4 -@@ -26,12 +26,13 @@ save_LDFLAGS="$LDFLAGS" - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - --SSL_LIBS="-lssl -lcrypto -lz" -+SSL_LIBS="$LIBS -lssl -lcrypto -lz" -+LIBS="$LIBS $SSL_LIBS" - - if test "$LIBSSL_HOME" != "/usr"; then - SSL_LDFLAGS="-L$LIBSSL_HOME/lib" - SSL_CPPFLAGS="-I$LIBSSL_HOME/include" -- LDFLAGS="-L$LIBSSL_HOME/lib $SSL_LIBS" -+ LDFLAGS="-L$LIBSSL_HOME/lib" - CFLAGS="$SSL_CPPFLAGS" - else - SSL_LDFLAGS="" -@@ -41,7 +42,12 @@ fi - have_ssl="no" - have_crypto="no" - --AC_CHECK_LIB([ssl], [SSL_library_init], [have_ssl="yes"], [AC_MSG_ERROR([Your OpenSSL installation is misconfigured or missing])], [-lcrypto -lz]) -+AC_LINK_IFELSE( -+ [AC_LANG_PROGRAM([[#include ]], -+ [[SSL_library_init();]])], -+ [have_ssl="yes";], -+ [AC_MSG_ERROR([Your OpenSSL installation is misconfigured or missing])]) -+ - - AC_CHECK_LIB([crypto], [EVP_EncryptInit], [have_crypto="yes"], [AC_MSG_ERROR([Your OpenSSL installation is misconfigured or missing])], [-lcrypto -lz]) - diff -Nru clamav-0.99.2+dfsg/debian/patches/series clamav-0.99.3~beta1+dfsg/debian/patches/series --- clamav-0.99.2+dfsg/debian/patches/series 2017-08-15 20:04:37.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/series 2017-11-22 21:56:26.000000000 +0000 @@ -1,19 +1,9 @@ Change-paths-in-sample-conf-file-to-match-Debian.patch add-support-for-system-tomsfastmath.patch -Allow-M-suffix-for-PCREMaxFileSize.patch -clamav_add_private_fts_implementation.patch -fix-ssize_t-size_t-off_t-printf-modifier.patch -libclamav-use-libmspack.patch -drop-AllowSupplementaryGroups-option-and-make-it-def.patch -make_it_compile_against_openssl_1_1_0.patch clamd_dont_depend_on_clamav_demon_socket.patch Add-support-for-LLVM-3.7.patch Add-support-for-LLVM-3.8.patch Add-support-for-LLVM-3.9.patch -bb11549-fix-temp-file-cleanup-issue.patch Fix_detection_of_libcurl.patch -zlib-check.patch -CVE-2017-6418.patch -CVE-2017-6420.patch -CVE-2017-6420-2.patch -fix_newer_zlib.patch \ No newline at end of file +clamsubmit-add-JSON-libs-to-clamsubmit.patch +fix_newer_zlib.patch diff -Nru clamav-0.99.2+dfsg/debian/patches/zlib-check.patch clamav-0.99.3~beta1+dfsg/debian/patches/zlib-check.patch --- clamav-0.99.2+dfsg/debian/patches/zlib-check.patch 2017-05-02 09:19:21.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/patches/zlib-check.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -## Description: add some description -## Origin/Author: add some origin or author -## Bug: bug URL -commit f0bcd186190fe6e67b3f0eaaceb7a99aa6a98865 -Author: Steven Morgan -Date: Thu Jan 5 12:30:35 2017 -0500 - - bb111711 - fix zlib version check - patch by Daniel J. Luke. - -diff --git a/m4/reorganization/libs/libz.m4 b/m4/reorganization/libs/libz.m4 -index b5c7414..f7b67ca 100644 ---- a/m4/reorganization/libs/libz.m4 -+++ b/m4/reorganization/libs/libz.m4 -@@ -29,9 +29,9 @@ then - AC_MSG_ERROR([Please install zlib and zlib-devel packages]) - else - -- vuln=`grep "ZLIB_VERSION \"1.2.0" $ZLIB_HOME/include/zlib.h` -+ vuln=`grep "ZLIB_VERSION \"1.2.0\"" $ZLIB_HOME/include/zlib.h` - if test -z "$vuln"; then -- vuln=`grep "ZLIB_VERSION \"1.2.1" $ZLIB_HOME/include/zlib.h` -+ vuln=`grep "ZLIB_VERSION \"1.2.1\"" $ZLIB_HOME/include/zlib.h` - fi - - if test -n "$vuln"; then diff -Nru clamav-0.99.2+dfsg/debian/rules clamav-0.99.3~beta1+dfsg/debian/rules --- clamav-0.99.2+dfsg/debian/rules 2017-05-02 09:24:17.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/rules 2017-11-22 21:56:26.000000000 +0000 @@ -45,7 +45,7 @@ CONFIG := CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \ --with-dbdir=/var/lib/clamav --sysconfdir=/etc/clamav \ --disable-clamav --disable-unrar --enable-milter --enable-dns-fix \ - --with-libjson \ + --with-libjson --with-system-libmspack \ --with-gnu-ld $(SYSTEM_LLVM) \ --with-systemdsystemunitdir=/lib/systemd/system @@ -96,7 +96,7 @@ fi;\ done; \ # Check if for library features whih may get upgrade. - if ! grep -q "CL_FLEVEL 82" libclamav/others.h ; then \ + if ! grep -q "CL_FLEVEL 83" libclamav/others.h ; then \ echo "cl_retflevel needs boosting in symbol file"; \ touch debian/exit; \ fi; diff -Nru clamav-0.99.2+dfsg/debian/split-tarball.sh clamav-0.99.3~beta1+dfsg/debian/split-tarball.sh --- clamav-0.99.2+dfsg/debian/split-tarball.sh 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/split-tarball.sh 2017-11-22 21:56:26.000000000 +0000 @@ -77,6 +77,8 @@ } /LTDL/d /ltdl/d +/.*m4\/reorganization\/llvm.m4/d +/.*m4\/reorganization\/libmspack.m4/d /AC_OUTPUT(\[.*Makefile/d s/clamscan\/clamscan.c/libclamunrar_iface\/unrar_iface.c/ ' configure.ac diff -Nru clamav-0.99.2+dfsg/debian/tests/clamd clamav-0.99.3~beta1+dfsg/debian/tests/clamd --- clamav-0.99.2+dfsg/debian/tests/clamd 2017-01-30 20:27:31.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/debian/tests/clamd 2017-11-22 21:56:26.000000000 +0000 @@ -10,7 +10,7 @@ cp `dirname $0`/../../unit_tests/input/bytecode.cvd /var/lib/clamav/daily.cvd > /dev/null 2>&1 # restart clamav -/etc/init.d/clamav-daemon start > /dev/null 2>&1 +invoke-rc.d clamav-daemon start > /dev/null 2>&1 if pidof -x $DAEMON > /dev/null; then echo "OK" Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/docs/clamdoc.pdf and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/docs/clamdoc.pdf differ diff -Nru clamav-0.99.2+dfsg/docs/clamdoc.tex clamav-0.99.3~beta1+dfsg/docs/clamdoc.tex --- clamav-0.99.2+dfsg/docs/clamdoc.tex 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/clamdoc.tex 2017-04-20 22:19:13.000000000 +0000 @@ -72,7 +72,7 @@ \vspace{3cm} \begin{flushright} \rule[-1ex]{8cm}{3pt}\\ - \huge Clam AntiVirus 0.99.2\\ + \huge Clam AntiVirus 0.99.3\\ \huge \emph{User Manual}\\ \end{flushright} @@ -84,7 +84,7 @@ \noindent \begin{boxedminipage}[b]{\textwidth} ClamAV User Manual, - \copyright \ 2016 Cisco Systems, Inc. + \copyright \ 2017 Cisco Systems, Inc. Authors: Tomasz Kojm\\ This document is distributed under the terms of the GNU General Public License v2.\\ @@ -424,7 +424,7 @@ \item Optionally if \verb+valgrind+ is available on your platform, the output of the following: \begin{verbatim} $ make check -$ CK_FORK=no ./libtool --mode=execute valgrind unit_tests/check-clamav +$ CK_FORK=no ./libtool --mode=execute valgrind unit_tests/check_clamav \end{verbatim} \end{itemize} @@ -472,7 +472,7 @@ One of the interesting features of \verb+clamd+ is on-access scanning based on fanotify, included in Linux since kernel 2.6.36. \textbf{This is not required to run clamd}. At the moment the fanotify header is - only avaliable for Linux. + only available for Linux. \\\\ Configure on-access scanning in \verb+clamd.conf+ and read the \ref{On-access} section for on-access scanning usage. @@ -754,7 +754,7 @@ OnAccessMountPath option. While this will disable on-access prevention, it will avoid potential system lockups caused by fanotify's blocking functionality. - \item Using the On-Access Scanner to watch a virtual filesytem will result + \item Using the On-Access Scanner to watch a virtual filesystem will result in undefined behaviour. \end{itemize} The default configuration utilizes inotify to recursively keep track of @@ -812,7 +812,7 @@ \subsection{Freshclam}\label{sec:freshclam} \verb+freshclam+ is ClamAV's virus database update tool and reads it's configuration from the file 'freshclam.conf' (this may be - overriden by command line options). Freshclam's default behavior is to + overridden by command line options). Freshclam's default behavior is to attempt to update databases that are paired with downloaded cdiffs. Potentially corrupted databases are not updated and are automatically fully replaced after several failed attempts unless otherwise specified. @@ -1055,9 +1055,10 @@ \subsubsection{Initialization} Before using libclamav, you should call \verb+cl_init()+ to initialize - it. When it's done, you're ready to create a new scan engine by calling - \verb+cl_engine_new()+. To free resources allocated by the engine use - \verb+cl_engine_free()+. Function prototypes: + it. \verb+CL_INIT_DEFAULT+ is a macro that can be passed to \verb+cl_init()+ + representing the default initialization settings. When it's done, you're ready + to create a new scan engine by calling \verb+cl_engine_new()+. To free resources + allocated by the engine use \verb+cl_engine_free()+. Function prototypes: \begin{verbatim} int cl_init(unsigned int options); struct cl_engine *cl_engine_new(void); @@ -1108,7 +1109,7 @@ unsigned int sigs = 0; int ret; - if((ret = cl_init()) != CL_SUCCESS) { + if((ret = cl_init(CL_INIT_DEFAULT)) != CL_SUCCESS) { printf("cl_init() error: %s\n", cl_strerror(ret)); return 1; } @@ -1188,7 +1189,7 @@ cl_statinidir(dbdir, &dbstat); \end{verbatim} To check for a change you just need to call \verb+cl_statchkdir+ and check - its return value (0 - no change, 1 - some change occured). Remember to reset + its return value (0 - no change, 1 - some change occurred). Remember to reset the \verb+cl_stat+ structure after reloading the database. \begin{verbatim} if(cl_statchkdir(&dbstat) == 1) { diff -Nru clamav-0.99.2+dfsg/docs/html/clamdoc.html clamav-0.99.3~beta1+dfsg/docs/html/clamdoc.html --- clamav-0.99.2+dfsg/docs/html/clamdoc.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/clamdoc.html 2017-07-19 19:03:40.000000000 +0000 @@ -56,7 +56,7 @@

-
Clam AntiVirus 0.99.2 +
Clam AntiVirus 0.99.3
User Manual
@@ -240,7 +240,7 @@

-Cisco 2016-04-21 +Cisco 2017-07-13
Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/docs/html/img2.png and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/docs/html/img2.png differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/docs/html/img3.png and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/docs/html/img3.png differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/docs/html/img5.png and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/docs/html/img5.png differ diff -Nru clamav-0.99.2+dfsg/docs/html/index.html clamav-0.99.3~beta1+dfsg/docs/html/index.html --- clamav-0.99.2+dfsg/docs/html/index.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/index.html 2017-07-19 19:03:40.000000000 +0000 @@ -56,7 +56,7 @@

-
Clam AntiVirus 0.99.2 +
Clam AntiVirus 0.99.3
User Manual
@@ -240,7 +240,7 @@

-Cisco 2016-04-21 +Cisco 2017-07-13
diff -Nru clamav-0.99.2+dfsg/docs/html/node10.html clamav-0.99.3~beta1+dfsg/docs/html/node10.html --- clamav-0.99.2+dfsg/docs/html/node10.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node10.html 2017-07-19 19:03:40.000000000 +0000 @@ -60,7 +60,7 @@



-Cisco 2016-04-21 +Cisco 2017-07-13
diff -Nru clamav-0.99.2+dfsg/docs/html/node11.html clamav-0.99.3~beta1+dfsg/docs/html/node11.html --- clamav-0.99.2+dfsg/docs/html/node11.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node11.html 2017-07-19 19:03:40.000000000 +0000 @@ -84,7 +84,7 @@

-Cisco 2016-04-21 +Cisco 2017-07-13
diff -Nru clamav-0.99.2+dfsg/docs/html/node12.html clamav-0.99.3~beta1+dfsg/docs/html/node12.html --- clamav-0.99.2+dfsg/docs/html/node12.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node12.html 2017-07-19 19:03:40.000000000 +0000 @@ -143,7 +143,7 @@ HREF="node1.html">Contents
-Cisco 2016-04-21 +Cisco 2017-07-13
diff -Nru clamav-0.99.2+dfsg/docs/html/node13.html clamav-0.99.3~beta1+dfsg/docs/html/node13.html --- clamav-0.99.2+dfsg/docs/html/node13.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node13.html 2017-07-19 19:03:40.000000000 +0000 @@ -74,7 +74,7 @@



-Cisco 2016-04-21 +Cisco 2017-07-13
diff -Nru clamav-0.99.2+dfsg/docs/html/node14.html clamav-0.99.3~beta1+dfsg/docs/html/node14.html --- clamav-0.99.2+dfsg/docs/html/node14.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node14.html 2017-07-19 19:03:40.000000000 +0000 @@ -68,7 +68,7 @@



-Cisco 2016-04-21 +Cisco 2017-07-13
diff -Nru clamav-0.99.2+dfsg/docs/html/node15.html clamav-0.99.3~beta1+dfsg/docs/html/node15.html --- clamav-0.99.2+dfsg/docs/html/node15.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node15.html 2017-07-19 19:03:40.000000000 +0000 @@ -74,7 +74,7 @@



-Cisco 2016-04-21 +Cisco 2017-07-13
diff -Nru clamav-0.99.2+dfsg/docs/html/node16.html clamav-0.99.3~beta1+dfsg/docs/html/node16.html --- clamav-0.99.2+dfsg/docs/html/node16.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node16.html 2017-07-19 19:03:40.000000000 +0000 @@ -65,7 +65,7 @@



-Cisco 2016-04-21 +Cisco 2017-07-13
diff -Nru clamav-0.99.2+dfsg/docs/html/node17.html clamav-0.99.3~beta1+dfsg/docs/html/node17.html --- clamav-0.99.2+dfsg/docs/html/node17.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node17.html 2017-07-19 19:03:40.000000000 +0000 @@ -77,7 +77,7 @@



-Cisco 2016-04-21 +Cisco 2017-07-13
diff -Nru clamav-0.99.2+dfsg/docs/html/node18.html clamav-0.99.3~beta1+dfsg/docs/html/node18.html --- clamav-0.99.2+dfsg/docs/html/node18.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node18.html 2017-07-19 19:03:40.000000000 +0000 @@ -141,7 +141,7 @@ HREF="node1.html">Contents
-Cisco 2016-04-21 +Cisco 2017-07-13
diff -Nru clamav-0.99.2+dfsg/docs/html/node19.html clamav-0.99.3~beta1+dfsg/docs/html/node19.html --- clamav-0.99.2+dfsg/docs/html/node19.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node19.html 2017-07-19 19:03:40.000000000 +0000 @@ -88,7 +88,7 @@
  • Optionally if valgrind is available on your platform, the output of the following:
     $ make check
    -$ CK_FORK=no ./libtool --mode=execute valgrind unit_tests/check-clamav
    +$ CK_FORK=no ./libtool --mode=execute valgrind unit_tests/check_clamav
     
  • @@ -96,7 +96,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node1.html clamav-0.99.3~beta1+dfsg/docs/html/node1.html --- clamav-0.99.2+dfsg/docs/html/node1.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node1.html 2017-07-19 19:03:40.000000000 +0000 @@ -173,7 +173,7 @@ SRC="img2.png" ALT="\begin{boxedminipage}[b]{\textwidth} ClamAV User Manual, -\copyright \ 2016 Cis... +\copyright \ 2017 Cis... ... Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. \end{boxedminipage}"> @@ -197,7 +197,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node20.html clamav-0.99.3~beta1+dfsg/docs/html/node20.html --- clamav-0.99.2+dfsg/docs/html/node20.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node20.html 2017-07-19 19:03:40.000000000 +0000 @@ -86,7 +86,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node21.html clamav-0.99.3~beta1+dfsg/docs/html/node21.html --- clamav-0.99.2+dfsg/docs/html/node21.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node21.html 2017-07-19 19:03:40.000000000 +0000 @@ -90,7 +90,7 @@

    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node22.html clamav-0.99.3~beta1+dfsg/docs/html/node22.html --- clamav-0.99.2+dfsg/docs/html/node22.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node22.html 2017-07-19 19:03:40.000000000 +0000 @@ -78,7 +78,7 @@

    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node23.html clamav-0.99.3~beta1+dfsg/docs/html/node23.html --- clamav-0.99.2+dfsg/docs/html/node23.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node23.html 2017-07-19 19:03:40.000000000 +0000 @@ -57,7 +57,7 @@ One of the interesting features of clamd is on-access scanning based on fanotify, included in Linux since kernel 2.6.36. This is not required to run clamd. At the moment the fanotify header is - only avaliable for Linux. + only available for Linux.

    @@ -67,7 +67,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node24.html clamav-0.99.3~beta1+dfsg/docs/html/node24.html --- clamav-0.99.2+dfsg/docs/html/node24.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node24.html 2017-07-19 19:03:40.000000000 +0000 @@ -91,7 +91,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node25.html clamav-0.99.3~beta1+dfsg/docs/html/node25.html --- clamav-0.99.2+dfsg/docs/html/node25.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node25.html 2017-07-19 19:03:40.000000000 +0000 @@ -74,7 +74,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node26.html clamav-0.99.3~beta1+dfsg/docs/html/node26.html --- clamav-0.99.2+dfsg/docs/html/node26.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node26.html 2017-07-19 19:03:40.000000000 +0000 @@ -140,7 +140,7 @@ HREF="node1.html">Contents
    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node27.html clamav-0.99.3~beta1+dfsg/docs/html/node27.html --- clamav-0.99.2+dfsg/docs/html/node27.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node27.html 2017-07-19 19:03:40.000000000 +0000 @@ -76,7 +76,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node28.html clamav-0.99.3~beta1+dfsg/docs/html/node28.html --- clamav-0.99.2+dfsg/docs/html/node28.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node28.html 2017-07-19 19:03:40.000000000 +0000 @@ -109,7 +109,7 @@ HREF="node1.html">Contents
    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node29.html clamav-0.99.3~beta1+dfsg/docs/html/node29.html --- clamav-0.99.2+dfsg/docs/html/node29.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node29.html 2017-07-19 19:03:40.000000000 +0000 @@ -89,7 +89,7 @@

    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node2.html clamav-0.99.3~beta1+dfsg/docs/html/node2.html --- clamav-0.99.2+dfsg/docs/html/node2.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node2.html 2017-07-19 19:03:40.000000000 +0000 @@ -78,7 +78,7 @@

    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node30.html clamav-0.99.3~beta1+dfsg/docs/html/node30.html --- clamav-0.99.2+dfsg/docs/html/node30.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node30.html 2017-07-19 19:03:40.000000000 +0000 @@ -235,7 +235,7 @@ HREF="node1.html">Contents
    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node31.html clamav-0.99.3~beta1+dfsg/docs/html/node31.html --- clamav-0.99.2+dfsg/docs/html/node31.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node31.html 2017-07-19 19:03:40.000000000 +0000 @@ -75,7 +75,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node32.html clamav-0.99.3~beta1+dfsg/docs/html/node32.html --- clamav-0.99.2+dfsg/docs/html/node32.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node32.html 2017-07-19 19:03:40.000000000 +0000 @@ -81,7 +81,7 @@ it will avoid potential system lockups caused by fanotify's blocking functionality. -
  • Using the On-Access Scanner to watch a virtual filesytem will result +
  • Using the On-Access Scanner to watch a virtual filesystem will result in undefined behaviour.
  • @@ -144,7 +144,7 @@ HREF="node1.html">Contents
    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node33.html clamav-0.99.3~beta1+dfsg/docs/html/node33.html --- clamav-0.99.2+dfsg/docs/html/node33.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node33.html 2017-07-19 19:03:40.000000000 +0000 @@ -69,7 +69,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node34.html clamav-0.99.3~beta1+dfsg/docs/html/node34.html --- clamav-0.99.2+dfsg/docs/html/node34.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node34.html 2017-07-19 19:03:40.000000000 +0000 @@ -71,7 +71,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node35.html clamav-0.99.3~beta1+dfsg/docs/html/node35.html --- clamav-0.99.2+dfsg/docs/html/node35.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node35.html 2017-07-19 19:03:40.000000000 +0000 @@ -62,7 +62,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node36.html clamav-0.99.3~beta1+dfsg/docs/html/node36.html --- clamav-0.99.2+dfsg/docs/html/node36.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node36.html 2017-07-19 19:03:40.000000000 +0000 @@ -58,7 +58,7 @@ freshclam is ClamAV's virus database update tool and reads it's configuration from the file 'freshclam.conf' (this may be - overriden by command line options). Freshclam's default behavior is to + overridden by command line options). Freshclam's default behavior is to attempt to update databases that are paired with downloaded cdiffs. Potentially corrupted databases are not updated and are automatically fully replaced after several failed attempts unless otherwise specified. @@ -85,7 +85,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node37.html clamav-0.99.3~beta1+dfsg/docs/html/node37.html --- clamav-0.99.2+dfsg/docs/html/node37.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node37.html 2017-07-19 19:03:40.000000000 +0000 @@ -115,7 +115,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node38.html clamav-0.99.3~beta1+dfsg/docs/html/node38.html --- clamav-0.99.2+dfsg/docs/html/node38.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node38.html 2017-07-19 19:03:40.000000000 +0000 @@ -69,7 +69,7 @@

    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node39.html clamav-0.99.3~beta1+dfsg/docs/html/node39.html --- clamav-0.99.2+dfsg/docs/html/node39.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node39.html 2017-07-19 19:03:40.000000000 +0000 @@ -80,7 +80,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node3.html clamav-0.99.3~beta1+dfsg/docs/html/node3.html --- clamav-0.99.2+dfsg/docs/html/node3.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node3.html 2017-07-19 19:03:40.000000000 +0000 @@ -216,7 +216,7 @@ HREF="node1.html">Contents
    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node40.html clamav-0.99.3~beta1+dfsg/docs/html/node40.html --- clamav-0.99.2+dfsg/docs/html/node40.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node40.html 2017-07-19 19:03:40.000000000 +0000 @@ -82,7 +82,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node41.html clamav-0.99.3~beta1+dfsg/docs/html/node41.html --- clamav-0.99.2+dfsg/docs/html/node41.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node41.html 2017-07-19 19:03:40.000000000 +0000 @@ -128,7 +128,7 @@

    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node42.html clamav-0.99.3~beta1+dfsg/docs/html/node42.html --- clamav-0.99.2+dfsg/docs/html/node42.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node42.html 2017-07-19 19:03:40.000000000 +0000 @@ -62,7 +62,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node43.html clamav-0.99.3~beta1+dfsg/docs/html/node43.html --- clamav-0.99.2+dfsg/docs/html/node43.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node43.html 2017-07-19 19:03:40.000000000 +0000 @@ -78,7 +78,7 @@

    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node44.html clamav-0.99.3~beta1+dfsg/docs/html/node44.html --- clamav-0.99.2+dfsg/docs/html/node44.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node44.html 2017-07-19 19:03:40.000000000 +0000 @@ -86,7 +86,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node45.html clamav-0.99.3~beta1+dfsg/docs/html/node45.html --- clamav-0.99.2+dfsg/docs/html/node45.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node45.html 2017-07-19 19:03:40.000000000 +0000 @@ -61,7 +61,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node46.html clamav-0.99.3~beta1+dfsg/docs/html/node46.html --- clamav-0.99.2+dfsg/docs/html/node46.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node46.html 2017-07-19 19:03:40.000000000 +0000 @@ -119,7 +119,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node47.html clamav-0.99.3~beta1+dfsg/docs/html/node47.html --- clamav-0.99.2+dfsg/docs/html/node47.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node47.html 2017-07-19 19:03:40.000000000 +0000 @@ -75,7 +75,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node48.html clamav-0.99.3~beta1+dfsg/docs/html/node48.html --- clamav-0.99.2+dfsg/docs/html/node48.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node48.html 2017-07-19 19:03:40.000000000 +0000 @@ -69,7 +69,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node49.html clamav-0.99.3~beta1+dfsg/docs/html/node49.html --- clamav-0.99.2+dfsg/docs/html/node49.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node49.html 2017-07-19 19:03:40.000000000 +0000 @@ -74,7 +74,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node4.html clamav-0.99.3~beta1+dfsg/docs/html/node4.html --- clamav-0.99.2+dfsg/docs/html/node4.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node4.html 2017-07-19 19:03:40.000000000 +0000 @@ -85,7 +85,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node50.html clamav-0.99.3~beta1+dfsg/docs/html/node50.html --- clamav-0.99.2+dfsg/docs/html/node50.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node50.html 2017-07-19 19:03:40.000000000 +0000 @@ -90,7 +90,7 @@

    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node51.html clamav-0.99.3~beta1+dfsg/docs/html/node51.html --- clamav-0.99.2+dfsg/docs/html/node51.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node51.html 2017-07-19 19:03:40.000000000 +0000 @@ -63,7 +63,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node52.html clamav-0.99.3~beta1+dfsg/docs/html/node52.html --- clamav-0.99.2+dfsg/docs/html/node52.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node52.html 2017-07-19 19:03:40.000000000 +0000 @@ -56,9 +56,10 @@ Initialization Before using libclamav, you should call cl_init() to initialize - it. When it's done, you're ready to create a new scan engine by calling - cl_engine_new(). To free resources allocated by the engine use - cl_engine_free(). Function prototypes: + it. CL_INIT_DEFAULT is a macro that can be passed to cl_init() + representing the default initialization settings. When it's done, you're ready + to create a new scan engine by calling cl_engine_new(). To free resources + allocated by the engine use cl_engine_free(). Function prototypes:
     	int cl_init(unsigned int options);
     	struct cl_engine *cl_engine_new(void);
    @@ -72,7 +73,7 @@
     



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node53.html clamav-0.99.3~beta1+dfsg/docs/html/node53.html --- clamav-0.99.2+dfsg/docs/html/node53.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node53.html 2017-07-19 19:03:40.000000000 +0000 @@ -108,7 +108,7 @@ unsigned int sigs = 0; int ret; - if((ret = cl_init()) != CL_SUCCESS) { + if((ret = cl_init(CL_INIT_DEFAULT)) != CL_SUCCESS) { printf("cl_init() error: %s\n", cl_strerror(ret)); return 1; } @@ -124,7 +124,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node54.html clamav-0.99.3~beta1+dfsg/docs/html/node54.html --- clamav-0.99.2+dfsg/docs/html/node54.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node54.html 2017-07-19 19:03:40.000000000 +0000 @@ -68,7 +68,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node55.html clamav-0.99.3~beta1+dfsg/docs/html/node55.html --- clamav-0.99.2+dfsg/docs/html/node55.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node55.html 2017-07-19 19:03:40.000000000 +0000 @@ -74,7 +74,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node56.html clamav-0.99.3~beta1+dfsg/docs/html/node56.html --- clamav-0.99.2+dfsg/docs/html/node56.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node56.html 2017-07-19 19:03:40.000000000 +0000 @@ -78,7 +78,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node57.html clamav-0.99.3~beta1+dfsg/docs/html/node57.html --- clamav-0.99.2+dfsg/docs/html/node57.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node57.html 2017-07-19 19:03:40.000000000 +0000 @@ -72,7 +72,7 @@ cl_statinidir(dbdir, &dbstat);
    To check for a change you just need to call cl_statchkdir and check - its return value (0 - no change, 1 - some change occured). Remember to reset + its return value (0 - no change, 1 - some change occurred). Remember to reset the cl_stat structure after reloading the database.
     	if(cl_statchkdir(&dbstat) == 1) {
    @@ -102,7 +102,7 @@
     



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node58.html clamav-0.99.3~beta1+dfsg/docs/html/node58.html --- clamav-0.99.2+dfsg/docs/html/node58.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node58.html 2017-07-19 19:03:40.000000000 +0000 @@ -221,7 +221,7 @@ HREF="node1.html">Contents
    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node59.html clamav-0.99.3~beta1+dfsg/docs/html/node59.html --- clamav-0.99.2+dfsg/docs/html/node59.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node59.html 2017-07-19 19:03:40.000000000 +0000 @@ -62,7 +62,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node5.html clamav-0.99.3~beta1+dfsg/docs/html/node5.html --- clamav-0.99.2+dfsg/docs/html/node5.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node5.html 2017-07-19 19:03:40.000000000 +0000 @@ -64,7 +64,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node60.html clamav-0.99.3~beta1+dfsg/docs/html/node60.html --- clamav-0.99.2+dfsg/docs/html/node60.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node60.html 2017-07-19 19:03:40.000000000 +0000 @@ -64,7 +64,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node61.html clamav-0.99.3~beta1+dfsg/docs/html/node61.html --- clamav-0.99.2+dfsg/docs/html/node61.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node61.html 2017-07-19 19:03:40.000000000 +0000 @@ -66,7 +66,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node62.html clamav-0.99.3~beta1+dfsg/docs/html/node62.html --- clamav-0.99.2+dfsg/docs/html/node62.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node62.html 2017-07-19 19:03:40.000000000 +0000 @@ -64,7 +64,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node63.html clamav-0.99.3~beta1+dfsg/docs/html/node63.html --- clamav-0.99.2+dfsg/docs/html/node63.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node63.html 2017-07-19 19:03:40.000000000 +0000 @@ -81,7 +81,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node64.html clamav-0.99.3~beta1+dfsg/docs/html/node64.html --- clamav-0.99.2+dfsg/docs/html/node64.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node64.html 2017-07-19 19:03:40.000000000 +0000 @@ -612,7 +612,7 @@ HREF="node1.html">Contents
    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node65.html clamav-0.99.3~beta1+dfsg/docs/html/node65.html --- clamav-0.99.2+dfsg/docs/html/node65.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node65.html 2017-07-19 19:03:40.000000000 +0000 @@ -458,7 +458,7 @@ HREF="node1.html">Contents
    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node66.html clamav-0.99.3~beta1+dfsg/docs/html/node66.html --- clamav-0.99.2+dfsg/docs/html/node66.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node66.html 2017-07-19 19:03:40.000000000 +0000 @@ -62,7 +62,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node67.html clamav-0.99.3~beta1+dfsg/docs/html/node67.html --- clamav-0.99.2+dfsg/docs/html/node67.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node67.html 2017-07-19 19:03:40.000000000 +0000 @@ -61,7 +61,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node68.html clamav-0.99.3~beta1+dfsg/docs/html/node68.html --- clamav-0.99.2+dfsg/docs/html/node68.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node68.html 2017-07-19 19:03:40.000000000 +0000 @@ -142,7 +142,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node69.html clamav-0.99.3~beta1+dfsg/docs/html/node69.html --- clamav-0.99.2+dfsg/docs/html/node69.html 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node69.html 2017-07-19 19:03:40.000000000 +0000 @@ -0,0 +1,133 @@ + + + + + +Emeritus Team + + + + + + + + + + + + + + + + + + + +

    +Emeritus Team +

    + +

    + +

      +
    • aCaB <acab*clamav.net>, Italy +
      +Role: virus database maintainer, coder + +

      +

    • +
    • Christoph Cordes <ccordes*clamav.net>, Germany +
      +Role: virus database maintainer + +

      +

    • +
    • Mike Cathey <mike*clamav.net>, USA +
      +Role: co-sysadmin + +

      +

    • +
    • Diego d'Ambra <diego*clamav.net>, Denmark +
      +Role: virus database maintainer + +

      +

    • +
    • Luca Gibelli <luca*clamav.net>, Italy +
      +Role: sysadmin, mirror coordinator + +

      +

    • +
    • Nigel Horne <njh*clamav.net>, United Kingdom +
      +Role: coder + +

      +

    • +
    • Arnaud Jacques <arnaud*clamav.net>, France +
      +Role: virus database maintainer + +

      +

    • +
    • Tomasz Kojm <tkojm*clamav.net>, Poland +
      +Role: project leader, coder + +

      +

    • +
    • Tomasz Papszun <tomek*clamav.net>, Poland +
      +Role: various help + +

      +

    • +
    • Sven Strickroth <sven*clamav.net>, Germany +
      +Role: virus database maintainer, virus submission management + +

      +

    • +
    • Edwin Torok <edwin*clamav.net>, Romania +
      +Role: coder + +

      +

    • +
    • Trog <trog*clamav.net>, United Kingdom +
      +Role: coder + +
    • +
    +

    +
    +Cisco 2017-07-13 +
    + + diff -Nru clamav-0.99.2+dfsg/docs/html/node6.html clamav-0.99.3~beta1+dfsg/docs/html/node6.html --- clamav-0.99.2+dfsg/docs/html/node6.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node6.html 2017-07-19 19:03:40.000000000 +0000 @@ -77,7 +77,7 @@

    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node7.html clamav-0.99.3~beta1+dfsg/docs/html/node7.html --- clamav-0.99.2+dfsg/docs/html/node7.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node7.html 2017-07-19 19:03:40.000000000 +0000 @@ -68,7 +68,7 @@

    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node8.html clamav-0.99.3~beta1+dfsg/docs/html/node8.html --- clamav-0.99.2+dfsg/docs/html/node8.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node8.html 2017-07-19 19:03:40.000000000 +0000 @@ -76,7 +76,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/node9.html clamav-0.99.3~beta1+dfsg/docs/html/node9.html --- clamav-0.99.2+dfsg/docs/html/node9.html 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/node9.html 2017-07-19 19:03:40.000000000 +0000 @@ -59,7 +59,7 @@



    -Cisco 2016-04-21 +Cisco 2017-07-13
    diff -Nru clamav-0.99.2+dfsg/docs/html/WARNINGS clamav-0.99.3~beta1+dfsg/docs/html/WARNINGS --- clamav-0.99.2+dfsg/docs/html/WARNINGS 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/html/WARNINGS 2017-07-19 19:03:40.000000000 +0000 @@ -7,6 +7,4 @@ redefining command \email previous meaning of \email will be lost - -clamdoc.tex is newer than clamdoc.aux: Please rerun latex. \includegraphics couldn't copy /home/smorgan/clamav-devel/docs/html/demon.png to tree: diff -Nru clamav-0.99.2+dfsg/docs/Makefile.in clamav-0.99.3~beta1+dfsg/docs/Makefile.in --- clamav-0.99.2+dfsg/docs/Makefile.in 2016-04-22 16:19:52.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/Makefile.in 2017-06-23 21:20:56.000000000 +0000 @@ -104,10 +104,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -162,12 +163,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -291,6 +297,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -318,7 +326,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -412,6 +429,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/docs/man/clamav-milter.conf.5.in clamav-0.99.3~beta1+dfsg/docs/man/clamav-milter.conf.5.in --- clamav-0.99.2+dfsg/docs/man/clamav-milter.conf.5.in 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/man/clamav-milter.conf.5.in 2016-10-13 15:45:43.000000000 +0000 @@ -57,11 +57,6 @@ .br Default: unset (don\'t drop privileges) .TP -\fBAllowSupplementaryGroups BOOL\fR -Initialize supplementary group access (clamav-milter must be started by root). -.br -Default: no -.TP \fBReadTimeout NUMBER\fR Waiting for data from clamd will timeout after this time (seconds). .br diff -Nru clamav-0.99.2+dfsg/docs/man/clamd.conf.5.in clamav-0.99.3~beta1+dfsg/docs/man/clamd.conf.5.in --- clamav-0.99.2+dfsg/docs/man/clamd.conf.5.in 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/man/clamd.conf.5.in 2016-10-13 15:46:46.000000000 +0000 @@ -270,11 +270,6 @@ .br Default: disabled .TP -\fBAllowSupplementaryGroups BOOL\fR -Initialize a supplementary group access (the process must be started by root). -.br -Default: no -.TP \fBBytecode BOOL\fR With this option enabled ClamAV will load bytecode from the database. It is highly recommended you keep this option turned on, otherwise you may miss detections for many new viruses. .br diff -Nru clamav-0.99.2+dfsg/docs/man/clamdscan.1.in clamav-0.99.3~beta1+dfsg/docs/man/clamdscan.1.in --- clamav-0.99.2+dfsg/docs/man/clamdscan.1.in 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/man/clamdscan.1.in 2016-11-03 16:01:29.000000000 +0000 @@ -90,7 +90,7 @@ .TP 1 : Virus(es) found. .TP -2 : An error occured. +2 : An error occurred. .SH "CREDITS" Please check the full documentation for credits. .SH "AUTHOR" diff -Nru clamav-0.99.2+dfsg/docs/man/clamdtop.1.in clamav-0.99.3~beta1+dfsg/docs/man/clamdtop.1.in --- clamav-0.99.2+dfsg/docs/man/clamdtop.1.in 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/man/clamdtop.1.in 2016-11-03 16:01:29.000000000 +0000 @@ -179,9 +179,9 @@ environment. IPv6 support has been added. If specifying an IPv6 address, please use the normal IPv6 addressing rules. If specifying both an IPv6 address and a port combination, encapsulate the IPv6 address in square brakets (e.g. [::1]:3410). .SH "RETURN CODES" .LP -0 : Normal terminator +0 : Normal termination .TP ->0: Error occured. +>0: Error occurred. .SH "CREDITS" Please check the full documentation for credits. .SH "AUTHOR" diff -Nru clamav-0.99.2+dfsg/docs/man/clamscan.1.in clamav-0.99.3~beta1+dfsg/docs/man/clamscan.1.in --- clamav-0.99.2+dfsg/docs/man/clamscan.1.in 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/man/clamscan.1.in 2017-03-08 14:06:34.000000000 +0000 @@ -149,6 +149,9 @@ .TP \fB\-\-algorithmic\-detection[=yes(*)/no]\fR In some cases (eg. complex malware, exploits in graphic files, and others), ClamAV uses special algorithms to provide accurate detection. This option can be used to control the algorithmic detection. +.TP +\fB\-\-normalize[=yes(*)/no]\fR +Normalize (compress whitespace, downcase, etc.) html, script, and text files. Use normalize=no for yara compatibility. .TP \fB\-\-scan\-pe[=yes(*)/no]\fR PE stands for Portable Executable \- it's an executable file format used in all 32\-bit versions of Windows operating systems. By default ClamAV performs deeper analysis of executable files and attempts to decompress popular executable packers such as UPX, Petite, and FSG. If you turn off this option, the original files will still be scanned but without additional processing. @@ -227,7 +230,7 @@ This option sets the maximum recursive calls to HWP3 parsing function (default: 16). .TP \fB\-\-pcre-match-limit=#n\fR -Maximum calls to the PCRE match function (default: 10000). +Maximum calls to the PCRE match function (default: 100000). .TP \fB\-\-pcre-recmatch-limit=#n\fR Maximum recursive calls to the PCRE match function (default: 5000). @@ -281,7 +284,7 @@ .TP 1 : Virus(es) found. .TP -2 : Some error(s) occured. +2 : Some error(s) occurred. .SH "CREDITS" Please check the full documentation for credits. .SH "AUTHOR" diff -Nru clamav-0.99.2+dfsg/docs/man/clamsubmit.1.in clamav-0.99.3~beta1+dfsg/docs/man/clamsubmit.1.in --- clamav-0.99.2+dfsg/docs/man/clamsubmit.1.in 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/man/clamsubmit.1.in 2017-02-20 18:36:39.000000000 +0000 @@ -26,6 +26,9 @@ .TP \fB-p FILE\fR Submit a file that reports as a false positive (ClamAV flags the file as virus). FILE can be \- to specify stdin. Mutually exclusive with \-n. +.TP +\fB-V VIRUS\fR +The name of the virus detected as false positive. This option is required for false positive submissions. .SH "AUTHOR" .LP Shawn Webb diff -Nru clamav-0.99.2+dfsg/docs/man/freshclam.conf.5.in clamav-0.99.3~beta1+dfsg/docs/man/freshclam.conf.5.in --- clamav-0.99.2+dfsg/docs/man/freshclam.conf.5.in 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/man/freshclam.conf.5.in 2016-10-13 15:45:43.000000000 +0000 @@ -76,11 +76,6 @@ .br Default: no .TP -\fBAllowSupplementaryGroups BOOL\fR -Initialize supplementary group access (freshclam must be started by root). -.br -Default: disabled -.TP \fBUpdateLogFile STRING\fR Enable logging to a specified file. Highly recommended. .br diff -Nru clamav-0.99.2+dfsg/docs/man/sigtool.1.in clamav-0.99.3~beta1+dfsg/docs/man/sigtool.1.in --- clamav-0.99.2+dfsg/docs/man/sigtool.1.in 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/man/sigtool.1.in 2016-11-03 16:01:29.000000000 +0000 @@ -54,8 +54,8 @@ \fB\-i, \-\-info\fR Print a CVD information and verify MD5 and a digital signature. .TP -\fB\-b, \-\-build\fR -Build a CVD file. \-s, \-\-server is required. +\fB\-\-build=FILE, \-b FILE\fR +Build a CVD file. \-s, \-\-server is required for signed virus databases(.cvd), or, \-\-unsigned for unsigned(.cud). .TP \fB\-\-max\-bad\-sigs=NUMBER\fR Maximum number of mismatched signatures when building a CVD. Default: 3000 @@ -74,7 +74,7 @@ Don't create a .cdiff file when building a new database file. .TP \fB\-\-unsigned\fR -Create a database file without digital signatures (.cua). +Create a database file without digital signatures (.cud). .TP \fB\-\-server\fR ClamAV Signing Service address (for virus database maintainers only). Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/docs/signatures.pdf and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/docs/signatures.pdf differ diff -Nru clamav-0.99.2+dfsg/docs/signatures.tex clamav-0.99.3~beta1+dfsg/docs/signatures.tex --- clamav-0.99.2+dfsg/docs/signatures.tex 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/docs/signatures.tex 2016-11-03 16:01:29.000000000 +0000 @@ -826,7 +826,7 @@ \item \verb+VirusName:+ Virus name to be displayed when signature matches \item \verb+ContainerType:+ one of \verb+CL_TYPE_ZIP+, \verb+CL_TYPE_RAR+, \verb+CL_TYPE_ARJ+,\\ - \verb+CL_TYPE_CAB+, \verb+CL_TYPE_7Z+, \verb+CL_TYPE_MAIL+, \verb+CL_TYPE_(POSIX|OLD)_TAR+,\\ + \verb+CL_TYPE_MSCAB+, \verb+CL_TYPE_7Z+, \verb+CL_TYPE_MAIL+, \verb+CL_TYPE_(POSIX|OLD)_TAR+,\\ \verb+CL_TYPE_CPIO_(OLD|ODC|NEWC|CRC)+ or \verb+*+ to match any of the container types listed here \item \verb+ContainerSize:+ size of the container file itself (eg. size of @@ -940,7 +940,34 @@ \item YARA rules in ClamAV must contain at least one literal, hexadecimal, or regular expression string. \end{itemize} - + In addition, there are a few more ClamAV processing modes that may affect the outcome of YARA rules. + \begin{itemize} + \item \emph{File decomposition and decompression} - Since ClamAV uses file decomposition and decompression + to find viruses within de-archived and uncompressed inner files, YARA rules executed by ClamAV + will match against these files as well. + \item \emph{Normalization} - By default, ClamAV normalizes HTML, JavaScript, and ASCII text files. + YARA rules in ClamAV will match against the normalized result. The effects of normalization + of these file types may be captured using \verb+clamscan --leave-temps --tempdir=mytempdir+. + YARA rules may then be written using the normalized file(s) found in \verb+mytempdir+. + Alternatively, starting with ClamAV 0.99.3, \verb+clamscan --normalize=no+ will prevent + normalization and only scan the raw file. To obtain similar behavior prior to 0.99.2, use + \verb+clamscan --scan-html=no+. The corresponding parameters for clamd.conf are \verb+Normalize+ + and \verb+ScanHTML+. + \item \emph{YARA conditions driven by string matches} - All YARA conditions are driven by string matches in + ClamAV. This saves from executing every YARA rule on every file. Any YARA condition may be augmented + with a string match clause which is always true, such as: + \begin{verbatim} + rule CheckFileSize + { + strings: + $abc = "abc" + condition: + ($abc or not $abc) and filesize < 200KB + } + \end{verbatim} + This will ensure that the YARA condition always performs the desired action (checking the file size in this example), + \end{itemize} + \subsection{Passwords for archive files [experimental]} ClamAV 0.99 allows for users to specify password attempts for certain password-compatible archives. Passwords will be attempted in order of appearance in the password signature file which use the extension @@ -977,7 +1004,7 @@ should generate the following files: \begin{itemize} \item nocomment.html - the file is normalized, lower-case, with all - comments and superflous white space removed + comments and superfluous white space removed \item notags.html - as above but with all HTML tags removed \end{itemize} The code automatically decodes JScript.encode parts and char ref's (e.g. @@ -987,7 +1014,7 @@ \subsection{Text files} Similarly to HTML all ASCII text files get normalized (converted - to lower-case, all superflous white space and control characters removed, + to lower-case, all superfluous white space and control characters removed, etc.) before scanning. Use \verb+clamscan --leave-temps+ to obtain a normalized file then create a signature with the target type 7. diff -Nru clamav-0.99.2+dfsg/etc/clamav-milter.conf.sample clamav-0.99.3~beta1+dfsg/etc/clamav-milter.conf.sample --- clamav-0.99.2+dfsg/etc/clamav-milter.conf.sample 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/etc/clamav-milter.conf.sample 2016-10-13 15:45:43.000000000 +0000 @@ -38,11 +38,6 @@ # Default: unset (don't drop privileges) #User clamav -# Initialize supplementary group access (clamav-milter must be started by root). -# -# Default: no -#AllowSupplementaryGroups no - # Waiting for data from clamd will timeout after this time (seconds). # Value of 0 disables the timeout. # diff -Nru clamav-0.99.2+dfsg/etc/clamd.conf.sample clamav-0.99.3~beta1+dfsg/etc/clamd.conf.sample --- clamav-0.99.2+dfsg/etc/clamd.conf.sample 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/etc/clamd.conf.sample 2017-03-08 14:06:34.000000000 +0000 @@ -56,6 +56,14 @@ # Default: no #LogRotate yes +# Enable Prelude output. +# Default: no +#PreludeEnable yes +# +# Set the name of the analyzer used by prelude-admin. +# Default: ClamAV +#PreludeAnalyzerName ClamAV + # Log additional information about the infected file, such as its # size and hash, together with the virus name. #ExtendedDetectionInfo yes @@ -140,7 +148,7 @@ # Default: 5 #CommandReadTimeout 5 -# This option specifies how long to wait (in miliseconds) if the send buffer is full. +# This option specifies how long to wait (in milliseconds) if the send buffer is full. # Keep this value low to prevent clamd hanging # # Default: 500 @@ -194,10 +202,6 @@ # Default: don't drop privileges #User clamav -# Initialize supplementary group access (clamd must be started by root). -# Default: no -#AllowSupplementaryGroups no - # Stop daemon when libclamav reports out of memory condition. #ExitOnOOM yes @@ -547,7 +551,7 @@ # For more information on match_limit, see the PCRE documentation. # Negative values are not allowed. # WARNING: setting this limit too high may severely impact performance. -# Default: 10000 +# Default: 100000 #PCREMatchLimit 20000 # This option sets the maximum recursive calls to the PCRE match function during an instance of regex matching. @@ -648,7 +652,7 @@ # Default: TrustSigned #BytecodeSecurity TrustSigned -# Set bytecode timeout in miliseconds. +# Set bytecode timeout in milliseconds. # # Default: 5000 # BytecodeTimeout 1000 diff -Nru clamav-0.99.2+dfsg/etc/freshclam.conf.sample clamav-0.99.3~beta1+dfsg/etc/freshclam.conf.sample --- clamav-0.99.2+dfsg/etc/freshclam.conf.sample 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/etc/freshclam.conf.sample 2016-10-13 15:45:43.000000000 +0000 @@ -55,10 +55,6 @@ # Default: clamav (may depend on installation options) #DatabaseOwner clamav -# Initialize supplementary group access (freshclam must be started by root). -# Default: no -#AllowSupplementaryGroups yes - # Use DNS to verify virus database version. Freshclam uses DNS TXT records # to verify database and software versions. With this directive you can change # the database verification domain. diff -Nru clamav-0.99.2+dfsg/etc/Makefile.in clamav-0.99.3~beta1+dfsg/etc/Makefile.in --- clamav-0.99.2+dfsg/etc/Makefile.in 2016-04-22 16:19:52.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/etc/Makefile.in 2017-06-23 21:20:56.000000000 +0000 @@ -105,10 +105,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -163,12 +164,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -287,6 +293,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -314,7 +322,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -408,6 +425,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/freshclam/freshclam.c clamav-0.99.3~beta1+dfsg/freshclam/freshclam.c --- clamav-0.99.2+dfsg/freshclam/freshclam.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/freshclam/freshclam.c 2017-07-19 19:03:40.000000000 +0000 @@ -150,7 +150,7 @@ mprintf (" Clam AntiVirus: freshclam %s\n", get_version ()); printf (" By The ClamAV Team: http://www.clamav.net/about.html#credits\n"); - printf (" (C) 2007-2015 Cisco Systems, Inc.\n\n"); + printf (" (C) 2007-2017 Cisco Systems, Inc.\n\n"); mprintf (" --help -h show help\n"); mprintf @@ -191,7 +191,7 @@ mprintf (" --on-update-execute=COMMAND execute COMMAND after successful update\n"); mprintf - (" --on-error-execute=COMMAND execute COMMAND if errors occured\n"); + (" --on-error-execute=COMMAND execute COMMAND if errors occurred\n"); mprintf (" --on-outdated-execute=COMMAND execute COMMAND when software is outdated\n"); mprintf @@ -419,28 +419,19 @@ return FCE_USERINFO; } - if (optget (opts, "AllowSupplementaryGroups")->enabled) - { #ifdef HAVE_INITGROUPS - if (initgroups (dbowner, user->pw_gid)) - { - logg ("^initgroups() failed.\n"); + if (initgroups(dbowner, user->pw_gid)) { + logg ("^initgroups() failed.\n"); optfree (opts); - return FCE_USERORGROUP; - } -#endif - } - else - { -#ifdef HAVE_SETGROUPS - if (setgroups (1, &user->pw_gid)) - { - logg ("^setgroups() failed.\n"); + return FCE_USERORGROUP; + } +#elif HAVE_SETGROUPS + if (setgroups(1, &user->pw_gid)) { + logg ("^setgroups() failed.\n"); optfree (opts); - return FCE_USERORGROUP; - } + return FCE_USERORGROUP; + } #endif - } if (setgid (user->pw_gid)) { diff -Nru clamav-0.99.2+dfsg/freshclam/Makefile.in clamav-0.99.3~beta1+dfsg/freshclam/Makefile.in --- clamav-0.99.2+dfsg/freshclam/Makefile.in 2016-04-22 16:19:52.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/freshclam/Makefile.in 2017-06-23 21:20:56.000000000 +0000 @@ -109,10 +109,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -167,12 +168,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -344,6 +350,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -371,7 +379,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @SSL_LDFLAGS@ @SSL_LIBS@ $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @THREAD_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -465,6 +482,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/freshclam/manager.c clamav-0.99.3~beta1+dfsg/freshclam/manager.c --- clamav-0.99.2+dfsg/freshclam/manager.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/freshclam/manager.c 2016-10-13 15:45:43.000000000 +0000 @@ -2348,6 +2348,7 @@ } else if (!strncasecmp (url, "file://", 7)) { + time_t dbtime, rtime; rpath = &url[7]; #ifdef _WIN32 dbname = strrchr (rpath, '\\'); @@ -2360,12 +2361,24 @@ return FCE_FAILEDUPDATE; } + if (CLAMSTAT (rpath, &sb) == -1) + { + logg ("DatabaseCustomURL: file %s missing\n", rpath); + return FCE_FAILEDUPDATE; + } + rtime = sb.st_mtime; + dbtime = (CLAMSTAT (dbname, &sb) != -1) ? sb.st_mtime : 0; + if (dbtime > rtime) + { + logg ("%s is up to date (version: custom database)\n", dbname); + return FC_UPTODATE; + } + newfile = cli_gentemp (updtmpdir); if (!newfile) return FCE_FAILEDUPDATE; /* FIXME: preserve file permissions, calculate % */ - logg ("Downloading %s [ 0%%]\r", dbname); if (cli_filecopy (rpath, newfile) == -1) { logg ("DatabaseCustomURL: Can't copy file %s into database directory\n", rpath); @@ -2880,5 +2893,5 @@ if (newver) free (newver); - return 0; + return updated ? 0 : FC_UPTODATE; } diff -Nru clamav-0.99.2+dfsg/libclamav/7z_iface.c clamav-0.99.3~beta1+dfsg/libclamav/7z_iface.c --- clamav-0.99.2+dfsg/libclamav/7z_iface.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/7z_iface.c 2017-04-20 22:19:13.000000000 +0000 @@ -108,11 +108,7 @@ res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp); if(res == SZ_ERROR_ENCRYPTED && DETECT_ENCRYPTED) { cli_dbgmsg("cli_7unz: Encrypted header found in archive.\n"); - cli_append_virus(ctx, "Heuristics.Encrypted.7Zip"); - viruses_found++; - if(!SCAN_ALL) { - found = CL_VIRUS; - } + found = cli_append_virus(ctx, "Heuristics.Encrypted.7Zip"); } else if(res == SZ_OK) { UInt32 i, blockIndex = 0xFFFFFFFF; Byte *outBuffer = 0; @@ -164,11 +160,13 @@ encrypted = 1; if(DETECT_ENCRYPTED) { cli_dbgmsg("cli_7unz: Encrypted files found in archive.\n"); - cli_append_virus(ctx, "Heuristics.Encrypted.7Zip"); - viruses_found++; - if(!SCAN_ALL) { - found = CL_VIRUS; - break; + found = cli_append_virus(ctx, "Heuristics.Encrypted.7Zip"); + if (found != CL_CLEAN) { + if (found == CL_VIRUS) { + if (SCAN_ALL) + viruses_found++; + } else + break; } } } diff -Nru clamav-0.99.2+dfsg/libclamav/apm.c clamav-0.99.3~beta1+dfsg/libclamav/apm.c --- clamav-0.99.2+dfsg/libclamav/apm.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/apm.c 2017-04-20 22:19:13.000000000 +0000 @@ -248,6 +248,7 @@ int ret = CL_CLEAN, tmp = CL_CLEAN; off_t pos; uint32_t max_prtns = 0; + int virus_found = 0; prtn_intxn_list_init(&prtncheck); @@ -286,35 +287,30 @@ tmp = prtn_intxn_list_check(&prtncheck, &pitxn, apentry.pBlockStart, apentry.pBlockCount); if (tmp != CL_CLEAN) { - if ((ctx->options & CL_SCAN_ALLMATCHES) && (tmp == CL_VIRUS)) { + if (tmp == CL_VIRUS) { apm_parsemsg("Name: %s\n", (char*)aptable.name); apm_parsemsg("Type: %s\n", (char*)aptable.type); cli_dbgmsg("cli_scanapm: detected intersection with partitions " "[%u, %u]\n", pitxn, i); - cli_append_virus(ctx, PRTN_INTXN_DETECTION); + ret = cli_append_virus(ctx, PRTN_INTXN_DETECTION); + if (ret == CL_VIRUS) + virus_found = 1; + if (SCAN_ALL || ret == CL_CLEAN) + tmp = 0; + else + goto leave; + } else { ret = tmp; - tmp = 0; - } - else if (tmp == CL_VIRUS) { - apm_parsemsg("Name: %s\n", (char*)aptable.name); - apm_parsemsg("Type: %s\n", (char*)aptable.type); - - cli_dbgmsg("cli_scanapm: detected intersection with partitions " - "[%u, %u]\n", pitxn, i); - cli_append_virus(ctx, PRTN_INTXN_DETECTION); - prtn_intxn_list_free(&prtncheck); - return CL_VIRUS; - } - else { - prtn_intxn_list_free(&prtncheck); - return tmp; + goto leave; } } - pos += sectorsize; } + leave: prtn_intxn_list_free(&prtncheck); + if (virus_found) + return CL_VIRUS; return ret; } diff -Nru clamav-0.99.2+dfsg/libclamav/blob.c clamav-0.99.3~beta1+dfsg/libclamav/blob.c --- clamav-0.99.2+dfsg/libclamav/blob.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/blob.c 2016-10-13 15:45:43.000000000 +0000 @@ -619,6 +619,7 @@ { int rc; STATBUF sb; + int virus_found = 0; if(fb->isInfected) return CL_VIRUS; @@ -636,11 +637,14 @@ fflush(fb->fp); lseek(fb->fd, 0, SEEK_SET); FSTAT(fb->fd, &sb); - if(cli_matchmeta(fb->ctx, fb->b.name, sb.st_size, sb.st_size, 0, 0, 0, NULL) == CL_VIRUS) - return CL_VIRUS; + if(cli_matchmeta(fb->ctx, fb->b.name, sb.st_size, sb.st_size, 0, 0, 0, NULL) == CL_VIRUS) { + if (!(fb->ctx->options & CL_SCAN_ALLMATCHES)) + return CL_VIRUS; + virus_found = 1; + } rc = cli_magic_scandesc(fb->fd, fb->ctx); - if(rc == CL_VIRUS) { + if(rc == CL_VIRUS || virus_found != 0) { cli_dbgmsg("%s is infected\n", fb->fullname); return CL_VIRUS; } diff -Nru clamav-0.99.2+dfsg/libclamav/bytecode_api.c clamav-0.99.3~beta1+dfsg/libclamav/bytecode_api.c --- clamav-0.99.2+dfsg/libclamav/bytecode_api.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/bytecode_api.c 2017-02-20 18:36:39.000000000 +0000 @@ -123,8 +123,8 @@ return -1; } if (off < 0 || off > ctx->file_size) { - cli_dbgmsg("bcapi_seek: out of file: %ld (max %d)\n", - off, ctx->file_size); + cli_dbgmsg("bcapi_seek: out of file: %lld (max %d)\n", + (long long)off, ctx->file_size); return -1; } cli_event_int(EV, BCEV_OFFSET, off); @@ -525,13 +525,13 @@ cli_dbgmsg("bytecode: scanning extracted file %s\n", ctx->tempfile); cctx = (cli_ctx*)ctx->ctx; if (cctx) { - cli_file_t current = cctx->container_type; - if (ctx->containertype != CL_TYPE_ANY) - cctx->container_type = ctx->containertype; cctx->recursion++; + if (ctx->containertype != CL_TYPE_ANY) { + size_t csize = cli_get_container_size(cctx, -2); + cli_set_container(cctx, ctx->containertype, csize); + } res = cli_magic_scandesc(ctx->outfd, cctx); cctx->recursion--; - cctx->container_type = current; if (res == CL_VIRUS) { ctx->virname = cli_get_last_virus(cctx); ctx->found = 1; diff -Nru clamav-0.99.2+dfsg/libclamav/bytecode.c clamav-0.99.3~beta1+dfsg/libclamav/bytecode.c --- clamav-0.99.2+dfsg/libclamav/bytecode.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/bytecode.c 2017-06-23 21:16:39.000000000 +0000 @@ -1406,7 +1406,7 @@ } bcfunc->dbgnodes = cli_malloc(num*sizeof(*bcfunc->dbgnodes)); if (!bcfunc->dbgnodes) { - cli_errmsg("Unable to allocate memory for dbg nodes: %u\n", num*sizeof(*bcfunc->dbgnodes)); + cli_errmsg("Unable to allocate memory for dbg nodes: %lu\n", num*sizeof(*bcfunc->dbgnodes)); return CL_EMEM; } for (i=0;ifuncid; inst.u.ops.ops = ctx->operands; inst.u.ops.opsizes = ctx->opsizes; - cli_dbgmsg("Bytecode %u: executing in interpeter mode\n", bc->id); + cli_dbgmsg("Bytecode %u: executing in interpreter mode\n", bc->id); ctx->on_jit = 0; @@ -1834,7 +1834,7 @@ /* need to be called here to catch any extracted but not yet scanned files */ - if (ctx->outfd) + if (ctx->outfd && (ret != CL_VIRUS || cctx->options & CL_SCAN_ALLMATCHES)) cli_bcapi_extract_new(ctx, -1); } if (bc->state == bc_jit || test_mode) { @@ -1854,7 +1854,7 @@ /* need to be called here to catch any extracted but not yet scanned files */ - if (ctx->outfd) + if (ctx->outfd && (ret != CL_VIRUS || cctx->options & CL_SCAN_ALLMATCHES)) cli_bcapi_extract_new(ctx, -1); } cli_event_time_stop(g_sigevents, bc->sigtime_id); @@ -2071,7 +2071,7 @@ bc->numGlobalBytes = 0; gmap = cli_malloc(bc->num_globals*sizeof(*gmap)); if (!gmap) { - cli_errmsg("interpreter: Unable to allocate memory for global map: %u\n", bc->num_globals*sizeof(*gmap)); + cli_errmsg("interpreter: Unable to allocate memory for global map: %lu\n", bc->num_globals*sizeof(*gmap)); return CL_EMEM; } for (j=0;jnum_globals;j++) { @@ -2153,7 +2153,7 @@ unsigned totValues = bcfunc->numValues + bcfunc->numConstants + bc->num_globals; unsigned *map = cli_malloc(sizeof(*map)*totValues); if (!map) { - cli_errmsg("interpreter: Unable to allocate memory for map: %u\n", sizeof(*map)*totValues); + cli_errmsg("interpreter: Unable to allocate memory for map: %lu\n", sizeof(*map)*totValues); free(gmap); return CL_EMEM; } @@ -2771,6 +2771,9 @@ const struct cli_bc *bc = &bcs->all_bcs[bc_idx-1]; struct cli_pe_hook_data pehookdata; + if (bc_idx == 0) + return CL_ENULLARG; + memset(&ctx, 0, sizeof(ctx)); cli_bytecode_context_setfuncid(&ctx, bc, 0); ctx.hooks.match_counts = lsigcnt; @@ -2808,15 +2811,19 @@ return CL_SUCCESS; } if (ctx.virname) { - int rc; - cli_dbgmsg("Bytecode found virus: %s\n", ctx.virname); - cli_append_virus(cctx, ctx.virname); - if (!strncmp(ctx.virname, "BC.Heuristics", 13)) - rc = cli_found_possibly_unwanted(cctx); - else - rc = CL_VIRUS; - cli_bytecode_context_clear(&ctx); - return rc; + if (cctx->num_viruses == 0) { + int rc; + cli_dbgmsg("Bytecode found virus: %s\n", ctx.virname); + if (!strncmp(ctx.virname, "BC.Heuristics", 13)) + rc = cli_append_possibly_unwanted(cctx, ctx.virname); + else + rc = cli_append_virus(cctx, ctx.virname); + cli_bytecode_context_clear(&ctx); + return rc; + } + else { + return CL_VIRUS; + } } ret = cli_bytecode_context_getresult_int(&ctx); cli_dbgmsg("Bytecode %u returned code: %u\n", bc->id, ret); @@ -3201,7 +3208,7 @@ return; } // globals - printf("found a total of %d globals\n", bc->num_globals); + printf("found a total of %zu globals\n", bc->num_globals); printf("GID ID VALUE\n"); printf("------------------------------------------------------------------------\n"); for (i = 0; i < bc->num_globals; ++i) { diff -Nru clamav-0.99.2+dfsg/libclamav/bytecode_detect.h clamav-0.99.3~beta1+dfsg/libclamav/bytecode_detect.h --- clamav-0.99.2+dfsg/libclamav/bytecode_detect.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/bytecode_detect.h 2017-01-13 18:12:34.000000000 +0000 @@ -64,6 +64,7 @@ os_solaris, os_win32, os_win64, + os_generic, os_ANY = 0xff }; diff -Nru clamav-0.99.2+dfsg/libclamav/bytecode_vm.c clamav-0.99.3~beta1+dfsg/libclamav/bytecode_vm.c --- clamav-0.99.2+dfsg/libclamav/bytecode_vm.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/bytecode_vm.c 2016-10-13 15:45:43.000000000 +0000 @@ -71,7 +71,7 @@ #define CHECK_EQ(a,b) #define CHECK_GT(a,b) #endif -#ifdef CL_DEBUG +#if 0 /* too verbose, use #ifdef CL_DEBUG if needed */ #define CHECK_UNREACHABLE do { cli_dbgmsg("bytecode: unreachable executed!\n"); return CL_EBYTECODE; } while(0) #define TRACE_PTR(ptr, s) cli_dbgmsg("bytecode trace: ptr %llx, +%x\n", ptr, s); #define TRACE_R(x) cli_dbgmsg("bytecode trace: %u, read %llx\n", pc, (long long)x); @@ -153,7 +153,7 @@ /* not enough room here, allocate new chunk */ chunk = cli_malloc(sizeof(*stack->chunk)); if (!chunk) { - cli_warnmsg("cli_stack_alloc: Unable to allocate memory for stack-chunk: bytes: %u!\n", sizeof(*stack->chunk)); + cli_warnmsg("cli_stack_alloc: Unable to allocate memory for stack-chunk: bytes: %zu!\n", sizeof(*stack->chunk)); return NULL; } diff -Nru clamav-0.99.2+dfsg/libclamav/c++/bytecode2llvm.cpp clamav-0.99.3~beta1+dfsg/libclamav/c++/bytecode2llvm.cpp --- clamav-0.99.2+dfsg/libclamav/c++/bytecode2llvm.cpp 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/c++/bytecode2llvm.cpp 2016-11-03 16:01:29.000000000 +0000 @@ -2736,7 +2736,7 @@ badalloc.what()); return CL_EMEM; } catch (...) { - cli_errmsg("[Bytecode JIT]: Unexpected unknown exception occured\n"); + cli_errmsg("[Bytecode JIT]: Unexpected unknown exception occurred\n"); return CL_EBYTECODE; } return 0; diff -Nru clamav-0.99.2+dfsg/libclamav/c++/ClamBCRTChecks.cpp clamav-0.99.3~beta1+dfsg/libclamav/c++/ClamBCRTChecks.cpp --- clamav-0.99.2+dfsg/libclamav/c++/ClamBCRTChecks.cpp 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/c++/ClamBCRTChecks.cpp 2016-10-13 15:45:43.000000000 +0000 @@ -488,8 +488,13 @@ constType *I64Ty = Type::getInt64Ty(Base->getContext()); - if (Base->getType()->isPointerTy()) { - if (Argument *A = dyn_cast(Base)) { +#ifndef CLAMBC_COMPILER + // first arg is hidden ctx + if (Argument *A = dyn_cast(Base)) { + if (A->getArgNo() == 0) { + constType *Ty = cast(A->getType())->getElementType(); + return ConstantInt::get(I64Ty, TD->getTypeAllocSize(Ty)); + } else if (Base->getType()->isPointerTy()) { Function *F = A->getParent(); const FunctionType *FT = F->getFunctionType(); @@ -514,15 +519,6 @@ return BoundsMap[Base] = getValAtIdx(F, A->getArgNo()+1); } } - -#ifndef CLAMBC_COMPILER - // first arg is hidden ctx - if (Argument *A = dyn_cast(Base)) { - if (A->getArgNo() == 0) { - constType *Ty = cast(A->getType())->getElementType(); - return ConstantInt::get(I64Ty, TD->getTypeAllocSize(Ty)); - } - } if (LoadInst *LI = dyn_cast(Base)) { Value *V = GetUnderlyingObject(LI->getPointerOperand()->stripPointerCasts(), TD); if (Argument *A = dyn_cast(V)) { @@ -534,6 +530,33 @@ } } } +#else + if (Base->getType()->isPointerTy()) { + if (Argument *A = dyn_cast(Base)) { + Function *F = A->getParent(); + const FunctionType *FT = F->getFunctionType(); + + bool checks = true; + // last argument check + if (A->getArgNo() == (FT->getNumParams()-1)) { + //printDiagnostic("pointer argument cannot be last argument", F); + errs() << "pointer argument cannot be last argument\n"; + errs() << *F << "\n"; + checks = false; + } + + // argument after pointer MUST be a integer (unsigned probably too) + if (checks && !FT->getParamType(A->getArgNo()+1)->isIntegerTy()) { + //printDiagnostic("argument following pointer argument is not an integer", F); + errs() << "argument following pointer argument is not an integer\n"; + errs() << *F << "\n"; + checks = false; + } + + if (checks) + return BoundsMap[Base] = getValAtIdx(F, A->getArgNo()+1); + } + } #endif if (PHINode *PN = dyn_cast(Base)) { BasicBlock::iterator It = PN; diff -Nru clamav-0.99.2+dfsg/libclamav/c++/configure clamav-0.99.3~beta1+dfsg/libclamav/c++/configure --- clamav-0.99.2+dfsg/libclamav/c++/configure 2016-04-22 16:19:47.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/c++/configure 2017-04-20 22:19:13.000000000 +0000 @@ -648,11 +648,11 @@ DEBUG_BUILD_FALSE DEBUG_BUILD_TRUE LLVM_VERSION -subdirs LLVMCONFIG_LIBFILES LLVMCONFIG_LIBS LLVMCONFIG_LDFLAGS LLVMCONFIG_CXXFLAGS +subdirs llvmconfig GMAKE ifGNUmake @@ -1472,9 +1472,9 @@ --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-system-llvm Use system llvm instead of built-in, uses full path - to llvm-config or bin directory (default=search PATH - environment variable) + --with-system-llvm Specify system llvm location or to use old package, + uses full path to llvm-config or bin directory + (default=search PATH environment variable) --with-llvm-linking specifies method to linking llvm [static|dynamic], only valid with --with-system-llvm @@ -5277,12 +5277,13 @@ save_CFLAGS="$CFLAGS" save_LIBS="$LIBS" -SSL_LIBS="-lssl -lcrypto -lz" +SSL_LIBS="$LIBS -lssl -lcrypto -lz" +LIBS="$LIBS $SSL_LIBS" if test "$LIBSSL_HOME" != "/usr"; then SSL_LDFLAGS="-L$LIBSSL_HOME/lib" SSL_CPPFLAGS="-I$LIBSSL_HOME/include" - LDFLAGS="-L$LIBSSL_HOME/lib $SSL_LIBS" + LDFLAGS="-L$LIBSSL_HOME/lib" CFLAGS="$SSL_CPPFLAGS" else SSL_LDFLAGS="" @@ -5292,47 +5293,24 @@ have_ssl="no" have_crypto="no" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5 -$as_echo_n "checking for SSL_library_init in -lssl... " >&6; } -if ${ac_cv_lib_ssl_SSL_library_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lssl -lcrypto -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 SSL_library_init (); +#include int main () { -return SSL_library_init (); +SSL_library_init(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ssl_SSL_library_init=yes + have_ssl="yes"; else - ac_cv_lib_ssl_SSL_library_init=no + as_fn_error $? "Your OpenSSL installation is misconfigured or missing" "$LINENO" 5 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_ssl_SSL_library_init" >&5 -$as_echo "$ac_cv_lib_ssl_SSL_library_init" >&6; } -if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then : - have_ssl="yes" -else - as_fn_error $? "Your OpenSSL installation is misconfigured or missing" "$LINENO" 5 -fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_EncryptInit in -lcrypto" >&5 @@ -16412,10 +16390,18 @@ fi +if test "$enable_llvm" != "no"; then + # Check whether --with-system-llvm was given. if test "${with_system_llvm+set}" = set; then : - withval=$with_system_llvm; case "$withval" in + withval=$with_system_llvm; system_llvm=$withval; if test "$enable_llvm" = "auto"; then enable_llvm="yes"; fi +else + system_llvm="yes" +fi + + +case "$system_llvm" in yes) # Extract the first word of "llvm-config", so it can be a program name with args. set dummy llvm-config; ac_word=$2 @@ -16458,7 +16444,7 @@ if test "x$llvmconfig" = "x"; then - as_fn_error $? "llvm-config cannot be found within PATH" "$LINENO" 5 + llvmoptserrmsg="llvm-config cannot be found within PATH" fi ;; no) ;; @@ -16512,13 +16498,12 @@ fi if test "x$llvmconfig" = "x"; then - as_fn_error $? "llvm-config does not exist at $withval" "$LINENO" 5 + llvmoptserrmsg="llvm-config does not exist at $withval" fi ;; - esac - -fi +esac +if test "x$llvmconfig" != "x"; then # Check whether --with-llvm-linking was given. @@ -16543,31 +16528,38 @@ fi +llvmver=`$llvmconfig --version` + +else +llvmver="2.8" +system_llvm="internal" + +fi +fi +if test "x$llvmflagerrmsg" != "x"; then + as_fn_error $? "$llvmflagerrmsg" "$LINENO" 5 +fi + if test "x$llvmconfig" != "x"; then - llvmver=`$llvmconfig --version` { $as_echo "$as_me:${as_lineno-$LINENO}: Using external LLVM" >&5 $as_echo "$as_me: Using external LLVM" >&6;} else - llvmver="2.8" packaged_llvm="yes" + + +subdirs="$subdirs llvm" + fi -llvmver_val=`echo "$llvmver" | sed -e 's/svn//g'` +llvmver_prefix=`expr "$llvmver" : '\([^0-9]*\)'` +llvmver_frag=${llvmver#$llvmver_prefix} + +llvmver_major=`expr "$llvmver_frag" : '\([0-9]*\)'` +llvmver_frag=${llvmver_frag#*\.} +llvmver_minor=`expr "$llvmver_frag" : '\([0-9]*\)'` +llvmver_frag=${llvmver_frag#*\.} +llvmver_patch=`expr "$llvmver_frag" : '\([0-9]*\)'` -case $host_os in - darwin* ) - llvmver_sval=`echo "$llvmver_val" | sed -Ee 's/[0-9]+//' | sed -e 's/^\.//'` - llvmver_major=`echo "$llvmver_val" | sed -Ee 's/([0-9]+).*/\1/'` - llvmver_minor=`echo "$llvmver_sval" | sed -Ee 's/([0-9]+).*/\1/'` - llvmver_patch=`echo "$llvmver_sval" | sed -Ee 's/[0-9]+//' | sed -e 's/^\.//' | sed -Ee 's/([0-9]+).*/\1/'` - ;; - *) - llvmver_sval=`echo "$llvmver_val" | sed -re 's/[0-9]+//' | sed -e 's/^\.//'` - llvmver_major=`echo "$llvmver_val" | sed -re 's/([0-9]+).*/\1/'` - llvmver_minor=`echo "$llvmver_sval" | sed -re 's/([0-9]+).*/\1/'` - llvmver_patch=`echo "$llvmver_sval" | sed -re 's/[0-9]+//' | sed -e 's/^\.//' | sed -re 's/([0-9]+).*/\1/'` - ;; -esac llvmver_suffix= if test "x$llvmver_patch" = "x"; then llvmver_patch=0 @@ -16631,15 +16623,6 @@ $as_echo "$as_me: LIBS from llvm-config: $LLVMCONFIG_LIBS" >&6;} fi llvmver_int=${llvmver_major}${llvmver_minor} - - -if test "x$llvmconfig" = "x"; then - - -subdirs="$subdirs llvm" - -fi - LLVM_VERSION=$llvmver_int diff -Nru clamav-0.99.2+dfsg/libclamav/c++/configure.ac clamav-0.99.3~beta1+dfsg/libclamav/c++/configure.ac --- clamav-0.99.2+dfsg/libclamav/c++/configure.ac 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/c++/configure.ac 2016-10-13 15:45:43.000000000 +0000 @@ -50,13 +50,82 @@ GMAKE="$llvm_cv_gnu_make_command" AC_SUBST([GMAKE]) -m4_include(m4/llvm-flags.m4) +m4_include(m4/llvm-opts.m4) +if test "x$llvmflagerrmsg" != "x"; then + AC_MSG_ERROR([$llvmflagerrmsg]) +fi -if test "x$llvmconfig" = "x"; then +dnl Version number check +if test "x$llvmconfig" != "x"; then + AC_MSG_NOTICE([Using external LLVM]) +else + packaged_llvm="yes" dnl macro not available in older autotools AC_CONFIG_SUBDIRS([llvm]) fi +llvmver_prefix=`expr "$llvmver" : '\([[^0-9]]*\)'` +llvmver_frag=${llvmver#$llvmver_prefix} + +llvmver_major=`expr "$llvmver_frag" : '\([[0-9]]*\)'` +llvmver_frag=${llvmver_frag#*\.} +llvmver_minor=`expr "$llvmver_frag" : '\([[0-9]]*\)'` +llvmver_frag=${llvmver_frag#*\.} +llvmver_patch=`expr "$llvmver_frag" : '\([[0-9]]*\)'` + +dnl suffix unused as of LLVM 3.4.1 +llvmver_suffix= +if test "x$llvmver_patch" = "x"; then + llvmver_patch=0 +fi + +AC_MSG_CHECKING([for supported LLVM version]) +llvmver_test=${llvmver_major}${llvmver_minor}${llvmver_patch} +if test "x$packaged_llvm" = "xyes"; then + AC_MSG_RESULT([ok ($llvmver)]) +elif test $llvmver_test -lt 290; then + AC_MSG_RESULT([no ($llvmver)]) + AC_MSG_ERROR([LLVM >= 2.9 required, but "$llvmver"($llvmver_test) found]) +elif test $llvmver_test -lt 360; then + llvmcomp="jit nativecodegen scalaropts ipo" + AC_MSG_RESULT([ok ($llvmver)]) +elif test $llvmver_test -lt 370; then + dnl LLVM 3.6.0 removed jit, so we have to use mcjit + dnl and we're using InitializeNativeTargetAsmParser, so we need the architecture specific parsers + llvmcomp="mcjit nativecodegen scalaropts ipo x86asmparser powerpcasmparser" + AC_MSG_RESULT([ok ($llvmver)]) +else + AC_MSG_RESULT([no ($llvmver)]) + AC_MSG_ERROR([LLVM < 3.7 required, but "$llvmver"($llvmver_test) found]) +fi + +dnl acquire the required flags to properly link in external LLVM +if test "x$llvmconfig" != "x"; then + AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`]) + + if test "x$llvm_linking" = "xdynamic"; then + AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`]) + AC_SUBST(LLVMCONFIG_LIBS, [-lLLVM-$llvmver]) + AC_SUBST(LLVMCONFIG_LIBFILES, []) + else + if test $llvmver_test -ge 350; then + dnl LLVM 3.5.0 and after splits linker flags into two sets + ldflags=`$llvmconfig --ldflags` + syslibs=`$llvmconfig --system-libs` + AC_SUBST(LLVMCONFIG_LDFLAGS, ["$ldflags $syslibs"]) + else + AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`]) + fi + AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs $llvmcomp`]) + AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles $llvmcomp`]) + fi + + AC_MSG_NOTICE([CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS]) + AC_MSG_NOTICE([LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS]) + AC_MSG_NOTICE([LIBS from llvm-config: $LLVMCONFIG_LIBS]) +fi +dnl patch does not affect clamav source (yet) +llvmver_int=${llvmver_major}${llvmver_minor} AC_SUBST([LLVM_VERSION], [$llvmver_int]) AC_ARG_ENABLE([llvm],AC_HELP_STRING([-enable-llvm], diff -Nru clamav-0.99.2+dfsg/libclamav/c++/m4/llvm-flags.m4 clamav-0.99.3~beta1+dfsg/libclamav/c++/m4/llvm-flags.m4 --- clamav-0.99.2+dfsg/libclamav/c++/m4/llvm-flags.m4 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/c++/m4/llvm-flags.m4 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -dnl Act as a single handler point for LLVM options -dnl Compile a set of compile and linker flags for LLVM -dnl Populates LLVMCONFIG_CXXFLAGS, LLVMCONFIG_LDFLAGS, LLVMCONFIG_LIBS, and LLVMCONFIG_LIBFILES macros -dnl Assigns llvmver_int, system_llvm, llvm_linking, and enable_llvm variables (for tracking in features summary) - -dnl Determine if LLVM is requested (or auto, reassigned if system-llvm specified) -AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm], -[enable 'llvm' JIT/verifier support @<:@default=auto@:>@]), -[enable_llvm=$enableval], [enable_llvm="auto"]) - -dnl Determine whether to user built in LLVM or to use system-specified LLVM -dnl locate the llvmconfig program -AC_ARG_WITH([system-llvm], AC_HELP_STRING([--with-system-llvm], -[Use system llvm instead of built-in, uses full path to llvm-config or bin directory - (default=search PATH environment variable)]), -[case "$withval" in - yes) - AC_PATH_PROG([llvmconfig], [llvm-config]) - if test "x$llvmconfig" = "x"; then - AC_MSG_ERROR([llvm-config cannot be found within PATH]) - fi - ;; - no) ;; - *) - if test -d "$withval"; then - AC_PATH_PROG([llvmconfig], [llvm-config], [], [$withval/bin]) - else - llvmconfig=$withval - if test ! -x "$llvmconfig"; then - llvmconfig="" - fi - fi - - if test "x$llvmconfig" = "x"; then - AC_MSG_ERROR([llvm-config does not exist at $withval]) - fi - ;; - esac -]) - -dnl Determine linking method to external LLVM, built-in only does static linking -AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking], -[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])], -[if test "x$llvmconfig" = "x"; then - AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without valid llvm-config]) -else - case "$withval" in - static) - llvm_linking="static" - ;; - dynamic) - llvm_linking="dynamic" - ;; - *) - AC_MSG_ERROR([Invalid argument to --with-llvm-linking]) - esac -fi -], [llvm_linking=""]) - -dnl Version number check -if test "x$llvmconfig" != "x"; then - llvmver=`$llvmconfig --version` - AC_MSG_NOTICE([Using external LLVM]) -else - llvmver="2.8" - packaged_llvm="yes" -fi - -llvmver_val=`echo "$llvmver" | sed -e 's/svn//g'` -AC_CANONICAL_HOST -case $host_os in - darwin* ) - llvmver_sval=`echo "$llvmver_val" | sed -Ee 's/[[0-9]]+//' | sed -e 's/^\.//'` - llvmver_major=`echo "$llvmver_val" | sed -Ee 's/([[0-9]]+).*/\1/'` - llvmver_minor=`echo "$llvmver_sval" | sed -Ee 's/([[0-9]]+).*/\1/'` - llvmver_patch=`echo "$llvmver_sval" | sed -Ee 's/[[0-9]]+//' | sed -e 's/^\.//' | sed -Ee 's/([[0-9]]+).*/\1/'` - ;; - *) - llvmver_sval=`echo "$llvmver_val" | sed -re 's/[[0-9]]+//' | sed -e 's/^\.//'` - llvmver_major=`echo "$llvmver_val" | sed -re 's/([[0-9]]+).*/\1/'` - llvmver_minor=`echo "$llvmver_sval" | sed -re 's/([[0-9]]+).*/\1/'` - llvmver_patch=`echo "$llvmver_sval" | sed -re 's/[[0-9]]+//' | sed -e 's/^\.//' | sed -re 's/([[0-9]]+).*/\1/'` - ;; -esac -dnl suffix unused as of LLVM 3.4.1 -llvmver_suffix= -if test "x$llvmver_patch" = "x"; then - llvmver_patch=0 -fi - -AC_MSG_CHECKING([for supported LLVM version]) -llvmver_test=${llvmver_major}${llvmver_minor}${llvmver_patch} -if test "x$packaged_llvm" = "xyes"; then - AC_MSG_RESULT([ok ($llvmver)]) -elif test $llvmver_test -lt 290; then - AC_MSG_RESULT([no ($llvmver)]) - AC_MSG_ERROR([LLVM >= 2.9 required, but "$llvmver"($llvmver_test) found]) -elif test $llvmver_test -lt 360; then - llvmcomp="jit nativecodegen scalaropts ipo" - AC_MSG_RESULT([ok ($llvmver)]) -elif test $llvmver_test -lt 370; then - dnl LLVM 3.6.0 removed jit, so we have to use mcjit - dnl and we're using InitializeNativeTargetAsmParser, so we need the architecture specific parsers - llvmcomp="mcjit nativecodegen scalaropts ipo x86asmparser powerpcasmparser" - AC_MSG_RESULT([ok ($llvmver)]) -else - AC_MSG_RESULT([no ($llvmver)]) - AC_MSG_ERROR([LLVM < 3.7 required, but "$llvmver"($llvmver_test) found]) -fi - -dnl aquire the required flags to properly link in external LLVM -if test "x$llvmconfig" != "x"; then - AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`]) - - if test "x$llvm_linking" = "xdynamic"; then - AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`]) - AC_SUBST(LLVMCONFIG_LIBS, [-lLLVM-$llvmver]) - AC_SUBST(LLVMCONFIG_LIBFILES, []) - else - if test $llvmver_test -ge 350; then - dnl LLVM 3.5.0 and after splits linker flags into two sets - ldflags=`$llvmconfig --ldflags` - syslibs=`$llvmconfig --system-libs` - AC_SUBST(LLVMCONFIG_LDFLAGS, ["$ldflags $syslibs"]) - else - AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`]) - fi - AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs $llvmcomp`]) - AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles $llvmcomp`]) - fi - - AC_MSG_NOTICE([CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS]) - AC_MSG_NOTICE([LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS]) - AC_MSG_NOTICE([LIBS from llvm-config: $LLVMCONFIG_LIBS]) -fi -dnl patch does not affect clamav source (yet) -llvmver_int=${llvmver_major}${llvmver_minor} diff -Nru clamav-0.99.2+dfsg/libclamav/c++/m4/llvm-opts.m4 clamav-0.99.3~beta1+dfsg/libclamav/c++/m4/llvm-opts.m4 --- clamav-0.99.2+dfsg/libclamav/c++/m4/llvm-opts.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/c++/m4/llvm-opts.m4 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,74 @@ +dnl Act as a single handler point for LLVM options +dnl Assigns enable_llvm, system_llvm, llvm_linking, and llvmver variables +dnl Assigns llvmoptserrmsg variable on error + +dnl Determine if LLVM is requested (or auto, reassigned if system-llvm specified) +dnl Overrides "auto" with "yes" if a system-llvm is specified +AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm], +[enable 'llvm' JIT/verifier support @<:@default=auto@:>@]), +[enable_llvm=$enableval], [enable_llvm="auto"]) + +if test "$enable_llvm" != "no"; then + +dnl Determine whether to user built in LLVM or to use system-specified LLVM +dnl locate the llvmconfig program +AC_ARG_WITH([system-llvm], AC_HELP_STRING([--with-system-llvm], +[Specify system llvm location or to use old package, uses full path to llvm-config or bin directory + (default=search PATH environment variable)]), +[system_llvm=$withval; if test "$enable_llvm" = "auto"; then enable_llvm="yes"; fi], [system_llvm="yes"]) + +case "$system_llvm" in + yes) + AC_PATH_PROG([llvmconfig], [llvm-config]) + if test "x$llvmconfig" = "x"; then + llvmoptserrmsg="llvm-config cannot be found within PATH" + fi + ;; + no) ;; + *) + if test -d "$withval"; then + AC_PATH_PROG([llvmconfig], [llvm-config], [], [$withval/bin]) + else + llvmconfig=$withval + if test ! -x "$llvmconfig"; then + llvmconfig="" + fi + fi + + if test "x$llvmconfig" = "x"; then + llvmoptserrmsg="llvm-config does not exist at $withval" + fi + ;; +esac + +if test "x$llvmconfig" != "x"; then + +dnl Determine linking method to external LLVM, built-in only does static linking +AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking], +[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])], +[if test "x$llvmconfig" = "x"; then + AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without valid llvm-config]) +else + case "$withval" in + static) + llvm_linking="static" + ;; + dynamic) + llvm_linking="dynamic" + ;; + *) + AC_MSG_ERROR([Invalid argument to --with-llvm-linking]) + esac +fi +], [llvm_linking=""]) + +llvmver=`$llvmconfig --version` + +else dnl test "x$llvmconfig" != "x" + +llvmver="2.8" +system_llvm="internal" + +fi dnl test "x$llvmconfig" != "x" + +fi dnl test "enable_llvm" != "no diff -Nru clamav-0.99.2+dfsg/libclamav/c++/Makefile.am clamav-0.99.3~beta1+dfsg/libclamav/c++/Makefile.am --- clamav-0.99.2+dfsg/libclamav/c++/Makefile.am 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/c++/Makefile.am 2016-10-13 15:45:43.000000000 +0000 @@ -63,7 +63,11 @@ libclamavcxx_la_LIBADD+=libllvmcodegen.la libllvmsystem.la -LLVM_CXXFLAGS=-Woverloaded-virtual -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings +# crdaviso@cisco.com - Removed -pedantic from the following line to allow +# building on CentOS 5 (g++ 4.1.2). An openssl header file is included that +# includes a comma at the end of an enumerator list, which is valid in C99 but +# not C++98, so -pedantic produces an error and the build fails. +LLVM_CXXFLAGS=-Woverloaded-virtual -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings unittest_CXXFLAGS=@NO_VARIADIC_MACROS@ @NO_MISSING_FIELD_INITIALIZERS@ -DGTEST_HAS_TR1_TUPLE=0 TBLGENFILES=llvm/include/llvm/Intrinsics.gen X86GenRegisterInfo.h.inc X86GenRegisterNames.inc X86GenRegisterInfo.inc X86GenInstrNames.inc X86GenInstrInfo.inc\ diff -Nru clamav-0.99.2+dfsg/libclamav/c++/Makefile.in clamav-0.99.3~beta1+dfsg/libclamav/c++/Makefile.in --- clamav-0.99.2+dfsg/libclamav/c++/Makefile.in 2016-04-22 16:18:10.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/c++/Makefile.in 2017-06-23 21:20:45.000000000 +0000 @@ -123,7 +123,7 @@ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/../../m4/reorganization/libs/openssl.m4 \ - $(top_srcdir)/m4/llvm-flags.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/llvm-opts.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ @@ -1093,7 +1093,12 @@ @BUILD_EXTERNAL_LLVM_FALSE@libclamavcxx_la_LIBADD = libllvmjit.la \ @BUILD_EXTERNAL_LLVM_FALSE@ $(am__append_3) $(am__append_6) \ @BUILD_EXTERNAL_LLVM_FALSE@ libllvmcodegen.la libllvmsystem.la -@BUILD_EXTERNAL_LLVM_FALSE@LLVM_CXXFLAGS = -Woverloaded-virtual -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings + +# crdaviso@cisco.com - Removed -pedantic from the following line to allow +# building on CentOS 5 (g++ 4.1.2). An openssl header file is included that +# includes a comma at the end of an enumerator list, which is valid in C99 but +# not C++98, so -pedantic produces an error and the build fails. +@BUILD_EXTERNAL_LLVM_FALSE@LLVM_CXXFLAGS = -Woverloaded-virtual -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings @BUILD_EXTERNAL_LLVM_FALSE@unittest_CXXFLAGS = @NO_VARIADIC_MACROS@ @NO_MISSING_FIELD_INITIALIZERS@ -DGTEST_HAS_TR1_TUPLE=0 @BUILD_EXTERNAL_LLVM_FALSE@TBLGENFILES = llvm/include/llvm/Intrinsics.gen X86GenRegisterInfo.h.inc X86GenRegisterNames.inc X86GenRegisterInfo.inc X86GenInstrNames.inc X86GenInstrInfo.inc\ @BUILD_EXTERNAL_LLVM_FALSE@ X86GenDAGISel.inc X86GenFastISel.inc X86GenCallingConv.inc\ diff -Nru clamav-0.99.2+dfsg/libclamav/c++/PointerTracking.cpp clamav-0.99.3~beta1+dfsg/libclamav/c++/PointerTracking.cpp --- clamav-0.99.2+dfsg/libclamav/c++/PointerTracking.cpp 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/c++/PointerTracking.cpp 2016-11-03 16:01:29.000000000 +0000 @@ -52,7 +52,7 @@ using namespace llvm; #if LLVM_VERSION < 29 -/* function is succeeded in later LLVM with LLVM correspoding standalone */ +/* function is succeeded in later LLVM with LLVM corresponding standalone */ static Value *GetUnderlyingObject(Value *P, TargetData *TD) { return P->getUnderlyingObject(); diff -Nru clamav-0.99.2+dfsg/libclamav/cab.c clamav-0.99.3~beta1+dfsg/libclamav/cab.c --- clamav-0.99.2+dfsg/libclamav/cab.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/cab.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,685 +0,0 @@ -/* - * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. - * Copyright (C) 2007-2008 Sourcefire, Inc. - * - * Authors: Tomasz Kojm - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ - -#if HAVE_CONFIG_H -#include "clamav-config.h" -#endif - -#include -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include - -#include "clamav.h" -#include "cltypes.h" -#include "others.h" -#include "mspack.h" -#include "cab.h" - -#define EC32(x) cli_readint32(&x) /* Convert little endian to host */ -#define EC16(x) cli_readint16(&x) - -/* hard limits */ -#define CAB_FOLDER_LIMIT 5000 -#define CAB_FILE_LIMIT 5000 - -/* Cabinet format data structures */ - -struct cab_hdr { - uint32_t signature; /* file signature */ - uint32_t res1; /* reserved */ - uint32_t cbCabinet; /* size of cabinet file */ - uint32_t res2; /* reserved */ - uint32_t coffFiles; /* offset of the first file entry */ - uint32_t res3; /* reserved */ - uint8_t versionMinor; /* file format version, minor */ - uint8_t versionMajor; /* file format version, major */ - uint16_t cFolders; /* number of folder entries */ - uint16_t cFiles; /* number of file entries */ - uint16_t flags; /* option flags */ - uint16_t setID; /* multiple cabs related */ - uint16_t iCabinet; /* multiple cabs related */ -}; - -struct cab_hdr_opt { - uint16_t cbCFHeader; /* size of reserved header area */ - uint8_t cbCFFolder; /* size of reserved folder area */ - uint8_t cbCFData; /* size of reserved block area */ -}; - -struct cab_folder_hdr -{ - uint32_t coffCabStart; /* offset of the first data block */ - uint16_t cCFData; /* number of data blocks */ - uint16_t typeCompress; /* compression type */ -}; - -struct cab_file_hdr -{ - uint32_t cbFile; /* uncompressed size */ - uint32_t uoffFolderStart; /* uncompressed offset of file in folder */ - uint16_t iFolder; /* folder index */ - uint16_t date; /* date stamp */ - uint16_t time; /* time stamp */ - uint16_t attribs; /* attribute flags */ -}; - -struct cab_block_hdr -{ - uint32_t csum; /* data block checksum */ - uint16_t cbData; /* number of compressed bytes */ - uint16_t cbUncomp; /* number of uncompressed bytes */ -}; - -static char *cab_readstr(fmap_t *map, off_t *offset, int *ret) -{ - int i; - const char *str; - char *retstr; - - if(!(str = fmap_need_offstr(map, *offset, 256))) { - *ret = CL_EFORMAT; - return NULL; - } - - i = strlen(str) + 1; - if(i>=255) { - fmap_unneed_ptr(map, str, i); - *ret = CL_EFORMAT; - return NULL; - } - - *offset += i; - if((retstr = cli_malloc(i))) - memcpy(retstr, str, i); - fmap_unneed_ptr(map, str, i); - - if(!retstr) { - *ret = CL_EMEM; - return NULL; - } - - *ret = CL_SUCCESS; - return retstr; -} - -static int cab_chkname(char *name, int san) -{ - size_t i, len = strlen(name); - - - for(i = 0; i < len; i++) { - if(!san && (strchr("%/*?|\\\"+=<>;:\t ", name[i]) || !isascii(name[i]))) { - cli_dbgmsg("cab_chkname: File name contains disallowed characters\n"); - return 1; - } else if(san && !isalnum(name[i])) { - name[i] = '*'; - } - } - - return 0; -} - -void cab_free(struct cab_archive *cab) -{ - struct cab_folder *folder; - struct cab_file *file; - - - if(cab->state) { - if(cab->state->stream) { - switch(cab->state->cmethod & 0x000f) { - case 0x0001: - mszip_free(cab->state->stream); - break; - case 0x0002: - qtm_free(cab->state->stream); - break; - case 0x0003: - lzx_free(cab->state->stream); - } - } - free(cab->state); - } - - while(cab->folders) { - folder = cab->folders; - cab->folders = cab->folders->next; - free(folder); - } - - while(cab->files) { - file = cab->files; - cab->files = cab->files->next; - free(file->name); - free(file); - } -} - -int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab) -{ - unsigned int i, folders = 0; - struct cab_file *file, *lfile = NULL; - struct cab_folder *folder, *lfolder = NULL; - const struct cab_hdr *hdr; - const struct cab_hdr_opt *hdr_opt; - uint16_t fidx; - uint32_t coffFiles; - char *pt; - int ret; - off_t resfold = 0, rsize, cur_offset = offset; - - if(!(hdr=fmap_need_off_once(map, cur_offset, sizeof(*hdr)))) { - cli_dbgmsg("cab_open: Can't read cabinet header\n"); - return CL_EFORMAT; /* most likely a corrupted file */ - } - cur_offset += sizeof(*hdr); - - if(EC32(hdr->signature) != 0x4643534d) { - cli_dbgmsg("cab_open: Incorrect CAB signature\n"); - return CL_EFORMAT; - } else { - cli_dbgmsg("CAB: -------------- Cabinet file ----------------\n"); - } - - rsize = map->len; - - memset(cab, 0, sizeof(struct cab_archive)); - - cab->length = EC32(hdr->cbCabinet); - cli_dbgmsg("CAB: Cabinet length: %u\n", cab->length); - if((off_t) cab->length > rsize) { - cli_dbgmsg("CAB: Truncating file size from %lu to %lu\n", (unsigned long int) cab->length, (unsigned long int) rsize); - cab->length = (uint32_t) rsize; - } - - cab->nfolders = EC16(hdr->cFolders); - if(!cab->nfolders) { - cli_dbgmsg("cab_open: No folders in cabinet (fake cab?)\n"); - return CL_EFORMAT; - } else { - cli_dbgmsg("CAB: Folders: %u\n", cab->nfolders); - if(cab->nfolders > CAB_FOLDER_LIMIT) { - cab->nfolders = CAB_FOLDER_LIMIT; - cli_dbgmsg("CAB: *** Number of folders limited to %u ***\n", cab->nfolders); - } - } - - cab->nfiles = EC16(hdr->cFiles); - if(!cab->nfiles) { - cli_dbgmsg("cab_open: No files in cabinet (fake cab?)\n"); - return CL_EFORMAT; - } else { - cli_dbgmsg("CAB: Files: %u\n", cab->nfiles); - if(cab->nfiles > CAB_FILE_LIMIT) { - cab->nfiles = CAB_FILE_LIMIT; - cli_dbgmsg("CAB: *** Number of files limited to %u ***\n", cab->nfiles); - } - } - - cli_dbgmsg("CAB: File format version: %u.%u\n", hdr->versionMajor, hdr->versionMinor); - - cab->flags = EC16(hdr->flags); - coffFiles = EC16(hdr->coffFiles); - - if(cab->flags & 0x0004) { - if(!(hdr_opt = fmap_need_off_once(map, cur_offset, sizeof(*hdr_opt)))) { - cli_dbgmsg("cab_open: Can't read file header (fake cab?)\n"); - return CL_EFORMAT; /* most likely a corrupted file */ - } - - cab->reshdr = EC16(hdr_opt->cbCFHeader); - resfold = hdr_opt->cbCFFolder; - cab->resdata = hdr_opt->cbCFData; - - cur_offset += sizeof(*hdr_opt) + cab->reshdr; - if(cab->reshdr) { - if(cab->reshdr >= rsize) { - cli_dbgmsg("cab_open: Can't lseek to %u (fake cab?)\n", cab->reshdr); - return CL_EFORMAT; /* most likely a corrupted file */ - } - } - } - - if(cab->flags & 0x0001) { /* preceding cabinet */ - /* name */ - pt = cab_readstr(map, &cur_offset, &ret); - if(ret) - return ret; - if(cab_chkname(pt, 0)) - cli_dbgmsg("CAB: Invalid name of preceding cabinet\n"); - else - cli_dbgmsg("CAB: Preceding cabinet name: %s\n", pt); - free(pt); - /* info */ - pt = cab_readstr(map, &cur_offset, &ret); - if(ret) - return ret; - if(cab_chkname(pt, 0)) - cli_dbgmsg("CAB: Invalid info for preceding cabinet\n"); - else - cli_dbgmsg("CAB: Preceding cabinet info: %s\n", pt); - free(pt); - } - - if(cab->flags & 0x0002) { /* next cabinet */ - /* name */ - pt = cab_readstr(map, &cur_offset, &ret); - if(ret) - return ret; - if(cab_chkname(pt, 0)) - cli_dbgmsg("CAB: Invalid name of next cabinet\n"); - else - cli_dbgmsg("CAB: Next cabinet name: %s\n", pt); - free(pt); - /* info */ - pt = cab_readstr(map, &cur_offset, &ret); - if(ret) - return ret; - if(cab_chkname(pt, 0)) - cli_dbgmsg("CAB: Invalid info for next cabinet\n"); - else - cli_dbgmsg("CAB: Next cabinet info: %s\n", pt); - free(pt); - } - - /* folders */ - for(i = 0; i < cab->nfolders; i++) { - const struct cab_folder_hdr *folder_hdr; - - if(!(folder_hdr = fmap_need_off_once(map, cur_offset, sizeof(*folder_hdr)))) { - cli_dbgmsg("cab_open: Can't read header for folder %u\n", i); - break; - } - - cur_offset += sizeof(*folder_hdr) + resfold; - - if(EC32(folder_hdr->coffCabStart) + offset > rsize) { - cli_dbgmsg("CAB: Folder out of file\n"); - continue; - } - - if((EC16(folder_hdr->typeCompress) & 0x000f) > 3) { - cli_dbgmsg("CAB: Unknown compression method\n"); - continue; - } - - folder = (struct cab_folder *) cli_calloc(1, sizeof(struct cab_folder)); - if(!folder) { - cli_errmsg("cab_open: Can't allocate memory for folder\n"); - cab_free(cab); - return CL_EMEM; - } - - folder->cab = (struct cab_archive *) cab; - folder->offset = (off_t) EC32(folder_hdr->coffCabStart) + offset; - folder->nblocks = EC16(folder_hdr->cCFData); - folder->cmethod = EC16(folder_hdr->typeCompress); - - cli_dbgmsg("CAB: Folder record %u\n", i); - cli_dbgmsg("CAB: Folder offset: %u\n", (unsigned int) folder->offset); - cli_dbgmsg("CAB: Folder compression method: %d\n", folder->cmethod); - - if(!lfolder) - cab->folders = folder; - else - lfolder->next = folder; - - lfolder = folder; - folders++; - } - cli_dbgmsg("CAB: Recorded folders: %u\n", folders); - - /* files */ - if(cab->nfolders != folders) { - if(coffFiles >= rsize) { - cli_dbgmsg("cab_open: Can't lseek to hdr.coffFiles\n"); - cab_free(cab); - return CL_EFORMAT; - } - cur_offset = coffFiles; - } - for(i = 0; i < cab->nfiles; i++) { - const struct cab_file_hdr *file_hdr; - - if(!(file_hdr = fmap_need_off_once(map, cur_offset, sizeof(*file_hdr)))) { - cli_dbgmsg("cab_open: Can't read file %u header\n", i); - break; - } - cur_offset += sizeof(*file_hdr); - - file = (struct cab_file *) cli_calloc(1, sizeof(struct cab_file)); - if(!file) { - cli_errmsg("cab_open: Can't allocate memory for file\n"); - cab_free(cab); - return CL_EMEM; - } - - file->cab = cab; - cab->map = map; - file->offset = EC32(file_hdr->uoffFolderStart); - file->length = EC32(file_hdr->cbFile); - file->attribs = EC16(file_hdr->attribs); - fidx = EC16(file_hdr->iFolder); - file->error = CL_SUCCESS; - - file->name = cab_readstr(map, &cur_offset, &ret); - if(ret) { - free(file); - continue; - } - cab_chkname(file->name, 1); - - cli_dbgmsg("CAB: File record %u\n", i); - cli_dbgmsg("CAB: File name: %s\n", file->name); - cli_dbgmsg("CAB: File offset: %u\n", (unsigned int) file->offset); - cli_dbgmsg("CAB: File folder index: %u\n", fidx); - cli_dbgmsg("CAB: File attribs: 0x%x\n", file->attribs); - if(file->attribs & 0x01) - cli_dbgmsg("CAB: * file is read-only\n"); - if(file->attribs & 0x02) - cli_dbgmsg("CAB: * file is hidden\n"); - if(file->attribs & 0x04) - cli_dbgmsg("CAB: * file is a system file\n"); - if(file->attribs & 0x20) - cli_dbgmsg("CAB: * file modified since last backup\n"); - if(file->attribs & 0x40) - cli_dbgmsg("CAB: * file to be run after extraction\n"); - if(file->attribs & 0x80) - cli_dbgmsg("CAB: * file name contains UTF\n"); - - /* folder index */ - if(fidx < 0xfffd) { - if(fidx > cab->nfolders) { - cli_dbgmsg("cab_open: File %s is not associated with any folder\n", file->name); - free(file->name); - free(file); - continue; - } - - file->folder = cab->folders; - while(file->folder && fidx--) - file->folder = file->folder->next; - - if(!file->folder) { - cli_dbgmsg("cab_open: Folder not found for file %s\n", file->name); - free(file->name); - free(file); - continue; - } - - } else { - cli_dbgmsg("CAB: File is split *skipping*\n"); - free(file->name); - free(file); - continue; - } - - if(!lfile) - cab->files = file; - else - lfile->next = file; - - lfile = file; - - } - - return CL_SUCCESS; -} - -static int cab_read_block(struct cab_file *file) -{ - const struct cab_block_hdr *block_hdr; - struct cab_state *state = file->cab->state; - - if(!(block_hdr = fmap_need_off_once(file->cab->map, file->cab->cur_offset, sizeof(*block_hdr)))) { - cli_dbgmsg("cab_read_block: Can't read block header\n"); - return CL_EFORMAT; /* most likely a corrupted file */ - } - - file->cab->cur_offset += sizeof(*block_hdr) + file->cab->resdata; - state->blklen = EC16(block_hdr->cbData); - state->outlen = EC16(block_hdr->cbUncomp); - - if(fmap_readn(file->cab->map, state->block, file->cab->cur_offset, state->blklen) != state->blklen) { - cli_dbgmsg("cab_read_block: Can't read block data\n"); - return CL_EFORMAT; /* most likely a corrupted file */ - } - - file->cab->cur_offset += state->blklen; - state->pt = state->end = state->block; - state->end += state->blklen; - - return CL_SUCCESS; -} - -static int cab_read(struct cab_file *file, unsigned char *buffer, int bytes) -{ - uint16_t todo, left; - - - if((file->cab->state->blknum > file->folder->nblocks) && !file->lread) { - file->error = CL_BREAK; - return -1; - } - - todo = bytes; - while(todo > 0) { - left = file->cab->state->end - file->cab->state->pt; - - if(left) { - if(left > todo) - left = todo; - - memcpy(buffer, file->cab->state->pt, left); - file->cab->state->pt += left; - buffer += left; - todo -= left; - - } else { - if(file->cab->state->blknum++ >= file->folder->nblocks) - break; - - file->error = cab_read_block(file); - if(file->error) - return -1; - - if((file->folder->cmethod & 0x000f) == 0x0002) /* Quantum hack */ - *file->cab->state->end++ = 0xff; - - if(file->cab->state->blknum >= file->folder->nblocks) { - if((file->folder->cmethod & 0x000f) == 0x0003) { /* LZX hack */ - lzx_set_output_length(file->cab->state->stream, (off_t) ((file->cab->state->blknum - 1) * 32768 + file->cab->state->outlen)); - } - } else { - if(file->cab->state->outlen != 32768) { - cli_dbgmsg("cab_read: WARNING: partial data block\n"); - } - } - } - } - - return file->lread = bytes - todo; -} - -static int cab_unstore(struct cab_file *file) -{ - int todo, bread, bytes = file->length; - unsigned char buff[4096]; - - - if(bytes < 0) { - cli_dbgmsg("cab_unstore: bytes < 0\n"); - return CL_EFORMAT; - } - - todo = MIN((unsigned int) bytes, file->max_size); - - while(1) { - - if((unsigned int) todo <= sizeof(buff)) - bread = todo; - else - bread = sizeof(buff); - - if((bread = cab_read(file, buff, bread)) == -1) { - cli_dbgmsg("cab_unstore: cab_read failed\n"); - return file->error; - } else if(cli_writen(file->ofd, buff, bread) != bread) { - cli_warnmsg("cab_unstore: Can't write %d bytes to descriptor %d\n", bread, file->ofd); - return CL_EWRITE; - } - - todo -= bread; - - if(!bread || todo <= 0) - break; - } - - return CL_SUCCESS; -} - -#define CAB_CHGFOLDER \ - if(!file->cab->actfol || (file->folder != file->cab->actfol) \ - || (file->cab->state && file->cab->state->cmethod != file->folder->cmethod)) { \ - if(file->cab->state) { \ - if(file->cab->state->stream) { \ - switch(file->cab->state->cmethod & 0x000f) { \ - case 0x0001: \ - mszip_free(file->cab->state->stream); \ - break; \ - case 0x0002: \ - qtm_free(file->cab->state->stream); \ - break; \ - case 0x0003: \ - lzx_free(file->cab->state->stream); \ - } \ - } \ - free(file->cab->state); \ - file->cab->state = NULL; \ - } \ - file->cab->cur_offset = file->folder->offset; \ - file->cab->state = (struct cab_state *) cli_calloc(1, sizeof(struct cab_state)); \ - if(!file->cab->state) { \ - cli_errmsg("cab_extract: Can't allocate memory for internal state\n"); \ - close(file->ofd); \ - return CL_EMEM; \ - } \ - file->cab->state->cmethod = file->folder->cmethod; \ - switch(file->folder->cmethod & 0x000f) { \ - case 0x0001: \ - file->cab->state->stream = (struct mszip_stream *) mszip_init(file->ofd, 4096, 1, file, &cab_read); \ - break; \ - case 0x0002: \ - file->cab->state->stream = (struct qtm_stream *) qtm_init(file->ofd, (int) (file->folder->cmethod >> 8) & 0x1f, 4096, file, &cab_read); \ - break; \ - case 0x0003: \ - file->cab->state->stream = (struct lzx_stream *) lzx_init(file->ofd, (int) (file->folder->cmethod >> 8) & 0x1f, 0, 4096, 0, file, &cab_read); \ - } \ - if((file->folder->cmethod & 0x000f) && !file->cab->state->stream) { \ - close(file->ofd); \ - return CL_EUNPACK; \ - } \ - file->cab->actfol = file->folder; \ - } else { \ - if(file->cab->state && file->cab->state->stream) { \ - switch(file->cab->state->cmethod & 0x000f) { \ - case 0x0001: \ - ((struct mszip_stream *) file->cab->state->stream)->ofd = file->ofd; \ - break; \ - case 0x0002: \ - ((struct qtm_stream *) file->cab->state->stream)->ofd = file->ofd; \ - break; \ - case 0x0003: \ - ((struct lzx_stream *) file->cab->state->stream)->ofd = file->ofd; \ - break; \ - } \ - } \ - } - - -int cab_extract(struct cab_file *file, const char *name) -{ - int ret; - - - if(!file || !name) { - cli_errmsg("cab_extract: !file || !name\n"); - return CL_ENULLARG; - } - - if(!file->folder) { - cli_errmsg("cab_extract: file->folder == NULL\n"); - return CL_ENULLARG; - } - - file->ofd = open(name, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU); - if(file->ofd == -1) { - cli_errmsg("cab_extract: Can't open file %s in write mode\n", name); - return CL_ECREAT; - } - - switch(file->folder->cmethod & 0x000f) { - case 0x0000: /* STORE */ - cli_dbgmsg("CAB: Compression method: STORED\n"); - CAB_CHGFOLDER; - if(file->length > file->cab->length) { - cli_dbgmsg("cab_extract: Stored file larger than archive itself, trimming down\n"); - file->length = file->cab->length; - } - ret = cab_unstore(file); - break; - - case 0x0001: /* MSZIP */ - cli_dbgmsg("CAB: Compression method: MSZIP\n"); - CAB_CHGFOLDER; - ret = mszip_decompress(file->cab->state->stream, file->length); - break; - - case 0x0002: /* QUANTUM */ - cli_dbgmsg("CAB: Compression method: QUANTUM\n"); - CAB_CHGFOLDER; - ret = qtm_decompress(file->cab->state->stream, file->length); - break; - - case 0x0003: /* LZX */ - cli_dbgmsg("CAB: Compression method: LZX\n"); - CAB_CHGFOLDER; - ret = lzx_decompress(file->cab->state->stream, file->length); - break; - - default: - cli_dbgmsg("CAB: Not supported compression method: 0x%x\n", file->folder->cmethod & 0x000f); - ret = CL_EFORMAT; - } - - close(file->ofd); - - if(ret == CL_BREAK) - ret = CL_SUCCESS; - - return ret; -} diff -Nru clamav-0.99.2+dfsg/libclamav/cab.h clamav-0.99.3~beta1+dfsg/libclamav/cab.h --- clamav-0.99.2+dfsg/libclamav/cab.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/cab.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. - * Copyright (C) 2007-2008 Sourcefire, Inc. - * - * Authors: Tomasz Kojm - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ - -#ifndef __CAB_H -#define __CAB_H - -#include -#include "cltypes.h" -#include "fmap.h" - -#define CAB_BLOCKMAX 65535 -#define CAB_INPUTMAX (CAB_BLOCKMAX + 6144) - -struct cab_archive { - struct cab_folder *folders, *actfol; - struct cab_file *files; - struct cab_state *state; - fmap_t *map; - off_t cur_offset; - uint32_t length; - uint16_t nfolders; - uint16_t nfiles; - uint16_t flags; - uint16_t reshdr; - uint8_t resdata; -}; - -struct cab_state { - unsigned char *pt, *end; - void *stream; - unsigned char block[CAB_INPUTMAX]; - uint16_t blklen; - uint16_t outlen; - uint16_t blknum; - uint16_t cmethod; -}; - -struct cab_file { - off_t offset; - char *name; - uint32_t length; - int error; - int lread; - int ofd; - struct cab_folder *folder; - struct cab_file *next; - struct cab_archive *cab; - uint16_t attribs; - uint64_t max_size, written_size; -}; - -struct cab_folder { - struct cab_archive *cab; - off_t offset; - struct cab_folder *next; - uint16_t cmethod; - uint16_t nblocks; -}; - -int cab_open(fmap_t *map, off_t offset, struct cab_archive *cab); -int cab_extract(struct cab_file *file, const char *name); -void cab_free(struct cab_archive *cab); - -#endif diff -Nru clamav-0.99.2+dfsg/libclamav/chmunpack.c clamav-0.99.3~beta1+dfsg/libclamav/chmunpack.c --- clamav-0.99.2+dfsg/libclamav/chmunpack.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/chmunpack.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,746 +0,0 @@ -/* - * Extract component parts of MS CHM files - * - * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. - * Copyright (C) 2007-2008 Sourcefire, Inc. - * - * Authors: Trog - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ - -#if HAVE_CONFIG_H -#include "clamav-config.h" -#endif - -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#include - -#include "clamav.h" -#include "fmap.h" -#include "others.h" -#include "mspack.h" -#include "cltypes.h" -#include "chmunpack.h" -#include "cab.h" - -#ifndef HAVE_ATTRIB_PACKED -#define __attribute__(x) -#endif - -#ifdef HAVE_PRAGMA_PACK -#pragma pack(1) -#endif - -#ifdef HAVE_PRAGMA_PACK_HPPA -#pragma pack 1 -#endif - -#define CHM_CHUNK_HDR_LEN (0x14) - -#define CHM_CONTROL_LEN (0x18) -typedef struct lzx_control_tag { - uint32_t length __attribute__ ((packed)); - unsigned char signature[4]; - uint32_t version __attribute__ ((packed)); - uint32_t reset_interval __attribute__ ((packed)); - uint32_t window_size __attribute__ ((packed)); - uint32_t cache_size __attribute__ ((packed)); -} lzx_control_t; - -/* Don't need to include rt_offset in the strucuture len*/ -#define CHM_RESET_TABLE_LEN (0x24) -typedef struct lzx_reset_table_tag { - uint32_t num_entries __attribute__ ((packed)); - uint32_t entry_size __attribute__ ((packed)); - uint32_t table_offset __attribute__ ((packed)); - uint64_t uncom_len __attribute__ ((packed)); - uint64_t com_len __attribute__ ((packed)); - uint64_t frame_len __attribute__ ((packed)); - off_t rt_offset __attribute__ ((packed)); -} lzx_reset_table_t; - -typedef struct lzx_content_tag { - uint64_t offset; - uint64_t length; -} lzx_content_t; - -#ifdef HAVE_PRAGMA_PACK -#pragma pack() -#endif - -#ifdef HAVE_PRAGMA_PACK_HPPA -#pragma pack -#endif - -#define CHM_SYS_CONTROL_NAME "::DataSpace/Storage/MSCompressed/ControlData" -#define CHM_SYS_CONTENT_NAME "::DataSpace/Storage/MSCompressed/Content" -#define CHM_SYS_RESETTABLE_NAME "::DataSpace/Storage/MSCompressed/Transform/{7FC28940-9D31-11D0-9B27-00A0C91E9C7C}/InstanceData/ResetTable" - -#define CHM_SYS_CONTROL_LEN 44 -#define CHM_SYS_CONTENT_LEN 40 -#define CHM_SYS_RESETTABLE_LEN 105 - -#define chm_endian_convert_16(x) le16_to_host(x) -#define chm_endian_convert_32(x) le32_to_host(x) -#define chm_endian_convert_64(x) le64_to_host(x) - -/* Read in a block of data from either the mmap area or the given fd */ -static int chm_read_data(fmap_t *map, char *dest, off_t offset, off_t len) -{ - const void *src = fmap_need_off_once(map, offset, len); - if(!src) return FALSE; - memcpy(dest, src, len); - return TRUE; -} - -/* Read callback for lzx compressed data */ -static int chm_readn(struct cab_file *file, unsigned char *buffer, int bytes) { - int ret = fmap_readn(file->cab->map, buffer, file->cab->cur_offset, bytes); - if(ret > 0) - file->cab->cur_offset += ret; - return ret; -} - -static uint64_t chm_copy_file_data(int ifd, int ofd, uint64_t len) -{ - unsigned char data[8192]; - uint64_t count, rem; - unsigned int todo; - - rem = len; - - while (rem > 0) { - todo = MIN(8192, rem); - count = cli_readn(ifd, data, todo); - if (count != todo) { - return len-rem; - } - if (cli_writen(ofd, data, count) != (int64_t)count) { - return len-rem-count; - } - rem -= count; - } - return len; -} - -static void itsf_print_header(chm_itsf_header_t *itsf_hdr) -{ - if (!itsf_hdr) { - return; - } - - cli_dbgmsg("---- ITSF ----\n"); - cli_dbgmsg("Signature:\t%c%c%c%c\n", itsf_hdr->signature[0], - itsf_hdr->signature[1],itsf_hdr->signature[2],itsf_hdr->signature[3]); - cli_dbgmsg("Version:\t%d\n", itsf_hdr->version); - cli_dbgmsg("Header len:\t%d\n", itsf_hdr->header_len); - cli_dbgmsg("Lang ID:\t%d\n", itsf_hdr->lang_id); - cli_dbgmsg("Sec0 offset:\t%lu\n", (unsigned long int) itsf_hdr->sec0_offset); - cli_dbgmsg("Sec0 len:\t%lu\n", (unsigned long int) itsf_hdr->sec0_len); - cli_dbgmsg("Dir offset:\t%lu\n", (unsigned long int) itsf_hdr->dir_offset); - cli_dbgmsg("Dir len:\t%lu\n", (unsigned long int) itsf_hdr->dir_len); - if (itsf_hdr->version > 2) { - cli_dbgmsg("Data offset:\t%lu\n\n", (unsigned long int) itsf_hdr->data_offset); - } -} - -static int itsf_read_header(chm_metadata_t *metadata) -{ - chm_itsf_header_t *itsf_hdr = &metadata->itsf_hdr; - if (!chm_read_data(metadata->map, (char *)itsf_hdr, 0, CHM_ITSF_MIN_LEN)) - return FALSE; - if (memcmp(itsf_hdr->signature, "ITSF", 4) != 0) { - cli_dbgmsg("ITSF signature mismatch\n"); - return FALSE; - } - itsf_hdr->version = chm_endian_convert_32(itsf_hdr->version); - itsf_hdr->header_len = chm_endian_convert_32(itsf_hdr->header_len); - itsf_hdr->last_modified = chm_endian_convert_32(itsf_hdr->last_modified); - itsf_hdr->lang_id = chm_endian_convert_32(itsf_hdr->lang_id); - itsf_hdr->sec0_offset = chm_endian_convert_64(itsf_hdr->sec0_offset); - itsf_hdr->sec0_len = chm_endian_convert_64(itsf_hdr->sec0_len); - itsf_hdr->dir_offset = chm_endian_convert_64(itsf_hdr->dir_offset); - itsf_hdr->dir_len = chm_endian_convert_64(itsf_hdr->dir_len); - if (itsf_hdr->version > 2) { - itsf_hdr->data_offset = chm_endian_convert_64(itsf_hdr->data_offset); - } - return TRUE; -} - -static void itsp_print_header(chm_itsp_header_t *itsp_hdr) -{ - if (!itsp_hdr) { - return; - } - - cli_dbgmsg("---- ITSP ----\n"); - cli_dbgmsg("Signature:\t%c%c%c%c\n", itsp_hdr->signature[0], - itsp_hdr->signature[1],itsp_hdr->signature[2],itsp_hdr->signature[3]); - cli_dbgmsg("Version:\t%d\n", itsp_hdr->version); - cli_dbgmsg("Block len:\t%u\n", itsp_hdr->block_len); - cli_dbgmsg("Block idx int:\t%d\n", itsp_hdr->blockidx_intvl); - cli_dbgmsg("Index depth:\t%d\n", itsp_hdr->index_depth); - cli_dbgmsg("Index root:\t%d\n", itsp_hdr->index_root); - cli_dbgmsg("Index head:\t%u\n", itsp_hdr->index_head); - cli_dbgmsg("Index tail:\t%u\n", itsp_hdr->index_tail); - cli_dbgmsg("Num Blocks:\t%u\n", itsp_hdr->num_blocks); - cli_dbgmsg("Lang ID:\t%u\n\n", itsp_hdr->lang_id); -} - -static int itsp_read_header(chm_metadata_t *metadata, off_t offset) -{ - chm_itsp_header_t *itsp_hdr = &metadata->itsp_hdr; - if (!chm_read_data(metadata->map, (char *)itsp_hdr, offset, CHM_ITSP_LEN)) - return FALSE; - if (memcmp(itsp_hdr->signature, "ITSP", 4) != 0) { - cli_dbgmsg("ITSP signature mismatch\n"); - return FALSE; - } - - itsp_hdr->version = chm_endian_convert_32(itsp_hdr->version); - itsp_hdr->header_len = chm_endian_convert_32(itsp_hdr->header_len); - itsp_hdr->block_len = chm_endian_convert_32(itsp_hdr->block_len); - itsp_hdr->blockidx_intvl = chm_endian_convert_32(itsp_hdr->blockidx_intvl); - itsp_hdr->index_depth = chm_endian_convert_32(itsp_hdr->index_depth); - itsp_hdr->index_root = chm_endian_convert_32(itsp_hdr->index_root); - itsp_hdr->index_head = chm_endian_convert_32(itsp_hdr->index_head); - itsp_hdr->index_tail = chm_endian_convert_32(itsp_hdr->index_tail); - itsp_hdr->num_blocks = chm_endian_convert_32(itsp_hdr->num_blocks); - itsp_hdr->lang_id = chm_endian_convert_32(itsp_hdr->lang_id); - - if ((itsp_hdr->version != 1) || (itsp_hdr->header_len != CHM_ITSP_LEN)) { - cli_dbgmsg("ITSP header mismatch\n"); - return FALSE; - } - return TRUE; -} - -static uint64_t read_enc_int(const char **start, const char *end) -{ - uint64_t retval=0; - const char *current; - - current = *start; - - if (current > end) { - return 0; - } - - do { - if (current > end) { - return 0; - } - retval = (retval << 7) | (*current & 0x7f); - } while (*current++ & 0x80); - - *start = current; - return retval; -} - -/* Read control entries */ -static int read_control_entries(chm_metadata_t *metadata) -{ - const char *name; - uint64_t name_len, section, offset, length; - - while (metadata->chunk_entries--) { - if (metadata->chunk_current > metadata->chunk_end) { - cli_dbgmsg("read chunk entries failed\n"); - return FALSE; - } - - name_len = read_enc_int(&metadata->chunk_current, metadata->chunk_end); - if (((metadata->chunk_current + name_len) > metadata->chunk_end) || ((metadata->chunk_current + name_len) < metadata->chunk_data)) { - cli_dbgmsg("Bad CHM name_len detected\n"); - return FALSE; - } - name = metadata->chunk_current; - metadata->chunk_current += name_len; - section = read_enc_int(&metadata->chunk_current, metadata->chunk_end); - offset = read_enc_int(&metadata->chunk_current, metadata->chunk_end); - length = read_enc_int(&metadata->chunk_current, metadata->chunk_end); - - /* CHM_SYS_CONTENT_LEN is the shortest name we are searching for */ - if ((name_len >= CHM_SYS_CONTENT_LEN) && (name[0] == ':') && - (name[1] == ':')) { - if ((name_len == CHM_SYS_CONTROL_LEN) && (strcmp(name, CHM_SYS_CONTROL_NAME) == 0)) { - cli_dbgmsg("found CHM_SYS_CONTROL_NAME\n"); - metadata->sys_control.offset = offset; - metadata->sys_control.length = length; - } else if ((name_len == CHM_SYS_CONTENT_LEN) && (strcmp(name, CHM_SYS_CONTENT_NAME) == 0)) { - cli_dbgmsg("found CHM_SYS_CONTENT_NAME\n"); - metadata->sys_content.offset = offset; - metadata->sys_content.length = length; - } else if ((name_len == CHM_SYS_RESETTABLE_LEN) && (strcmp(name, CHM_SYS_RESETTABLE_NAME) == 0)) { - cli_dbgmsg("found CHM_SYS_RESETTABLE_NAME\n"); - metadata->sys_reset.offset = offset; - metadata->sys_reset.length = length; - } - } - } - return TRUE; -} - -static int prepare_file(chm_metadata_t *metadata) -{ - uint64_t name_len, section; - - while (metadata->chunk_entries != 0) { - if (metadata->chunk_current >= metadata->chunk_end) { - return CL_EFORMAT; - } - - name_len = read_enc_int(&metadata->chunk_current, metadata->chunk_end); - if (((metadata->chunk_current + name_len) >= metadata->chunk_end) || - ((metadata->chunk_current + name_len) < metadata->chunk_data)) { - cli_dbgmsg("Bad CHM name_len detected\n"); - return CL_EFORMAT; - } - metadata->chunk_current += name_len; - section = read_enc_int(&metadata->chunk_current, metadata->chunk_end); - metadata->file_offset = read_enc_int(&metadata->chunk_current, metadata->chunk_end); - metadata->file_length = read_enc_int(&metadata->chunk_current, metadata->chunk_end); - metadata->chunk_entries--; - if (section == 1) { - return CL_SUCCESS; - } - } - - return CL_BREAK; -} - -static int read_chunk(chm_metadata_t *metadata) -{ - cli_dbgmsg("in read_chunk\n"); - - if (metadata->itsp_hdr.block_len < 8 || metadata->itsp_hdr.block_len > 33554432) { - return CL_EFORMAT; - } - - if (metadata->chunk_offset > metadata->m_length) { - return CL_EFORMAT; - } - if ((metadata->chunk_offset + metadata->itsp_hdr.block_len) > metadata->m_length) { - return CL_EFORMAT; - } - metadata->chunk_data = fmap_need_off_once(metadata->map, metadata->chunk_offset, metadata->itsp_hdr.block_len); - if(!metadata->chunk_data) return CL_EFORMAT; - - metadata->chunk_current = metadata->chunk_data + CHM_CHUNK_HDR_LEN; - metadata->chunk_end = metadata->chunk_data + metadata->itsp_hdr.block_len; - - if (memcmp(metadata->chunk_data, "PMGL", 4) == 0) { - metadata->chunk_entries = (uint16_t)((((uint8_t const *)(metadata->chunk_data))[metadata->itsp_hdr.block_len-2] << 0) - | (((uint8_t const *)(metadata->chunk_data))[metadata->itsp_hdr.block_len-1] << 8)); - } else if (memcmp(metadata->chunk_data, "PMGI", 4) != 0) { - return CL_BREAK; - } - - return CL_SUCCESS; -} - -static void print_sys_control(lzx_control_t *lzx_control) -{ - if (!lzx_control) { - return; - } - - cli_dbgmsg("---- Control ----\n"); - cli_dbgmsg("Length:\t\t%u\n", lzx_control->length); - cli_dbgmsg("Signature:\t%c%c%c%c\n", lzx_control->signature[0], - lzx_control->signature[1],lzx_control->signature[2],lzx_control->signature[3]); - cli_dbgmsg("Version:\t%d\n", lzx_control->version); - cli_dbgmsg("Reset Interval:\t%d\n", lzx_control->reset_interval); - cli_dbgmsg("Window Size:\t%d\n", lzx_control->window_size); - cli_dbgmsg("Cache Size:\t%d\n\n", lzx_control->cache_size); -} - -static int read_sys_control(chm_metadata_t *metadata, lzx_control_t *lzx_control) -{ - off_t offset; - - if (metadata->sys_control.length != 28) { - return FALSE; - } - offset = metadata->itsf_hdr.data_offset + metadata->sys_control.offset; - if (offset < 0) { - return FALSE; - } - - if (!chm_read_data(metadata->map, (char *) lzx_control, offset, CHM_CONTROL_LEN)) { - return FALSE; - } - - lzx_control->length = chm_endian_convert_32(lzx_control->length); - lzx_control->version = chm_endian_convert_32(lzx_control->version); - lzx_control->reset_interval = chm_endian_convert_32(lzx_control->reset_interval); - lzx_control->window_size = chm_endian_convert_32(lzx_control->window_size); - lzx_control->cache_size = chm_endian_convert_32(lzx_control->cache_size); - - if (strncmp((const char *) "LZXC", (const char *) lzx_control->signature, 4) != 0) { - cli_dbgmsg("bad sys_control signature\n"); - return FALSE; - } - switch(lzx_control->version) { - case 1: - break; - case 2: - lzx_control->reset_interval *= LZX_FRAME_SIZE; - lzx_control->window_size *= LZX_FRAME_SIZE; - break; - default: - cli_dbgmsg("Unknown sys_control version:%d\n", lzx_control->version); - return FALSE; - } - - print_sys_control(lzx_control); - return TRUE; -} - -static void print_sys_content(lzx_content_t *lzx_content) -{ - if (!lzx_content) { - return; - } - - cli_dbgmsg("---- Content ----\n"); - cli_dbgmsg("Offset:\t%lu\n", (unsigned long int) lzx_content->offset); - cli_dbgmsg("Length:\t%lu\n\n", (unsigned long int) lzx_content->length); -} - -static int read_sys_content(chm_metadata_t *metadata, lzx_content_t *lzx_content) -{ - lzx_content->offset = metadata->itsf_hdr.data_offset + metadata->sys_content.offset; - lzx_content->length = metadata->sys_content.length; - - print_sys_content(lzx_content); - return TRUE; -} - -static void print_sys_reset_table(lzx_reset_table_t *lzx_reset_table) -{ - if (!lzx_reset_table) { - return; - } - - cli_dbgmsg("---- Reset Table ----\n"); - cli_dbgmsg("Num Entries:\t%u\n", lzx_reset_table->num_entries); - cli_dbgmsg("Entry Size:\t%u\n", lzx_reset_table->entry_size); - cli_dbgmsg("Table Offset:\t%u\n", lzx_reset_table->table_offset); - cli_dbgmsg("Uncom Len:\t%lu\n", (unsigned long int) lzx_reset_table->uncom_len); - cli_dbgmsg("Com Len:\t%lu\n", (unsigned long int) lzx_reset_table->com_len); - cli_dbgmsg("Frame Len:\t%lu\n\n", (unsigned long int) lzx_reset_table->frame_len); -} - -static int read_sys_reset_table(chm_metadata_t *metadata, lzx_reset_table_t *lzx_reset_table) -{ - off_t offset; - - if (metadata->sys_reset.length < 40) { - return FALSE; - } - /* Skip past unknown entry in offset calc */ - offset = metadata->itsf_hdr.data_offset + metadata->sys_reset.offset + 4; - - if (offset < 0) { - return FALSE; - } - - /* Save the entry offset for later use */ - lzx_reset_table->rt_offset = offset-4; - - if (!chm_read_data(metadata->map, (char *) lzx_reset_table, offset, CHM_RESET_TABLE_LEN)) { - return FALSE; - } - - lzx_reset_table->num_entries = chm_endian_convert_32(lzx_reset_table->num_entries); - lzx_reset_table->entry_size = chm_endian_convert_32(lzx_reset_table->entry_size); - lzx_reset_table->table_offset = chm_endian_convert_32(lzx_reset_table->table_offset); - lzx_reset_table->uncom_len = chm_endian_convert_64(lzx_reset_table->uncom_len); - lzx_reset_table->com_len = chm_endian_convert_64(lzx_reset_table->com_len); - lzx_reset_table->frame_len = chm_endian_convert_64(lzx_reset_table->frame_len); - - if (lzx_reset_table->frame_len != LZX_FRAME_SIZE) { - cli_dbgmsg("bad sys_reset_table frame_len: 0x%lx\n", (long unsigned int) lzx_reset_table->frame_len); - return FALSE; - } - if ((lzx_reset_table->entry_size != 4) && (lzx_reset_table->entry_size != 8)) { - cli_dbgmsg("bad sys_reset_table entry_size: 0x%x\n",lzx_reset_table->entry_size); - return FALSE; - } - print_sys_reset_table(lzx_reset_table); - return TRUE; -} - -/* *****************************************************************/ -/* This section interfaces to the mspack files. As such, this is a */ -/* little bit dirty compared to my usual code */ - -static int chm_decompress_stream(chm_metadata_t *metadata, const char *dirname, cli_ctx *ctx) -{ - lzx_content_t lzx_content; - lzx_reset_table_t lzx_reset_table; - lzx_control_t lzx_control; - int window_bits, length, tmpfd, retval=-1; - struct lzx_stream * stream; - char filename[1024]; - struct cab_file file; - struct cab_archive cab; - - snprintf(filename, 1024, "%s"PATHSEP"clamav-unchm.bin", dirname); - tmpfd = open(filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU); - if (tmpfd<0) { - cli_dbgmsg("open failed for %s\n", filename); - return -1; - } - - if (!metadata->sys_control.length || !metadata->sys_content.length ||!metadata->sys_reset.length) { - cli_dbgmsg("Control file missing\n"); - goto abort; - } - - if (!read_sys_control(metadata, &lzx_control)) { - goto abort; - } - if (!read_sys_content(metadata, &lzx_content)) { - goto abort; - } - if (!read_sys_reset_table(metadata, &lzx_reset_table)) { - goto abort; - } - - switch (lzx_control.window_size) { - case 0x008000: - window_bits = 15; - break; - case 0x010000: - window_bits = 16; - break; - case 0x020000: - window_bits = 17; - break; - case 0x040000: - window_bits = 18; - break; - case 0x080000: - window_bits = 19; - break; - case 0x100000: - window_bits = 20; - break; - case 0x200000: - window_bits = 21; - break; - default: - cli_dbgmsg("bad control window size: 0x%x\n", lzx_control.window_size); - goto abort; - } - - if (lzx_control.reset_interval % LZX_FRAME_SIZE) { - cli_dbgmsg("bad reset_interval: 0x%x\n", lzx_control.window_size); - goto abort; - } - - length = lzx_reset_table.uncom_len; - length += lzx_control.reset_interval; - length &= -lzx_control.reset_interval; - - cli_dbgmsg("Compressed offset: %lu\n", (unsigned long int) lzx_content.offset); - - memset(&file, 0, sizeof(struct cab_file)); - file.max_size = ctx->engine->maxfilesize; - file.cab = &cab; - cab.map = metadata->map; - cab.cur_offset = lzx_content.offset; - stream = lzx_init(tmpfd, window_bits, - lzx_control.reset_interval / LZX_FRAME_SIZE, - 4096, length, &file, chm_readn); - if (!stream) { - cli_dbgmsg("lzx_init failed\n"); - goto abort; - } - - lzx_decompress(stream, length); - lzx_free(stream); - -#ifndef _WIN32 - /* Delete the file */ - if(cli_unlink(filename)) - retval = -1; - else -#endif - retval = tmpfd; - -abort: - if ((retval == -1) && (tmpfd >= 0)) { - close(tmpfd); - } - return retval; -} - -/* ************ End dirty section ********************/ - -static int chm_init_metadata(chm_metadata_t *metadata) -{ - if (!metadata) { - return CL_ENULLARG; - } - - metadata->sys_control.length = metadata->sys_content.length = metadata->sys_reset.length = 0; - metadata->map = NULL; - metadata->ufd = -1; - metadata->num_chunks = metadata->chunk_entries = 0; - metadata->chunk_data = NULL; - return CL_SUCCESS; -} - -void cli_chm_close(chm_metadata_t *metadata) -{ - if (metadata->ufd >= 0) { - close(metadata->ufd); - } -} - -int cli_chm_extract_file(char *dirname, chm_metadata_t *metadata, cli_ctx *ctx) -{ - char filename[1024]; - uint64_t len; - - cli_dbgmsg("in cli_chm_extract_file\n"); - - if (lseek(metadata->ufd, metadata->file_offset, SEEK_SET) != (off_t) metadata->file_offset) { - cli_dbgmsg("seek in uncompressed stream failed\n"); - return CL_EFORMAT; - } - snprintf(filename, 1024, "%s"PATHSEP"%lu.chm", dirname, (unsigned long int) metadata->file_offset); - metadata->ofd = open(filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU); - if (metadata->ofd < 0) { - return CL_ECREAT; - } - len = ctx->engine->maxfilesize ? (MIN(ctx->engine->maxfilesize, metadata->file_length)) : metadata->file_length; - if (chm_copy_file_data(metadata->ufd, metadata->ofd, len) != len) { - cli_dbgmsg("failed to copy %lu bytes\n", (unsigned long int) len); - close(metadata->ofd); - return CL_EFORMAT; /* most likely a corrupted file */ - } - - return CL_SUCCESS; -} - -int cli_chm_prepare_file(chm_metadata_t *metadata) -{ - int retval; - - cli_dbgmsg("in cli_chm_prepare_file\n"); - - do { - if (metadata->chunk_entries == 0) { - if (metadata->num_chunks == 0) { - return CL_BREAK; - } - if ((retval = read_chunk(metadata)) != CL_SUCCESS) { - return retval; - } - metadata->num_chunks--; - metadata->chunk_offset += metadata->itsp_hdr.block_len; - } - retval = prepare_file(metadata); - } while (retval == CL_BREAK); /* Ran out of chunk entries before finding a file */ - return retval; -} - -int cli_chm_open(const char *dirname, chm_metadata_t *metadata, cli_ctx *ctx) -{ - int retval; - - cli_dbgmsg("in cli_chm_open\n"); - - if ((retval = chm_init_metadata(metadata)) != CL_SUCCESS) { - return retval; - } - - metadata->map = *ctx->fmap; - if(metadata->map->len < CHM_ITSF_MIN_LEN) - return CL_ESTAT; - metadata->m_length = metadata->map->len; - - if (!itsf_read_header(metadata)) { - goto abort; - } - itsf_print_header(&metadata->itsf_hdr); - - if (!itsp_read_header(metadata, metadata->itsf_hdr.dir_offset)) { - goto abort; - } - itsp_print_header(&metadata->itsp_hdr); - - metadata->chunk_offset = metadata->itsf_hdr.dir_offset+CHM_ITSP_LEN; - - /* TODO: need to check this first calculation, - currently have no files of this type */ - if (metadata->itsp_hdr.index_head > 0) { - metadata->chunk_offset += metadata->itsp_hdr.index_head * metadata->itsp_hdr.block_len; - } - - metadata->num_chunks = metadata->itsp_hdr.index_tail - metadata->itsp_hdr.index_head + 1; - - /* Versions before 3 didn't have a data_offset */ - /* TODO: need to check this calculation, - currently have no files of this type */ - if (metadata->itsf_hdr.version < 3) { - metadata->itsf_hdr.data_offset = metadata->itsf_hdr.dir_offset + CHM_ITSP_LEN + - (metadata->itsp_hdr.block_len*metadata->itsp_hdr.num_blocks); - } - - while (metadata->num_chunks) { - if (read_chunk(metadata) != CL_SUCCESS) { - cli_dbgmsg("read_chunk failed\n"); - goto abort; - } - if (read_control_entries(metadata) == FALSE) { - goto abort; - } - metadata->num_chunks--; - metadata->chunk_offset += metadata->itsp_hdr.block_len; - } - - if (!metadata->sys_content.length || !metadata->sys_control.length || !metadata->sys_reset.length) { - cli_dbgmsg("sys file missing\n"); - goto abort; - } - - metadata->ufd = chm_decompress_stream(metadata, dirname, ctx); - if (metadata->ufd == -1) { - goto abort; - } - - metadata->chunk_entries = 0; - metadata->chunk_data = NULL; - metadata->chunk_offset = metadata->itsf_hdr.dir_offset+CHM_ITSP_LEN; - metadata->num_chunks = metadata->itsp_hdr.index_tail - metadata->itsp_hdr.index_head + 1; - - return CL_SUCCESS; - -abort: - return CL_EFORMAT; -} diff -Nru clamav-0.99.2+dfsg/libclamav/chmunpack.h clamav-0.99.3~beta1+dfsg/libclamav/chmunpack.h --- clamav-0.99.2+dfsg/libclamav/chmunpack.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/chmunpack.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -/* - * Extract component parts of MS CHM files - * - * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. - * Copyright (C) 2007-2008 Sourcefire, Inc. - * - * Authors: Trog - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ - -#ifndef __CHM_UNPACK_H -#define __CHM_UNPACK_H - -#if HAVE_CONFIG_H -#include "clamav-config.h" -#endif - -#include "cltypes.h" -#include "others.h" -#include "fmap.h" - -#ifndef HAVE_ATTRIB_PACKED -#define __attribute__(x) -#endif - -#ifdef HAVE_PRAGMA_PACK -#pragma pack(1) -#endif - -#ifdef HAVE_PRAGMA_PACK_HPPA -#pragma pack 1 -#endif - -#define CHM_ITSF_MIN_LEN (0x60) -typedef struct chm_itsf_header_tag -{ - unsigned char signature[4]; - int32_t version __attribute__ ((packed)); - int32_t header_len __attribute__ ((packed)); - uint32_t unknown __attribute__ ((packed)); - uint32_t last_modified __attribute__ ((packed)); - uint32_t lang_id __attribute__ ((packed)); - unsigned char dir_clsid[16]; - unsigned char stream_clsid[16]; - uint64_t sec0_offset __attribute__ ((packed)); - uint64_t sec0_len __attribute__ ((packed)); - uint64_t dir_offset __attribute__ ((packed)); - uint64_t dir_len __attribute__ ((packed)); - uint64_t data_offset __attribute__ ((packed)); -} chm_itsf_header_t; - -#define CHM_ITSP_LEN (0x54) -typedef struct chm_itsp_header_tag -{ - unsigned char signature[4]; - int32_t version __attribute__ ((packed)); - int32_t header_len __attribute__ ((packed)); - int32_t unknown1 __attribute__ ((packed)); - uint32_t block_len __attribute__ ((packed)); - int32_t blockidx_intvl __attribute__ ((packed)); - int32_t index_depth __attribute__ ((packed)); - int32_t index_root __attribute__ ((packed)); - int32_t index_head __attribute__ ((packed)); - int32_t index_tail __attribute__ ((packed)); - int32_t unknown2 __attribute__ ((packed)); - uint32_t num_blocks __attribute__ ((packed)); - uint32_t lang_id __attribute__ ((packed)); - unsigned char system_clsid[16]; - unsigned char unknown4[16]; -} chm_itsp_header_t; - -#ifdef HAVE_PRAGMA_PACK -#pragma pack() -#endif - -#ifdef HAVE_PRAGMA_PACK_HPPA -#pragma pack -#endif - -typedef struct chm_sys_entry_tag -{ - uint64_t offset; - uint64_t length; -} chm_sys_entry_t; - -typedef struct chm_metadata_tag { - uint64_t file_length; - uint64_t file_offset; - chm_sys_entry_t sys_control; - chm_sys_entry_t sys_content; - chm_sys_entry_t sys_reset; - off_t m_length; - chm_itsf_header_t itsf_hdr; - chm_itsp_header_t itsp_hdr; - int ufd; - int ofd; - uint32_t num_chunks; - off_t chunk_offset; - const char *chunk_data; - const char *chunk_current; - const char *chunk_end; - fmap_t *map; - uint16_t chunk_entries; -} chm_metadata_t; - -int cli_chm_open(const char *dirname, chm_metadata_t *metadata, cli_ctx *ctx); -int cli_chm_prepare_file(chm_metadata_t *metadata); -int cli_chm_extract_file(char *dirname, chm_metadata_t *metadata, cli_ctx *ctx); -void cli_chm_close(chm_metadata_t *metadata); -#endif diff -Nru clamav-0.99.2+dfsg/libclamav/clamav.h clamav-0.99.3~beta1+dfsg/libclamav/clamav.h --- clamav-0.99.2+dfsg/libclamav/clamav.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/clamav.h 2017-02-20 18:36:39.000000000 +0000 @@ -32,7 +32,11 @@ #include /* Certain OSs already use 64bit variables in their stat struct */ -#define STAT64_BLACKLIST !defined(__FreeBSD__) && !defined(__APPLE__) +#if ( !defined(__FreeBSD__) && !defined(__APPLE__) ) +#define STAT64_BLACKLIST 1 +#else +#define STAT64_BLACKLIST 0 +#endif #if defined(HAVE_STAT64) && STAT64_BLACKLIST @@ -151,7 +155,7 @@ #define CL_SCAN_PE 0x20 #define CL_SCAN_BLOCKBROKEN 0x40 #define CL_SCAN_MAILURL 0x80 /* ignored */ -#define CL_SCAN_BLOCKMAX 0x100 /* ignored */ +#define CL_SCAN_BLOCKMAX 0x100 #define CL_SCAN_ALGORITHMIC 0x200 #define CL_SCAN_PHISHING_BLOCKSSL 0x800 /* ssl mismatches, not ssl by itself*/ #define CL_SCAN_PHISHING_BLOCKCLOAK 0x1000 diff -Nru clamav-0.99.2+dfsg/libclamav/conv.c clamav-0.99.3~beta1+dfsg/libclamav/conv.c --- clamav-0.99.2+dfsg/libclamav/conv.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/conv.c 2016-10-13 15:45:44.000000000 +0000 @@ -131,6 +131,10 @@ /* Ensure we're dealing with a NULL-terminated string */ p = (char *)malloc(elen+1); + if (NULL == p) { + BIO_free(b64); + return NULL; + } memcpy((void *)p, (void *)buf, elen); p[elen] = 0x00; buf = p; diff -Nru clamav-0.99.2+dfsg/libclamav/cpio.c clamav-0.99.3~beta1+dfsg/libclamav/cpio.c --- clamav-0.99.2+dfsg/libclamav/cpio.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/cpio.c 2016-10-13 15:45:44.000000000 +0000 @@ -102,14 +102,17 @@ char name[513]; unsigned int file = 0, trailer = 0; uint32_t filesize, namesize, hdr_namesize; - int ret, conv; + int ret = CL_CLEAN, conv; off_t pos = 0; + int virus_found = 0; while(fmap_readn(*ctx->fmap, &hdr_old, pos, sizeof(hdr_old)) == sizeof(hdr_old)) { pos += sizeof(hdr_old); - if(!hdr_old.magic && trailer) - return CL_SUCCESS; + if(!hdr_old.magic && trailer) { + ret = CL_SUCCESS; + goto leave; + } if(hdr_old.magic == 070707) { conv = 0; @@ -117,7 +120,8 @@ conv = 1; } else { cli_dbgmsg("cli_scancpio_old: Invalid magic number\n"); - return CL_EFORMAT; + ret = CL_EFORMAT; + goto leave; } cli_dbgmsg("CPIO: -- File %u --\n", ++file); @@ -148,8 +152,11 @@ if(!filesize) continue; - if(cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0, NULL) == CL_VIRUS) - return CL_VIRUS; + if(cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0, NULL) == CL_VIRUS) { + if (!SCAN_ALL) + return CL_VIRUS; + virus_found = 1; + } if((EC16(hdr_old.mode, conv) & 0170000) != 0100000) { @@ -157,11 +164,14 @@ } else { ret = cli_checklimits("cli_scancpio_old", ctx, filesize, 0, 0); if(ret == CL_EMAXFILES) { - return ret; + goto leave; } else if(ret == CL_SUCCESS) { ret = cli_map_scan(*ctx->fmap, pos, filesize, ctx, CL_TYPE_ANY); - if(ret == CL_VIRUS) - return ret; + if(ret == CL_VIRUS) { + if (!SCAN_ALL) + return ret; + virus_found = 1; + } } } if(filesize % 2) @@ -170,7 +180,10 @@ pos += filesize; } - return CL_CLEAN; + leave: + if (virus_found != 0) + return CL_VIRUS; + return ret; } int cli_scancpio_odc(cli_ctx *ctx) @@ -179,18 +192,20 @@ char name[513], buff[12]; unsigned int file = 0, trailer = 0; uint32_t filesize, namesize, hdr_namesize; - int ret; + int ret = CL_CLEAN; off_t pos = 0; + int virus_found = 0; while(fmap_readn(*ctx->fmap, &hdr_odc, pos, sizeof(hdr_odc)) == sizeof(hdr_odc)) { pos += sizeof(hdr_odc); if(!hdr_odc.magic[0] && trailer) - return CL_SUCCESS; + goto leave; if(strncmp(hdr_odc.magic, "070707", 6)) { cli_dbgmsg("cli_scancpio_odc: Invalid magic string\n"); - return CL_EFORMAT; + ret = CL_EFORMAT; + goto leave; } cli_dbgmsg("CPIO: -- File %u --\n", ++file); @@ -199,13 +214,15 @@ buff[6] = 0; if(sscanf(buff, "%o", &hdr_namesize) != 1) { cli_dbgmsg("cli_scancpio_odc: Can't convert name size\n"); - return CL_EFORMAT; + ret = CL_EFORMAT; + goto leave; } if(hdr_namesize) { namesize = MIN(sizeof(name), hdr_namesize); if ((uint32_t)fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) { cli_dbgmsg("cli_scancpio_odc: Can't read file name\n"); - return CL_EFORMAT; + ret = CL_EFORMAT; + goto leave; } pos += namesize; name[namesize - 1] = 0; @@ -222,29 +239,39 @@ buff[11] = 0; if(sscanf(buff, "%o", &filesize) != 1) { cli_dbgmsg("cli_scancpio_odc: Can't convert file size\n"); - return CL_EFORMAT; + ret = CL_EFORMAT; + goto leave; } cli_dbgmsg("CPIO: Filesize: %u\n", filesize); if(!filesize) continue; - if(cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0, NULL) == CL_VIRUS) - return CL_VIRUS; + if(cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0, NULL) == CL_VIRUS) { + if (!SCAN_ALL) + return CL_VIRUS; + virus_found = 1; + } ret = cli_checklimits("cli_scancpio_odc", ctx, filesize, 0, 0); if(ret == CL_EMAXFILES) { - return ret; + goto leave; } else if(ret == CL_SUCCESS) { ret = cli_map_scan(*ctx->fmap, pos, filesize, ctx, CL_TYPE_ANY); - if(ret == CL_VIRUS) - return ret; + if(ret == CL_VIRUS) { + if (!SCAN_ALL) + return ret; + virus_found = 1; + } } pos += filesize; } - return CL_CLEAN; + leave: + if (virus_found != 0) + return CL_VIRUS; + return ret; } int cli_scancpio_newc(cli_ctx *ctx, int crc) @@ -253,19 +280,21 @@ char name[513], buff[9]; unsigned int file = 0, trailer = 0; uint32_t filesize, namesize, hdr_namesize, pad; - int ret; + int ret = CL_CLEAN; off_t pos = 0; + int virus_found = 0; memset(name, 0, 513); while(fmap_readn(*ctx->fmap, &hdr_newc, pos, sizeof(hdr_newc)) == sizeof(hdr_newc)) { pos += sizeof(hdr_newc); if(!hdr_newc.magic[0] && trailer) - return CL_SUCCESS; + goto leave; if((!crc && strncmp(hdr_newc.magic, "070701", 6)) || (crc && strncmp(hdr_newc.magic, "070702", 6))) { cli_dbgmsg("cli_scancpio_newc: Invalid magic string\n"); - return CL_EFORMAT; + ret = CL_EFORMAT; + goto leave; } cli_dbgmsg("CPIO: -- File %u --\n", ++file); @@ -274,13 +303,15 @@ buff[8] = 0; if(sscanf(buff, "%x", &hdr_namesize) != 1) { cli_dbgmsg("cli_scancpio_newc: Can't convert name size\n"); - return CL_EFORMAT; + ret = CL_EFORMAT; + goto leave; } if(hdr_namesize) { namesize = MIN(sizeof(name), hdr_namesize); if ((uint32_t)fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) { cli_dbgmsg("cli_scancpio_newc: Can't read file name\n"); - return CL_EFORMAT; + ret = CL_EFORMAT; + goto leave; } pos += namesize; name[namesize - 1] = 0; @@ -302,23 +333,29 @@ buff[8] = 0; if(sscanf(buff, "%x", &filesize) != 1) { cli_dbgmsg("cli_scancpio_newc: Can't convert file size\n"); - return CL_EFORMAT; + ret = CL_EFORMAT; + goto leave; } cli_dbgmsg("CPIO: Filesize: %u\n", filesize); if(!filesize) continue; - if(cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0, NULL) == CL_VIRUS) - return CL_VIRUS; - + if(cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0, NULL) == CL_VIRUS) { + if (!SCAN_ALL) + return CL_VIRUS; + virus_found = 1; + } ret = cli_checklimits("cli_scancpio_newc", ctx, filesize, 0, 0); if(ret == CL_EMAXFILES) { - return ret; + goto leave; } else if(ret == CL_SUCCESS) { ret = cli_map_scan(*ctx->fmap, pos, filesize, ctx, CL_TYPE_ANY); - if(ret == CL_VIRUS) - return ret; + if(ret == CL_VIRUS) { + if (!SCAN_ALL) + return ret; + virus_found = 1; + } } if((pad = filesize % 4)) @@ -327,5 +364,8 @@ pos += filesize; } - return CL_CLEAN; + leave: + if (virus_found != 0) + return CL_VIRUS; + return ret; } diff -Nru clamav-0.99.2+dfsg/libclamav/crypto.c clamav-0.99.3~beta1+dfsg/libclamav/crypto.c --- clamav-0.99.2+dfsg/libclamav/crypto.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/crypto.c 2016-10-13 15:45:44.000000000 +0000 @@ -1096,7 +1096,6 @@ { X509_CRL *x=NULL; FILE *fp; - struct tm *tm; if (!(file)) return NULL; @@ -1110,21 +1109,13 @@ fclose(fp); if ((x)) { - tm = cl_ASN1_GetTimeT(x->crl->nextUpdate); - if (!(tm)) { - X509_CRL_free(x); - return NULL; - } - -#if !defined(_WIN32) - if (timegm(tm) < time(NULL)) { - X509_CRL_free(x); - free(tm); - return NULL; - } -#endif + ASN1_TIME *tme; - free(tm); + tme = X509_CRL_get_nextUpdate(x); + if (!tme || X509_cmp_current_time(tme) < 0) { + X509_CRL_free(x); + return NULL; + } } return x; diff -Nru clamav-0.99.2+dfsg/libclamav/dconf.c clamav-0.99.3~beta1+dfsg/libclamav/dconf.c --- clamav-0.99.2+dfsg/libclamav/dconf.c 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/dconf.c 2016-10-13 15:45:44.000000000 +0000 @@ -74,6 +74,7 @@ { "PE", "CATALOG", PE_CONF_CATALOG, 1 }, { "PE", "CERTS", PE_CONF_CERTS, 1 }, { "PE", "MATCHICON", PE_CONF_MATCHICON, 1 }, + { "PE", "IMPTBL", PE_CONF_IMPTBL, 1 }, { "ELF", NULL, 0x1, 1 }, @@ -130,6 +131,7 @@ { "OTHER", "PREFILTERING", OTHER_CONF_PREFILTERING,1 }, { "OTHER", "PDFNAMEOBJ", OTHER_CONF_PDFNAMEOBJ, 1 }, { "OTHER", "PRTNINTXN", OTHER_CONF_PRTNINTXN, 1 }, + { "OTHER", "LZW", OTHER_CONF_LZW, 1 }, { "PHISHING", "ENGINE", PHISHING_CONF_ENGINE, 1 }, { "PHISHING", "ENTCONV", PHISHING_CONF_ENTCONV, 1 }, diff -Nru clamav-0.99.2+dfsg/libclamav/dconf.h clamav-0.99.3~beta1+dfsg/libclamav/dconf.h --- clamav-0.99.2+dfsg/libclamav/dconf.h 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/dconf.h 2016-10-13 15:45:44.000000000 +0000 @@ -65,6 +65,7 @@ #define PE_CONF_CATALOG 0x10000 #define PE_CONF_CERTS 0x20000 #define PE_CONF_MATCHICON 0x40000 +#define PE_CONF_IMPTBL 0x80000 /* Archive flags */ #define ARCH_CONF_RAR 0x1 @@ -121,6 +122,7 @@ #define OTHER_CONF_PREFILTERING 0x80 #define OTHER_CONF_PDFNAMEOBJ 0x100 #define OTHER_CONF_PRTNINTXN 0x200 +#define OTHER_CONF_LZW 0x400 /* Phishing flags */ #define PHISHING_CONF_ENGINE 0x1 diff -Nru clamav-0.99.2+dfsg/libclamav/default.h clamav-0.99.3~beta1+dfsg/libclamav/default.h --- clamav-0.99.2+dfsg/libclamav/default.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/default.h 2017-03-08 14:06:34.000000000 +0000 @@ -49,7 +49,7 @@ #define CLI_DEFAULT_MAXPARTITIONS 50 /* TODO - set better defaults */ -#define CLI_DEFAULT_PCRE_MATCH_LIMIT 10000 +#define CLI_DEFAULT_PCRE_MATCH_LIMIT 100000 #define CLI_DEFAULT_PCRE_RECMATCH_LIMIT 5000 #define CLI_DEFAULT_PCRE_MAX_FILESIZE 26214400 diff -Nru clamav-0.99.2+dfsg/libclamav/disasm-common.h clamav-0.99.3~beta1+dfsg/libclamav/disasm-common.h --- clamav-0.99.2+dfsg/libclamav/disasm-common.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/disasm-common.h 2016-11-03 16:01:29.000000000 +0000 @@ -162,7 +162,7 @@ OP_RCR,/**< Rotate Carry Right */ OP_RDMSR,/**< Read from Model Specific Register */ OP_RDPMC,/**< Read Performance Monitoring Counters */ - OP_RDTSC,/**< Read Time-Stamp Coutner */ + OP_RDTSC,/**< Read Time-Stamp Counter */ OP_PREFIX_REPE,/**< Repeat String Operation Prefix while Equal */ OP_PREFIX_REPNE,/**< Repeat String Operation Prefix while Not Equal */ OP_RETF,/**< Return from Far Procedure */ diff -Nru clamav-0.99.2+dfsg/libclamav/elf.c clamav-0.99.3~beta1+dfsg/libclamav/elf.c --- clamav-0.99.2+dfsg/libclamav/elf.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/elf.c 2016-10-13 15:45:44.000000000 +0000 @@ -115,7 +115,9 @@ break; default: cli_dbgmsg("ELF: Unknown ELF class (%u)\n", file_hdr->hdr64.e_ident[4]); - return CL_EFORMAT; + if (ctx) + cli_append_virus(ctx, "Heuristics.Broken.Executable"); + return CL_VIRUS; } /* Need to know to endian convert */ diff -Nru clamav-0.99.2+dfsg/libclamav/entconv.c clamav-0.99.3~beta1+dfsg/libclamav/entconv.c --- clamav-0.99.2+dfsg/libclamav/entconv.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/entconv.c 2017-02-20 18:36:39.000000000 +0000 @@ -734,7 +734,7 @@ while (inleft && (outleft >= 2)) { /* iconv doesn't like inleft to be 0 */ const size_t outleft_last = outleft; assert(*iconv_struct != (iconv_t)-1); - rc = iconv(*iconv_struct, (const char **)(&input), &inleft, &out, &outleft); + rc = iconv(*iconv_struct, &input, &inleft, &out, &outleft); if(rc == (size_t)-1) { if(errno == E2BIG) { /* not enough space in output buffer */ diff -Nru clamav-0.99.2+dfsg/libclamav/events.c clamav-0.99.3~beta1+dfsg/libclamav/events.c --- clamav-0.99.2+dfsg/libclamav/events.c 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/events.c 2016-10-13 15:45:44.000000000 +0000 @@ -54,7 +54,7 @@ if (!ev) return NULL; ev->max = max_event; - ev->events = cli_calloc(max_event, max_event * sizeof(*ev->events)); + ev->events = cli_calloc(max_event, sizeof(*ev->events)); if (!ev->events) { free(ev); return NULL; diff -Nru clamav-0.99.2+dfsg/libclamav/filetypes.c clamav-0.99.3~beta1+dfsg/libclamav/filetypes.c --- clamav-0.99.2+dfsg/libclamav/filetypes.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/filetypes.c 2016-10-13 15:45:44.000000000 +0000 @@ -126,6 +126,8 @@ { "CL_TYPE_XML_HWP", CL_TYPE_XML_HWP }, { "CL_TYPE_HWPOLE2", CL_TYPE_HWPOLE2 }, { "CL_TYPE_OOXML_HWP", CL_TYPE_OOXML_HWP }, + { "CL_TYPE_PS", CL_TYPE_PS }, + { "CL_TYPE_MHTML", CL_TYPE_MHTML }, { NULL, CL_TYPE_IGNORED } }; diff -Nru clamav-0.99.2+dfsg/libclamav/filetypes.h clamav-0.99.3~beta1+dfsg/libclamav/filetypes.h --- clamav-0.99.2+dfsg/libclamav/filetypes.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/filetypes.h 2016-10-13 15:45:44.000000000 +0000 @@ -87,6 +87,7 @@ CL_TYPE_INTERNAL, CL_TYPE_HWP3, CL_TYPE_OOXML_HWP, + CL_TYPE_PS, /* Section for partition types */ CL_TYPE_PART_ANY, /* unknown partition type */ @@ -114,6 +115,7 @@ CL_TYPE_XML_XL, CL_TYPE_XML_HWP, CL_TYPE_HWPOLE2, + CL_TYPE_MHTML, CL_TYPE_OTHER, /* on-the-fly, used for target 14 (OTHER) */ CL_TYPE_IGNORED /* please don't add anything below */ diff -Nru clamav-0.99.2+dfsg/libclamav/filetypes_int.h clamav-0.99.3~beta1+dfsg/libclamav/filetypes_int.h --- clamav-0.99.2+dfsg/libclamav/filetypes_int.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/filetypes_int.h 2016-10-13 15:45:44.000000000 +0000 @@ -41,7 +41,7 @@ "0:0:000001ba:MPEG sys stream:CL_TYPE_ANY:CL_TYPE_IGNORED", "0:0:1f8b:GZip:CL_TYPE_ANY:CL_TYPE_GZ", "0:0:23407e5e:SCRENC:CL_TYPE_ANY:CL_TYPE_SCRENC", - "0:0:252150532d41646f62652d:PostScript:CL_TYPE_ANY:CL_TYPE_IGNORED", + "0:0:252150532d41646f62652d:PostScript:CL_TYPE_ANY:CL_TYPE_PS", "0:0:28546869732066696c65206d75737420626520636f6e76657274656420776974682042696e48657820342e3029:BinHex:CL_TYPE_ANY:CL_TYPE_BINHEX", "0:0:2e524d46:Real Media File:CL_TYPE_ANY:CL_TYPE_IGNORED", "0:0:3e46726f6d20:Mail:CL_TYPE_ANY:CL_TYPE_MAIL", @@ -193,6 +193,8 @@ "0:4:d0cf11e0a1b11ae1:HWP embedded OLE2:CL_TYPE_ANY:CL_TYPE_HWPOLE2", "0:0:48575020446f63756d656e742046696c652056332e3030201a0102030405:HWP 3.x Document:CL_TYPE_ANY:CL_TYPE_HWP3:82", "1:0:efbbbf3c3f786d6c2076657273696f6e3d22312e3022*3c4857504d4c:HWPML Document:CL_TYPE_ANY:CL_TYPE_XML_HWP:82", + "1:0:(4d|6d)(49|69)(4d|6d)(45|65)2d(56|76)657273696f6e3a20{-1024}0a(43|63)6f6e74656e742d(54|74)7970653a20:MHTML file:CL_TYPE_ANY:CL_TYPE_MHTML:83", + "1:*:0a(4d|6d)(49|69)(4d|6d)(45|65)2d(56|76)657273696f6e3a20{-1024}0a(43|63)6f6e74656e742d(54|74)7970653a20:MHTML file:CL_TYPE_ANY:CL_TYPE_MHTML:83", NULL }; diff -Nru clamav-0.99.2+dfsg/libclamav/fmap.c clamav-0.99.3~beta1+dfsg/libclamav/fmap.c --- clamav-0.99.2+dfsg/libclamav/fmap.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/fmap.c 2017-02-20 18:36:39.000000000 +0000 @@ -547,7 +547,7 @@ size_t len = m->pages * m->pgsz + m->hdrsz; fmap_lock; if (munmap((void *)m, len) == -1) /* munmap() failed */ - cli_warnmsg("funmap: unable to unmap memory segment at address: %p with length: %d\n", (void *)m, len); + cli_warnmsg("funmap: unable to unmap memory segment at address: %p with length: %zu\n", (void *)m, len); fmap_unlock; #endif } diff -Nru clamav-0.99.2+dfsg/libclamav/fmap.h clamav-0.99.3~beta1+dfsg/libclamav/fmap.h --- clamav-0.99.2+dfsg/libclamav/fmap.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/fmap.h 2017-04-20 22:19:13.000000000 +0000 @@ -80,6 +80,7 @@ HANDLE fh; HANDLE mh; #endif + unsigned char maphash[16]; uint32_t placeholder_for_bitmap; }; diff -Nru clamav-0.99.2+dfsg/libclamav/gpt.c clamav-0.99.3~beta1+dfsg/libclamav/gpt.c --- clamav-0.99.2+dfsg/libclamav/gpt.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/gpt.c 2017-04-20 22:19:13.000000000 +0000 @@ -604,6 +604,7 @@ off_t pos; size_t maplen; uint32_t max_prtns = 0; + int virus_found = 0; maplen = (*ctx->fmap)->real_len; @@ -647,23 +648,19 @@ else { tmp = prtn_intxn_list_check(&prtncheck, &pitxn, gpe.firstLBA, gpe.lastLBA - gpe.firstLBA + 1); if (tmp != CL_CLEAN) { - if ((ctx->options & CL_SCAN_ALLMATCHES) && (tmp == CL_VIRUS)) { + if (tmp == CL_VIRUS) { cli_dbgmsg("cli_scangpt: detected intersection with partitions " "[%u, %u]\n", pitxn, i); - cli_append_virus(ctx, PRTN_INTXN_DETECTION); + ret = cli_append_virus(ctx, PRTN_INTXN_DETECTION); + if (ret == CL_VIRUS) + virus_found = 1; + if (SCAN_ALL || ret == CL_CLEAN) + tmp = 0; + else + goto leave; + } else { ret = tmp; - tmp = 0; - } - else if (tmp == CL_VIRUS) { - cli_dbgmsg("cli_scangpt: detected intersection with partitions " - "[%u, %u]\n", pitxn, i); - cli_append_virus(ctx, PRTN_INTXN_DETECTION); - prtn_intxn_list_free(&prtncheck); - return CL_VIRUS; - } - else { - prtn_intxn_list_free(&prtncheck); - return tmp; + goto leave; } } } @@ -672,6 +669,9 @@ pos += hdr.tableEntrySize; } + leave: prtn_intxn_list_free(&prtncheck); + if (virus_found) + return CL_VIRUS; return ret; } diff -Nru clamav-0.99.2+dfsg/libclamav/hashtab.c clamav-0.99.3~beta1+dfsg/libclamav/hashtab.c --- clamav-0.99.2+dfsg/libclamav/hashtab.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/hashtab.c 2016-11-03 16:01:29.000000000 +0000 @@ -134,9 +134,9 @@ size_t lookups, queries, insert_tries, inserts; cli_dbgmsg("--------Hashtable usage report for %p--------------\n",(const void*)s); cli_dbgmsg("hash function calculations:%ld\n",s->PROFILE_STRUCT.calc_hash); - cli_dbgmsg("successfull finds/total searches: %ld/%ld; lookups: %ld\n", s->PROFILE_STRUCT.found, s->PROFILE_STRUCT.find_req, s->PROFILE_STRUCT.found_tries); - cli_dbgmsg("unsuccessfull finds/total searches: %ld/%ld; lookups: %ld\n", s->PROFILE_STRUCT.not_found, s->PROFILE_STRUCT.find_req , s->PROFILE_STRUCT.not_found_tries); - cli_dbgmsg("successfull finds during grow:%ld; lookups: %ld\n",s->PROFILE_STRUCT.grow_found, s->PROFILE_STRUCT.grow_found_tries); + cli_dbgmsg("successful finds/total searches: %ld/%ld; lookups: %ld\n", s->PROFILE_STRUCT.found, s->PROFILE_STRUCT.find_req, s->PROFILE_STRUCT.found_tries); + cli_dbgmsg("unsuccessful finds/total searches: %ld/%ld; lookups: %ld\n", s->PROFILE_STRUCT.not_found, s->PROFILE_STRUCT.find_req , s->PROFILE_STRUCT.not_found_tries); + cli_dbgmsg("successful finds during grow:%ld; lookups: %ld\n",s->PROFILE_STRUCT.grow_found, s->PROFILE_STRUCT.grow_found_tries); lookups = s->PROFILE_STRUCT.found_tries + s->PROFILE_STRUCT.not_found_tries + s->PROFILE_STRUCT.grow_found_tries; queries = s->PROFILE_STRUCT.find_req + s->PROFILE_STRUCT.grow_found; cli_dbgmsg("Find Lookups/total queries: %ld/%ld = %3f\n", lookups, queries, lookups*1.0/queries); @@ -739,7 +739,7 @@ size_t idx = hash32shift(key) & (hs->mask); size_t tries = 1; - /* check wether the entry is used, and if the key matches */ + /* check whether the entry is used, and if the key matches */ while(BITMAP_CONTAINS(hs->bitmap, idx) && (hs->keys[idx] != key)) { /* entry used, key different -> collision */ idx = (idx + tries++)&(hs->mask); diff -Nru clamav-0.99.2+dfsg/libclamav/hfsplus.c clamav-0.99.3~beta1+dfsg/libclamav/hfsplus.c --- clamav-0.99.2+dfsg/libclamav/hfsplus.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/hfsplus.c 2017-02-20 18:36:39.000000000 +0000 @@ -68,7 +68,7 @@ cli_dbgmsg("%s Header: depth %hu root %u leafRecords %u firstLeaf %u lastLeaf %u nodeSize %hu\n", pfx, hdr->treeDepth, hdr->rootNode, hdr->leafRecords, hdr->firstLeafNode, hdr->lastLeafNode, hdr->nodeSize); - cli_dbgmsg("%s Header: maxKeyLength %hu totalNodes %u freeNodes %u btreeType %hu attributes %x\n", + cli_dbgmsg("%s Header: maxKeyLength %hu totalNodes %u freeNodes %u btreeType %hhu attributes %x\n", pfx, hdr->maxKeyLength, hdr->totalNodes, hdr->freeNodes, hdr->btreeType, hdr->attributes); } diff -Nru clamav-0.99.2+dfsg/libclamav/hwp.c clamav-0.99.3~beta1+dfsg/libclamav/hwp.c --- clamav-0.99.2+dfsg/libclamav/hwp.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/hwp.c 2016-11-03 16:01:29.000000000 +0000 @@ -1036,7 +1036,7 @@ hwp3_debug("HWP3.x: Paragraph[%d, %d]: box object contains %u cell(s)\n", level, p, ncells); - /* cell informations (27 bytes x ncells(offset 80 of table)) */ + /* cell information (27 bytes x ncells(offset 80 of table)) */ hwp3_debug("HWP3.x: Paragraph[%d, %d]: box cell info array starts @ %llu\n", level, p, (long long unsigned)offset); offset += (27 * ncells); @@ -1525,7 +1525,7 @@ #endif if (fmap_readn(map, &infoid, (*offset), sizeof(infoid)) != sizeof(infoid)) { - cli_errmsg("HWP3.x: Failed to read infomation block id @ %llu\n", + cli_errmsg("HWP3.x: Failed to read information block id @ %llu\n", (long long unsigned)(*offset)); return CL_EREAD; } @@ -1547,16 +1547,16 @@ /* Booking Information(5) - no length field and no content */ if (infoid == 5) { - hwp3_debug("HWP3.x: Information Block[%llu]: TYPE: Booking Infomation\n", infoloc); + hwp3_debug("HWP3.x: Information Block[%llu]: TYPE: Booking Information\n", infoloc); #if HAVE_JSON if (ctx->options & CL_SCAN_FILE_PROPERTIES) - cli_jsonstr(entry, "Type", "Booking Infomation"); + cli_jsonstr(entry, "Type", "Booking Information"); #endif return CL_SUCCESS; } if (fmap_readn(map, &infolen, (*offset), sizeof(infolen)) != sizeof(infolen)) { - cli_errmsg("HWP3.x: Failed to read infomation block len @ %llu\n", + cli_errmsg("HWP3.x: Failed to read information block len @ %llu\n", (long long unsigned)(*offset)); return CL_EREAD; } @@ -1602,7 +1602,7 @@ #if HWP3_DEBUG /* additional fields can be added */ memset(field, 0, HWP3_FIELD_LENGTH); if (fmap_readn(map, field, (*offset), 16) != 16) { - cli_errmsg("HWP3.x: Failed to read infomation block field @ %llu\n", + cli_errmsg("HWP3.x: Failed to read information block field @ %llu\n", (long long unsigned)(*offset)); return CL_EREAD; } @@ -1610,7 +1610,7 @@ memset(field, 0, HWP3_FIELD_LENGTH); if (fmap_readn(map, field, (*offset)+16, 16) != 16) { - cli_errmsg("HWP3.x: Failed to read infomation block field @ %llu\n", + cli_errmsg("HWP3.x: Failed to read information block field @ %llu\n", (long long unsigned)(*offset)); return CL_EREAD; } @@ -1630,7 +1630,7 @@ ret = cli_map_scan(map, (*offset), infolen, ctx, CL_TYPE_ANY); break; case 3: /* Hypertext/Hyperlink Information */ - hwp3_debug("HWP3.x: Information Block[%llu]: TYPE: Hypertext/Hyperlink Infomation\n", infoloc); + hwp3_debug("HWP3.x: Information Block[%llu]: TYPE: Hypertext/Hyperlink Information\n", infoloc); if (infolen % 617) { cli_errmsg("HWP3.x: Information Block[%llu]: Invalid multiple of 617 => %u\n", infoloc, infolen); return CL_EFORMAT; @@ -1640,7 +1640,7 @@ hwp3_debug("HWP3.x: Information Block[%llu]: COUNT: %d entries\n", infoloc, count); #if HAVE_JSON if (ctx->options & CL_SCAN_FILE_PROPERTIES) { - cli_jsonstr(entry, "Type", "Hypertext/Hyperlink Infomation"); + cli_jsonstr(entry, "Type", "Hypertext/Hyperlink Information"); cli_jsonint(entry, "Count", count); } #endif @@ -1649,7 +1649,7 @@ #if HWP3_DEBUG /* additional fields can be added */ memset(field, 0, HWP3_FIELD_LENGTH); if (fmap_readn(map, field, (*offset), 256) != 256) { - cli_errmsg("HWP3.x: Failed to read infomation block field @ %llu\n", + cli_errmsg("HWP3.x: Failed to read information block field @ %llu\n", (long long unsigned)(*offset)); return CL_EREAD; } @@ -1669,7 +1669,7 @@ break; case 5: /* Booking Information */ /* should never run this as it is short-circuited above */ - hwp3_debug("HWP3.x: Information Block[%llu]: TYPE: Booking Infomation\n", infoloc); + hwp3_debug("HWP3.x: Information Block[%llu]: TYPE: Booking Information\n", infoloc); #if HAVE_JSON if (ctx->options & CL_SCAN_FILE_PROPERTIES) cli_jsonstr(entry, "Type", "Booking Information"); @@ -1686,7 +1686,7 @@ #if HWP3_DEBUG /* additional fields can be added */ memset(field, 0, HWP3_FIELD_LENGTH); if (fmap_readn(map, field, (*offset)+24, 256) != 256) { - cli_errmsg("HWP3.x: Failed to read infomation block field @ %llu\n", + cli_errmsg("HWP3.x: Failed to read information block field @ %llu\n", (long long unsigned)(*offset)); return CL_EREAD; } @@ -1933,11 +1933,13 @@ return cli_magic_scandesc(fd, ctx); } -static int hwpml_binary_cb(int fd, cli_ctx *ctx, int num_attribs, struct attrib_entry *attribs) +static int hwpml_binary_cb(int fd, cli_ctx *ctx, int num_attribs, struct attrib_entry *attribs, void *cbdata) { int i, ret, df = 0, com = 0, enc = 0; char *tempfile; + UNUSEDPARAM(cbdata); + /* check attributes for compression and encoding */ for (i = 0; i < num_attribs; i++) { if (!strcmp(attribs[i].key, "Compress")) { @@ -2058,6 +2060,7 @@ { #if HAVE_LIBXML2 struct msxml_cbdata cbdata; + struct msxml_ctx mxctx; xmlTextReaderPtr reader = NULL; int state, ret = CL_SUCCESS; @@ -2071,7 +2074,7 @@ reader = xmlReaderForIO(msxml_read_cb, NULL, &cbdata, "hwpml.xml", NULL, CLAMAV_MIN_XMLREADER_FLAGS); if (!reader) { - cli_dbgmsg("cli_scanhwpml: cannot intialize xmlReader\n"); + cli_dbgmsg("cli_scanhwpml: cannot initialize xmlReader\n"); #if HAVE_JSON ret = cli_json_parse_error(ctx->wrkproperty, "HWPML_ERROR_XML_READER_IO"); @@ -2079,7 +2082,9 @@ return ret; // libxml2 failed! } - ret = cli_msxml_parse_document(ctx, reader, hwpml_keys, num_hwpml_keys, 1, hwpml_binary_cb); + memset(&mxctx, 0, sizeof(mxctx)); + mxctx.scan_cb = hwpml_binary_cb; + ret = cli_msxml_parse_document(ctx, reader, hwpml_keys, num_hwpml_keys, MSXML_FLAG_JSON, &mxctx); xmlTextReaderClose(reader); xmlFreeTextReader(reader); diff -Nru clamav-0.99.2+dfsg/libclamav/ishield.c clamav-0.99.3~beta1+dfsg/libclamav/ishield.c --- clamav-0.99.2+dfsg/libclamav/ishield.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/ishield.c 2016-10-13 15:45:44.000000000 +0000 @@ -350,6 +350,7 @@ struct IS_CABSTUFF c = { NULL, -1, 0, 0 }; fmap_t *map = *ctx->fmap; unsigned fc = 0; + int virus_found = 0; while(ret == CL_CLEAN) { fname = fmap_need_offstr(map, coff, 2048); @@ -379,8 +380,12 @@ cli_dbgmsg("ishield: @%lx found file %s (%s) - version %s - size %lu\n", (unsigned long int) coff, fname, path, version, (unsigned long int) fsize); if(cli_matchmeta(ctx, fname, fsize, fsize, 0, fc++, 0, NULL) == CL_VIRUS) { - ret = CL_VIRUS; - break; + if (!SCAN_ALL) { + ret = CL_VIRUS; + break; + } + ret = CL_CLEAN; + virus_found = 1; } sz -= (data - fname) + fsize; @@ -436,6 +441,9 @@ } else if( ret == CL_BREAK ) ret = CL_CLEAN; } if(c.cabs) free(c.cabs); + + if (virus_found != 0) + return CL_VIRUS; return ret; } diff -Nru clamav-0.99.2+dfsg/libclamav/json_api.c clamav-0.99.3~beta1+dfsg/libclamav/json_api.c --- clamav-0.99.2+dfsg/libclamav/json_api.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/json_api.c 2016-10-18 15:26:35.000000000 +0000 @@ -401,9 +401,6 @@ if (obj && key && json_object_object_get_ex(obj, key, &newobj)) return json_object_is_type(newobj, json_type_object) ? newobj : NULL; - if (obj && key && json_object_object_get_ex(obj, key, &newobj)) - return json_object_is_type(newobj, json_type_object) ? newobj : NULL; - newobj = json_object_new_object(); if (!(newobj)) return NULL; @@ -447,6 +444,98 @@ } #endif +/* adding an object does NOT increment reference count */ +int cli_json_addowner(json_object *owner, json_object *child, const char *key, int idx) +{ + json_type objty; + if (NULL == owner) { + cli_dbgmsg("json: no owner object specified to cli_json_addowner\n"); + return CL_ENULLARG; + } + + if (NULL == child) { + cli_dbgmsg("json: no child object specified to cli_json_addowner\n"); + return CL_ENULLARG; + } + objty = json_object_get_type(owner); + + if (objty == json_type_object) { + if (NULL == key) { + cli_dbgmsg("json: null string specified as key to cli_addowner\n"); + return CL_ENULLARG; + } + json_object_object_add(owner, key, child); + } + else if (objty == json_type_array) { + if (idx < 0 || NULL == json_object_array_get_idx(owner, idx)) + json_object_array_add(owner, child); + else if (0 != json_object_array_put_idx(owner, idx, child)) { + /* this shouldn't be possible */ + cli_dbgmsg("json: cannot delete idx %d of owner array\n", idx); + return CL_BREAK; + } + } + else { + cli_dbgmsg("json: no owner object cannot hold ownership\n"); + return CL_EARG; + } + + /* increment reference count */ + json_object_get(child); + return CL_SUCCESS; +} + +/* deleting an object DOES decrement reference count */ +int cli_json_delowner(json_object *owner, const char *key, int idx) +{ + json_type objty; + json_object *obj; + if (NULL == owner) { + cli_dbgmsg("json: no owner object specified to cli_json_delowner\n"); + return CL_ENULLARG; + } + objty = json_object_get_type(owner); + + if (objty == json_type_object) { + if (NULL == key) { + cli_dbgmsg("json: null string specified as key to cli_delowner\n"); + return CL_ENULLARG; + } + + if (!json_object_object_get_ex(owner, key, &obj)) { + cli_dbgmsg("json: owner array does not have content with key %s\n", key); + return CL_EARG; + } + + json_object_object_del(owner, key); + } + else if (objty == json_type_array) { + json_object *empty; + + if (NULL == json_object_array_get_idx(owner, idx)) { + cli_dbgmsg("json: owner array does not have content at idx %d\n", idx); + return CL_EARG; + } + + /* allocate the empty object to replace target object */ + empty = cli_jsonobj(NULL, NULL); + if (NULL == empty) + return CL_EMEM; + + if (0 != json_object_array_put_idx(owner, idx, empty)) { + /* this shouldn't be possible */ + cli_dbgmsg("json: cannot delete idx %d of owner array\n", idx); + return CL_BREAK; + } + } + else { + cli_dbgmsg("json: no owner object cannot hold ownership\n"); + return CL_EARG; + } + + return CL_SUCCESS; +} + #else int cli_json_nojson() diff -Nru clamav-0.99.2+dfsg/libclamav/json_api.h clamav-0.99.3~beta1+dfsg/libclamav/json_api.h --- clamav-0.99.2+dfsg/libclamav/json_api.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/json_api.h 2016-10-13 15:45:44.000000000 +0000 @@ -46,9 +46,13 @@ int cli_jsonint64(json_object *obj, const char* key, int64_t i); int cli_jsonbool(json_object *obj, const char* key, int i); int cli_jsondouble(json_object *obj, const char* key, double d); + json_object *cli_jsonarray(json_object *obj, const char *key); int cli_jsonint_array(json_object *obj, int32_t val); json_object *cli_jsonobj(json_object *obj, const char *key); +int cli_json_addowner(json_object *owner, json_object *child, const char *key, int idx); +int cli_json_delowner(json_object *owner, const char *key, int idx); +#define cli_json_delobj(obj) json_object_put(obj) #if HAVE_DEPRECATED_JSON int json_object_object_get_ex(struct json_object *obj, const char *key, struct json_object **value); @@ -87,6 +91,10 @@ #define cli_jsondouble(o,n,d) cli_jsondouble_nojson(n,d) #define cli_jsonarray(o,k) cli_jsonarray_nojson(k) #define cli_jsonint_array(o,v) cli_jsonint_array_nojson(v) +#define cli_json_addowner(o,c,k,i) cli_json_nojson() +#define cli_json_delowner(o,k,i) cli_json_nojson() +#define cli_json_delobj(o) cli_json_nojson() + #endif #endif /*__JSON_C_H__*/ diff -Nru clamav-0.99.2+dfsg/libclamav/jsparse/js-norm.c clamav-0.99.3~beta1+dfsg/libclamav/jsparse/js-norm.c --- clamav-0.99.2+dfsg/libclamav/jsparse/js-norm.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/jsparse/js-norm.c 2016-11-03 16:01:29.000000000 +0000 @@ -871,7 +871,7 @@ } if (end != '\0') cli_js_process_buffer(state, &end, 1); - /* close remaining paranthesis */ + /* close remaining parenthesis */ for (i=0;icnt;i++) { if (tokens->data[i].type == TOK_PAR_OPEN) par_balance++; @@ -887,7 +887,7 @@ } } - /* we had to close unfinished strings, paranthesis, + /* we had to close unfinished strings, parenthesis, * so that the folders/decoders can run properly */ run_folders(&state->tokens); run_decoders(state); diff -Nru clamav-0.99.2+dfsg/libclamav/libclamav.map clamav-0.99.3~beta1+dfsg/libclamav/libclamav.map --- clamav-0.99.2+dfsg/libclamav/libclamav.map 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libclamav.map 2016-10-13 15:45:44.000000000 +0000 @@ -174,6 +174,7 @@ cli_scanbuff; cli_fmap_scandesc; cli_checkfp_pe; + cli_genhash_pe; html_screnc_decode; mpool_create; mpool_calloc; diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/aclocal.m4 clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/aclocal.m4 --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/aclocal.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/aclocal.m4 2017-01-13 18:14:03.000000000 +0000 @@ -0,0 +1,1190 @@ +# 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'.])]) + +# 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])]) + +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering + +# 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_MAINTAINER_MODE([DEFAULT-MODE]) +# ---------------------------------- +# Control maintainer-specific portions of Makefiles. +# Default is to disable them, unless 'enable' is passed literally. +# For symmetry, 'disable' may be passed as well. Anyway, the user +# can override the default with the --enable/--disable switch. +AC_DEFUN([AM_MAINTAINER_MODE], +[m4_case(m4_default([$1], [disable]), + [enable], [m4_define([am_maintainer_other], [disable])], + [disable], [m4_define([am_maintainer_other], [enable])], + [m4_define([am_maintainer_other], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) +AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode's default is 'disable' unless 'enable' is passed + AC_ARG_ENABLE([maintainer-mode], + [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], + am_maintainer_other[ make rules and dependencies not useful + (and sometimes confusing) to the casual installer])], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST([MAINT])dnl +] +) + +# 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 +]) + +# 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/libtool.m4]) +m4_include([m4/ltoptions.m4]) +m4_include([m4/ltsugar.m4]) +m4_include([m4/ltversion.m4]) +m4_include([m4/lt~obsolete.m4]) diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/AUTHORS clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/AUTHORS --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/AUTHORS 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/AUTHORS 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,12 @@ +Principal author: Stuart Caie + +Based on specification documents from Microsoft Corporation and PKWARE. + +Contributors: +- LZX compressor by Matthew Russotto +- Quantum decompressor by Matthew Russotto +- old inflate decompressor by Dirk Stoecker / InfoZIP team +- Huffman table builder adapted from unlzx by Dave Tritscher +- LZX decompressor fixes by Jae Jung and Igor Glucksmann +- Debianisation by Markus Sinner +- Quantum decompressor fix by Larry Frieson diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/ChangeLog clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/ChangeLog --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/ChangeLog 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/ChangeLog 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,549 @@ +2015-01-18 Stuart Caie + + * lzxd_decompress(): the byte-alignment code for reading uncompressed + block headers presumed it could wind i_ptr back 2 bytes, but this + hasn't been true since READ_BYTES was allowed to read bytes straddling + two blocks, leaving just 1 byte in the read buffer. Thanks to Jakub + Wilk for finding the issue and providing a sample file. + + * inflate(): off-by-one error. Distance codes are 0-29, not 0-30. + Thanks to Jakub Wilk again. + + * chmd_read_headers(), search_chunk(): another fix for checking pointer + is within a chunk, thanks again to Jakub Wilk. + +2015-01-17 Stuart Caie + + * GET_UTF8_CHAR(): Remove 5/6-byte encoding support and check decoded + chars are no more than U+10FFFF. + + * chmd_init_decomp(): A reset interval of 0 is invalid. Thanks to + Jakub Wilk for finding the issue and providing a sample and patch. + +2015-01-15 Stuart Caie + + * chmd_read_headers(): add a bounds check to prevent over-reading data, + which caused a segfault on 32-bit architectures. Thanks to Jakub Wilk. + + * search_chunk(): change the order of pointer arithmetic operations to + avoid overflow during bounds checks, which lead to segfaults on 32-bit + architectures. Again, thanks to Jakub Wilk for finding this issue, + providing sample files and a patch. + +2015-01-08 Stuart Caie + + * cabd_extract(): No longer uses broken state data if extracting from + folder 1, 2, 1 and setting up folder 2 fails. This prevents a jump to + null and thus segfault. Thanks to Jakub Wilk again. + + * cabd_read_string: reject empty strings. They are not found in any + valid CAB files. Thanks to Hanno Böck for sending me an example. + +2015-01-05 Stuart Caie + + * cabd_can_merge_folders(): disallow folder merging if the combined + folder would have more than 65535 data blocks. + + * cabd_decompress(): disallow files if their offset, length or + offset+length is more than 65535*32768, the maximum size of any + folder. Thanks to Jakub Wilk for identifying the problem and providing + a sample file. + +2014-04-20 Stuart Caie + + * readhuff.h: fixed the table overflow check, which allowed one more + code after capacity had been reached, resulting in a read of + uninitialized data inside the decoding table. Thanks to Denis Kroshin + for identifying the problem and providing a sample file. + +2013-05-27 Stuart Caie + + * test/oabx.c: added new example command for unpacking OAB files. + +2013-05-17 Stuart Caie + + * mspack.h: Support for decompressing a new file format, the Exchange + Offline Address Book (OAB). Thanks to David Woodhouse for writing + the implementation. I've bumped the version to 0.4alpha in celebration. + +2012-04-15 Stuart Caie + + * chmd_read_headers(): More thorough validation of CHM header values. + Thanks to Sergei Trofimovich for finding sample files. + + * read_reset_table(): Better test for overflow. Thanks again to + Sergei Trofimovich for generating a good example. + + * test/chminfo.c: this test program reads the reset table by itself + and was also susceptible to the same overflow problems. + +2012-03-16 Stuart Caie + + * Makefile.am, configure.ac: make the GCC warning flags conditional + on using the GCC compiler. Thanks to Dagobert Michelsen for letting + me know. + +2011-11-25 Stuart Caie + + * lzxd_decompress(): Prevent matches that go beyond the start + of the LZX stream. Thanks to Sergei Trofimovich for testing + with valgrind and finding a corrupt sample file that exercises + this scenario. + +2011-11-23 Stuart Caie + + * chmd_fast_find(): add a simple check against infinite PGML + loops. Thanks to Sergei Trofimovich for finding sample files. + Multi-step PGML or PGMI infinite loops remain possible. + +2011-06-17 Stuart Caie + + * read_reset_table(): wasn't reading the right offset for getting + the LZX uncompressed length. Thanks to Sergei Trofimovich for + finding the bug. + +2011-05-31 Stuart Caie + + * kwajd.c, mszipd.c: KWAJ type 4 files (MSZIP) are now supported. + Thanks to Clive Turvey for sending me the format details. + + * doc/szdd_kwaj_format.html: Updated documentation to cover + KWAJ's MSZIP compression. + +2011-05-11 Stuart Caie + + * cabd_find(): rethought how large vs small file support is + handled, as users were getting "library not compiled to support + large files" message on some small files. Now checks for actual + off_t overflow, rather than trying to preempt it. + +2011-05-10: Stuart Caie + + * chmd.c: implemented fast_find() + + * test/chmx.c: removed the multiple extraction orders, now it just + extracts in the fastest order + + * test/chmd_order.c: new program added to test that different + extraction orders don't affect the results of extraction + + * test/chmd_find.c: new program to test that fast_find() works. + Either supply your own filename to find, or it will try finding + every file in the CHM. + + * configure.ac: because CHM fast find requires case-insensitive + comparisons, tolower() or towlower() are used where possible. + These functions and their headers are checked for. + + * mspack.h: exposed struct mschmd_sec_mscompressed's spaninfo + and struct mschmd_header's first_pmgl, last_pmgl and chunk_cache + to the world. Check that the CHM decoder version is v2 or higher + before using them. + + * system.c: set CHM decoder version to v2 + +2011-04-27: Stuart Caie + + * many files: Made C++ compilers much happier with libmspack. + Changed char * to const char * where possible. + + * mspack.h: Changed user-supplied char * to const char *. + Unless you've written your own mspack_system implementation, + you will likely be unaffected. + If you have written your own mspack_system implementation: + 1: change open() so it takes a const char *filename + 2: change message() so it takes a const char *format + If you cast your function into the mspack_system struct, + you can change the cast instead of the function. + +2011-04-27: Stuart Caie + + * Makefile.am: changed CFLAGS from "-Wsign-compare -Wconversion + -pedantic" to "-W -Wno-unused". This enables more warnings, and + disables these specific warnings which are now a hinderance. + +2011-04-27: Stuart Caie + + * test/cabrip.c, test/chminfo.c: used macros from system.h for + printing offsets and reading 64-bit values, rather than + reinvent the wheel. + + * cabd_can_merge_folders(): declare variables at the start of + a block so older C compilers won't choke. + + * cabd_find(): avoid compiler complaints about non-initialised + variables. We know they'll get initialised before use, but the + compiler can't reverse a state machine to draw the same conclusion. + +2011-04-26: Stuart Caie + + * configure.ac, mspack/system.h: Added a configure test to get + the size of off_t. If off_t is 8 bytes or more, we presume this + system has large file support. This fixes LFS detection for Fedora + x86_64 and Darwin/Mac OS X, neither of which declare FILESIZEBITS in + . It's not against the POSIX standard to do this: "A + definition of [FILESIZEBITS] shall be omitted from the + header on specific implementations where the corresponding value is + equal to or greater than the stated minimum, but where the value can + vary depending on the file to which it is applied." + (http://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html) + Thanks to Edward Sheldrake for the patch. + +2011-04-26: Stuart Caie + + * chmd.c: all 64-bit integer reads are now consolidated into + the read_off64() function + + * chmd_read_headers(): this function has been made resilient + against accessing memory past the end of a chunk. Thanks to + Sergei Trofimovich for sending me examples and analysis. + + * chmd_init_decomp(): this function now reads the SpanInfo file + if the ResetTable file isn't available, it also checks that each + system file it needs is large enough before accessing it, and + some of its code has been split into several new functions: + find_sys_file(), read_reset_table() and read_spaninfo() + +2011-04-26: Stuart Caie + + * mspack.h, chmd.c: now reads the SpanInfo system file if the + ResetTable file isn't available. This adds a new spaninfo pointer + into struct mschmd_sec_mscompressed + +2011-04-26: Stuart Caie + + * test/chminfo.c: more sanity checks for corrupted CHM files where + entries go past the end of a PGML/PGMI chunk, thanks to + Sergei Trofimovich for sending me examples and analysis. + +2011-04-25: Stuart Caie + + * cabd_merge(): Drew D'Addesio showed me spanning cabinets which + don't have all the CFFILE entries they should, but otherwise have + all necessary data for extraction. Changed the merging folders + test to be less strict; if folders don't exactly match, warn which + files are missing, but allow merging if at least one necessary + file is present. + +2010-09-24: Stuart Caie + + * readhuff.h: Don't let build_decode_table() allow empty trees. + It's meant to be special case just for the LZX length tree, so + move that logic out to the LZX code. Thanks to Danny Kroshin for + discovering the bug. + + * lzxd.c: Allow empty length trees, but not other trees. If + the length tree is empty, fail if asked to decode a length symbol. + Again, thanks to Danny Kroshin for discovering the bug. + +2010-09-20: Stuart Caie + + * Makefile.am: Set EXTRA_DIST so it doesn't include .svn + directories in the distribution, but does include docs. + +2010-09-20: Stuart Caie + + * Makefile.am, configure.ac: Use modern auto* practises; turn on + automake silent rules where possible, use "m4" directory for libtool + macros, use LT_INIT instead of AC_PROG_LIBTOOL and use AM_CPPFLAGS + instead of INCLUDES. Thanks to Sergei Trofimovich for the patch. + +2010-09-15: Stuart Caie + + * many files: Made the code compile with C++ + - Renamed all 'this' variables/parameters to 'self' + - Added casts to all memory allocations. + - Added extern "C" to header files with extern declarations. + - Made system.c include system.h. + - Changed the K&R-style headers to ANSI-style headers in md5.c + +2010-08-04: Stuart Caie + + * many files: removed unnecessary include + +2010-07-19: Stuart Caie + + * cabd_md5.c, chmd_md5.c: Replace writing files to disk then + MD5summing them, with an MD5summer built into mspack_system. + Much, much faster results. + + * qtmd_decompress(): Robert Riebisch pointed out a Quantum + data integrity check that could never be tripped, because + frame_todo is unsigned, so it will never be decremented + below zero. Replaced the check with one that assumes that + decrementing past zero wraps frame_todo round to a number + more than its maximum value (QTM_FRAME_SIZE). + +2010-07-18: Stuart Caie + + * cabd.c: Special logic to pass cabd_sys_read() errors back + to cabd_extract() wasn't compatible with the decompressor + logic of returning the same error repeatedly once unpacking + fails. This meant that if decompressing failed because of + a read error, then the next file in the same folder would + come back as "no error", but the decompressed wouldn't have + even attempted to decompress the file. Added a new state + variable, read_error, with the same lifespan as a decompressor, + to pass the underlying reason for MSPACK_ERR_READ errors back. + + * mszipd.c: improve MS-ZIP recovery by saving all the bytes + decoded prior to a block failing. This requires remembering + how far we got through the block, so the code has been made + slightly slower (about 0.003 seconds slower per gigabyte + unpacked) by removing the local variable window_posn + and keeping it in the state structure instead. + +2010-07-16: Stuart Caie + + * Makefile.am: strange interactions. When -std=c99 is used, + my Ubuntu's (libc6-dev 2.11.1-0ubuntu7.2) does NOT + define fseeko() unless _LARGEFILE_SOURCE is also defined. But + configure always uses -std=gnu99, not -std=c99, so its test + determines _LARGEFILE_SOURCE isn't needed but HAVE_FSEEKO is + true. The implicit fseeko definition has a 32-bit rather than + 64-bit offset, which means the mode parameter is interpreted + as part of the offset, and the mode is taken from the stack, + which is generally 0 (SEEK_SET). This breaks all SEEK_CURs. + The code works fine when -std=c99 is not set, so just remove + it for the time being. + +2010-07-12: Stuart Caie + + * system.c: Reject reading/writing a negative number of bytes. + + * chmd.c: allow zero-length files to be seen. Previously they were + skipped because they were mistaken for directory entries. + +2010-07-08: Stuart Caie + + * qtmd.c: Larry Frieson found an important bug in the Quantum + decoder. Window wraps flush all unwritten data to disk. + However, sometimes less data is needed, which makes + out_bytes negative, which is then passed to write(). Some + write() implementations treat negative sizes it as a large + positive integer and segfault trying to write the buffer. + + * Makefile.am, test/*.c: fixed automake file so that the + package passes a "make distcheck". + +2010-07-07: Stuart Caie + + * doc/szdd_kwaj_format.html: explain SZDD/KWAJ file format. + + * lzssd.c: fixed SZDD decompression bugs. + + * test/chmd_compare: Add scripts for comparing chmd_md5 against + Microsoft's own code. + + * test/chmd_md5.c: remove the need to decompress everything + twice, as this is already in chmx.c if needed. + +2010-07-06: Stuart Caie + + * many files: added SZDD and KWAJ decompression support. + +2010-06-18: Stuart Caie + + * system.h: expanded the test for 64-bit largefile support so + it also works on 64-bit native operating systems where you + don't have to define _FILE_OFFSET_BITS. + +2010-06-17: Stuart Caie + + * libmspack.pc.in: Added pkg-config support. Thanks to + Patrice Dumas for the patch. + +2010-06-14: Stuart Caie + + * qtmd.c, lzxd.c, mszipd.c: created new headers, readbits.h and + readhuff.h, which bundle up the bit-reading and huffman-reading + code found in the MSZIP, LZX and Quantum decoders. + +2010-06-11: Stuart Caie + + * qtmd_static_init(): Removed function in favour of static const + tables, same rationale as for lzxd_static_init(). + + * qtmd_read_input(), zipd_read_input(): After testing against my + set of CABs from the wild, I've found both these functions _need_ + an extra EOF flag, like lzxd_read_input() has. So I've added + it. This means CABs get decoded properly AND there's no reading + fictional bytes. + +2010-06-03: Stuart Caie + + * test/cabd_md5.c: updated this so it has better output and + doesn't need to be in the same directory as the files for multi- + part sets. + +2010-05-20: Stuart Caie + + * qtmd_read_input(), zipd_read_input(): Both these functions are + essentially copies of lzxd_read_input(), but that has a feature + they don't have - an extra EOF flag. So if EOF is + encountered (sys->read() returns 0 bytes), these don't pass on the + error. Their respective bit-reading functions that called them + then go on to access at least one byte of the input buffer, which + doesn't exist as sys->read() returned 0. Thanks to Michael + Vidrevich for spotting this and providing a test case. + +2010-05-20: Stuart Caie + + * system.h: It turns out no configure.ac tests are needed to + decide between __func__ and __FUNCTION__, so I put the standard + one (__func__) back into the D() macro, along with some + special-case ifdefs for old versions of GCC. + + * lzxd_static_init(): Removed function in favour of static const + tables. Jorge Lodos thinks it causes multithreading problems, I + disagree. However, there are speed benefits to declaring the + tables as static const. + + * cabd_init_decomp(): Fixed code which never runs but would write + to a null pointer if it could. Changed it to an assert() as it + will only trip if someone rewrites the internals of cabd.c. Thanks + to Jorge Lodos for finding it. + + * inflate(): Fixed an off-by-one error: if the LITERAL table + emitted code 286, this would read one byte past the end of + lit_extrabits[]. Thanks to Jorge Lodos for finding it. + +2010-05-06: Stuart Caie + + * test/cabrip.c, test/chminfo.c: add fseeko() support + +2009-06-01: Stuart Caie + + * README: clarify the extended license terms + + * doc, Makefile.am: make the doxygen makefile work when using + an alternate build directory + +2006-09-20: Stuart Caie + + * system.h: I had a choice of adding more to configure.ac to + test for __func__ and __FUNCTION__, or just removing __FUNCTION__ + from the D() macro. I chose the latter. + + * Makefile.am: Now the --enable-debug in configure will actually + apply -DDEBUG to the sources. + +2006-09-20: Stuart Caie + + * qtmd_decompress(): Fixed a major bug in the QTM decoder, as + reported by Tomasz Kojm last year. Removed the restriction on + window sizes as a result. Correctly decodes the XLVIEW cabinets. + +2006-08-31: Stuart Caie + + * lzxd_decompress(): Two major bugs fixed. Firstly, the R0/R1/R2 + local variables weren't set to 1 after lzxd_reset_state(). + Secondly, the LZX decompression stream can sometimes become + odd-aligned (after an uncompressed block) and the next 16 bit + fetch needs to be split across two input buffers, ENSURE_BITS() + didn't cover this case. Many thanks to Igor Glucksmann for + discovering both these bugs. + +2005-06-30: Stuart Caie + + * cabd_search(): fixed problems with searching files > 4GB for + cabinets. + +2005-06-23: Stuart Caie + + * qtmd_init(): The QTM decoder is broken for QTM streams with a + window size less than the frame size. Until this is fixed, fail + to initialise QTM window sizes less than 15. Thanks to Tomasz Kojm + for finding the bug. + +2005-03-22: Stuart Caie + + * system.h: now undefs "read", as the latest glibc defines read() + as a macro which messes everything up. Thanks to Ville Skyttä for + the update. + +2005-03-14: Stuart Caie + + * test/multifh.c: write an mspack_system implementation that can + handle normal disk files, open file handles, open file descriptors + and raw memory all at the same time. + +2005-02-24: Stuart Caie + + * chmd_read_headers(): avoid infinite loop when chmhs1_ChunkSize is + zero. Thanks to Serge Semashko for the research and discovery. + +2005-02-18: Stuart Caie + + * mspack.h: renamed the "interface" parameter of mspack_version() to + "entity", as interface is a reserved word in C++. Thanks to Yuriy Z + for the discovery. + +2004-12-09: Stuart Caie + + * lzss.h, szdd.h, szddd.h: more work on the SZDD/LZSS design. + +2004-06-12: Stuart Caie + + * lzxd_static_init(): removed write to lzxd_extra_bits[52], thanks + to Nigel Horne from the ClamAV project. + +2004-04-23: Stuart Caie + + * mspack.h: changed 'this' parameters to 'self' to allow compiling in + C++ compilers, thanks to Michal Cihar for the suggestion. + + * mspack.h, system.h, mspack.def, winbuild.sh: integrated some changes + from Petr Blahos to let libmspack build as a Win32 DLL. + + * chmd_fast_find(): added the first part of this code, and comments + sufficient to finish it :) + +2004-04-08 Stuart Caie + + * test/chminfo.c: added a program for dumping useful data from CHM + files, e.g. index entries and reset tables. I wrote this a while ago + for investigating a corrupt cabinet, but I never committed it. + +2004-03-26 Stuart Caie + + * test/cabd_memory.c: added a new test example which shows an + mspack_system implementation that reads and writes from memory only, + no file I/O. Even the source code has a little cab file embedded in it. + +2004-03-10 Stuart Caie + + * cabd.c: updated the location of the CAB SDK. + + * cabd.c: changed a couple of MSPACK_ERR_READ errors not based on + read() failures into MSPACK_ERR_DATAFORMAT errors. + + * mszipd_decompress(): repair mode now aborts after writing a + repaired block if the error was a hard error (e.g. read error, out + of blocks, etc) + +2004-03-08 Stuart Caie + + * Makefile.am: now builds and installs a versioned library. + + * mszipd.c: completed a new MS-ZIP and inflate implementation. + + * system.c: added mspack_version() and committed to a versioned + ABI for the library. + + * cabd.c: made mszip repair functionality work correctly. + + * cabd.c: now identifies invalid block headers + + * doc/: API documentation is now included with the library, not + just on the web. + + * chmd.c: fixed error messages and 64-bit debug output. + + * chmd.c: now also catches NULL files in section 1. + + * test/chmx.c: now acts more like cabextract. + +2003-08-29 Stuart Caie + + * ChangeLog: started keeping a ChangeLog :) diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/compile clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/compile --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/compile 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/compile 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,347 @@ +#! /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: diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/config.guess clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/config.guess --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/config.guess 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/config.guess 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,1558 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2013 Free Software Foundation, Inc. + +timestamp='2013-06-10' + +# 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-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." + +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'` + ;; +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 ;; + i*: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; } + ;; + or1k:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + or32: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 [ "$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 + 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 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +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: diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/config.h.in clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/config.h.in --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/config.h.in 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/config.h.in 2017-01-13 18:14:09.000000000 +0000 @@ -0,0 +1,118 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Turn debugging mode on? */ +#undef DEBUG + +/* Define to 1 if you have the header file. */ +#undef HAVE_CTYPE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#undef HAVE_FSEEKO + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* 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 header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the `tolower' function. */ +#undef HAVE_TOLOWER + +/* Define to 1 if you have the `towlower' function. */ +#undef HAVE_TOWLOWER + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_WCTYPE_H + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* 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 + +/* The size of `off_t', as computed by sizeof. */ +#undef SIZEOF_OFF_T + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +#undef _LARGEFILE_SOURCE + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* 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 `int' if does not define. */ +#undef mode_t + +/* Define to `long int' if does not define. */ +#undef off_t + +/* Define to `unsigned int' if does not define. */ +#undef size_t diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/config.sub clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/config.sub --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/config.sub 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/config.sub 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,1791 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2013 Free Software Foundation, Inc. + +timestamp='2013-08-10' + +# 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-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." + +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 \ + | 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 \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 \ + | or1k | 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 | 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-* \ + | 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-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | 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 + ;; + 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-*) 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* \ + | -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*) + # 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 + ;; + or1k-*) + 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: diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/configure clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/configure --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/configure 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/configure 2017-06-23 21:20:49.000000000 +0000 @@ -0,0 +1,14778 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for libmspack 0.5alpha. +# +# 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 -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 +test \$(( 1 + 1 )) = 2 || 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 kyzer@4u.net about +$0: your system, including any error possibly output before +$0: this message. Then install a modern shell, or manually +$0: run the script under such a 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='libmspack' +PACKAGE_TARNAME='libmspack' +PACKAGE_VERSION='0.5alpha' +PACKAGE_STRING='libmspack 0.5alpha' +PACKAGE_BUGREPORT='kyzer@4u.net' +PACKAGE_URL='' + +ac_unique_file="mspack/mspack.h" +# 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" + +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +LIBOBJS +CPP +OTOOL64 +OTOOL +LIPO +NMEDIT +DSYMUTIL +MANIFEST_TOOL +RANLIB +ac_ct_AR +AR +DLLTOOL +OBJDUMP +LN_S +NM +ac_ct_DUMPBIN +DUMPBIN +LD +FGREP +EGREP +GREP +SED +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +LIBTOOL +GCC_FALSE +GCC_TRUE +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 +DEBUG_FALSE +DEBUG_TRUE +MAINT +MAINTAINER_MODE_FALSE +MAINTAINER_MODE_TRUE +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_maintainer_mode +enable_debug +enable_dependency_tracking +enable_shared +enable_static +with_pic +enable_fast_install +with_gnu_ld +with_sysroot +enable_libtool_lock +enable_largefile +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# 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 libmspack 0.5alpha 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/libmspack] + --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 libmspack 0.5alpha:";; + 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") + --disable-maintainer-mode + disable make rules and dependencies not useful (and + sometimes confusing) to the casual installer + --enable-debug enable debugging + --enable-dependency-tracking + do not reject slow dependency extractors + --disable-dependency-tracking + speeds up one-time build + --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) + --disable-largefile omit support for large files + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --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). + +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 + +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 +libmspack configure 0.5alpha +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_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_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_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_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_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_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 kyzer@4u.net ## +## --------------------------- ##" + ) | 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_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_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 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 libmspack $as_me 0.5alpha, 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 + +# 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 + + + +am__api_version='1.14' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; 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 \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$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. + + +# 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='libmspack' + VERSION='0.5alpha' + + +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 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 +$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } + # Check whether --enable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then : + enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=yes +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 +$as_echo "$USE_MAINTAINER_MODE" >&6; } + if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + + MAINT=$MAINTAINER_MODE_TRUE + + + +ac_config_headers="$ac_config_headers config.h" + + +# 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=0;; +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='\' + + +# --enable-debug option +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; enable_debug=$enableval +else + enable_debug=no +fi + +if test x$enable_debug = xyes; then + +$as_echo "#define DEBUG 1" >>confdefs.h + +fi + if test x$enable_debug = 'xyes'; then + DEBUG_TRUE= + DEBUG_FALSE='#' +else + DEBUG_TRUE='#' + DEBUG_FALSE= +fi + + +# Checks for programs. +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 + +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 + + + +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 + + + if test x$GCC = 'xyes'; then + GCC_TRUE= + GCC_FALSE='#' +else + GCC_TRUE='#' + GCC_FALSE= +fi + + +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' +macro_revision='1.3337' + + + + + + + + + + + + + +ltmain="$ac_aux_dir/ltmain.sh" + +# 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 + + +# 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 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 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 "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +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 ${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 + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + 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 "$lt_cv_path_NM" != "no"; 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 /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols" + ;; + *) + 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; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # 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 $i != 17 # 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"} + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 +$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,b/c, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 +$as_echo "$xsi_shell" >&6; } + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 +$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } +lt_shell_append=no +( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 +$as_echo "$lt_shell_append" >&6; } + + +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 "$GCC" != yes; then + reload_cmds=false + fi + ;; + darwin*) + if test "$GCC" = yes; 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 +# which 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. + # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. + if ( test "$lt_cv_nm_interface" = "BSD nm" && 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* | netbsdelf*-gnu) + 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*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; 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 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 "$ac_status" -eq 0; 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 "$ac_status" -ne 0; 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 "x$lt_cv_ar_at_file" = xno; 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 + 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 "$host_cpu" = ia64; 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 + +# 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 -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$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 -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/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 + # and D for any global 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};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print 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 con'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* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$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 "$pipe_works" = yes; 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 "$GCC" = yes; 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 "x$enable_libtool_lock" != xno && 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 which ABI we are using. + 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 which ABI we are using. + 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 "$lt_cv_prog_gnu_ld" = yes; 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* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + 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-*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*) + 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-*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*) + 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 x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +*-*solaris*) + # Find out which ABI we are using. + 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*) + 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 "x$lt_cv_path_mainfest_tool" != xyes; 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 $_lt_result -eq 0; 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 $_lt_result -eq 0 && $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 "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; 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 "$lt_cv_ld_force_load" = "no"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac + +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 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 + + +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 + + + + + +# Set options + + + + enable_dlopen=no + + + 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 + + +test -z "$pic_mode" && pic_mode=default + + + + + + + + # 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 "X${COLLECT_NAMES+set}" != Xset; 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 "$GCC" = yes; 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" + # 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 x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; 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 "$GCC" = yes; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + ;; + + 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 "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + 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' + ;; + 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 which 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" + # 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 x"$lt_cv_prog_compiler_pic_works" = xyes; 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 x"$lt_cv_prog_compiler_static_works" = xyes; 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 "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; 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 "$hard_links" = no; 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 "$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 + ;; + linux* | k*bsd*-gnu | gnu*) + link_all_deplibs=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 "$with_gnu_ld" = yes; 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 "$lt_use_gnu_ld_interface" = yes; 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 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 "$host_cpu" != ia64; 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 (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; 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 "$host_os" = linux-dietlibc; 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 "$tmp_diet" = no + 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' ;; + 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 "x$supports_anon_versioning" = xyes; 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 "x$supports_anon_versioning" = xyes; 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* | netbsdelf*-gnu) + 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 can not +*** 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 "$ld_shlibs" = no; 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 "$GCC" = yes && 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 "$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 + 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 $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); 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 "$GCC" = yes; 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 "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + link_all_deplibs=no + else + # not using gcc + if test "$host_cpu" = ia64; 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 "$aix_use_runtimelinking" = yes; 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 "$aix_use_runtimelinking" = yes; 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 "${lt_cv_aix_libpath+set}" = 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 "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; 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 "${lt_cv_aix_libpath+set}" = 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 "$with_gnu_ld" = yes; 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~linknames=' + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; + else + sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $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 "$lt_cv_ld_force_load" = "yes"; 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*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; 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 "$GCC" = yes; 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 $output_objdir/$soname = $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 $output_objdir/$soname = $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 "$GCC" = yes && test "$with_gnu_ld" = no; 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 "$with_gnu_ld" = no; 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 "$GCC" = yes && test "$with_gnu_ld" = no; 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 x"$lt_cv_prog_compiler__b" = xyes; 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 "$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_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 "$GCC" = yes; 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 "$lt_cv_irix_exported_symbol" = yes; 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* | netbsdelf*-gnu) + 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*) + 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__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; 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 + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + 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 + 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 "$GCC" = yes; 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 "$GCC" = yes; 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 "$GCC" = yes; 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 "$GCC" = yes; 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 "x$host_vendor" = xsequent; 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 "$GCC" = yes; 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 can NOT 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 "$GCC" = yes; 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 x$host_vendor = xsni; 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 "$ld_shlibs" = no && 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 "$enable_shared" = yes && test "$GCC" = yes; 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 "$GCC" = yes; 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 2>/dev/null` + 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" + else + 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 "$host_cpu" = ia64; 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 can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; 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%'\''`; test $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=yes + 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 "X$HPUX_IA64_MODE" = X32; 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 "$lt_cv_prog_gnu_ld" = yes; 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 + ;; + +# 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' + ;; + +netbsdelf*-gnu) + version_type=linux + 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='NetBSD ld.elf_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*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + 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 + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +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 "$with_gnu_ld" = yes; 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 "$with_gnu_ld" = yes; 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 "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = 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 "X$hardcode_automatic" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$hardcode_direct" != no && + # 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 "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && + test "$hardcode_minus_L" != no; 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 "$hardcode_action" = relink || + test "$inherit_rpath" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + if test "x$enable_dlopen" != xyes; 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 + + ;; + + *) + 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 "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && 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 "$cross_compiling" = yes; 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 "x$lt_cv_dlopen_self" = xyes; 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 "$cross_compiling" = yes; 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 which 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 "$can_build_shared" = "no" && 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 "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[4-9]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && 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 "$enable_shared" = yes || 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" + + + + + + + + + + + + + + + + ac_config_commands="$ac_config_commands libtool" + + + + +# Only expand once: + + + + +# Checks for header files. +{ $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 + +for ac_header in ctype.h limits.h stdlib.h wctype.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 + + +# Checks for typedefs, structures, and compiler characteristics. +{ $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" "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 + +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 + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of off_t" >&5 +$as_echo_n "checking size of off_t... " >&6; } +if ${ac_cv_sizeof_off_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (off_t))" "ac_cv_sizeof_off_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_off_t" = 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 77 "cannot compute sizeof (off_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_off_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_off_t" >&5 +$as_echo "$ac_cv_sizeof_off_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_OFF_T $ac_cv_sizeof_off_t +_ACEOF + + +for ac_func in tolower towlower +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 + + +# largefile support +# 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 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + 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 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + 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 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + 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 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + 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 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + 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 + + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5 +$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; } +if ${ac_cv_sys_largefile_source+:} false; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include /* for off_t */ + #include +int +main () +{ +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_sys_largefile_source=no; break +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGEFILE_SOURCE 1 +#include /* for off_t */ + #include +int +main () +{ +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_sys_largefile_source=1; break +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_cv_sys_largefile_source=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5 +$as_echo "$ac_cv_sys_largefile_source" >&6; } +case $ac_cv_sys_largefile_source in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source +_ACEOF +;; +esac +rm -rf conftest* + +# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug +# in glibc 2.1.3, but that breaks too many other things. +# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. +if test $ac_cv_sys_largefile_source != unknown; then + +$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h + +fi + + +# Checks for library functions. +ac_config_files="$ac_config_files Makefile libmspack.pc" + +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= +U= +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 "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then + as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${DEBUG_TRUE}" && test -z "${DEBUG_FALSE}"; then + as_fn_error $? "conditional \"DEBUG\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +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 "${GCC_TRUE}" && test -z "${GCC_FALSE}"; then + as_fn_error $? "conditional \"GCC\" 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 libmspack $as_me 0.5alpha, 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_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 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="\\ +libmspack config.status 0.5alpha +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" + + +# 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_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"`' +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"`' + +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_c_name_address \ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +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; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + 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; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +ac_aux_dir='$ac_aux_dir' +xsi_shell='$xsi_shell' +lt_shell_append='$lt_shell_append' + +# See if we are running on zsh, and set the options which 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' + TIMESTAMP='$TIMESTAMP' + 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 + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "libmspack.pc") CONFIG_FILES="$CONFIG_FILES libmspack.pc" ;; + + *) 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_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 :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 + ;; + + :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 +} + ;; + "libtool":C) + + # See if we are running on zsh, and set the options which 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$TIMESTAMP) $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="" + +# ### 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 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 + +# 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 in which 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 + +# ### 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 "X${COLLECT_NAMES+set}" != Xset; 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) + + if test x"$xsi_shell" = xyes; then + sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ +func_dirname ()\ +{\ +\ case ${1} in\ +\ */*) func_dirname_result="${1%/*}${2}" ;;\ +\ * ) func_dirname_result="${3}" ;;\ +\ esac\ +} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_basename ()$/,/^} # func_basename /c\ +func_basename ()\ +{\ +\ func_basename_result="${1##*/}"\ +} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ +func_dirname_and_basename ()\ +{\ +\ case ${1} in\ +\ */*) func_dirname_result="${1%/*}${2}" ;;\ +\ * ) func_dirname_result="${3}" ;;\ +\ esac\ +\ func_basename_result="${1##*/}"\ +} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ +func_stripname ()\ +{\ +\ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ +\ # positional parameters, so assign one to ordinary parameter first.\ +\ func_stripname_result=${3}\ +\ func_stripname_result=${func_stripname_result#"${1}"}\ +\ func_stripname_result=${func_stripname_result%"${2}"}\ +} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ +func_split_long_opt ()\ +{\ +\ func_split_long_opt_name=${1%%=*}\ +\ func_split_long_opt_arg=${1#*=}\ +} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ +func_split_short_opt ()\ +{\ +\ func_split_short_opt_arg=${1#??}\ +\ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ +} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ +func_lo2o ()\ +{\ +\ case ${1} in\ +\ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ +\ *) func_lo2o_result=${1} ;;\ +\ esac\ +} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_xform ()$/,/^} # func_xform /c\ +func_xform ()\ +{\ + func_xform_result=${1%.*}.lo\ +} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_arith ()$/,/^} # func_arith /c\ +func_arith ()\ +{\ + func_arith_result=$(( $* ))\ +} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_len ()$/,/^} # func_len /c\ +func_len ()\ +{\ + func_len_result=${#1}\ +} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + +fi + +if test x"$lt_shell_append" = xyes; then + sed -e '/^func_append ()$/,/^} # func_append /c\ +func_append ()\ +{\ + eval "${1}+=\\${2}"\ +} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ +func_append_quoted ()\ +{\ +\ func_quote_for_eval "${2}"\ +\ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ +} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + # Save a `func_append' function call where possible by direct use of '+=' + sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +else + # Save a `func_append' function call even when '+=' is not available + sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +fi + +if test x"$_lt_function_replace_fail" = x":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 +$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} +fi + + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + ;; + + 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 + diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/configure.ac clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/configure.ac --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/configure.ac 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/configure.ac 2016-12-05 20:15:48.000000000 +0000 @@ -0,0 +1,51 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. +AC_PREREQ(2.59) +AC_INIT([libmspack],[0.5alpha],[kyzer@4u.net]) +AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE([foreign]) +AM_MAINTAINER_MODE([enable]) +AC_CONFIG_SRCDIR([mspack/mspack.h]) +AC_CONFIG_HEADER([config.h]) + +dnl Enable silent rules by default (if yet support in automake) +dnl use 'make V=1' to look at verbose commandline +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +# --enable-debug option +AC_ARG_ENABLE(debug, + AS_HELP_STRING(--enable-debug,enable debugging), + enable_debug=$enableval, + enable_debug=no) +if test x$enable_debug = xyes; then + AC_DEFINE(DEBUG, 1, [Turn debugging mode on?]) +fi +AM_CONDITIONAL(DEBUG, test x$enable_debug = 'xyes') + +# Checks for programs. +AC_PROG_CC +AM_CONDITIONAL(GCC, test x$GCC = 'xyes') +AC_PROG_INSTALL +LT_INIT +AC_EXEEXT + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([ctype.h limits.h stdlib.h wctype.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_INLINE +AC_TYPE_MODE_T +AC_TYPE_OFF_T +AC_TYPE_SIZE_T +AC_CHECK_SIZEOF([off_t]) +AC_CHECK_FUNCS([tolower towlower]) + +# largefile support +AC_SYS_LARGEFILE +AC_FUNC_FSEEKO + +# Checks for library functions. +AC_CONFIG_FILES([Makefile libmspack.pc]) +AC_OUTPUT diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/COPYING.LIB clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/COPYING.LIB --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/COPYING.LIB 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/COPYING.LIB 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 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 Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + 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 Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +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 and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +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 other code 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. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + 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, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser 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 combine 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) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) 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. + + d) 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. + + e) 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 materials to be 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 with +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 Lesser 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 + + 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser 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! + + diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/depcomp clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/depcomp --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/depcomp 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/depcomp 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,791 @@ +#! /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: diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/INSTALL clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/INSTALL --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/INSTALL 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/INSTALL 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,370 @@ +Installation Instructions +************************* + +Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, +Inc. + + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. + +Basic Installation +================== + + Briefly, the shell command `./configure && make && make install' +should configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + + The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package, generally using the just-built uninstalled binaries. + + 4. Type `make install' to install the programs and any data files and + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. + + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + HP-UX `make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as `configure' are involved. Use GNU `make' +instead. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS + KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf limitation. Until the limitation is lifted, you can use +this workaround: + + CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/install-sh clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/install-sh --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/install-sh 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/install-sh 2017-01-13 18:12:34.000000000 +0000 @@ -0,0 +1,527 @@ +#!/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: diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/libmspack.pc.in clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/libmspack.pc.in --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/libmspack.pc.in 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/libmspack.pc.in 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: @PACKAGE@ +Description: Compressors and decompressors for Microsoft formats +Version: @VERSION@ +Libs: -L${libdir} -lmspack +Cflags: -I${includedir} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/ltmain.sh clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/ltmain.sh --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/ltmain.sh 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/ltmain.sh 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,9661 @@ + +# libtool (GNU libtool) 2.4.2 +# Written by Gordon Matzigkeit , 1996 + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, +# 2007, 2008, 2009, 2010, 2011 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 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. + +# Usage: $progname [OPTION]... [MODE-ARG]... +# +# Provide generalized library-building support services. +# +# --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 +# --preserve-dup-deps don't remove duplicate dependency libraries +# --quiet, --silent don't print informational messages +# --no-quiet, --no-silent +# print informational messages (default) +# --no-warn don't display warning messages +# --tag=TAG use configuration variables from tag TAG +# -v, --verbose print more informational messages than default +# --no-verbose don't print the extra informational messages +# --version print version information +# -h, --help, --help-all print short, long, or detailed 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) +# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 +# automake: $automake_version +# autoconf: $autoconf_version +# +# Report bugs to . +# GNU libtool home page: . +# General help using GNU software: . + +PROGRAM=libtool +PACKAGE=libtool +VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1" +TIMESTAMP="" +package_revision=1.3337 + +# 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 + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + +# NLS nuisances: We save the old values to restore during execute mode. +lt_user_locale= +lt_safe_locale= +for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +do + eval "if test \"\${$lt_var+set}\" = set; then + save_$lt_var=\$$lt_var + $lt_var=C + export $lt_var + lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" + lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" + fi" +done +LC_ALL=C +LANGUAGE=C +export LANGUAGE LC_ALL + +$lt_unset CDPATH + + +# 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" + + + +: ${CP="cp -f"} +test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${SHELL="${CONFIG_SHELL-/bin/sh}"} +: ${Xsed="$SED -e 1s/^X//"} + +# Global variables: +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. + +exit_status=$EXIT_SUCCESS + +# Make sure IFS has a sensible default +lt_nl=' +' +IFS=" $lt_nl" + +dirname="s,/[^/]*$,," +basename="s,^.*/,," + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} # func_dirname may be replaced by extended shell implementation + + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "${1}" | $SED "$basename"` +} # func_basename may be replaced by extended shell implementation + + +# 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" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi + func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` +} # func_dirname_and_basename may be replaced by extended shell implementation + + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# 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). +# func_strip_suffix prefix name +func_stripname () +{ + 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 may be replaced by extended shell implementation + + +# These SED scripts presuppose an absolute path with a trailing slash. +pathcar='s,^/\([^/]*\).*$,\1,' +pathcdr='s,^/[^/]*,,' +removedotparts=':dotsl + s@/\./@/@g + t dotsl + s,/\.$,/,' +collapseslashes='s@/\{1,\}@/@g' +finalslash='s,/*$,/,' + +# 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. +# value returned in "$func_normal_abspath_result" +func_normal_abspath () +{ + # 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 "$removedotparts" -e "$collapseslashes" -e "$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 "$pathcar"` + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$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_normal_abspath_result=$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_relative_path SRCDIR DSTDIR +# generates a relative path from SRCDIR to DSTDIR, with a trailing +# slash if non-empty, suitable for immediately appending a filename +# without needing to append a separator. +# value returned in "$func_relative_path_result" +func_relative_path () +{ + 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 "x$func_relative_path_tlibdir" = x ; 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 "x$func_stripname_result" != x ; then + func_relative_path_result=${func_relative_path_result}/${func_stripname_result} + fi + + # Normalisation. If bindir is libdir, return empty string, + # else relative path ending with a slash; either way, target + # file name can be directly appended. + if test ! -z "$func_relative_path_result"; then + func_stripname './' '' "$func_relative_path_result/" + func_relative_path_result=$func_stripname_result + fi +} + +# The name of this program: +func_dirname_and_basename "$progpath" +progname=$func_basename_result + +# Make sure we have an absolute path for reexecution: +case $progpath in + [\\/]*|[A-Za-z]:\\*) ;; + *[\\/]*) + progdir=$func_dirname_result + progdir=`cd "$progdir" && pwd` + progpath="$progdir/$progname" + ;; + *) + save_IFS="$IFS" + IFS=${PATH_SEPARATOR-:} + for progdir in $PATH; do + IFS="$save_IFS" + test -x "$progdir/$progname" && break + done + IFS="$save_IFS" + test -n "$progdir" || progdir=`pwd` + progpath="$progdir/$progname" + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed="${SED}"' -e 1s/^X//' +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +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 +# which contains forward slashes, into one that contains +# (escaped) backslashes. A very naive implementation. +lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + +# Re-`\' parameter expansions in output of double_quote_subst that were +# `\'-ed in input to the same. If an odd number of `\' preceded a '$' +# in input to 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 '$'. +bs='\\' +bs2='\\\\' +bs4='\\\\\\\\' +dollar='\$' +sed_double_backslash="\ + s/$bs4/&\\ +/g + s/^$bs2$dollar/$bs&/ + s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g + s/\n//g" + +# Standard options: +opt_dry_run=false +opt_help=false +opt_quiet=false +opt_verbose=false +opt_warning=: + +# func_echo arg... +# Echo program name prefixed message, along with the current mode +# name if it has been set yet. +func_echo () +{ + $ECHO "$progname: ${opt_mode+$opt_mode: }$*" +} + +# func_verbose arg... +# Echo program name prefixed message in verbose mode only. +func_verbose () +{ + $opt_verbose && 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_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + +# func_error arg... +# Echo program name prefixed message to standard error. +func_error () +{ + $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 +} + +# func_warning arg... +# Echo program name prefixed warning message to standard error. +func_warning () +{ + $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 + + # bash bug again: + : +} + +# func_fatal_error arg... +# Echo program name prefixed message to standard error, and exit. +func_fatal_error () +{ + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + +# func_fatal_help arg... +# Echo program name prefixed message to standard error, followed by +# a help hint, and exit. +func_fatal_help () +{ + func_error ${1+"$@"} + func_fatal_error "$help" +} +help="Try \`$progname --help' for more information." ## default + + +# func_grep expression filename +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + $GREP "$1" "$2" >/dev/null 2>&1 +} + + +# func_mkdir_p directory-path +# Make sure the entire path to DIRECTORY-PATH is available. +func_mkdir_p () +{ + my_directory_path="$1" + my_dir_list= + + if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then + + # Protect directory names starting with `-' + case $my_directory_path in + -*) my_directory_path="./$my_directory_path" ;; + esac + + # While some portion of DIR does not yet exist... + while test ! -d "$my_directory_path"; do + # ...make a list in topmost first order. Use a colon delimited + # list incase some portion of path contains whitespace. + my_dir_list="$my_directory_path:$my_dir_list" + + # If the last portion added has no slash in it, the list is done + case $my_directory_path in */*) ;; *) break ;; esac + + # ...otherwise throw away the child directory and loop + my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` + done + my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` + + save_mkdir_p_IFS="$IFS"; IFS=':' + for my_dir in $my_dir_list; do + IFS="$save_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 "$my_dir" 2>/dev/null || : + done + IFS="$save_mkdir_p_IFS" + + # Bail out if we (or some other process) failed to create a directory. + test -d "$my_directory_path" || \ + func_fatal_error "Failed to create \`$1'" + fi +} + + +# func_mktempdir [string] +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, STRING is the basename for that directory. +func_mktempdir () +{ + my_template="${TMPDIR-/tmp}/${1-$progname}" + + if test "$opt_dry_run" = ":"; then + # Return a directory name, but don't create it in dry-run mode + my_tmpdir="${my_template}-$$" + else + + # If mktemp works, use that first and foremost + my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` + + if test ! -d "$my_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + my_tmpdir="${my_template}-${RANDOM-0}$$" + + save_mktempdir_umask=`umask` + umask 0077 + $MKDIR "$my_tmpdir" + umask $save_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$my_tmpdir" || \ + func_fatal_error "cannot create temporary directory \`$my_tmpdir'" + fi + + $ECHO "$my_tmpdir" +} + + +# func_quote_for_eval arg +# Aesthetically quote ARG to be evaled later. +# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT +# is double-quoted, suitable for a subsequent eval, whereas +# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters +# which are still active within double quotes backslashified. +func_quote_for_eval () +{ + case $1 in + *[\\\`\"\$]*) + func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; + *) + func_quote_for_eval_unquoted_result="$1" ;; + esac + + case $func_quote_for_eval_unquoted_result in + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and and variable + # expansion for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" + ;; + *) + func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" + esac +} + + +# 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 () +{ + case $1 in + *[\\\`\"]*) + my_arg=`$ECHO "$1" | $SED \ + -e "$double_quote_subst" -e "$sed_double_backslash"` ;; + *) + my_arg="$1" ;; + esac + + case $my_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. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + my_arg="\"$my_arg\"" + ;; + esac + + func_quote_for_expand_result="$my_arg" +} + + +# func_show_eval cmd [fail_exp] +# Unless opt_silent 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 () +{ + my_cmd="$1" + my_fail_exp="${2-:}" + + ${opt_silent-false} || { + func_quote_for_expand "$my_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + if ${opt_dry_run-false}; then :; else + eval "$my_cmd" + my_status=$? + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + fi +} + + +# func_show_eval_locale cmd [fail_exp] +# Unless opt_silent 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 () +{ + my_cmd="$1" + my_fail_exp="${2-:}" + + ${opt_silent-false} || { + func_quote_for_expand "$my_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + if ${opt_dry_run-false}; then :; else + eval "$lt_user_locale + $my_cmd" + my_status=$? + eval "$lt_safe_locale" + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + 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 () +{ + case $1 in + [0-9]* | *[!a-zA-Z0-9_]*) + func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` + ;; + * ) + func_tr_sh_result=$1 + ;; + esac +} + + +# func_version +# Echo version message to standard output and exit. +func_version () +{ + $opt_debug + + $SED -n '/(C)/!b go + :more + /\./!{ + N + s/\n# / / + b more + } + :go + /^# '$PROGRAM' (GNU /,/# warranty; / { + s/^# // + s/^# *$// + s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ + p + }' < "$progpath" + exit $? +} + +# func_usage +# Echo short help message to standard output and exit. +func_usage () +{ + $opt_debug + + $SED -n '/^# Usage:/,/^# *.*--help/ { + s/^# // + s/^# *$// + s/\$progname/'$progname'/ + p + }' < "$progpath" + echo + $ECHO "run \`$progname --help | more' for full usage" + exit $? +} + +# func_help [NOEXIT] +# Echo long help message to standard output and exit, +# unless 'noexit' is passed as argument. +func_help () +{ + $opt_debug + + $SED -n '/^# Usage:/,/# Report bugs to/ { + :print + s/^# // + s/^# *$// + s*\$progname*'$progname'* + s*\$host*'"$host"'* + s*\$SHELL*'"$SHELL"'* + s*\$LTCC*'"$LTCC"'* + s*\$LTCFLAGS*'"$LTCFLAGS"'* + s*\$LD*'"$LD"'* + s/\$with_gnu_ld/'"$with_gnu_ld"'/ + s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ + s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ + p + d + } + /^# .* home page:/b print + /^# General help using/b print + ' < "$progpath" + ret=$? + if test -z "$1"; then + exit $ret + fi +} + +# func_missing_arg argname +# Echo program name prefixed message to standard error and set global +# exit_cmd. +func_missing_arg () +{ + $opt_debug + + func_error "missing argument for $1." + exit_cmd=exit +} + + +# 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. +func_split_short_opt () +{ + my_sed_short_opt='1s/^\(..\).*$/\1/;q' + my_sed_short_rest='1s/^..\(.*\)$/\1/;q' + + func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` + func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` +} # func_split_short_opt may be replaced by extended shell implementation + + +# func_split_long_opt longopt +# Set func_split_long_opt_name and func_split_long_opt_arg shell +# variables after splitting LONGOPT at the `=' sign. +func_split_long_opt () +{ + my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' + my_sed_long_arg='1s/^--[^=]*=//' + + func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` + func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` +} # func_split_long_opt may be replaced by extended shell implementation + +exit_cmd=: + + + + + +magic="%%%MAGIC variable%%%" +magic_exe="%%%MAGIC EXE variable%%%" + +# Global variables. +nonopt= +preserve_args= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" +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= + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "${1}=\$${1}\${2}" +} # func_append may be replaced by extended shell implementation + +# func_append_quoted var value +# Quote VALUE and append to the end of shell variable VAR, separated +# by a space. +func_append_quoted () +{ + func_quote_for_eval "${2}" + eval "${1}=\$${1}\\ \$func_quote_for_eval_result" +} # func_append_quoted may be replaced by extended shell implementation + + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "${@}"` +} # func_arith may be replaced by extended shell implementation + + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` +} # func_len may be replaced by extended shell implementation + + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` +} # func_lo2o may be replaced by extended shell implementation + + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` +} # func_xform may be replaced by extended shell implementation + + +# func_fatal_configuration arg... +# Echo program name prefixed message to standard error, followed by +# a configuration failure hint, and exit. +func_fatal_configuration () +{ + func_error ${1+"$@"} + func_error "See the $PACKAGE documentation for more information." + func_fatal_error "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 "$build_libtool_libs" = yes; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; 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 +} + + +# 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 + + + +# Option defaults: +opt_debug=: +opt_dry_run=false +opt_config=false +opt_preserve_dup_deps=false +opt_features=false +opt_finish=false +opt_help=false +opt_help_all=false +opt_silent=: +opt_warning=: +opt_verbose=: +opt_silent=false +opt_verbose=false + + +# Parse options once, thoroughly. This comes as soon as possible in the +# script to make things like `--version' happen as quickly as we can. +{ + # this just eases exit handling + while test $# -gt 0; do + opt="$1" + shift + case $opt in + --debug|-x) opt_debug='set -x' + func_echo "enabling shell trace mode" + $opt_debug + ;; + --dry-run|--dryrun|-n) + opt_dry_run=: + ;; + --config) + opt_config=: +func_config + ;; + --dlopen|-dlopen) + optarg="$1" + opt_dlopen="${opt_dlopen+$opt_dlopen +}$optarg" + shift + ;; + --preserve-dup-deps) + opt_preserve_dup_deps=: + ;; + --features) + opt_features=: +func_features + ;; + --finish) + opt_finish=: +set dummy --mode finish ${1+"$@"}; shift + ;; + --help) + opt_help=: + ;; + --help-all) + opt_help_all=: +opt_help=': help-all' + ;; + --mode) + test $# = 0 && func_missing_arg $opt && break + optarg="$1" + opt_mode="$optarg" +case $optarg in + # Valid mode arguments: + clean|compile|execute|finish|install|link|relink|uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $opt" + exit_cmd=exit + break + ;; +esac + shift + ;; + --no-silent|--no-quiet) + opt_silent=false +func_append preserve_args " $opt" + ;; + --no-warning|--no-warn) + opt_warning=false +func_append preserve_args " $opt" + ;; + --no-verbose) + opt_verbose=false +func_append preserve_args " $opt" + ;; + --silent|--quiet) + opt_silent=: +func_append preserve_args " $opt" + opt_verbose=false + ;; + --verbose|-v) + opt_verbose=: +func_append preserve_args " $opt" +opt_silent=false + ;; + --tag) + test $# = 0 && func_missing_arg $opt && break + optarg="$1" + opt_tag="$optarg" +func_append preserve_args " $opt $optarg" +func_enable_tag "$optarg" + shift + ;; + + -\?|-h) func_usage ;; + --help) func_help ;; + --version) func_version ;; + + # Separate optargs to long options: + --*=*) + func_split_long_opt "$opt" + set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} + shift + ;; + + # Separate non-argument short options: + -\?*|-h*|-n*|-v*) + func_split_short_opt "$opt" + set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + --) break ;; + -*) func_fatal_help "unrecognized option \`$opt'" ;; + *) set dummy "$opt" ${1+"$@"}; shift; break ;; + esac + done + + # Validate options: + + # save first non-option argument + if test "$#" -gt 0; then + nonopt="$opt" + shift + fi + + # preserve --debug + test "$opt_debug" = : || 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 + + if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + func_fatal_configuration "not configured to build any kind of library" + fi + + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$opt_dlopen" && test "$opt_mode" != execute; 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." + } + + + # Bail if the options were screwed + $exit_cmd $EXIT_FAILURE +} + + + + +## ----------- ## +## Main. ## +## ----------- ## + +# 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 "$lalib_p" = yes +} + +# 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 () +{ + $opt_debug + save_ifs=$IFS; IFS='~' + for cmd in $1; do + IFS=$save_ifs + eval cmd=\"$cmd\" + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 "$build_libtool_libs" = yes; then + write_lobj=\'${2}\' + else + write_lobj=none + fi + + if test "$build_old_libs" = yes; 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 "$lt_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 () +{ + $opt_debug + # 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + # awkward: cmd appends spaces to result + func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | + $SED -e 's/[ ]*$//' -e "$lt_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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + $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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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_mode_compile arg... +func_mode_compile () +{ + $opt_debug + # 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 "$build_libtool_libs" != yes && \ + func_fatal_configuration "can not 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 "$build_old_libs" = yes; 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 "$pic_mode" = no && test "$deplibs_check_method" != pass_all; 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 "$compiler_c_o" = no; 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 "$need_locks" = yes; 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 "$need_locks" = warn; 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 "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test "$pic_mode" != no; 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 "$need_locks" = warn && + 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 "$suppress_opt" = yes; then + suppress_output=' >/dev/null 2>&1' + fi + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + if test "$pic_mode" != yes; then + # Don't build PIC code + command="$base_compile $qsrcfile$pie_flag" + else + command="$base_compile $qsrcfile $pic_flag" + fi + if test "$compiler_c_o" = yes; 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 "$need_locks" = warn && + 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 "$need_locks" != no; then + removelist=$lockfile + $RM "$lockfile" + fi + } + + exit $EXIT_SUCCESS +} + +$opt_help || { + test "$opt_mode" = compile && 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 () +{ + $opt_debug + # 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 test "X$opt_dry_run" = Xfalse; then + 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" + else + # 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 + fi +} + +test "$opt_mode" = execute && func_mode_execute ${1+"$@"} + + +# func_mode_finish arg... +func_mode_finish () +{ + $opt_debug + 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_silent && 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 "$opt_mode" = finish && func_mode_finish ${1+"$@"} + + +# func_mode_install arg... +func_mode_install () +{ + $opt_debug + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # 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=no + 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=yes ;; + -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$prev" = x-m && 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=yes + if test "$isdir" = yes; 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 "$build_old_libs" = yes; 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=yes + 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'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + func_warning "\`$lib' has not been installed in \`$libdir'" + finalize=no + fi + done + + relink_command= + func_source "$wrapper" + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + $opt_dry_run || { + if test "$finalize" = yes; 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_silent || { + 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 "$opt_mode" = install && 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 () +{ + $opt_debug + my_outputname="$1" + my_originator="$2" + my_pic_p="${3-no}" + my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` + my_dlsyms= + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; 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$TIMESTAMP) $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 con'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 + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; 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 + + 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[]; +LT_DLSYM_CONST lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[] = +{\ + { \"$my_originator\", (void *) 0 }," + + 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" ;; + *) + if test "X$my_pic_p" != Xno; then + pic_flag_for_symtable=" $pic_flag" + fi + ;; + 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"' + + # 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_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 () +{ + $opt_debug + 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 + 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 + } + }'` + 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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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 which possess that section. Heuristic: eliminate + # all those which 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_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 () +{ + $opt_debug + 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 () +{ + $opt_debug + 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_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 () +{ + $opt_debug + 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 () +{ + $opt_debug + f_ex_an_ar_dir="$1"; shift + f_ex_an_ar_oldlib="$1" + if test "$lock_old_archive_extraction" = yes; 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 "$lock_old_archive_extraction" = yes; 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 () +{ + $opt_debug + 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` + darwin_base_archive=`basename "$darwin_archive"` + 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 in which 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$TIMESTAMP) $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/ which is used only on +# windows platforms, and (c) all begin with the string "--lt-" +# (application programs are unlikely to have options which 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$TIMESTAMP) $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 "$fast_install" = yes; 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 "$shlibpath_overrides_runpath" = yes && 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 + +/* 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 platforms) ... */ +#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 +# ifndef _INTPTR_T_DEFINED +# define _INTPTR_T_DEFINED +# define intptr_t int +# endif +#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 ((void *) 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]; + int 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 = 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 (strcmp (str, pat) == 0) + *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 + int 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) + { + int orig_value_len = strlen (orig_value); + int 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 #' */ + int len = strlen (new_value); + while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) + { + new_value[len-1] = '\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 () +{ + $opt_debug + case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in + *import*) : ;; + *) false ;; + esac +} + +# func_mode_link arg... +func_mode_link () +{ + $opt_debug + 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 + # which 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 which 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=no + 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 "$build_libtool_libs" != yes && \ + func_fatal_configuration "can not build a shared library" + build_old_libs=no + break + ;; + -all-static | -static | -static-libtool-libs) + case $arg in + -all-static) + if test "$build_libtool_libs" = yes && 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) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + func_append compile_command " @SYMFILE@" + func_append finalize_command " @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; 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 + ;; + 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 "$pic_object" = none && + test "$non_pic_object" = none; 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 "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; 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 "$prev" = dlprefiles; 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 "$non_pic_object" != none; 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 "$pic_object" = none ; 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 "$prev" = rpath; 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$arg" = "X-export-symbols"; 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$arg" = "X-lc" || test "X$arg" = "X-lm"; 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$arg" = "X-lc" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && 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$arg" = "X-lc" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test "X$arg" = "X-lc" && continue + ;; + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + func_append deplibs " $arg" + 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*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + -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*|-flto*|-fwhopr*|-fuse-linker-plugin) + 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 "$pic_object" = none && + test "$non_pic_object" = none; 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 "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; 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 "$prev" = dlprefiles; 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 "$non_pic_object" != none; 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 "$pic_object" = none ; 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 "$prev" = dlfiles; then + # This library was specified with -dlopen. + func_append dlfiles " $func_resolve_sysroot_result" + prev= + elif test "$prev" = dlprefiles; 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 "$export_dynamic" = yes && 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 "$linkmode" = lib; 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=no + 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 "$linkmode,$pass" = "lib,link"; 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 "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then + case $pass in + dlopen) libs="$dlfiles" ;; + dlpreopen) libs="$dlprefiles" ;; + link) + libs="$deplibs %DEPLIBS%" + test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" + ;; + esac + fi + if test "$linkmode,$pass" = "lib,dlpreopen"; 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 "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi + + for deplib in $libs; do + lib= + found=no + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + func_append compiler_flags " $deplib" + if test "$linkmode" = lib ; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) func_append new_inherited_linker_flags " $deplib" ;; + esac + fi + fi + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + func_warning "\`-l' is ignored for archives/objects" + continue + fi + func_stripname '-l' '' "$deplib" + name=$func_stripname_result + if test "$linkmode" = lib; 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 "$search_ext" = ".la"; then + found=yes + else + found=no + fi + break 2 + fi + done + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + else # 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 "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; 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=no + func_dirname "$lib" "" "." + ladir="$func_dirname_result" + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + fi + ;; # -l + *.ltframework) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + if test "$linkmode" = lib ; 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 "$pass" = conv && 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 "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test "$pass" = scan; 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 "$pass" = link; 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 "$pass" = conv; 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=no + 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=yes + fi + ;; + pass_all) + valid_a_lib=yes + ;; + esac + if test "$valid_a_lib" != yes; then + 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." + else + echo + $ECHO "*** Warning: Linking the shared library $output against the" + $ECHO "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + ;; + esac + continue + ;; + prog) + if test "$pass" != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; 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=yes + continue + ;; + esac # case $deplib + + if test "$found" = yes || test -f "$lib"; then : + else + func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" + fi + + # 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 "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test "$linkmode" != prog && test "$linkmode" != lib; }; then + test -n "$dlopen" && func_append dlfiles " $dlopen" + test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" + fi + + if test "$pass" = conv; 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" + 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 + elif test "$linkmode" != prog && test "$linkmode" != lib; then + func_fatal_error "\`$lib' is not a convenience library" + fi + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + if test -n "$old_library" && + { test "$prefer_static_libs" = yes || + test "$prefer_static_libs,$installed" = "built,no"; }; 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 "$pass" = dlopen; then + if test -z "$libdir"; then + func_fatal_error "cannot -dlopen a convenience library: \`$lib'" + fi + if test -z "$dlname" || + test "$dlopen_support" != yes || + test "$build_libtool_libs" = no; 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 "X$installed" = Xyes; 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 "X$hardcode_automatic" = Xyes && 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 "$pass" = dlpreopen; then + if test -z "$libdir" && test "$linkmode" = prog; 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 "$linkmode" = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; 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 "$linkmode" = prog && test "$pass" != link; then + func_append newlib_search_path " $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + 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 test "$linkalldeplibs" = yes; 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 "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { { test "$prefer_static_libs" = no || + test "$prefer_static_libs,$installed" = "built,yes"; } || + 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 test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + 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 "$use_static_libs" = built && test "$installed" = yes; then + use_static_libs=no + fi + if test -n "$library_names" && + { test "$use_static_libs" = no || 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 "$installed" = no; 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 "$shouldnotlink" = yes && test "$pass" = link; then + echo + if test "$linkmode" = prog; 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 "$linkmode" = lib && + test "$hardcode_into_libs" = yes; 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 "$linkmode" = prog || test "$opt_mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; 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 can not + # 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 "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes && + test "$hardcode_direct_absolute" = no; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; 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 "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; 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 "$linkmode" = prog; 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 "$hardcode_direct" != yes && + test "$hardcode_minus_L" != yes && + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) func_append finalize_shlibpath "$libdir:" ;; + esac + fi + fi + fi + + if test "$linkmode" = prog || test "$opt_mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes && + test "$hardcode_direct_absolute" = no; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) func_append finalize_shlibpath "$libdir:" ;; + esac + add="-l$name" + elif test "$hardcode_automatic" = yes; 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 "$linkmode" = prog; 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 "$linkmode" = prog; 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 "$hardcode_direct" != unsupported; 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 "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; 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 can not 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 "$module" = yes; 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 "$build_old_libs" = no; 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 "$linkmode" = lib; then + if test -n "$dependency_libs" && + { test "$hardcode_into_libs" != yes || + test "$build_old_libs" = yes || + test "$link_static" = yes; }; 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 "$link_static" = no && 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 "$link_all_deplibs" != no; 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 "$pass" = link; then + if test "$linkmode" = "prog"; 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 "$pass" = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test "$pass" != dlopen; then + if test "$pass" != conv; then + # 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= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_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 "$linkmode" = prog; then + dlfiles="$newdlfiles" + fi + if test "$linkmode" = prog || test "$linkmode" = lib; then + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; 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 "$module" = no && \ + func_fatal_help "libtool library \`$output' must begin with \`lib'" + + if test "$need_lib_prefix" != no; 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 "$deplibs_check_method" != pass_all; 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 "$dlself" != no && \ + func_warning "\`-dlopen self' is ignored for libtool libraries" + + set dummy $rpath + shift + test "$#" -gt 1 && \ + func_warning "ignoring multiple \`-rpath's for a libtool library" + + install_libdir="$1" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; 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 + # which 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 + ;; + *) + func_fatal_configuration "$modename: unknown library version type \`$version_type'" + ;; + 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" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current" + ;; + + irix | nonstopux) + if test "X$lt_irix_increment" = "Xno"; 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 "$loop" -ne 0; 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 "$loop" -ne 0; 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 filesystems. + 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 "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + func_warning "undefined symbols not allowed in $host shared libraries" + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + + fi + + func_generate_dlsyms "$libname" "$libname" "yes" + func_append libobjs " $symfileobj" + test "X$libobjs" = "X " && libobjs= + + if test "$opt_mode" != relink; 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 "X$precious_files_regex" != "X"; 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 "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; 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 "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; 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 "$build_libtool_libs" = yes; 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 "$build_libtool_need_lc" = "yes"; 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 "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; 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 "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; 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 "X$deplibs_check_method" = "Xnone"; 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 "$droppeddeps" = yes; then + if test "$module" = yes; 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 "$build_old_libs" = no; 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 "$allow_undefined" = no; 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 "$build_old_libs" = no; 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 "$build_libtool_libs" = yes; then + # Remove ${wl} instances when linking with ld. + # FIXME: should test the right _cmds variable. + case $archive_cmds in + *\$LD\ *) wl= ;; + esac + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$opt_mode" != relink && 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 "$opt_mode" != relink && 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 + if test "x`$SED 1q $export_symbols`" != xEXPORTS; then + # 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 + fi + ;; + esac + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || 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 "$try_normal_branch" = yes \ + && { 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 "X$skipped_export" != "X:"; 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 "X$skipped_export" != "X:" && 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 "$compiler_needs_object" = yes && + 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 "$thread_safe" = yes && 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 "$opt_mode" = relink; 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 "$module" = yes && 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 "X$skipped_export" != "X:" && + 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 "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; 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 "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then + output=${output_objdir}/${output_la}.lnk + func_verbose "creating linker input file list: $output" + : > $output + set x $save_libobjs + shift + firstobj= + if test "$compiler_needs_object" = yes; 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 "X$objlist" = X || + 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 "$k" -eq 1 ; 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 + + if ${skipped_export-false}; then + 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 + 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_silent || { + 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 "$opt_mode" = relink; 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 + + if ${skipped_export-false}; then + 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 + 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 "$module" = yes && 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="$save_ifs" + eval cmd=\"$cmd\" + $opt_silent || { + 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 "$opt_mode" = relink; 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 "$opt_mode" = relink; 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 "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; 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 "$build_libtool_libs" != yes && 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" ### testsuite: skip nested quoting test + + 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 + + if test "$build_libtool_libs" != yes; then + 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 + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; 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" + + test "$preload" = yes \ + && test "$dlopen_support" = unknown \ + && test "$dlopen_self" = unknown \ + && test "$dlopen_self_static" = unknown && \ + 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 "$tagname" = CXX ; 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 "$build_old_libs" = yes; 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@" "no" + + # template prelinking step + if test -n "$prelink_cmds"; then + func_execute_cmds "$prelink_cmds" 'exit $?' + fi + + wrappers_required=yes + case $host in + *cegcc* | *mingw32ce*) + # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. + wrappers_required=no + ;; + *cygwin* | *mingw* ) + if test "$build_libtool_libs" != yes; then + wrappers_required=no + fi + ;; + *) + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + wrappers_required=no + fi + ;; + esac + if test "$wrappers_required" = no; then + # 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 + fi + + 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 "$no_install" = yes; 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 + + if test "$hardcode_action" = relink; then + # 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" + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # 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 + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save $symfileobj" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$old_deplibs $non_pic_objects" + if test "$preload" = yes && test -f "$symfileobj"; then + func_append oldobjs " $symfileobj" + fi + fi + addlibs="$old_convenience" + fi + + 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 "$build_libtool_libs" = yes; 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 "X$oldobjs" = "X" ; 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 "$build_old_libs" = yes && 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 "$hardcode_automatic" = yes ; then + relink_command= + fi + + # Only create the output if not a dry run. + $opt_dry_run || { + for installed in no yes; do + if test "$installed" = yes; 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 "x$bindir" != x ; + 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$TIMESTAMP) $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 can not 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 "$installed" = no && test "$need_relink" = yes; 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 +} + +{ test "$opt_mode" = link || test "$opt_mode" = relink; } && + func_mode_link ${1+"$@"} + + +# func_mode_uninstall arg... +func_mode_uninstall () +{ + $opt_debug + RM="$nonopt" + files= + rmforce= + 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=yes ;; + -*) 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 "X$dir" = X.; then + odir="$objdir" + else + odir="$dir/$objdir" + fi + func_basename "$file" + name="$func_basename_result" + test "$opt_mode" = uninstall && odir="$dir" + + # Remember odir for removal later, being careful to avoid duplicates + if test "$opt_mode" = clean; 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 test "$rmforce" = yes; 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" 'test "$rmforce" = yes || exit_status=1' + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || 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 "$pic_object" != none; 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 "$non_pic_object" != none; then + func_append rmfiles " $dir/$non_pic_object" + fi + fi + ;; + + *) + if test "$opt_mode" = clean ; 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 "$fast_install" = yes && 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 +} + +{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && + func_mode_uninstall ${1+"$@"} + +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 +# in which 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: +# vi:sw=2 + diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 2016-11-03 20:21:16.000000000 +0000 @@ -0,0 +1,8 @@ +dnl Act as a single handler point for libmspack options +dnl Assigns system_libmspack variable + +dnl Determine whether to use the internal libmspack or to use system-specified libmspack +AC_ARG_WITH([system-libmspack], AC_HELP_STRING([--with-system-libmspack], +[Specify system libmspack location or to use internal package, uses full path to libmspack or bin directory + (default=search PATH environment variable)]), +[system_libmspack=$withval], [system_libmspack="no"]) diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/libtool.m4 clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/libtool.m4 --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/libtool.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/libtool.m4 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,7997 @@ +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# 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 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. + +m4_define([_LT_COPYING], [dnl +# 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. +]) + +# serial 57 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT +AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_CC_BASENAME(CC) +# ------------------- +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +m4_defun([_LT_CC_BASENAME], +[for cc_temp in $1""; 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-%%"` +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl + +_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_WITH_SYSROOT])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl + +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 "X${COLLECT_NAMES+set}" != Xset; 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 + +_LT_CC_BASENAME([$compiler]) + +# 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 + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PREPARE_SED_QUOTE_VARS +# -------------------------- +# Define a few sed substitution that help us do robust quoting. +m4_defun([_LT_PREPARE_SED_QUOTE_VARS], +[# 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' +]) + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from `configure', and `config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# `config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain="$ac_aux_dir/ltmain.sh" +])# _LT_PROG_LTMAIN + + +## ------------------------------------- ## +## Accumulate code for creating libtool. ## +## ------------------------------------- ## + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the `libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + +## ------------------------ ## +## FIXME: Eliminate VARNAME ## +## ------------------------ ## + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[m4_assert([$# <= 2])dnl +_$0(m4_quote(m4_default([$1], [[, ]])), + m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), + m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) +m4_define([_lt_decl_varnames_tagged], +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to `config.status' so that its +# declaration there will have the same value as in `configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags="_LT_TAGS"dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into `config.status', and then the shell code to quote escape them in +# for loops in `config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# 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' +_LT_CONFIG_STATUS_DECLARATIONS +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 lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +_LT_OUTPUT_LIBTOOL_INIT +]) + +# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) +# ------------------------------------ +# Generate a child script FILE with all initialization necessary to +# reuse the environment learned by the parent script, and make the +# file executable. If COMMENT is supplied, it is inserted after the +# `#!' sequence but before initialization text begins. After this +# macro, additional text can be appended to FILE to form the body of +# the child script. The macro ends with non-zero status if the +# file could not be fully written (such as if the disk is full). +m4_ifdef([AS_INIT_GENERATED], +[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], +[m4_defun([_LT_GENERATED_FILE_INIT], +[m4_require([AS_PREPARE])]dnl +[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl +[lt_write_fail=0 +cat >$1 <<_ASEOF || lt_write_fail=1 +#! $SHELL +# Generated by $as_me. +$2 +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$1 <<\_ASEOF || lt_write_fail=1 +AS_SHELL_SANITIZE +_AS_PREPARE +exec AS_MESSAGE_FD>&1 +_ASEOF +test $lt_write_fail = 0 && chmod +x $1[]dnl +m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], +[# Run this file to recreate a libtool stub with the current configuration.]) + +cat >>"$CONFIG_LT" <<\_LTEOF +lt_cl_silent=false +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +\`$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2011 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test $[#] != 0 +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try \`$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try \`$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +lt_cl_success=: +test "$silent" = yes && + lt_config_lt_args="$lt_config_lt_args --quiet" +exec AS_MESSAGE_LOG_FD>/dev/null +$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false +exec AS_MESSAGE_LOG_FD>>config.log +$lt_cl_success || AS_EXIT(1) +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options which 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$TIMESTAMP) $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. +# +_LT_COPYING +_LT_LIBTOOL_TAGS + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### 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 "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # 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) + + _LT_PROG_REPLACE_SHELLFNS + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Go], [_LT_LANG(GO)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +m4_ifndef([AC_PROG_GO], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) +dnl AC_DEFUN([AC_LIBTOOL_RC], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# 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 +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +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* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +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* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [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" >&AS_MESSAGE_LOG_FD + $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 >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + + AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], + [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" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD + echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD + $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD + $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 >&AS_MESSAGE_LOG_FD + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + ]) + 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 "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; 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 "$lt_cv_ld_force_load" = "no"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES([TAG]) +# --------------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + if test "$lt_cv_ld_force_load" = "yes"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + case $cc_basename in + ifort*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; then + output_verbose_link_cmd=func_echo_all + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="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}" + _LT_TAGVAR(module_expsym_cmds, $1)="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}" + m4_if([$1], [CXX], +[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_TAGVAR(archive_cmds, $1)="\$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}" + _LT_TAGVAR(archive_expsym_cmds, $1)="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 + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) +# ---------------------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +# Store the results from the different compilers for each TAGNAME. +# Allow to override them for all tags through lt_cv_aix_libpath. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +if test "${lt_cv_aix_libpath+set}" = set; then + aix_libpath=$lt_cv_aix_libpath +else + AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], + [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ + lt_aix_libpath_sed='[ + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }]' + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`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_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi],[]) + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" + fi + ]) + aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) +fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[m4_divert_text([M4SH-INIT], [$1 +])])# _LT_SHELL_INIT + + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Find how we can fake an echo command that does not interpret backslash. +# In particular, with Autoconf 2.60 or later we add some code to the start +# of the generated configure script which will find a shell with a builtin +# printf (which we can use as an echo command). +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +AC_MSG_CHECKING([how to print strings]) +# 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*) AC_MSG_RESULT([printf]) ;; + print*) AC_MSG_RESULT([print -r]) ;; + *) AC_MSG_RESULT([cat]) ;; +esac + +m4_ifdef([_AS_DETECT_SUGGESTED], +[_AS_DETECT_SUGGESTED([ + 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" )])]) + +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_WITH_SYSROOT +# ---------------- +AC_DEFUN([_LT_WITH_SYSROOT], +[AC_MSG_CHECKING([for sysroot]) +AC_ARG_WITH([sysroot], +[ --with-sysroot[=DIR] Search for dependent libraries within DIR + (or the compiler's sysroot if not specified).], +[], [with_sysroot=no]) + +dnl lt_sysroot will always be passed unquoted. We quote it here +dnl in case the user passed a directory name. +lt_sysroot= +case ${with_sysroot} in #( + yes) + if test "$GCC" = yes; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + AC_MSG_RESULT([${with_sysroot}]) + AC_MSG_ERROR([The sysroot must be an absolute path.]) + ;; +esac + + AC_MSG_RESULT([${lt_sysroot:-no}]) +_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl +[dependent libraries, and in which our libraries should be installed.])]) + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && 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 which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); 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 which ABI we are using. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; 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* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); 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-*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*) + 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-*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*) + 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" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-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" +])# _LT_ENABLE_LOCK + + +# _LT_PROG_AR +# ----------- +m4_defun([_LT_PROG_AR], +[AC_CHECK_TOOLS(AR, [ar], false) +: ${AR=ar} +: ${AR_FLAGS=cru} +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) + +AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], + [lt_cv_ar_at_file=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM], + [echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([lt_ar_try]) + if test "$ac_status" -eq 0; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + AC_TRY_EVAL([lt_ar_try]) + if test "$ac_status" -ne 0; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + ]) + ]) + +if test "x$lt_cv_ar_at_file" = xno; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi +_LT_DECL([], [archiver_list_spec], [1], + [How to feed a file listing to the archiver]) +])# _LT_PROG_AR + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[_LT_PROG_AR + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# 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 + 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 +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +_LT_DECL([], [lock_old_archive_extraction], [0], + [Whether to use a lock for old archive extraction]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # 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\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + 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 + $2=yes + fi + fi + $RM conftest* +]) + +if test x"[$]$2" = xyes; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + 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>&AS_MESSAGE_LOG_FD + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + 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; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # 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 $i != 17 # 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 +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +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 AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "x$enable_dlopen" != xyes; 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 + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && 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" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + 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 +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=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\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + 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_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $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* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links="nottested" +if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + 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 + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[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]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", + [Define to the sub-directory in which libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && + # 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 "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || + test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +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" + AC_MSG_RESULT([yes]) +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" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_OBJDUMP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test "$GCC" = yes; 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 2>/dev/null` + 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" + else + 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 "$host_cpu" = ia64; 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 can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; 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%'\''`; test $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}' +m4_if([$1], [],[ + 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`' +m4_if([$1], [],[ + 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=yes + 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 "X$HPUX_IA64_MODE" = X32; 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 "$lt_cv_prog_gnu_ld" = yes; 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 + ;; + +# 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 + AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], + [lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [lt_cv_shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + ]) + 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' + ;; + +netbsdelf*-gnu) + version_type=linux + 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='NetBSD ld.elf_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*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + 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 + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +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 "$with_gnu_ld" = yes; 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 "$with_gnu_ld" = yes; 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 +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[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]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [install_override_mode], [1], + [Permission mode override for installation of shared libraries]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], + [Run-time system search path for libraries]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program which can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[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 +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + 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]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program which can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PROG_ECHO_BACKSLASH])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + 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 + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[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 &1 /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* | netbsdelf*-gnu) + 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*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; 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 +]) + +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 + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method = "file_magic"]) +_LT_DECL([], [file_magic_glob], [1], + [How to find potential files when deplibs_check_method = "file_magic"]) +_LT_DECL([], [want_nocaseglob], [1], + [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[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 + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + 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]) +if test "$lt_cv_path_NM" != "no"; 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 + AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) + case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols" + ;; + *) + DUMPBIN=: + ;; + esac + fi + AC_SUBST([DUMPBIN]) + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + +# _LT_CHECK_SHAREDLIB_FROM_LINKLIB +# -------------------------------- +# how to determine the name of the shared library +# associated with a specific link library. +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +m4_require([_LT_DECL_DLLTOOL]) +AC_CACHE_CHECK([how to associate runtime and link libraries], +lt_cv_sharedlib_from_linklib_cmd, +[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 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 +]) +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + +_LT_DECL([], [sharedlib_from_linklib_cmd], [1], + [Command to associate shared and link libraries]) +])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB + + +# _LT_PATH_MANIFEST_TOOL +# ---------------------- +# locate the manifest tool +m4_defun([_LT_PATH_MANIFEST_TOOL], +[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], + [lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&AS_MESSAGE_LOG_FD + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest*]) +if test "x$lt_cv_path_mainfest_tool" != xyes; then + MANIFEST_TOOL=: +fi +_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl +])# _LT_PATH_MANIFEST_TOOL + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + case $cc_basename in + nvcc*) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; + *) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; + esac + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# 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 "$host_cpu" = ia64; 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 + +# 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 -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$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 -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/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 + # and D for any global 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};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print 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 AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && 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 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT@&t@_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT@&t@_DLSYM_CONST +#else +# define LT@&t@_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@&t@_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$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_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && 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" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +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 + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +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 + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +_LT_DECL([], [nm_file_list_spec], [1], + [Specify filename containing input files for $NM]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-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_TAGVAR(lt_prog_compiler_pic, $1)='-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 + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + 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_TAGVAR(lt_prog_compiler_pic, $1)=-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_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--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). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+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_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-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_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64 which still supported -KPIC. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-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_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) + # IBM XL 8.0, 9.0 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd* | netbsdelf*-gnu) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-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_TAGVAR(lt_prog_compiler_pic, $1)='-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 + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + + 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_TAGVAR(lt_prog_compiler_pic, $1)='-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_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + 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). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-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_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + # old Intel for x86_64 which still supported -KPIC. + ecc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' + _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' + ;; + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-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_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + *Sun\ F* | *Sun*Fortran*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac + +AC_CACHE_CHECK([for $compiler option to produce PIC], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['_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 + _LT_TAGVAR(export_symbols_cmds, $1)='$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 + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw* | cegcc*) + case $cc_basename in + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + ;; + esac + ;; + linux* | k*bsd*-gnu | gnu*) + _LT_TAGVAR(link_all_deplibs, $1)=no + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # 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'. + _LT_TAGVAR(exclude_expsyms, $1)=['_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. +dnl Note also adjust exclude_expsyms for C++ above. + 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 "$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 + ;; + linux* | k*bsd*-gnu | gnu*) + _LT_TAGVAR(link_all_deplibs, $1)=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=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 "$with_gnu_ld" = yes; 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 "$lt_use_gnu_ld_interface" = yes; 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 + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${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 + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v 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 "$host_cpu" != ia64; then + _LT_TAGVAR(ld_shlibs, $1)=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 + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$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)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+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 + _LT_TAGVAR(archive_cmds, $1)='$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 (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; 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 + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${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. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='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 "$host_os" = linux-dietlibc; 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 "$tmp_diet" = no + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='${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 + _LT_TAGVAR(whole_archive_flag_spec, $1)='${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 + _LT_TAGVAR(whole_archive_flag_spec, $1)= + tmp_sharedflag='--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 + _LT_TAGVAR(whole_archive_flag_spec, $1)='${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' + _LT_TAGVAR(compiler_needs_object, $1)=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='${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' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='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 + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='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 + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$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 + _LT_TAGVAR(ld_shlibs, $1)=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 + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** 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 + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$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. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=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 + 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 + _LT_TAGVAR(export_symbols_cmds, $1)='$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 + _LT_TAGVAR(export_symbols_cmds, $1)='$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 $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); 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. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GCC" = yes; 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 + _LT_TAGVAR(hardcode_direct, $1)=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 + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + _LT_TAGVAR(link_all_deplibs, $1)=no + else + # not using gcc + if test "$host_cpu" = ia64; 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 "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${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. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$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. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${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. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + if test "$with_gnu_ld" = yes; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$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 + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$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)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-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 + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # 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. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; + else + sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $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, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='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 + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=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. + _LT_TAGVAR(archive_cmds, $1)='$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. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + esac + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=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*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes && test "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$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*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + m4_if($1, [], [ + # 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) + _LT_LINKER_OPTION([if $CC understands -b], + _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], + [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) + ;; + esac + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$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. + AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], + [lt_cv_irix_exported_symbol], + [save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], + [C++], [[int foo (void) { return 0; }]], + [Fortran 77], [[ + subroutine foo + end]], + [Fortran], [[ + subroutine foo + end]])])], + [lt_cv_irix_exported_symbol=yes], + [lt_cv_irix_exported_symbol=no]) + LDFLAGS="$save_LDFLAGS"]) + if test "$lt_cv_irix_exported_symbol" = yes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$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 + _LT_TAGVAR(archive_cmds, $1)='$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' + _LT_TAGVAR(archive_expsym_cmds, $1)='$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 + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(archive_cmds, $1)='$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' + _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$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 + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$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 + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$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' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$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' + _LT_TAGVAR(archive_expsym_cmds, $1)='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 + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='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='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='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}' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='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 + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=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 "$GCC" = yes; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT 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. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_TAGVAR(archive_cmds, $1) 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. + AC_CACHE_CHECK([whether -lc should be explicitly linked in], + [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), + [$RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + ]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [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]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [postlink_cmds], [2], + [Commands necessary for finishing linking programs]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$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);}' + +_LT_TAG_COMPILER +# 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 +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +## 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_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report which library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && 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 "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC="$lt_save_CC" +])# _LT_LANG_C_CONFIG + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$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 "$_lt_caught_CXX_error" != yes; 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. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # 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 + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + LT_PATH_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 "$with_gnu_ld" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$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' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${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 + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + 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. + _LT_TAGVAR(archive_cmds, $1)='$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 + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + 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 + 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. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GXX" = yes; 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 + _LT_TAGVAR(hardcode_direct, $1)=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 + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; 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 "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${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. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$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. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${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. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + if test "$with_gnu_ld" = yes; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared + # libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$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 + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=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. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # 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. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; + else + $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $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, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='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, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$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 (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; 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 + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd2.*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=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 + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $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 "$GXX" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$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 $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=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 + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$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 "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$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 + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${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. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='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++ + _LT_TAGVAR(archive_cmds, $1)='$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. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$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 + _LT_TAGVAR(archive_cmds, $1)='$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 + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=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. + _LT_TAGVAR(archive_cmds, $1)='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' + _LT_TAGVAR(archive_expsym_cmds, $1)='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"' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$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."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$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 + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) + _LT_TAGVAR(prelink_cmds, $1)='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`"' + _LT_TAGVAR(old_archive_cmds, $1)='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' + _LT_TAGVAR(archive_cmds, $1)='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' + _LT_TAGVAR(archive_expsym_cmds, $1)='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 + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$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 + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${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++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$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 + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # 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 + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='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 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${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' + _LT_TAGVAR(compiler_needs_object, $1)=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. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=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*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd2*) + # C++ shared libraries are fairly broken + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd=func_echo_all + else + _LT_TAGVAR(ld_shlibs, $1)=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. + _LT_TAGVAR(archive_cmds, $1)='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' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$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' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$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' + _LT_TAGVAR(archive_expsym_cmds, $1)='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' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # 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 "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$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' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$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 + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # 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 + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='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' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=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?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=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. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$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. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='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 -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. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='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 -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 + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT 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. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ + '"$_LT_TAGVAR(old_archive_cmds, $1)" + _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ + '"$_LT_TAGVAR(reload_cmds, $1)" + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$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 + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + + _LT_TAGVAR(GCC, $1)="$GXX" + _LT_TAGVAR(LD, $1)="$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... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + 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 "$_lt_caught_CXX_error" != yes + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_FUNC_STRIPNAME_CNF +# ---------------------- +# func_stripname_cnf prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# 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). +# +# This function is identical to the (non-XSI) version of func_stripname, +# except this one can be used by m4 code that may be executed by configure, +# rather than the libtool script. +m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl +AC_REQUIRE([_LT_DECL_SED]) +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) +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 +])# _LT_FUNC_STRIPNAME_CNF + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_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 + +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); 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 $p = "-L" || + test $p = "-R"; 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 "$pre_test_object_deps_done" = no; 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 "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${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 "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)="${prev}${p}" + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${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 "$pre_test_object_deps_done" = no; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)="$p" + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)="$p" + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext +CFLAGS=$_lt_libdeps_save_CFLAGS + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[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. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; + +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 "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-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 "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_LANG_PUSH(Fortran 77) +if test -z "$F77" || test "X$F77" = "Xno"; then + _lt_disable_F77=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 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 "$_lt_disable_F77" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${F77-"f77"} + CFLAGS=$FFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && 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 "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$G77" + _LT_TAGVAR(LD, $1)="$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... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" + CFLAGS="$lt_save_CFLAGS" +fi # test "$_lt_disable_F77" != yes + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_LANG_PUSH(Fortran) + +if test -z "$FC" || test "X$FC" = "Xno"; then + _lt_disable_FC=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC 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 "$_lt_disable_FC" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${FC-"f95"} + CFLAGS=$FCFLAGS + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && 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 "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" + _LT_TAGVAR(LD, $1)="$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... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test "$_lt_disable_FC" != yes + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +CFLAGS=$GCJFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## 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_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# Go did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## 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_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GO_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +CFLAGS= +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_OBJDUMP +# -------------- +# If we don't have a new enough Autoconf to choose the best objdump +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_OBJDUMP], +[AC_CHECK_TOOL(OBJDUMP, objdump, false) +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) +AC_SUBST([OBJDUMP]) +]) + +# _LT_DECL_DLLTOOL +# ---------------- +# Ensure DLLTOOL variable is set. +m4_defun([_LT_DECL_DLLTOOL], +[AC_CHECK_TOOL(DLLTOOL, dlltool, false) +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) +AC_SUBST([DLLTOOL]) +]) + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,b/c, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +AC_MSG_RESULT([$xsi_shell]) +_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) + +AC_MSG_CHECKING([whether the shell understands "+="]) +lt_shell_append=no +( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +AC_MSG_RESULT([$lt_shell_append]) +_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# 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 +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) +# ------------------------------------------------------ +# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and +# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. +m4_defun([_LT_PROG_FUNCTION_REPLACE], +[dnl { +sed -e '/^$1 ()$/,/^} # $1 /c\ +$1 ()\ +{\ +m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) +} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: +]) + + +# _LT_PROG_REPLACE_SHELLFNS +# ------------------------- +# Replace existing portable implementations of several shell functions with +# equivalent extended shell implementations where those features are available.. +m4_defun([_LT_PROG_REPLACE_SHELLFNS], +[if test x"$xsi_shell" = xyes; then + _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac]) + + _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl + func_basename_result="${1##*/}"]) + + _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}"]) + + _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"}]) + + _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl + func_split_long_opt_name=${1%%=*} + func_split_long_opt_arg=${1#*=}]) + + _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl + func_split_short_opt_arg=${1#??} + func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) + + _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac]) + + _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) + + _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) + + _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) +fi + +if test x"$lt_shell_append" = xyes; then + _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) + + _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl + func_quote_for_eval "${2}" +dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ + eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) + + # Save a `func_append' function call where possible by direct use of '+=' + sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +else + # Save a `func_append' function call even when '+=' is not available + sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +fi + +if test x"$_lt_function_replace_fail" = x":"; then + AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) +fi +]) + +# _LT_PATH_CONVERSION_FUNCTIONS +# ----------------------------- +# Determine which file name conversion functions should be used by +# func_to_host_file (and, implicitly, by func_to_host_path). These are needed +# for certain cross-compile configurations and native mingw. +m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_MSG_CHECKING([how to convert $build file names to $host format]) +AC_CACHE_VAL(lt_cv_to_host_file_cmd, +[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 +]) +to_host_file_cmd=$lt_cv_to_host_file_cmd +AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) +_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], + [0], [convert $build file names to $host format])dnl + +AC_MSG_CHECKING([how to convert $build file names to toolchain format]) +AC_CACHE_VAL(lt_cv_to_tool_file_cmd, +[#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 +]) +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) +_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], + [0], [convert $build files to toolchain format])dnl +])# _LT_PATH_CONVERSION_FUNCTIONS diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/lt~obsolete.m4 clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/lt~obsolete.m4 --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/lt~obsolete.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/lt~obsolete.m4 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,98 @@ +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# 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. + +# serial 5 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) +m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) +m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) +m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) +m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) +m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) +m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/ltoptions.m4 clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/ltoptions.m4 --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/ltoptions.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/ltoptions.m4 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,384 @@ +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# Written by Gary V. Vaughan, 2004 +# +# 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. + +# serial 7 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option `$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl `shared' nor `disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + ]) +])# _LT_SET_OPTIONS + + +## --------------------------------- ## +## Macros to handle LT_INIT options. ## +## --------------------------------- ## + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [1], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the `shared' and +# `disable-shared' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [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], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the `static' and +# `disable-static' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [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], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the `fast-install' +# and `disable-fast-install' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [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], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the `pic-only' and `no-pic' +# LT_INIT options. +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [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], + [pic_mode=default]) + +test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + +## ----------------- ## +## LTDL_INIT Options ## +## ----------------- ## + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/ltsugar.m4 clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/ltsugar.m4 --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/ltsugar.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/ltsugar.m4 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,123 @@ +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# 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. + +# serial 6 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59 which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +# Needed until we can rely on m4_combine added in Autoconf 2.62. +m4_define([lt_combine], +[m4_if(m4_eval([$# > 3]), [1], + [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl +[[m4_foreach([_Lt_prefix], [$2], + [m4_foreach([_Lt_suffix], + ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, + [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/ltversion.m4 clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/ltversion.m4 --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/m4/ltversion.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/m4/ltversion.m4 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,23 @@ +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# 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. + +# @configure_input@ + +# serial 3337 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.4.2]) +m4_define([LT_PACKAGE_REVISION], [1.3337]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.4.2' +macro_revision='1.3337' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/Makefile.am clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/Makefile.am --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/Makefile.am 2016-10-18 15:26:35.000000000 +0000 @@ -0,0 +1,56 @@ +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libmspack.pc + +dist-hook: + -rm -f $(distdir)/*.la + +ACLOCAL_AMFLAGS = -I m4 +AM_CFLAGS = +# add "-DMSPACK_NO_DEFAULT_SYSTEM" to remove default mspack_system +if DEBUG +AM_CFLAGS += -DDEBUG +endif +if GCC +AM_CFLAGS += -Wall -Wextra -Wno-unused-parameter +endif +AM_CPPFLAGS = -I$(top_srcdir)/mspack #-I$(top_srcdir)/test + +lib_LTLIBRARIES = libmspack.la +include_HEADERS = mspack/mspack.h + +noinst_LTLIBRARIES = libmscabd.la libmschmd.la + +libmspack_la_SOURCES = mspack/mspack.h \ + mspack/system.h mspack/system.c \ + mspack/cab.h mspack/cabc.c mspack/cabd.c \ + mspack/chm.h mspack/chmc.c mspack/chmd.c \ + mspack/hlp.h mspack/hlpc.c mspack/hlpd.c \ + mspack/lit.h mspack/litc.c mspack/litd.c \ + mspack/kwaj.h mspack/kwajc.c mspack/kwajd.c \ + mspack/szdd.h mspack/szddc.c mspack/szddd.c \ + mspack/oab.h mspack/oabc.c mspack/oabd.c \ + mspack/lzx.h mspack/lzxc.c mspack/lzxd.c \ + mspack/mszip.h mspack/mszipc.c mspack/mszipd.c \ + mspack/qtm.h mspack/qtmd.c \ + mspack/readbits.h mspack/readhuff.h \ + mspack/lzss.h mspack/lzssd.c \ + mspack/des.h mspack/sha.h \ + mspack/crc32.c mspack/crc32.h +libmspack_la_LDFLAGS = -export-symbols-regex '^mspack_' -version-info 1:0:1 + +libmscabd_la_SOURCES = mspack/mspack.h \ + mspack/system.h mspack/system.c \ + mspack/cab.h mspack/cabd.c \ + mspack/lzx.h mspack/lzxd.c \ + mspack/mszip.h mspack/mszipd.c \ + mspack/qtm.h mspack/qtmd.c \ + mspack/readbits.h mspack/readhuff.h +libmscabd_la_LDFLAGS = -export-symbols-regex '^mspack_' + +libmschmd_la_SOURCES = mspack/mspack.h \ + mspack/system.h mspack/system.c \ + mspack/chm.h mspack/chmd.c \ + mspack/lzx.h mspack/lzxd.c \ + mspack/readbits.h mspack/readhuff.h +libmschmd_la_LDFLAGS = -export-symbols-regex '^mspack_' + diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/Makefile.in clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/Makefile.in --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/Makefile.in 2017-01-13 18:14:04.000000000 +0000 @@ -0,0 +1,1134 @@ +# 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@ +pkglibexecdir = $(libexecdir)/@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@ +# add "-DMSPACK_NO_DEFAULT_SYSTEM" to remove default mspack_system +@DEBUG_TRUE@am__append_1 = -DDEBUG +@GCC_TRUE@am__append_2 = -Wall -Wextra -Wno-unused-parameter +subdir = . +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/configure $(am__configure_deps) \ + $(srcdir)/config.h.in $(srcdir)/libmspack.pc.in depcomp \ + $(include_HEADERS) AUTHORS COPYING.LIB ChangeLog INSTALL NEWS \ + README TODO compile config.guess config.sub install-sh missing \ + ltmain.sh +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = libmspack.pc +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \ + "$(DESTDIR)$(includedir)" +LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) +libmscabd_la_LIBADD = +am_libmscabd_la_OBJECTS = system.lo cabd.lo lzxd.lo mszipd.lo qtmd.lo +libmscabd_la_OBJECTS = $(am_libmscabd_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 = +libmscabd_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libmscabd_la_LDFLAGS) $(LDFLAGS) -o $@ +libmschmd_la_LIBADD = +am_libmschmd_la_OBJECTS = system.lo chmd.lo lzxd.lo +libmschmd_la_OBJECTS = $(am_libmschmd_la_OBJECTS) +libmschmd_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libmschmd_la_LDFLAGS) $(LDFLAGS) -o $@ +libmspack_la_LIBADD = +am_libmspack_la_OBJECTS = system.lo cabc.lo cabd.lo chmc.lo chmd.lo \ + hlpc.lo hlpd.lo litc.lo litd.lo kwajc.lo kwajd.lo szddc.lo \ + szddd.lo oabc.lo oabd.lo lzxc.lo lzxd.lo mszipc.lo mszipd.lo \ + qtmd.lo lzssd.lo crc32.lo +libmspack_la_OBJECTS = $(am_libmspack_la_OBJECTS) +libmspack_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libmspack_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)/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 = $(libmscabd_la_SOURCES) $(libmschmd_la_SOURCES) \ + $(libmspack_la_SOURCES) +DIST_SOURCES = $(libmscabd_la_SOURCES) $(libmschmd_la_SOURCES) \ + $(libmspack_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +DATA = $(pkgconfig_DATA) +HEADERS = $(include_HEADERS) +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 +CSCOPE = cscope +AM_RECURSIVE_TARGETS = cscope +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + if test -d "$(distdir)"; then \ + find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -rf "$(distdir)" \ + || { sleep 5 && rm -rf "$(distdir)"; }; \ + else :; fi +am__post_remove_distdir = $(am__remove_distdir) +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +DIST_TARGETS = dist-gzip +distuninstallcheck_listfiles = find . -type f -print +am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ + | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +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@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +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@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +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_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@ +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@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +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@ +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libmspack.pc +ACLOCAL_AMFLAGS = -I m4 +AM_CFLAGS = $(am__append_1) $(am__append_2) +AM_CPPFLAGS = -I$(top_srcdir)/mspack #-I$(top_srcdir)/test +lib_LTLIBRARIES = libmspack.la +include_HEADERS = mspack/mspack.h +noinst_LTLIBRARIES = libmscabd.la libmschmd.la +libmspack_la_SOURCES = mspack/mspack.h \ + mspack/system.h mspack/system.c \ + mspack/cab.h mspack/cabc.c mspack/cabd.c \ + mspack/chm.h mspack/chmc.c mspack/chmd.c \ + mspack/hlp.h mspack/hlpc.c mspack/hlpd.c \ + mspack/lit.h mspack/litc.c mspack/litd.c \ + mspack/kwaj.h mspack/kwajc.c mspack/kwajd.c \ + mspack/szdd.h mspack/szddc.c mspack/szddd.c \ + mspack/oab.h mspack/oabc.c mspack/oabd.c \ + mspack/lzx.h mspack/lzxc.c mspack/lzxd.c \ + mspack/mszip.h mspack/mszipc.c mspack/mszipd.c \ + mspack/qtm.h mspack/qtmd.c \ + mspack/readbits.h mspack/readhuff.h \ + mspack/lzss.h mspack/lzssd.c \ + mspack/des.h mspack/sha.h \ + mspack/crc32.c mspack/crc32.h + +libmspack_la_LDFLAGS = -export-symbols-regex '^mspack_' -version-info 1:0:1 +libmscabd_la_SOURCES = mspack/mspack.h \ + mspack/system.h mspack/system.c \ + mspack/cab.h mspack/cabd.c \ + mspack/lzx.h mspack/lzxd.c \ + mspack/mszip.h mspack/mszipd.c \ + mspack/qtm.h mspack/qtmd.c \ + mspack/readbits.h mspack/readhuff.h + +libmscabd_la_LDFLAGS = -export-symbols-regex '^mspack_' +libmschmd_la_SOURCES = mspack/mspack.h \ + mspack/system.h mspack/system.c \ + mspack/chm.h mspack/chmd.c \ + mspack/lzx.h mspack/lzxd.c \ + mspack/readbits.h mspack/readhuff.h + +libmschmd_la_LDFLAGS = -export-symbols-regex '^mspack_' +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(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 config.h +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +libmspack.pc: $(top_builddir)/config.status $(srcdir)/libmspack.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $@ + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_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}; \ + } + +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}; \ + } + +libmscabd.la: $(libmscabd_la_OBJECTS) $(libmscabd_la_DEPENDENCIES) $(EXTRA_libmscabd_la_DEPENDENCIES) + $(AM_V_CCLD)$(libmscabd_la_LINK) $(libmscabd_la_OBJECTS) $(libmscabd_la_LIBADD) $(LIBS) + +libmschmd.la: $(libmschmd_la_OBJECTS) $(libmschmd_la_DEPENDENCIES) $(EXTRA_libmschmd_la_DEPENDENCIES) + $(AM_V_CCLD)$(libmschmd_la_LINK) $(libmschmd_la_OBJECTS) $(libmschmd_la_LIBADD) $(LIBS) + +libmspack.la: $(libmspack_la_OBJECTS) $(libmspack_la_DEPENDENCIES) $(EXTRA_libmspack_la_DEPENDENCIES) + $(AM_V_CCLD)$(libmspack_la_LINK) -rpath $(libdir) $(libmspack_la_OBJECTS) $(libmspack_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cabc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cabd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chmc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chmd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crc32.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hlpc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hlpd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kwajc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kwajd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/litc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/litd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzssd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzxc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzxd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mszipc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mszipd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oabc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oabd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtmd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/system.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/szddc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/szddd.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 $@ $< + +system.lo: mspack/system.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT system.lo -MD -MP -MF $(DEPDIR)/system.Tpo -c -o system.lo `test -f 'mspack/system.c' || echo '$(srcdir)/'`mspack/system.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/system.Tpo $(DEPDIR)/system.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/system.c' object='system.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o system.lo `test -f 'mspack/system.c' || echo '$(srcdir)/'`mspack/system.c + +cabd.lo: mspack/cabd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cabd.lo -MD -MP -MF $(DEPDIR)/cabd.Tpo -c -o cabd.lo `test -f 'mspack/cabd.c' || echo '$(srcdir)/'`mspack/cabd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cabd.Tpo $(DEPDIR)/cabd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/cabd.c' object='cabd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cabd.lo `test -f 'mspack/cabd.c' || echo '$(srcdir)/'`mspack/cabd.c + +lzxd.lo: mspack/lzxd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lzxd.lo -MD -MP -MF $(DEPDIR)/lzxd.Tpo -c -o lzxd.lo `test -f 'mspack/lzxd.c' || echo '$(srcdir)/'`mspack/lzxd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lzxd.Tpo $(DEPDIR)/lzxd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/lzxd.c' object='lzxd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lzxd.lo `test -f 'mspack/lzxd.c' || echo '$(srcdir)/'`mspack/lzxd.c + +mszipd.lo: mspack/mszipd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mszipd.lo -MD -MP -MF $(DEPDIR)/mszipd.Tpo -c -o mszipd.lo `test -f 'mspack/mszipd.c' || echo '$(srcdir)/'`mspack/mszipd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mszipd.Tpo $(DEPDIR)/mszipd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/mszipd.c' object='mszipd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mszipd.lo `test -f 'mspack/mszipd.c' || echo '$(srcdir)/'`mspack/mszipd.c + +qtmd.lo: mspack/qtmd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT qtmd.lo -MD -MP -MF $(DEPDIR)/qtmd.Tpo -c -o qtmd.lo `test -f 'mspack/qtmd.c' || echo '$(srcdir)/'`mspack/qtmd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/qtmd.Tpo $(DEPDIR)/qtmd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/qtmd.c' object='qtmd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o qtmd.lo `test -f 'mspack/qtmd.c' || echo '$(srcdir)/'`mspack/qtmd.c + +chmd.lo: mspack/chmd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT chmd.lo -MD -MP -MF $(DEPDIR)/chmd.Tpo -c -o chmd.lo `test -f 'mspack/chmd.c' || echo '$(srcdir)/'`mspack/chmd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/chmd.Tpo $(DEPDIR)/chmd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/chmd.c' object='chmd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o chmd.lo `test -f 'mspack/chmd.c' || echo '$(srcdir)/'`mspack/chmd.c + +cabc.lo: mspack/cabc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cabc.lo -MD -MP -MF $(DEPDIR)/cabc.Tpo -c -o cabc.lo `test -f 'mspack/cabc.c' || echo '$(srcdir)/'`mspack/cabc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cabc.Tpo $(DEPDIR)/cabc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/cabc.c' object='cabc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cabc.lo `test -f 'mspack/cabc.c' || echo '$(srcdir)/'`mspack/cabc.c + +chmc.lo: mspack/chmc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT chmc.lo -MD -MP -MF $(DEPDIR)/chmc.Tpo -c -o chmc.lo `test -f 'mspack/chmc.c' || echo '$(srcdir)/'`mspack/chmc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/chmc.Tpo $(DEPDIR)/chmc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/chmc.c' object='chmc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o chmc.lo `test -f 'mspack/chmc.c' || echo '$(srcdir)/'`mspack/chmc.c + +hlpc.lo: mspack/hlpc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hlpc.lo -MD -MP -MF $(DEPDIR)/hlpc.Tpo -c -o hlpc.lo `test -f 'mspack/hlpc.c' || echo '$(srcdir)/'`mspack/hlpc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hlpc.Tpo $(DEPDIR)/hlpc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/hlpc.c' object='hlpc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hlpc.lo `test -f 'mspack/hlpc.c' || echo '$(srcdir)/'`mspack/hlpc.c + +hlpd.lo: mspack/hlpd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hlpd.lo -MD -MP -MF $(DEPDIR)/hlpd.Tpo -c -o hlpd.lo `test -f 'mspack/hlpd.c' || echo '$(srcdir)/'`mspack/hlpd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hlpd.Tpo $(DEPDIR)/hlpd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/hlpd.c' object='hlpd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hlpd.lo `test -f 'mspack/hlpd.c' || echo '$(srcdir)/'`mspack/hlpd.c + +litc.lo: mspack/litc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT litc.lo -MD -MP -MF $(DEPDIR)/litc.Tpo -c -o litc.lo `test -f 'mspack/litc.c' || echo '$(srcdir)/'`mspack/litc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/litc.Tpo $(DEPDIR)/litc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/litc.c' object='litc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o litc.lo `test -f 'mspack/litc.c' || echo '$(srcdir)/'`mspack/litc.c + +litd.lo: mspack/litd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT litd.lo -MD -MP -MF $(DEPDIR)/litd.Tpo -c -o litd.lo `test -f 'mspack/litd.c' || echo '$(srcdir)/'`mspack/litd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/litd.Tpo $(DEPDIR)/litd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/litd.c' object='litd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o litd.lo `test -f 'mspack/litd.c' || echo '$(srcdir)/'`mspack/litd.c + +kwajc.lo: mspack/kwajc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kwajc.lo -MD -MP -MF $(DEPDIR)/kwajc.Tpo -c -o kwajc.lo `test -f 'mspack/kwajc.c' || echo '$(srcdir)/'`mspack/kwajc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kwajc.Tpo $(DEPDIR)/kwajc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/kwajc.c' object='kwajc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kwajc.lo `test -f 'mspack/kwajc.c' || echo '$(srcdir)/'`mspack/kwajc.c + +kwajd.lo: mspack/kwajd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kwajd.lo -MD -MP -MF $(DEPDIR)/kwajd.Tpo -c -o kwajd.lo `test -f 'mspack/kwajd.c' || echo '$(srcdir)/'`mspack/kwajd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kwajd.Tpo $(DEPDIR)/kwajd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/kwajd.c' object='kwajd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kwajd.lo `test -f 'mspack/kwajd.c' || echo '$(srcdir)/'`mspack/kwajd.c + +szddc.lo: mspack/szddc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT szddc.lo -MD -MP -MF $(DEPDIR)/szddc.Tpo -c -o szddc.lo `test -f 'mspack/szddc.c' || echo '$(srcdir)/'`mspack/szddc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/szddc.Tpo $(DEPDIR)/szddc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/szddc.c' object='szddc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o szddc.lo `test -f 'mspack/szddc.c' || echo '$(srcdir)/'`mspack/szddc.c + +szddd.lo: mspack/szddd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT szddd.lo -MD -MP -MF $(DEPDIR)/szddd.Tpo -c -o szddd.lo `test -f 'mspack/szddd.c' || echo '$(srcdir)/'`mspack/szddd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/szddd.Tpo $(DEPDIR)/szddd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/szddd.c' object='szddd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o szddd.lo `test -f 'mspack/szddd.c' || echo '$(srcdir)/'`mspack/szddd.c + +oabc.lo: mspack/oabc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT oabc.lo -MD -MP -MF $(DEPDIR)/oabc.Tpo -c -o oabc.lo `test -f 'mspack/oabc.c' || echo '$(srcdir)/'`mspack/oabc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/oabc.Tpo $(DEPDIR)/oabc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/oabc.c' object='oabc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o oabc.lo `test -f 'mspack/oabc.c' || echo '$(srcdir)/'`mspack/oabc.c + +oabd.lo: mspack/oabd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT oabd.lo -MD -MP -MF $(DEPDIR)/oabd.Tpo -c -o oabd.lo `test -f 'mspack/oabd.c' || echo '$(srcdir)/'`mspack/oabd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/oabd.Tpo $(DEPDIR)/oabd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/oabd.c' object='oabd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o oabd.lo `test -f 'mspack/oabd.c' || echo '$(srcdir)/'`mspack/oabd.c + +lzxc.lo: mspack/lzxc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lzxc.lo -MD -MP -MF $(DEPDIR)/lzxc.Tpo -c -o lzxc.lo `test -f 'mspack/lzxc.c' || echo '$(srcdir)/'`mspack/lzxc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lzxc.Tpo $(DEPDIR)/lzxc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/lzxc.c' object='lzxc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lzxc.lo `test -f 'mspack/lzxc.c' || echo '$(srcdir)/'`mspack/lzxc.c + +mszipc.lo: mspack/mszipc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mszipc.lo -MD -MP -MF $(DEPDIR)/mszipc.Tpo -c -o mszipc.lo `test -f 'mspack/mszipc.c' || echo '$(srcdir)/'`mspack/mszipc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mszipc.Tpo $(DEPDIR)/mszipc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/mszipc.c' object='mszipc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mszipc.lo `test -f 'mspack/mszipc.c' || echo '$(srcdir)/'`mspack/mszipc.c + +lzssd.lo: mspack/lzssd.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lzssd.lo -MD -MP -MF $(DEPDIR)/lzssd.Tpo -c -o lzssd.lo `test -f 'mspack/lzssd.c' || echo '$(srcdir)/'`mspack/lzssd.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lzssd.Tpo $(DEPDIR)/lzssd.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/lzssd.c' object='lzssd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lzssd.lo `test -f 'mspack/lzssd.c' || echo '$(srcdir)/'`mspack/lzssd.c + +crc32.lo: mspack/crc32.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT crc32.lo -MD -MP -MF $(DEPDIR)/crc32.Tpo -c -o crc32.lo `test -f 'mspack/crc32.c' || echo '$(srcdir)/'`mspack/crc32.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/crc32.Tpo $(DEPDIR)/crc32.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack/crc32.c' object='crc32.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o crc32.lo `test -f 'mspack/crc32.c' || echo '$(srcdir)/'`mspack/crc32.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool config.lt +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) + +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" +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) +clean-cscope: + -rm -f cscope.files +cscope.files: clean-cscope cscopelist +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 + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d "$(distdir)" || mkdir "$(distdir)" + @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 + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook + -test -n "$(am__skip_mode_fix)" \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r "$(distdir)" +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__post_remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 + $(am__post_remove_distdir) + +dist-lzip: distdir + tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz + $(am__post_remove_distdir) + +dist-xz: distdir + tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz + $(am__post_remove_distdir) + +dist-tarZ: distdir + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__post_remove_distdir) + +dist-shar: distdir + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__post_remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__post_remove_distdir) + +dist dist-all: + $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' + $(am__post_remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lz*) \ + lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ + *.tar.xz*) \ + xz -dc $(distdir).tar.xz | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir) + chmod u+w $(distdir) + mkdir $(distdir)/_build $(distdir)/_inst + chmod a-w $(distdir) + test -d $(distdir)/_build || exit 0; \ + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && am__cwd=`pwd` \ + && $(am__cd) $(distdir)/_build \ + && ../configure \ + $(AM_DISTCHECK_CONFIGURE_FLAGS) \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + --srcdir=.. --prefix="$$dc_install_base" \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ + && cd "$$am__cwd" \ + || exit 1 + $(am__post_remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @test -n '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: trying to run $@ with an empty' \ + '$$(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + $(am__cd) '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) config.h +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +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-libLTLIBRARIES clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-includeHEADERS install-pkgconfigDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +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 -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -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: uninstall-includeHEADERS uninstall-libLTLIBRARIES \ + uninstall-pkgconfigDATA + +.MAKE: all install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \ + clean-cscope clean-generic clean-libLTLIBRARIES clean-libtool \ + clean-noinstLTLIBRARIES cscope cscopelist-am ctags ctags-am \ + dist dist-all dist-bzip2 dist-gzip dist-hook dist-lzip \ + dist-shar dist-tarZ dist-xz dist-zip distcheck distclean \ + distclean-compile distclean-generic distclean-hdr \ + distclean-libtool distclean-tags distcleancheck distdir \ + distuninstallcheck 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-includeHEADERS install-info \ + install-info-am install-libLTLIBRARIES install-man install-pdf \ + install-pdf-am install-pkgconfigDATA 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 \ + uninstall-includeHEADERS uninstall-libLTLIBRARIES \ + uninstall-pkgconfigDATA + + +dist-hook: + -rm -f $(distdir)/*.la + +# 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: diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/Makefile.intmspack.in clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/Makefile.intmspack.in --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/Makefile.intmspack.in 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/Makefile.intmspack.in 2016-11-03 20:21:16.000000000 +0000 @@ -0,0 +1,9 @@ +.PHONY: distdir distclean maintainer-clean +distdir: + echo "make distdir requires --with-system-mspack=no" + exit 1 + +# nothing to do here, rules must exist for distclean to succeed +distclean: + -rm -f Makefile +maintainer-clean: diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/missing clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/missing --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/missing 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/missing 2016-12-05 20:15:48.000000000 +0000 @@ -0,0 +1,221 @@ +#! /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." + + echo "If you pulled this source code from a git repo," + echo "try running 'autoreconf -ivf' to resolve this warning" + + 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 + +# Modification to exit normally after printing warning. +exit 0 + +# 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: diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/cabc.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/cabc.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/cabc.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/cabc.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,24 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* CAB compression implementation */ + +#include +#include + +struct mscab_compressor * + mspack_create_cab_compressor(struct mspack_system *sys) +{ + /* todo */ + return NULL; +} + +void mspack_destroy_cab_compressor(struct mscab_compressor *self) { + /* todo */ +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/cabd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/cabd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/cabd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/cabd.c 2017-07-20 19:40:15.000000000 +0000 @@ -0,0 +1,1463 @@ +/* This file is part of libmspack. + * (C) 2003-2011 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* Cabinet (.CAB) files are a form of file archive. Each cabinet contains + * "folders", which are compressed spans of data. Each cabinet has + * "files", whose metadata is in the cabinet header, but whose actual data + * is stored compressed in one of the "folders". Cabinets can span more + * than one physical file on disk, in which case they are a "cabinet set", + * and usually the last folder of each cabinet extends into the next + * cabinet. + * + * For a complete description of the format, see the MSDN site: + * http://msdn.microsoft.com/en-us/library/bb267310.aspx + */ + +/* CAB decompression implementation */ + +#include +#include +#include + +/* Notes on compliance with cabinet specification: + * + * One of the main changes between cabextract 0.6 and libmspack's cab + * decompressor is the move from block-oriented decompression to + * stream-oriented decompression. + * + * cabextract would read one data block from disk, decompress it with the + * appropriate method, then write the decompressed data. The CAB + * specification is specifically designed to work like this, as it ensures + * compression matches do not span the maximum decompressed block size + * limit of 32kb. + * + * However, the compression algorithms used are stream oriented, with + * specific hacks added to them to enforce the "individual 32kb blocks" + * rule in CABs. In other file formats, they do not have this limitation. + * + * In order to make more generalised decompressors, libmspack's CAB + * decompressor has moved from being block-oriented to more stream + * oriented. This also makes decompression slightly faster. + * + * However, this leads to incompliance with the CAB specification. The + * CAB controller can no longer ensure each block of input given to the + * decompressors is matched with their output. The "decompressed size" of + * each individual block is thrown away. + * + * Each CAB block is supposed to be seen as individually compressed. This + * means each consecutive data block can have completely different + * "uncompressed" sizes, ranging from 1 to 32768 bytes. However, in + * reality, all data blocks in a folder decompress to exactly 32768 bytes, + * excepting the final block. + * + * Given this situation, the decompression algorithms are designed to + * realign their input bitstreams on 32768 output-byte boundaries, and + * various other special cases have been made. libmspack will not + * correctly decompress LZX or Quantum compressed folders where the blocks + * do not follow this "32768 bytes until last block" pattern. It could be + * implemented if needed, but hopefully this is not necessary -- it has + * not been seen in over 3Gb of CAB archives. + */ + +/* prototypes */ +static struct mscabd_cabinet * cabd_open( + struct mscab_decompressor *base, const char *filename); +static void cabd_close( + struct mscab_decompressor *base, struct mscabd_cabinet *origcab); +static int cabd_read_headers( + struct mspack_system *sys, struct mspack_file *fh, + struct mscabd_cabinet_p *cab, off_t offset, int quiet); +static char *cabd_read_string( + struct mspack_system *sys, struct mspack_file *fh, int *error); + +static struct mscabd_cabinet *cabd_search( + struct mscab_decompressor *base, const char *filename); +static int cabd_find( + struct mscab_decompressor_p *self, unsigned char *buf, + struct mspack_file *fh, const char *filename, off_t flen, + off_t *firstlen, struct mscabd_cabinet_p **firstcab); + +static int cabd_prepend( + struct mscab_decompressor *base, struct mscabd_cabinet *cab, + struct mscabd_cabinet *prevcab); +static int cabd_append( + struct mscab_decompressor *base, struct mscabd_cabinet *cab, + struct mscabd_cabinet *nextcab); +static int cabd_merge( + struct mscab_decompressor *base, struct mscabd_cabinet *lcab, + struct mscabd_cabinet *rcab); +static int cabd_can_merge_folders( + struct mspack_system *sys, struct mscabd_folder_p *lfol, + struct mscabd_folder_p *rfol); + +static int cabd_extract( + struct mscab_decompressor *base, struct mscabd_file *file, + const char *filename); +static int cabd_init_decomp( + struct mscab_decompressor_p *self, unsigned int ct); +static void cabd_free_decomp( + struct mscab_decompressor_p *self); +static int cabd_sys_read( + struct mspack_file *file, void *buffer, int bytes); +static int cabd_sys_write( + struct mspack_file *file, void *buffer, int bytes); +static int cabd_sys_read_block( + struct mspack_system *sys, struct mscabd_decompress_state *d, int *out, + int ignore_cksum); +static unsigned int cabd_checksum( + unsigned char *data, unsigned int bytes, unsigned int cksum); +static struct noned_state *noned_init( + struct mspack_system *sys, struct mspack_file *in, struct mspack_file *out, + int bufsize); + +static int noned_decompress( + struct noned_state *s, off_t bytes); +static void noned_free( + struct noned_state *state); + +static int cabd_param( + struct mscab_decompressor *base, int param, int value); + +static int cabd_error( + struct mscab_decompressor *base); + + +/*************************************** + * MSPACK_CREATE_CAB_DECOMPRESSOR + *************************************** + * constructor + */ +struct mscab_decompressor * + mspack_create_cab_decompressor(struct mspack_system *sys) +{ + struct mscab_decompressor_p *self = NULL; + + if (!sys) sys = mspack_default_system; + if (!mspack_valid_system(sys)) return NULL; + + if ((self = (struct mscab_decompressor_p *) sys->alloc(sys, sizeof(struct mscab_decompressor_p)))) { + self->base.open = &cabd_open; + self->base.close = &cabd_close; + self->base.search = &cabd_search; + self->base.extract = &cabd_extract; + self->base.prepend = &cabd_prepend; + self->base.append = &cabd_append; + self->base.set_param = &cabd_param; + self->base.last_error = &cabd_error; + self->system = sys; + self->d = NULL; + self->error = MSPACK_ERR_OK; + + self->param[MSCABD_PARAM_SEARCHBUF] = 32768; + self->param[MSCABD_PARAM_FIXMSZIP] = 0; + self->param[MSCABD_PARAM_DECOMPBUF] = 4096; + } + return (struct mscab_decompressor *) self; +} + +/*************************************** + * MSPACK_DESTROY_CAB_DECOMPRESSOR + *************************************** + * destructor + */ +void mspack_destroy_cab_decompressor(struct mscab_decompressor *base) { + struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) base; + if (self) { + struct mspack_system *sys = self->system; + if (self->d) { + if (self->d->infh) sys->close(self->d->infh); + cabd_free_decomp(self); + sys->free(self->d); + } + sys->free(self); + } +} + + +/*************************************** + * CABD_OPEN + *************************************** + * opens a file and tries to read it as a cabinet file + */ +static struct mscabd_cabinet *cabd_open(struct mscab_decompressor *base, + const char *filename) +{ + struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) base; + struct mscabd_cabinet_p *cab = NULL; + struct mspack_system *sys; + struct mspack_file *fh; + int error; + + if (!base) return NULL; + sys = self->system; + + if ((fh = sys->open(sys, filename, MSPACK_SYS_OPEN_READ))) { + if ((cab = (struct mscabd_cabinet_p *) sys->alloc(sys, sizeof(struct mscabd_cabinet_p)))) { + cab->base.filename = filename; + error = cabd_read_headers(sys, fh, cab, (off_t) 0, 0); + if (error) { + cabd_close(base, (struct mscabd_cabinet *) cab); + cab = NULL; + } + self->error = error; + } + else { + self->error = MSPACK_ERR_NOMEMORY; + } + sys->close(fh); + } + else { + self->error = MSPACK_ERR_OPEN; + } + return (struct mscabd_cabinet *) cab; +} + +/*************************************** + * CABD_CLOSE + *************************************** + * frees all memory associated with a given mscabd_cabinet. + */ +static void cabd_close(struct mscab_decompressor *base, + struct mscabd_cabinet *origcab) +{ + struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) base; + struct mscabd_folder_data *dat, *ndat; + struct mscabd_cabinet *cab, *ncab; + struct mscabd_folder *fol, *nfol; + struct mscabd_file *fi, *nfi; + struct mspack_system *sys; + + if (!base) return; + sys = self->system; + + self->error = MSPACK_ERR_OK; + + while (origcab) { + /* free files */ + for (fi = origcab->files; fi; fi = nfi) { + nfi = fi->next; + sys->free(fi->filename); + sys->free(fi); + } + + /* free folders */ + for (fol = origcab->folders; fol; fol = nfol) { + nfol = fol->next; + + /* free folder decompression state if it has been decompressed */ + if (self->d && (self->d->folder == (struct mscabd_folder_p *) fol)) { + if (self->d->infh) sys->close(self->d->infh); + cabd_free_decomp(self); + sys->free(self->d); + self->d = NULL; + } + + /* free folder data segments */ + for (dat = ((struct mscabd_folder_p *)fol)->data.next; dat; dat = ndat) { + ndat = dat->next; + sys->free(dat); + } + sys->free(fol); + } + + /* free predecessor cabinets (and the original cabinet's strings) */ + for (cab = origcab; cab; cab = ncab) { + ncab = cab->prevcab; + sys->free(cab->prevname); + sys->free(cab->nextname); + sys->free(cab->previnfo); + sys->free(cab->nextinfo); + if (cab != origcab) sys->free(cab); + } + + /* free successor cabinets */ + for (cab = origcab->nextcab; cab; cab = ncab) { + ncab = cab->nextcab; + sys->free(cab->prevname); + sys->free(cab->nextname); + sys->free(cab->previnfo); + sys->free(cab->nextinfo); + sys->free(cab); + } + + /* free actual cabinet structure */ + cab = origcab->next; + sys->free(origcab); + + /* repeat full procedure again with the cab->next pointer (if set) */ + origcab = cab; + } +} + +/*************************************** + * CABD_READ_HEADERS + *************************************** + * reads the cabinet file header, folder list and file list. + * fills out a pre-existing mscabd_cabinet structure, allocates memory + * for folders and files as necessary + */ +static int cabd_read_headers(struct mspack_system *sys, + struct mspack_file *fh, + struct mscabd_cabinet_p *cab, + off_t offset, int quiet) +{ + int num_folders, num_files, folder_resv, i, x; + struct mscabd_folder_p *fol, *linkfol = NULL; + struct mscabd_file *file, *linkfile = NULL; + unsigned char buf[64]; + + /* initialise pointers */ + cab->base.next = NULL; + cab->base.files = NULL; + cab->base.folders = NULL; + cab->base.prevcab = cab->base.nextcab = NULL; + cab->base.prevname = cab->base.nextname = NULL; + cab->base.previnfo = cab->base.nextinfo = NULL; + + cab->base.base_offset = offset; + + /* seek to CFHEADER */ + if (sys->seek(fh, offset, MSPACK_SYS_SEEK_START)) { + return MSPACK_ERR_SEEK; + } + + /* read in the CFHEADER */ + if (sys->read(fh, &buf[0], cfhead_SIZEOF) != cfhead_SIZEOF) { + return MSPACK_ERR_READ; + } + + /* check for "MSCF" signature */ + if (EndGetI32(&buf[cfhead_Signature]) != 0x4643534D) { + return MSPACK_ERR_SIGNATURE; + } + + /* some basic header fields */ + cab->base.length = EndGetI32(&buf[cfhead_CabinetSize]); + cab->base.set_id = EndGetI16(&buf[cfhead_SetID]); + cab->base.set_index = EndGetI16(&buf[cfhead_CabinetIndex]); + + /* get the number of folders */ + num_folders = EndGetI16(&buf[cfhead_NumFolders]); + if (num_folders == 0) { + if (!quiet) sys->message(fh, "no folders in cabinet."); + return MSPACK_ERR_DATAFORMAT; + } + + /* get the number of files */ + num_files = EndGetI16(&buf[cfhead_NumFiles]); + if (num_files == 0) { + if (!quiet) sys->message(fh, "no files in cabinet."); + return MSPACK_ERR_DATAFORMAT; + } + + /* check cabinet version */ + if ((buf[cfhead_MajorVersion] != 1) && (buf[cfhead_MinorVersion] != 3)) { + if (!quiet) sys->message(fh, "WARNING; cabinet version is not 1.3"); + } + + /* read the reserved-sizes part of header, if present */ + cab->base.flags = EndGetI16(&buf[cfhead_Flags]); + if (cab->base.flags & cfheadRESERVE_PRESENT) { + if (sys->read(fh, &buf[0], cfheadext_SIZEOF) != cfheadext_SIZEOF) { + return MSPACK_ERR_READ; + } + cab->base.header_resv = EndGetI16(&buf[cfheadext_HeaderReserved]); + folder_resv = buf[cfheadext_FolderReserved]; + cab->block_resv = buf[cfheadext_DataReserved]; + + if (cab->base.header_resv > 60000) { + if (!quiet) sys->message(fh, "WARNING; reserved header > 60000."); + } + + /* skip the reserved header */ + if (cab->base.header_resv) { + if (sys->seek(fh, (off_t) cab->base.header_resv, MSPACK_SYS_SEEK_CUR)) { + return MSPACK_ERR_SEEK; + } + } + } + else { + cab->base.header_resv = 0; + folder_resv = 0; + cab->block_resv = 0; + } + + /* read name and info of preceeding cabinet in set, if present */ + if (cab->base.flags & cfheadPREV_CABINET) { + cab->base.prevname = cabd_read_string(sys, fh, &x); if (x) return x; + cab->base.previnfo = cabd_read_string(sys, fh, &x); if (x) return x; + } + + /* read name and info of next cabinet in set, if present */ + if (cab->base.flags & cfheadNEXT_CABINET) { + cab->base.nextname = cabd_read_string(sys, fh, &x); if (x) return x; + cab->base.nextinfo = cabd_read_string(sys, fh, &x); if (x) return x; + } + + /* read folders */ + for (i = 0; i < num_folders; i++) { + if (sys->read(fh, &buf[0], cffold_SIZEOF) != cffold_SIZEOF) { + return MSPACK_ERR_READ; + } + if (folder_resv) { + if (sys->seek(fh, (off_t) folder_resv, MSPACK_SYS_SEEK_CUR)) { + return MSPACK_ERR_SEEK; + } + } + + if (!(fol = (struct mscabd_folder_p *) sys->alloc(sys, sizeof(struct mscabd_folder_p)))) { + return MSPACK_ERR_NOMEMORY; + } + fol->base.next = NULL; + fol->base.comp_type = EndGetI16(&buf[cffold_CompType]); + fol->base.num_blocks = EndGetI16(&buf[cffold_NumBlocks]); + fol->data.next = NULL; + fol->data.cab = (struct mscabd_cabinet_p *) cab; + fol->data.offset = offset + (off_t) + ( (unsigned int) EndGetI32(&buf[cffold_DataOffset]) ); + fol->merge_prev = NULL; + fol->merge_next = NULL; + + /* link folder into list of folders */ + if (!linkfol) cab->base.folders = (struct mscabd_folder *) fol; + else linkfol->base.next = (struct mscabd_folder *) fol; + linkfol = fol; + } + + /* read files */ + for (i = 0; i < num_files; i++) { + if (sys->read(fh, &buf[0], cffile_SIZEOF) != cffile_SIZEOF) { + return MSPACK_ERR_READ; + } + + if (!(file = (struct mscabd_file *) sys->alloc(sys, sizeof(struct mscabd_file)))) { + return MSPACK_ERR_NOMEMORY; + } + + file->next = NULL; + file->length = EndGetI32(&buf[cffile_UncompressedSize]); + file->attribs = EndGetI16(&buf[cffile_Attribs]); + file->offset = EndGetI32(&buf[cffile_FolderOffset]); + + /* set folder pointer */ + x = EndGetI16(&buf[cffile_FolderIndex]); + if (x < cffileCONTINUED_FROM_PREV) { + /* normal folder index; count up to the correct folder. the folder + * pointer will be NULL if folder index is invalid */ + struct mscabd_folder *ifol = cab->base.folders; + while (x--) if (ifol) ifol = ifol->next; + file->folder = ifol; + + if (!ifol) { + sys->free(file); + D(("invalid folder index")) + return MSPACK_ERR_DATAFORMAT; + } + } + else { + /* either CONTINUED_TO_NEXT, CONTINUED_FROM_PREV or + * CONTINUED_PREV_AND_NEXT */ + if ((x == cffileCONTINUED_TO_NEXT) || + (x == cffileCONTINUED_PREV_AND_NEXT)) + { + /* get last folder */ + struct mscabd_folder *ifol = cab->base.folders; + while (ifol->next) ifol = ifol->next; + file->folder = ifol; + + /* set "merge next" pointer */ + fol = (struct mscabd_folder_p *) ifol; + if (!fol->merge_next) fol->merge_next = file; + } + + if ((x == cffileCONTINUED_FROM_PREV) || + (x == cffileCONTINUED_PREV_AND_NEXT)) + { + /* get first folder */ + file->folder = cab->base.folders; + + /* set "merge prev" pointer */ + fol = (struct mscabd_folder_p *) file->folder; + if (!fol->merge_prev) fol->merge_prev = file; + } + } + + /* get time */ + x = EndGetI16(&buf[cffile_Time]); + file->time_h = x >> 11; + file->time_m = (x >> 5) & 0x3F; + file->time_s = (x << 1) & 0x3E; + + /* get date */ + x = EndGetI16(&buf[cffile_Date]); + file->date_d = x & 0x1F; + file->date_m = (x >> 5) & 0xF; + file->date_y = (x >> 9) + 1980; + + /* get filename */ + file->filename = cabd_read_string(sys, fh, &x); + if (x) { + sys->free(file); + return x; + } + + /* link file entry into file list */ + if (!linkfile) cab->base.files = file; + else linkfile->next = file; + linkfile = file; + } + + return MSPACK_ERR_OK; +} + +static char *cabd_read_string(struct mspack_system *sys, + struct mspack_file *fh, int *error) +{ + off_t base = sys->tell(fh); + char buf[256], *str; + unsigned int i, ok; + ssize_t len; + + /* read up to 256 bytes */ + len = sys->read(fh, &buf[0], 256); + if (len <= 0) { + *error = MSPACK_ERR_READ; + return NULL; + } + + /* search for a null terminator in the buffer. reject empty strings */ + for (i = 1, ok = 0; i < len; i++) if (!buf[i]) { ok = 1; break; } + if (!ok) { + *error = MSPACK_ERR_DATAFORMAT; + return NULL; + } + + len = i + 1; + + /* set the data stream to just after the string and return */ + if (sys->seek(fh, base + (off_t)len, MSPACK_SYS_SEEK_START)) { + *error = MSPACK_ERR_SEEK; + return NULL; + } + + if (!(str = (char *) sys->alloc(sys, len))) { + *error = MSPACK_ERR_NOMEMORY; + return NULL; + } + + sys->copy(&buf[0], str, len); + *error = MSPACK_ERR_OK; + return str; +} + +/*************************************** + * CABD_SEARCH, CABD_FIND + *************************************** + * cabd_search opens a file, finds its extent, allocates a search buffer, + * then reads through the whole file looking for possible cabinet headers. + * if it finds any, it tries to read them as real cabinets. returns a linked + * list of results + * + * cabd_find is the inner loop of cabd_search, to make it easier to + * break out of the loop and be sure that all resources are freed + */ +static struct mscabd_cabinet *cabd_search(struct mscab_decompressor *base, + const char *filename) +{ + struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) base; + struct mscabd_cabinet_p *cab = NULL; + struct mspack_system *sys; + unsigned char *search_buf; + struct mspack_file *fh; + off_t filelen, firstlen = 0; + + if (!base) return NULL; + sys = self->system; + + /* allocate a search buffer */ + search_buf = (unsigned char *) sys->alloc(sys, (size_t) self->param[MSCABD_PARAM_SEARCHBUF]); + if (!search_buf) { + self->error = MSPACK_ERR_NOMEMORY; + return NULL; + } + + /* open file and get its full file length */ + if ((fh = sys->open(sys, filename, MSPACK_SYS_OPEN_READ))) { + if (!(self->error = mspack_sys_filelen(sys, fh, &filelen))) { + self->error = cabd_find(self, search_buf, fh, filename, + filelen, &firstlen, &cab); + } + + /* truncated / extraneous data warning: */ + if (firstlen && (firstlen != filelen) && + (!cab || (cab->base.base_offset == 0))) + { + if (firstlen < filelen) { + sys->message(fh, "WARNING; possible %" LD + " extra bytes at end of file.", + filelen - firstlen); + } + else { + sys->message(fh, "WARNING; file possibly truncated by %" LD " bytes.", + firstlen - filelen); + } + } + + sys->close(fh); + } + else { + self->error = MSPACK_ERR_OPEN; + } + + /* free the search buffer */ + sys->free(search_buf); + + return (struct mscabd_cabinet *) cab; +} + +static int cabd_find(struct mscab_decompressor_p *self, unsigned char *buf, + struct mspack_file *fh, const char *filename, off_t flen, + off_t *firstlen, struct mscabd_cabinet_p **firstcab) +{ + struct mscabd_cabinet_p *cab, *link = NULL; + off_t caboff, offset, length; + struct mspack_system *sys = self->system; + unsigned char *p, *pend, state = 0; + unsigned int cablen_u32 = 0, foffset_u32 = 0; + int false_cabs = 0; + +#ifndef LARGEFILE_SUPPORT + /* detect 32-bit off_t overflow */ + if (flen < 0) { + sys->message(fh, largefile_msg); + return MSPACK_ERR_OK; + } +#endif + + /* search through the full file length */ + for (offset = 0; offset < flen; offset += length) { + /* search length is either the full length of the search buffer, or the + * amount of data remaining to the end of the file, whichever is less. */ + length = flen - offset; + if (length > self->param[MSCABD_PARAM_SEARCHBUF]) { + length = self->param[MSCABD_PARAM_SEARCHBUF]; + } + + /* fill the search buffer with data from disk */ + if (sys->read(fh, &buf[0], (int) length) != (int) length) { + return MSPACK_ERR_READ; + } + + /* FAQ avoidance strategy */ + if ((offset == 0) && (EndGetI32(&buf[0]) == 0x28635349)) { + sys->message(fh, "WARNING; found InstallShield header. " + "This is probably an InstallShield file. " + "Use UNSHIELD from www.synce.org to unpack it."); + } + + /* read through the entire buffer. */ + for (p = &buf[0], pend = &buf[length]; p < pend; ) { + switch (state) { + /* starting state */ + case 0: + /* we spend most of our time in this while loop, looking for + * a leading 'M' of the 'MSCF' signature */ + while (p < pend && *p != 0x4D) p++; + /* if we found tht 'M', advance state */ + if (p++ < pend) state = 1; + break; + + /* verify that the next 3 bytes are 'S', 'C' and 'F' */ + case 1: state = (*p++ == 0x53) ? 2 : 0; break; + case 2: state = (*p++ == 0x43) ? 3 : 0; break; + case 3: state = (*p++ == 0x46) ? 4 : 0; break; + + /* we don't care about bytes 4-7 (see default: for action) */ + + /* bytes 8-11 are the overall length of the cabinet */ + case 8: cablen_u32 = *p++; state++; break; + case 9: cablen_u32 |= *p++ << 8; state++; break; + case 10: cablen_u32 |= *p++ << 16; state++; break; + case 11: cablen_u32 |= *p++ << 24; state++; break; + + /* we don't care about bytes 12-15 (see default: for action) */ + + /* bytes 16-19 are the offset within the cabinet of the filedata */ + case 16: foffset_u32 = *p++; state++; break; + case 17: foffset_u32 |= *p++ << 8; state++; break; + case 18: foffset_u32 |= *p++ << 16; state++; break; + case 19: foffset_u32 |= *p++ << 24; + /* now we have recieved 20 bytes of potential cab header. work out + * the offset in the file of this potential cabinet */ + caboff = offset + (p - &buf[0]) - 20; + + /* should reading cabinet fail, restart search just after 'MSCF' */ + offset = caboff + 4; + + /* capture the "length of cabinet" field if there is a cabinet at + * offset 0 in the file, regardless of whether the cabinet can be + * read correctly or not */ + if (caboff == 0) *firstlen = (off_t) cablen_u32; + + /* check that the files offset is less than the alleged length of + * the cabinet, and that the offset + the alleged length are + * 'roughly' within the end of overall file length */ + if ((foffset_u32 < cablen_u32) && + ((caboff + (off_t) foffset_u32) < (flen + 32)) && + ((caboff + (off_t) cablen_u32) < (flen + 32)) ) + { + /* likely cabinet found -- try reading it */ + if (!(cab = (struct mscabd_cabinet_p *) sys->alloc(sys, sizeof(struct mscabd_cabinet_p)))) { + return MSPACK_ERR_NOMEMORY; + } + cab->base.filename = filename; + if (cabd_read_headers(sys, fh, cab, caboff, 1)) { + /* destroy the failed cabinet */ + cabd_close((struct mscab_decompressor *) self, + (struct mscabd_cabinet *) cab); + false_cabs++; + } + else { + /* cabinet read correctly! */ + + /* link the cab into the list */ + if (!link) *firstcab = cab; + else link->base.next = (struct mscabd_cabinet *) cab; + link = cab; + + /* cause the search to restart after this cab's data. */ + offset = caboff + (off_t) cablen_u32; + +#ifndef LARGEFILE_SUPPORT + /* detect 32-bit off_t overflow */ + if (offset < caboff) { + sys->message(fh, largefile_msg); + return MSPACK_ERR_OK; + } +#endif + } + } + + /* restart search */ + if (offset >= flen) return MSPACK_ERR_OK; + if (sys->seek(fh, offset, MSPACK_SYS_SEEK_START)) { + return MSPACK_ERR_SEEK; + } + length = 0; + p = pend; + state = 0; + break; + + /* for bytes 4-7 and 12-15, just advance state/pointer */ + default: + p++, state++; + } /* switch(state) */ + } /* for (... p < pend ...) */ + } /* for (... offset < length ...) */ + + if (false_cabs) { + D(("%d false cabinets found", false_cabs)) + } + + return MSPACK_ERR_OK; +} + +/*************************************** + * CABD_MERGE, CABD_PREPEND, CABD_APPEND + *************************************** + * joins cabinets together, also merges split folders between these two + * cabinets only. This includes freeing the duplicate folder and file(s) + * and allocating a further mscabd_folder_data structure to append to the + * merged folder's data parts list. + */ +static int cabd_prepend(struct mscab_decompressor *base, + struct mscabd_cabinet *cab, + struct mscabd_cabinet *prevcab) +{ + return cabd_merge(base, prevcab, cab); +} + +static int cabd_append(struct mscab_decompressor *base, + struct mscabd_cabinet *cab, + struct mscabd_cabinet *nextcab) +{ + return cabd_merge(base, cab, nextcab); +} + +static int cabd_merge(struct mscab_decompressor *base, + struct mscabd_cabinet *lcab, + struct mscabd_cabinet *rcab) +{ + struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) base; + struct mscabd_folder_data *data, *ndata; + struct mscabd_folder_p *lfol, *rfol; + struct mscabd_file *fi, *rfi, *lfi; + struct mscabd_cabinet *cab; + struct mspack_system *sys; + + if (!self) return MSPACK_ERR_ARGS; + sys = self->system; + + /* basic args check */ + if (!lcab || !rcab || (lcab == rcab)) { + D(("lcab NULL, rcab NULL or lcab = rcab")) + return self->error = MSPACK_ERR_ARGS; + } + + /* check there's not already a cabinet attached */ + if (lcab->nextcab || rcab->prevcab) { + D(("cabs already joined")) + return self->error = MSPACK_ERR_ARGS; + } + + /* do not create circular cabinet chains */ + for (cab = lcab->prevcab; cab; cab = cab->prevcab) { + if (cab == rcab) {D(("circular!")) return self->error = MSPACK_ERR_ARGS;} + } + for (cab = rcab->nextcab; cab; cab = cab->nextcab) { + if (cab == lcab) {D(("circular!")) return self->error = MSPACK_ERR_ARGS;} + } + + /* warn about odd set IDs or indices */ + if (lcab->set_id != rcab->set_id) { + sys->message(NULL, "WARNING; merged cabinets with differing Set IDs."); + } + + if (lcab->set_index > rcab->set_index) { + sys->message(NULL, "WARNING; merged cabinets with odd order."); + } + + /* merging the last folder in lcab with the first folder in rcab */ + lfol = (struct mscabd_folder_p *) lcab->folders; + rfol = (struct mscabd_folder_p *) rcab->folders; + while (lfol->base.next) lfol = (struct mscabd_folder_p *) lfol->base.next; + + /* do we need to merge folders? */ + if (!lfol->merge_next && !rfol->merge_prev) { + /* no, at least one of the folders is not for merging */ + + /* attach cabs */ + lcab->nextcab = rcab; + rcab->prevcab = lcab; + + /* attach folders */ + lfol->base.next = (struct mscabd_folder *) rfol; + + /* attach files */ + fi = lcab->files; + while (fi->next) fi = fi->next; + fi->next = rcab->files; + } + else { + /* folder merge required - do the files match? */ + if (! cabd_can_merge_folders(sys, lfol, rfol)) { + return self->error = MSPACK_ERR_DATAFORMAT; + } + + /* allocate a new folder data structure */ + if (!(data = (struct mscabd_folder_data *) sys->alloc(sys, sizeof(struct mscabd_folder_data)))) { + return self->error = MSPACK_ERR_NOMEMORY; + } + + /* attach cabs */ + lcab->nextcab = rcab; + rcab->prevcab = lcab; + + /* append rfol's data to lfol */ + ndata = &lfol->data; + while (ndata->next) ndata = ndata->next; + ndata->next = data; + *data = rfol->data; + rfol->data.next = NULL; + + /* lfol becomes rfol. + * NOTE: special case, don't merge if rfol is merge prev and next, + * rfol->merge_next is going to be deleted, so keep lfol's version + * instead */ + lfol->base.num_blocks += rfol->base.num_blocks - 1; + if ((rfol->merge_next == NULL) || + (rfol->merge_next->folder != (struct mscabd_folder *) rfol)) + { + lfol->merge_next = rfol->merge_next; + } + + /* attach the rfol's folder (except the merge folder) */ + while (lfol->base.next) lfol = (struct mscabd_folder_p *) lfol->base.next; + lfol->base.next = rfol->base.next; + + /* free disused merge folder */ + sys->free(rfol); + + /* attach rfol's files */ + fi = lcab->files; + while (fi->next) fi = fi->next; + fi->next = rcab->files; + + /* delete all files from rfol's merge folder */ + lfi = NULL; + for (fi = lcab->files; fi ; fi = rfi) { + rfi = fi->next; + /* if file's folder matches the merge folder, unlink and free it */ + if (fi->folder == (struct mscabd_folder *) rfol) { + if (lfi) lfi->next = rfi; else lcab->files = rfi; + sys->free(fi->filename); + sys->free(fi); + } + else lfi = fi; + } + } + + /* all done! fix files and folders pointers in all cabs so they all + * point to the same list */ + for (cab = lcab->prevcab; cab; cab = cab->prevcab) { + cab->files = lcab->files; + cab->folders = lcab->folders; + } + + for (cab = lcab->nextcab; cab; cab = cab->nextcab) { + cab->files = lcab->files; + cab->folders = lcab->folders; + } + + return self->error = MSPACK_ERR_OK; +} + +/* decides if two folders are OK to merge */ +static int cabd_can_merge_folders(struct mspack_system *sys, + struct mscabd_folder_p *lfol, + struct mscabd_folder_p *rfol) +{ + struct mscabd_file *lfi, *rfi, *l, *r; + int matching = 1; + + /* check that both folders use the same compression method/settings */ + if (lfol->base.comp_type != rfol->base.comp_type) { + D(("folder merge: compression type mismatch")) + return 0; + } + + /* check there are not too many data blocks after merging */ + if ((lfol->base.num_blocks + rfol->base.num_blocks) > CAB_FOLDERMAX) { + D(("folder merge: too many data blocks in merged folders")) + return 0; + } + + if (!(lfi = lfol->merge_next) || !(rfi = rfol->merge_prev)) { + D(("folder merge: one cabinet has no files to merge")) + return 0; + } + + /* for all files in lfol (which is the last folder in whichever cab and + * only has files to merge), compare them to the files from rfol. They + * should be identical in number and order. to verify this, check the + * offset and length of each file. */ + for (l=lfi, r=rfi; l; l=l->next, r=r->next) { + if (!r || (l->offset != r->offset) || (l->length != r->length)) { + matching = 0; + break; + } + } + + if (matching) return 1; + + /* if rfol does not begin with an identical copy of the files in lfol, make + * make a judgement call; if at least ONE file from lfol is in rfol, allow + * the merge with a warning about missing files. */ + matching = 0; + for (l = lfi; l; l = l->next) { + for (r = rfi; r; r = r->next) { + if (l->offset == r->offset && l->length == r->length) break; + } + if (r) matching = 1; else sys->message(NULL, + "WARNING; merged file %s not listed in both cabinets", l->filename); + } + return matching; +} + + +/*************************************** + * CABD_EXTRACT + *************************************** + * extracts a file from a cabinet + */ +static int cabd_extract(struct mscab_decompressor *base, + struct mscabd_file *file, const char *filename) +{ + struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) base; + struct mscabd_folder_p *fol; + struct mspack_system *sys; + struct mspack_file *fh; + + if (!self) return MSPACK_ERR_ARGS; + if (!file) return self->error = MSPACK_ERR_ARGS; + + sys = self->system; + fol = (struct mscabd_folder_p *) file->folder; + + /* validate the file's offset and length */ + if ( (file->offset > CAB_LENGTHMAX) || (file->length > CAB_LENGTHMAX) || + ((file->offset + file->length) > CAB_LENGTHMAX)) + { + return self->error = MSPACK_ERR_DATAFORMAT; + } + + /* check if file can be extracted */ + if ((!fol) || (fol->merge_prev) || + (((file->offset + file->length) / CAB_BLOCKMAX) > fol->base.num_blocks)) + { + sys->message(NULL, "ERROR; file \"%s\" cannot be extracted, " + "cabinet set is incomplete.", file->filename); + return self->error = MSPACK_ERR_DATAFORMAT; + } + + /* allocate generic decompression state */ + if (!self->d) { + self->d = (struct mscabd_decompress_state *) sys->alloc(sys, sizeof(struct mscabd_decompress_state)); + if (!self->d) return self->error = MSPACK_ERR_NOMEMORY; + self->d->folder = NULL; + self->d->data = NULL; + self->d->sys = *sys; + self->d->sys.read = &cabd_sys_read; + self->d->sys.write = &cabd_sys_write; + self->d->state = NULL; + self->d->infh = NULL; + self->d->incab = NULL; + } + + /* do we need to change folder or reset the current folder? */ + if ((self->d->folder != fol) || (self->d->offset > file->offset) || + !self->d->state) + { + /* free any existing decompressor */ + cabd_free_decomp(self); + + /* do we need to open a new cab file? */ + if (!self->d->infh || (fol->data.cab != self->d->incab)) { + /* close previous file handle if from a different cab */ + if (self->d->infh) sys->close(self->d->infh); + self->d->incab = fol->data.cab; + self->d->infh = sys->open(sys, fol->data.cab->base.filename, + MSPACK_SYS_OPEN_READ); + if (!self->d->infh) return self->error = MSPACK_ERR_OPEN; + } + /* seek to start of data blocks */ + if (sys->seek(self->d->infh, fol->data.offset, MSPACK_SYS_SEEK_START)) { + return self->error = MSPACK_ERR_SEEK; + } + + /* set up decompressor */ + if (cabd_init_decomp(self, (unsigned int) fol->base.comp_type)) { + return self->error; + } + + /* initialise new folder state */ + self->d->folder = fol; + self->d->data = &fol->data; + self->d->offset = 0; + self->d->block = 0; + self->d->i_ptr = self->d->i_end = &self->d->input[0]; + + /* read_error lasts for the lifetime of a decompressor */ + self->read_error = MSPACK_ERR_OK; + } + + /* open file for output */ + if (!(fh = sys->open(sys, filename, MSPACK_SYS_OPEN_WRITE))) { + return self->error = MSPACK_ERR_OPEN; + } + + self->error = MSPACK_ERR_OK; + + /* if file has more than 0 bytes */ + if (file->length) { + off_t bytes; + int error; + /* get to correct offset. + * - use NULL fh to say 'no writing' to cabd_sys_write() + * - if cabd_sys_read() has an error, it will set self->read_error + * and pass back MSPACK_ERR_READ + */ + self->d->outfh = NULL; + if ((bytes = file->offset - self->d->offset)) { + error = self->d->decompress(self->d->state, bytes); + self->error = (error == MSPACK_ERR_READ) ? self->read_error : error; + } + + /* if getting to the correct offset was error free, unpack file */ + if (!self->error) { + self->d->outfh = fh; + error = self->d->decompress(self->d->state, (off_t) file->length); + self->error = (error == MSPACK_ERR_READ) ? self->read_error : error; + } + } + + /* close output file */ + sys->close(fh); + self->d->outfh = NULL; + + return self->error; +} + +/*************************************** + * CABD_INIT_DECOMP, CABD_FREE_DECOMP + *************************************** + * cabd_init_decomp initialises decompression state, according to which + * decompression method was used. relies on self->d->folder being the same + * as when initialised. + * + * cabd_free_decomp frees decompression state, according to which method + * was used. + */ +static int cabd_init_decomp(struct mscab_decompressor_p *self, unsigned int ct) +{ + struct mspack_file *fh = (struct mspack_file *) self; + + assert(self && self->d); + + self->d->comp_type = ct; + + switch (ct & cffoldCOMPTYPE_MASK) { + case cffoldCOMPTYPE_NONE: + self->d->decompress = (int (*)(void *, off_t)) &noned_decompress; + self->d->state = noned_init(&self->d->sys, fh, fh, + self->param[MSCABD_PARAM_DECOMPBUF]); + break; + case cffoldCOMPTYPE_MSZIP: + self->d->decompress = (int (*)(void *, off_t)) &mszipd_decompress; + self->d->state = mszipd_init(&self->d->sys, fh, fh, + self->param[MSCABD_PARAM_DECOMPBUF], + self->param[MSCABD_PARAM_FIXMSZIP]); + break; + case cffoldCOMPTYPE_QUANTUM: + self->d->decompress = (int (*)(void *, off_t)) &qtmd_decompress; + self->d->state = qtmd_init(&self->d->sys, fh, fh, (int) (ct >> 8) & 0x1f, + self->param[MSCABD_PARAM_DECOMPBUF]); + break; + case cffoldCOMPTYPE_LZX: + self->d->decompress = (int (*)(void *, off_t)) &lzxd_decompress; + self->d->state = lzxd_init(&self->d->sys, fh, fh, (int) (ct >> 8) & 0x1f, 0, + self->param[MSCABD_PARAM_DECOMPBUF], (off_t)0,0); + break; + default: + return self->error = MSPACK_ERR_DATAFORMAT; + } + return self->error = (self->d->state) ? MSPACK_ERR_OK : MSPACK_ERR_NOMEMORY; +} + +static void cabd_free_decomp(struct mscab_decompressor_p *self) { + if (!self || !self->d || !self->d->state) return; + + switch (self->d->comp_type & cffoldCOMPTYPE_MASK) { + case cffoldCOMPTYPE_NONE: noned_free((struct noned_state *) self->d->state); break; + case cffoldCOMPTYPE_MSZIP: mszipd_free((struct mszipd_stream *) self->d->state); break; + case cffoldCOMPTYPE_QUANTUM: qtmd_free((struct qtmd_stream *) self->d->state); break; + case cffoldCOMPTYPE_LZX: lzxd_free((struct lzxd_stream *) self->d->state); break; + } + self->d->decompress = NULL; + self->d->state = NULL; +} + +/*************************************** + * CABD_SYS_READ, CABD_SYS_WRITE + *************************************** + * cabd_sys_read is the internal reader function which the decompressors + * use. will read data blocks (and merge split blocks) from the cabinet + * and serve the read bytes to the decompressors + * + * cabd_sys_write is the internal writer function which the decompressors + * use. it either writes data to disk (self->d->outfh) with the real + * sys->write() function, or does nothing with the data when + * self->d->outfh == NULL. advances self->d->offset + */ +static int cabd_sys_read(struct mspack_file *file, void *buffer, int bytes) { + struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) file; + unsigned char *buf = (unsigned char *) buffer; + struct mspack_system *sys = self->system; + int avail, todo, outlen, ignore_cksum; + + ignore_cksum = self->param[MSCABD_PARAM_FIXMSZIP] && + ((self->d->comp_type & cffoldCOMPTYPE_MASK) == cffoldCOMPTYPE_MSZIP); + + todo = bytes; + while (todo > 0) { + avail = self->d->i_end - self->d->i_ptr; + + /* if out of input data, read a new block */ + if (avail) { + /* copy as many input bytes available as possible */ + if (avail > todo) avail = todo; + sys->copy(self->d->i_ptr, buf, (size_t) avail); + self->d->i_ptr += avail; + buf += avail; + todo -= avail; + } + else { + /* out of data, read a new block */ + + /* check if we're out of input blocks, advance block counter */ + if (self->d->block++ >= self->d->folder->base.num_blocks) { + self->read_error = MSPACK_ERR_DATAFORMAT; + break; + } + + /* read a block */ + self->read_error = cabd_sys_read_block(sys, self->d, &outlen, ignore_cksum); + if (self->read_error) return -1; + + /* special Quantum hack -- trailer byte to allow the decompressor + * to realign itself. CAB Quantum blocks, unlike LZX blocks, can have + * anything from 0 to 4 trailing null bytes. */ + if ((self->d->comp_type & cffoldCOMPTYPE_MASK)==cffoldCOMPTYPE_QUANTUM) { + *self->d->i_end++ = 0xFF; + } + + /* is this the last block? */ + if (self->d->block >= self->d->folder->base.num_blocks) { + /* last block */ + if ((self->d->comp_type & cffoldCOMPTYPE_MASK) == cffoldCOMPTYPE_LZX) { + /* special LZX hack -- on the last block, inform LZX of the + * size of the output data stream. */ + lzxd_set_output_length((struct lzxd_stream *) self->d->state, (off_t) + ((self->d->block-1) * CAB_BLOCKMAX + outlen)); + } + } + else { + /* not the last block */ + if (outlen != CAB_BLOCKMAX) { + self->system->message(self->d->infh, + "WARNING; non-maximal data block"); + } + } + } /* if (avail) */ + } /* while (todo > 0) */ + return bytes - todo; +} + +static int cabd_sys_write(struct mspack_file *file, void *buffer, int bytes) { + struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) file; + self->d->offset += bytes; + if (self->d->outfh) { + return self->system->write(self->d->outfh, buffer, bytes); + } + return bytes; +} + +/*************************************** + * CABD_SYS_READ_BLOCK + *************************************** + * reads a whole data block from a cab file. the block may span more than + * one cab file, if it does then the fragments will be reassembled + */ +static int cabd_sys_read_block(struct mspack_system *sys, + struct mscabd_decompress_state *d, + int *out, int ignore_cksum) +{ + unsigned char hdr[cfdata_SIZEOF]; + unsigned int cksum; + int len; + + /* reset the input block pointer and end of block pointer */ + d->i_ptr = d->i_end = &d->input[0]; + + do { + /* read the block header */ + if (sys->read(d->infh, &hdr[0], cfdata_SIZEOF) != cfdata_SIZEOF) { + return MSPACK_ERR_READ; + } + + /* skip any reserved block headers */ + if (d->data->cab->block_resv && + sys->seek(d->infh, (off_t) d->data->cab->block_resv, + MSPACK_SYS_SEEK_CUR)) + { + return MSPACK_ERR_SEEK; + } + + /* blocks must not be over CAB_INPUTMAX in size */ + len = EndGetI16(&hdr[cfdata_CompressedSize]); + if (((d->i_end - d->i_ptr) + len) > CAB_INPUTMAX) { + D(("block size > CAB_INPUTMAX (%ld + %d)", + (long)(d->i_end - d->i_ptr), len)) + return MSPACK_ERR_DATAFORMAT; + } + + /* blocks must not expand to more than CAB_BLOCKMAX */ + if (EndGetI16(&hdr[cfdata_UncompressedSize]) > CAB_BLOCKMAX) { + D(("block size > CAB_BLOCKMAX")) + return MSPACK_ERR_DATAFORMAT; + } + + /* read the block data */ + if (sys->read(d->infh, d->i_end, len) != len) { + return MSPACK_ERR_READ; + } + + /* perform checksum test on the block (if one is stored) */ + if ((cksum = EndGetI32(&hdr[cfdata_CheckSum]))) { + unsigned int sum2 = cabd_checksum(d->i_end, (unsigned int) len, 0); + if (cabd_checksum(&hdr[4], 4, sum2) != cksum) { + if (!ignore_cksum) return MSPACK_ERR_CHECKSUM; + sys->message(d->infh, "WARNING; bad block checksum found"); + } + } + + /* advance end of block pointer to include newly read data */ + d->i_end += len; + + /* uncompressed size == 0 means this block was part of a split block + * and it continues as the first block of the next cabinet in the set. + * otherwise, this is the last part of the block, and no more block + * reading needs to be done. + */ + /* EXIT POINT OF LOOP -- uncompressed size != 0 */ + if ((*out = EndGetI16(&hdr[cfdata_UncompressedSize]))) { + return MSPACK_ERR_OK; + } + + /* otherwise, advance to next cabinet */ + + /* close current file handle */ + sys->close(d->infh); + d->infh = NULL; + + /* advance to next member in the cabinet set */ + if (!(d->data = d->data->next)) { + D(("ran out of splits in cabinet set")) + return MSPACK_ERR_DATAFORMAT; + } + + /* open next cab file */ + d->incab = d->data->cab; + if (!(d->infh = sys->open(sys, d->incab->base.filename, + MSPACK_SYS_OPEN_READ))) + { + return MSPACK_ERR_OPEN; + } + + /* seek to start of data blocks */ + if (sys->seek(d->infh, d->data->offset, MSPACK_SYS_SEEK_START)) { + return MSPACK_ERR_SEEK; + } + } while (1); + + /* not reached */ + return MSPACK_ERR_OK; +} + +static unsigned int cabd_checksum(unsigned char *data, unsigned int bytes, + unsigned int cksum) +{ + unsigned int len, ul = 0; + + for (len = bytes >> 2; len--; data += 4) { + cksum ^= ((data[0]) | (data[1]<<8) | (data[2]<<16) | (data[3]<<24)); + } + + switch (bytes & 3) { + case 3: ul |= *data++ << 16; + case 2: ul |= *data++ << 8; + case 1: ul |= *data; + } + cksum ^= ul; + + return cksum; +} + +/*************************************** + * NONED_INIT, NONED_DECOMPRESS, NONED_FREE + *************************************** + * the "not compressed" method decompressor + */ +struct noned_state { + struct mspack_system *sys; + struct mspack_file *i; + struct mspack_file *o; + unsigned char *buf; + int bufsize; +}; + +static struct noned_state *noned_init(struct mspack_system *sys, + struct mspack_file *in, + struct mspack_file *out, + int bufsize) +{ + struct noned_state *state = (struct noned_state *) sys->alloc(sys, sizeof(struct noned_state)); + unsigned char *buf = (unsigned char *) sys->alloc(sys, (size_t) bufsize); + if (state && buf) { + state->sys = sys; + state->i = in; + state->o = out; + state->buf = buf; + state->bufsize = bufsize; + } + else { + sys->free(buf); + sys->free(state); + state = NULL; + } + return state; +} + +static int noned_decompress(struct noned_state *s, off_t bytes) { + int run; + while (bytes > 0) { + run = (bytes > s->bufsize) ? s->bufsize : (int) bytes; + if (s->sys->read(s->i, &s->buf[0], run) != run) return MSPACK_ERR_READ; + if (s->sys->write(s->o, &s->buf[0], run) != run) return MSPACK_ERR_WRITE; + bytes -= run; + } + return MSPACK_ERR_OK; +} + +static void noned_free(struct noned_state *state) { + struct mspack_system *sys; + if (state) { + sys = state->sys; + sys->free(state->buf); + sys->free(state); + } +} + + +/*************************************** + * CABD_PARAM + *************************************** + * allows a parameter to be set + */ +static int cabd_param(struct mscab_decompressor *base, int param, int value) { + struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) base; + if (!self) return MSPACK_ERR_ARGS; + + switch (param) { + case MSCABD_PARAM_SEARCHBUF: + if (value < 4) return MSPACK_ERR_ARGS; + self->param[MSCABD_PARAM_SEARCHBUF] = value; + break; + case MSCABD_PARAM_FIXMSZIP: + self->param[MSCABD_PARAM_FIXMSZIP] = value; + break; + case MSCABD_PARAM_DECOMPBUF: + if (value < 4) return MSPACK_ERR_ARGS; + self->param[MSCABD_PARAM_DECOMPBUF] = value; + break; + default: + return MSPACK_ERR_ARGS; + } + return MSPACK_ERR_OK; +} + +/*************************************** + * CABD_ERROR + *************************************** + * returns the last error that occurred + */ +static int cabd_error(struct mscab_decompressor *base) { + struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) base; + return (self) ? self->error : MSPACK_ERR_ARGS; +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/cab.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/cab.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/cab.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/cab.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,134 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_CAB_H +#define MSPACK_CAB_H 1 + +#include +#include +#include + +/* generic CAB definitions */ + +/* structure offsets */ +#define cfhead_Signature (0x00) +#define cfhead_CabinetSize (0x08) +#define cfhead_FileOffset (0x10) +#define cfhead_MinorVersion (0x18) +#define cfhead_MajorVersion (0x19) +#define cfhead_NumFolders (0x1A) +#define cfhead_NumFiles (0x1C) +#define cfhead_Flags (0x1E) +#define cfhead_SetID (0x20) +#define cfhead_CabinetIndex (0x22) +#define cfhead_SIZEOF (0x24) +#define cfheadext_HeaderReserved (0x00) +#define cfheadext_FolderReserved (0x02) +#define cfheadext_DataReserved (0x03) +#define cfheadext_SIZEOF (0x04) +#define cffold_DataOffset (0x00) +#define cffold_NumBlocks (0x04) +#define cffold_CompType (0x06) +#define cffold_SIZEOF (0x08) +#define cffile_UncompressedSize (0x00) +#define cffile_FolderOffset (0x04) +#define cffile_FolderIndex (0x08) +#define cffile_Date (0x0A) +#define cffile_Time (0x0C) +#define cffile_Attribs (0x0E) +#define cffile_SIZEOF (0x10) +#define cfdata_CheckSum (0x00) +#define cfdata_CompressedSize (0x04) +#define cfdata_UncompressedSize (0x06) +#define cfdata_SIZEOF (0x08) + +/* flags */ +#define cffoldCOMPTYPE_MASK (0x000f) +#define cffoldCOMPTYPE_NONE (0x0000) +#define cffoldCOMPTYPE_MSZIP (0x0001) +#define cffoldCOMPTYPE_QUANTUM (0x0002) +#define cffoldCOMPTYPE_LZX (0x0003) +#define cfheadPREV_CABINET (0x0001) +#define cfheadNEXT_CABINET (0x0002) +#define cfheadRESERVE_PRESENT (0x0004) +#define cffileCONTINUED_FROM_PREV (0xFFFD) +#define cffileCONTINUED_TO_NEXT (0xFFFE) +#define cffileCONTINUED_PREV_AND_NEXT (0xFFFF) + +/* CAB data blocks are <= 32768 bytes in uncompressed form. Uncompressed + * blocks have zero growth. MSZIP guarantees that it won't grow above + * uncompressed size by more than 12 bytes. LZX guarantees it won't grow + * more than 6144 bytes. Quantum has no documentation, but the largest + * block seen in the wild is 337 bytes above uncompressed size. + */ +#define CAB_BLOCKMAX (32768) +#define CAB_INPUTMAX (CAB_BLOCKMAX+6144) + +/* There are no more than 65535 data blocks per folder, so a folder cannot + * be more than 32768*65535 bytes in length. As files cannot span more than + * one folder, this is also their max offset, length and offset+length limit. + */ +#define CAB_FOLDERMAX (65535) +#define CAB_LENGTHMAX (CAB_BLOCKMAX * CAB_FOLDERMAX) + +/* CAB compression definitions */ + +struct mscab_compressor_p { + struct mscab_compressor base; + struct mspack_system *system; + /* todo */ +}; + +/* CAB decompression definitions */ + +struct mscabd_decompress_state { + struct mscabd_folder_p *folder; /* current folder we're extracting from */ + struct mscabd_folder_data *data; /* current folder split we're in */ + unsigned int offset; /* uncompressed offset within folder */ + unsigned int block; /* which block are we decompressing? */ + struct mspack_system sys; /* special I/O code for decompressor */ + int comp_type; /* type of compression used by folder */ + int (*decompress)(void *, off_t); /* decompressor code */ + void *state; /* decompressor state */ + struct mscabd_cabinet_p *incab; /* cabinet where input data comes from */ + struct mspack_file *infh; /* input file handle */ + struct mspack_file *outfh; /* output file handle */ + unsigned char *i_ptr, *i_end; /* input data consumed, end */ + unsigned char input[CAB_INPUTMAX]; /* one input block of data */ +}; + +struct mscab_decompressor_p { + struct mscab_decompressor base; + struct mscabd_decompress_state *d; + struct mspack_system *system; + int param[3]; /* !!! MATCH THIS TO NUM OF PARAMS IN MSPACK.H !!! */ + int error, read_error; +}; + +struct mscabd_cabinet_p { + struct mscabd_cabinet base; + off_t blocks_off; /* offset to data blocks */ + int block_resv; /* reserved space in data blocks */ +}; + +/* there is one of these for every cabinet a folder spans */ +struct mscabd_folder_data { + struct mscabd_folder_data *next; + struct mscabd_cabinet_p *cab; /* cabinet file of this folder span */ + off_t offset; /* cabinet offset of first datablock */ +}; + +struct mscabd_folder_p { + struct mscabd_folder base; + struct mscabd_folder_data data; /* where are the data blocks? */ + struct mscabd_file *merge_prev; /* first file needing backwards merge */ + struct mscabd_file *merge_next; /* first file needing forwards merge */ +}; + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/chmc.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/chmc.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/chmc.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/chmc.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,24 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* CHM compression implementation */ + +#include +#include + +struct mschm_compressor * + mspack_create_chm_compressor(struct mspack_system *sys) +{ + /* todo */ + return NULL; +} + +void mspack_destroy_chm_compressor(struct mschm_compressor *self) { + /* todo */ +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/chmd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/chmd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/chmd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/chmd.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,1386 @@ +/* This file is part of libmspack. + * (C) 2003-2011 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* CHM decompression implementation */ + +#include +#include + +/* prototypes */ +static struct mschmd_header * chmd_open( + struct mschm_decompressor *base, const char *filename); +static struct mschmd_header * chmd_fast_open( + struct mschm_decompressor *base, const char *filename); +static struct mschmd_header *chmd_real_open( + struct mschm_decompressor *base, const char *filename, int entire); +static void chmd_close( + struct mschm_decompressor *base, struct mschmd_header *chm); +static int chmd_read_headers( + struct mspack_system *sys, struct mspack_file *fh, + struct mschmd_header *chm, int entire); +static int chmd_fast_find( + struct mschm_decompressor *base, struct mschmd_header *chm, + const char *filename, struct mschmd_file *f_ptr, int f_size); +static unsigned char *read_chunk( + struct mschm_decompressor_p *self, struct mschmd_header *chm, + struct mspack_file *fh, unsigned int chunk); +static int search_chunk( + struct mschmd_header *chm, const unsigned char *chunk, const char *filename, + const unsigned char **result, const unsigned char **result_end); +static inline int compare( + const char *s1, const char *s2, int l1, int l2); +static int chmd_extract( + struct mschm_decompressor *base, struct mschmd_file *file, + const char *filename); +static int chmd_sys_write( + struct mspack_file *file, void *buffer, int bytes); +static int chmd_init_decomp( + struct mschm_decompressor_p *self, struct mschmd_file *file); +static int read_reset_table( + struct mschm_decompressor_p *self, struct mschmd_sec_mscompressed *sec, + int entry, off_t *length_ptr, off_t *offset_ptr); +static int read_spaninfo( + struct mschm_decompressor_p *self, struct mschmd_sec_mscompressed *sec, + off_t *length_ptr); +static int find_sys_file( + struct mschm_decompressor_p *self, struct mschmd_sec_mscompressed *sec, + struct mschmd_file **f_ptr, const char *name); +static unsigned char *read_sys_file( + struct mschm_decompressor_p *self, struct mschmd_file *file); +static int chmd_error( + struct mschm_decompressor *base); +static int read_off64( + off_t *var, unsigned char *mem, struct mspack_system *sys, + struct mspack_file *fh); + +/* filenames of the system files used for decompression. + * Content and ControlData are essential. + * ResetTable is preferred, but SpanInfo can be used if not available + */ +static const char *content_name = "::DataSpace/Storage/MSCompressed/Content"; +static const char *control_name = "::DataSpace/Storage/MSCompressed/ControlData"; +static const char *spaninfo_name = "::DataSpace/Storage/MSCompressed/SpanInfo"; +static const char *rtable_name = "::DataSpace/Storage/MSCompressed/Transform/" + "{7FC28940-9D31-11D0-9B27-00A0C91E9C7C}/InstanceData/ResetTable"; + +/*************************************** + * MSPACK_CREATE_CHM_DECOMPRESSOR + *************************************** + * constructor + */ +struct mschm_decompressor * + mspack_create_chm_decompressor(struct mspack_system *sys) +{ + struct mschm_decompressor_p *self = NULL; + + if (!sys) sys = mspack_default_system; + if (!mspack_valid_system(sys)) return NULL; + + if ((self = (struct mschm_decompressor_p *) sys->alloc(sys, sizeof(struct mschm_decompressor_p)))) { + self->base.open = &chmd_open; + self->base.close = &chmd_close; + self->base.extract = &chmd_extract; + self->base.last_error = &chmd_error; + self->base.fast_open = &chmd_fast_open; + self->base.fast_find = &chmd_fast_find; + self->system = sys; + self->error = MSPACK_ERR_OK; + self->d = NULL; + } + return (struct mschm_decompressor *) self; +} + +/*************************************** + * MSPACK_DESTROY_CAB_DECOMPRESSOR + *************************************** + * destructor + */ +void mspack_destroy_chm_decompressor(struct mschm_decompressor *base) { + struct mschm_decompressor_p *self = (struct mschm_decompressor_p *) base; + if (self) { + struct mspack_system *sys = self->system; + if (self->d) { + if (self->d->infh) sys->close(self->d->infh); + if (self->d->state) lzxd_free(self->d->state); + sys->free(self->d); + } + sys->free(self); + } +} + +/*************************************** + * CHMD_OPEN + *************************************** + * opens a file and tries to read it as a CHM file. + * Calls chmd_real_open() with entire=1. + */ +static struct mschmd_header *chmd_open(struct mschm_decompressor *base, + const char *filename) +{ + return chmd_real_open(base, filename, 1); +} + +/*************************************** + * CHMD_FAST_OPEN + *************************************** + * opens a file and tries to read it as a CHM file, but does not read + * the file headers. Calls chmd_real_open() with entire=0 + */ +static struct mschmd_header *chmd_fast_open(struct mschm_decompressor *base, + const char *filename) +{ + return chmd_real_open(base, filename, 0); +} + +/*************************************** + * CHMD_REAL_OPEN + *************************************** + * the real implementation of chmd_open() and chmd_fast_open(). It simply + * passes the "entire" parameter to chmd_read_headers(), which will then + * either read all headers, or a bare mininum. + */ +static struct mschmd_header *chmd_real_open(struct mschm_decompressor *base, + const char *filename, int entire) +{ + struct mschm_decompressor_p *self = (struct mschm_decompressor_p *) base; + struct mschmd_header *chm = NULL; + struct mspack_system *sys; + struct mspack_file *fh; + int error; + + if (!base) return NULL; + sys = self->system; + + if ((fh = sys->open(sys, filename, MSPACK_SYS_OPEN_READ))) { + if ((chm = (struct mschmd_header *) sys->alloc(sys, sizeof(struct mschmd_header)))) { + chm->filename = filename; + error = chmd_read_headers(sys, fh, chm, entire); + if (error) { + /* if the error is DATAFORMAT, and there are some results, return + * partial results with a warning, rather than nothing */ + if (error == MSPACK_ERR_DATAFORMAT && (chm->files || chm->sysfiles)) { + sys->message(fh, "WARNING; contents are corrupt"); + error = MSPACK_ERR_OK; + } + else { + chmd_close(base, chm); + chm = NULL; + } + } + self->error = error; + } + else { + self->error = MSPACK_ERR_NOMEMORY; + } + sys->close(fh); + } + else { + self->error = MSPACK_ERR_OPEN; + } + return chm; +} + +/*************************************** + * CHMD_CLOSE + *************************************** + * frees all memory associated with a given mschmd_header + */ +static void chmd_close(struct mschm_decompressor *base, + struct mschmd_header *chm) +{ + struct mschm_decompressor_p *self = (struct mschm_decompressor_p *) base; + struct mschmd_file *fi, *nfi; + struct mspack_system *sys; + unsigned int i; + + if (!base) return; + sys = self->system; + + self->error = MSPACK_ERR_OK; + + /* free files */ + for (fi = chm->files; fi; fi = nfi) { + nfi = fi->next; + sys->free(fi); + } + for (fi = chm->sysfiles; fi; fi = nfi) { + nfi = fi->next; + sys->free(fi); + } + + /* if this CHM was being decompressed, free decompression state */ + if (self->d && (self->d->chm == chm)) { + if (self->d->infh) sys->close(self->d->infh); + if (self->d->state) lzxd_free(self->d->state); + sys->free(self->d); + self->d = NULL; + } + + /* if this CHM had a chunk cache, free it and contents */ + if (chm->chunk_cache) { + for (i = 0; i < chm->num_chunks; i++) sys->free(chm->chunk_cache[i]); + sys->free(chm->chunk_cache); + } + + sys->free(chm); +} + +/*************************************** + * CHMD_READ_HEADERS + *************************************** + * reads the basic CHM file headers. If the "entire" parameter is + * non-zero, all file entries will also be read. fills out a pre-existing + * mschmd_header structure, allocates memory for files as necessary + */ + +/* The GUIDs found in CHM headers */ +static const unsigned char guids[32] = { + /* {7C01FD10-7BAA-11D0-9E0C-00A0-C922-E6EC} */ + 0x10, 0xFD, 0x01, 0x7C, 0xAA, 0x7B, 0xD0, 0x11, + 0x9E, 0x0C, 0x00, 0xA0, 0xC9, 0x22, 0xE6, 0xEC, + /* {7C01FD11-7BAA-11D0-9E0C-00A0-C922-E6EC} */ + 0x11, 0xFD, 0x01, 0x7C, 0xAA, 0x7B, 0xD0, 0x11, + 0x9E, 0x0C, 0x00, 0xA0, 0xC9, 0x22, 0xE6, 0xEC +}; + +/* reads an encoded integer into a variable; 7 bits of data per byte, + * the high bit is used to indicate that there is another byte */ +#define READ_ENCINT(var) do { \ + (var) = 0; \ + do { \ + if (p >= end) goto chunk_end; \ + (var) = ((var) << 7) | (*p & 0x7F); \ + } while (*p++ & 0x80); \ +} while (0) + +static int chmd_read_headers(struct mspack_system *sys, struct mspack_file *fh, + struct mschmd_header *chm, int entire) +{ + unsigned int section, name_len, x, errors, num_chunks; + unsigned char buf[0x54], *chunk = NULL, *name, *p, *end; + struct mschmd_file *fi, *link = NULL; + off_t offset, length; + int num_entries; + + /* initialise pointers */ + chm->files = NULL; + chm->sysfiles = NULL; + chm->chunk_cache = NULL; + chm->sec0.base.chm = chm; + chm->sec0.base.id = 0; + chm->sec1.base.chm = chm; + chm->sec1.base.id = 1; + chm->sec1.content = NULL; + chm->sec1.control = NULL; + chm->sec1.spaninfo = NULL; + chm->sec1.rtable = NULL; + + /* read the first header */ + if (sys->read(fh, &buf[0], chmhead_SIZEOF) != chmhead_SIZEOF) { + return MSPACK_ERR_READ; + } + + /* check ITSF signature */ + if (EndGetI32(&buf[chmhead_Signature]) != 0x46535449) { + return MSPACK_ERR_SIGNATURE; + } + + /* check both header GUIDs */ + if (mspack_memcmp(&buf[chmhead_GUID1], &guids[0], 32L) != 0) { + D(("incorrect GUIDs")) + return MSPACK_ERR_SIGNATURE; + } + + chm->version = EndGetI32(&buf[chmhead_Version]); + chm->timestamp = EndGetM32(&buf[chmhead_Timestamp]); + chm->language = EndGetI32(&buf[chmhead_LanguageID]); + if (chm->version > 3) { + sys->message(fh, "WARNING; CHM version > 3"); + } + + /* read the header section table */ + if (sys->read(fh, &buf[0], chmhst3_SIZEOF) != chmhst3_SIZEOF) { + return MSPACK_ERR_READ; + } + + /* chmhst3_OffsetCS0 does not exist in version 1 or 2 CHM files. + * The offset will be corrected later, once HS1 is read. + */ + if (read_off64(&offset, &buf[chmhst_OffsetHS0], sys, fh) || + read_off64(&chm->dir_offset, &buf[chmhst_OffsetHS1], sys, fh) || + read_off64(&chm->sec0.offset, &buf[chmhst3_OffsetCS0], sys, fh)) + { + return MSPACK_ERR_DATAFORMAT; + } + + /* seek to header section 0 */ + if (sys->seek(fh, offset, MSPACK_SYS_SEEK_START)) { + return MSPACK_ERR_SEEK; + } + + /* read header section 0 */ + if (sys->read(fh, &buf[0], chmhs0_SIZEOF) != chmhs0_SIZEOF) { + return MSPACK_ERR_READ; + } + if (read_off64(&chm->length, &buf[chmhs0_FileLen], sys, fh)) { + return MSPACK_ERR_DATAFORMAT; + } + + /* seek to header section 1 */ + if (sys->seek(fh, chm->dir_offset, MSPACK_SYS_SEEK_START)) { + return MSPACK_ERR_SEEK; + } + + /* read header section 1 */ + if (sys->read(fh, &buf[0], chmhs1_SIZEOF) != chmhs1_SIZEOF) { + return MSPACK_ERR_READ; + } + + chm->dir_offset = sys->tell(fh); + chm->chunk_size = EndGetI32(&buf[chmhs1_ChunkSize]); + chm->density = EndGetI32(&buf[chmhs1_Density]); + chm->depth = EndGetI32(&buf[chmhs1_Depth]); + chm->index_root = EndGetI32(&buf[chmhs1_IndexRoot]); + chm->num_chunks = EndGetI32(&buf[chmhs1_NumChunks]); + chm->first_pmgl = EndGetI32(&buf[chmhs1_FirstPMGL]); + chm->last_pmgl = EndGetI32(&buf[chmhs1_LastPMGL]); + + if (chm->version < 3) { + /* versions before 3 don't have chmhst3_OffsetCS0 */ + chm->sec0.offset = chm->dir_offset + (chm->chunk_size * chm->num_chunks); + } + + /* check if content offset or file size is wrong */ + if (chm->sec0.offset > chm->length) { + D(("content section begins after file has ended")) + return MSPACK_ERR_DATAFORMAT; + } + + /* ensure there are chunks and that chunk size is + * large enough for signature and num_entries */ + if (chm->chunk_size < (pmgl_Entries + 2)) { + D(("chunk size not large enough")) + return MSPACK_ERR_DATAFORMAT; + } + if (chm->num_chunks == 0) { + D(("no chunks")) + return MSPACK_ERR_DATAFORMAT; + } + + /* The chunk_cache data structure is not great; large values for num_chunks + * or num_chunks*chunk_size can exhaust all memory. Until a better chunk + * cache is implemented, put arbitrary limits on num_chunks and chunk size. + */ + if (chm->num_chunks > 100000) { + D(("more than 100,000 chunks")) + return MSPACK_ERR_DATAFORMAT; + } + if ((off_t)chm->chunk_size * (off_t)chm->num_chunks > chm->length) { + D(("chunks larger than entire file")) + return MSPACK_ERR_DATAFORMAT; + } + + /* common sense checks on header section 1 fields */ + if ((chm->chunk_size & (chm->chunk_size - 1)) != 0) { + sys->message(fh, "WARNING; chunk size is not a power of two"); + } + if (chm->first_pmgl != 0) { + sys->message(fh, "WARNING; first PMGL chunk is not zero"); + } + if (chm->first_pmgl > chm->last_pmgl) { + D(("first pmgl chunk is after last pmgl chunk")) + return MSPACK_ERR_DATAFORMAT; + } + if (chm->index_root != 0xFFFFFFFF && chm->index_root > chm->num_chunks) { + D(("index_root outside valid range")) + return MSPACK_ERR_DATAFORMAT; + } + + /* if we are doing a quick read, stop here! */ + if (!entire) { + return MSPACK_ERR_OK; + } + + /* seek to the first PMGL chunk, and reduce the number of chunks to read */ + if ((x = chm->first_pmgl) != 0) { + if (sys->seek(fh,(off_t) (x * chm->chunk_size), MSPACK_SYS_SEEK_CUR)) { + return MSPACK_ERR_SEEK; + } + } + num_chunks = chm->last_pmgl - x + 1; + + if (!(chunk = (unsigned char *) sys->alloc(sys, (size_t)chm->chunk_size))) { + return MSPACK_ERR_NOMEMORY; + } + + /* read and process all chunks from FirstPMGL to LastPMGL */ + errors = 0; + while (num_chunks--) { + /* read next chunk */ + if (sys->read(fh, chunk, (int)chm->chunk_size) != (int)chm->chunk_size) { + sys->free(chunk); + return MSPACK_ERR_READ; + } + + /* process only directory (PMGL) chunks */ + if (EndGetI32(&chunk[pmgl_Signature]) != 0x4C474D50) continue; + + if (EndGetI32(&chunk[pmgl_QuickRefSize]) < 2) { + sys->message(fh, "WARNING; PMGL quickref area is too small"); + } + if (EndGetI32(&chunk[pmgl_QuickRefSize]) > + ((int)chm->chunk_size - pmgl_Entries)) + { + sys->message(fh, "WARNING; PMGL quickref area is too large"); + } + + p = &chunk[pmgl_Entries]; + end = &chunk[chm->chunk_size - 2]; + num_entries = EndGetI16(end); + + while (num_entries--) { + READ_ENCINT(name_len); + if (name_len > (unsigned int) (end - p)) goto chunk_end; + name = p; p += name_len; + READ_ENCINT(section); + READ_ENCINT(offset); + READ_ENCINT(length); + + /* empty files and directory names are stored as a file entry at + * offset 0 with length 0. We want to keep empty files, but not + * directory names, which end with a "/" */ + if ((offset == 0) && (length == 0)) { + if ((name_len > 0) && (name[name_len-1] == '/')) continue; + } + + if (section > 1) { + sys->message(fh, "invalid section number '%u'.", section); + continue; + } + + if (!(fi = (struct mschmd_file *) sys->alloc(sys, sizeof(struct mschmd_file) + name_len + 1))) { + sys->free(chunk); + return MSPACK_ERR_NOMEMORY; + } + + fi->next = NULL; + fi->filename = (char *) &fi[1]; + fi->section = ((section == 0) ? (struct mschmd_section *) (&chm->sec0) + : (struct mschmd_section *) (&chm->sec1)); + fi->offset = offset; + fi->length = length; + sys->copy(name, fi->filename, (size_t) name_len); + fi->filename[name_len] = '\0'; + + if (name[0] == ':' && name[1] == ':') { + /* system file */ + if (mspack_memcmp(&name[2], &content_name[2], 31L) == 0) { + if (mspack_memcmp(&name[33], &content_name[33], 8L) == 0) { + chm->sec1.content = fi; + } + else if (mspack_memcmp(&name[33], &control_name[33], 11L) == 0) { + chm->sec1.control = fi; + } + else if (mspack_memcmp(&name[33], &spaninfo_name[33], 8L) == 0) { + chm->sec1.spaninfo = fi; + } + else if (mspack_memcmp(&name[33], &rtable_name[33], 72L) == 0) { + chm->sec1.rtable = fi; + } + } + fi->next = chm->sysfiles; + chm->sysfiles = fi; + } + else { + /* normal file */ + if (link) link->next = fi; else chm->files = fi; + link = fi; + } + } + + /* this is reached either when num_entries runs out, or if + * reading data from the chunk reached a premature end of chunk */ + chunk_end: + if (num_entries >= 0) { + D(("chunk ended before all entries could be read")) + errors++; + } + + } + sys->free(chunk); + return (errors > 0) ? MSPACK_ERR_DATAFORMAT : MSPACK_ERR_OK; +} + +/*************************************** + * CHMD_FAST_FIND + *************************************** + * uses PMGI index chunks and quickref data to quickly locate a file + * directly from the on-disk index. + * + * TODO: protect against infinite loops in chunks (where pgml_NextChunk + * or a PGMI index entry point to an already visited chunk) + */ +static int chmd_fast_find(struct mschm_decompressor *base, + struct mschmd_header *chm, const char *filename, + struct mschmd_file *f_ptr, int f_size) +{ + struct mschm_decompressor_p *self = (struct mschm_decompressor_p *) base; + struct mspack_system *sys; + struct mspack_file *fh; + const unsigned char *chunk, *p, *end; + int err = MSPACK_ERR_OK, result = -1; + unsigned int n, sec; + + if (!self || !chm || !f_ptr || (f_size != sizeof(struct mschmd_file))) { + return MSPACK_ERR_ARGS; + } + sys = self->system; + + /* clear the results structure */ + memset(f_ptr, 0, f_size); + + if (!(fh = sys->open(sys, chm->filename, MSPACK_SYS_OPEN_READ))) { + return MSPACK_ERR_OPEN; + } + + /* go through PMGI chunk hierarchy to reach PMGL chunk */ + if (chm->index_root < chm->num_chunks) { + n = chm->index_root; + for (;;) { + if (!(chunk = read_chunk(self, chm, fh, n))) { + sys->close(fh); + return self->error; + } + + /* search PMGI/PMGL chunk. exit early if no entry found */ + if ((result = search_chunk(chm, chunk, filename, &p, &end)) <= 0) { + break; + } + + /* found result. loop around for next chunk if this is PMGI */ + if (chunk[3] == 0x4C) break; else READ_ENCINT(n); + } + } + else { + /* PMGL chunks only, search from first_pmgl to last_pmgl */ + for (n = chm->first_pmgl; n <= chm->last_pmgl; + n = EndGetI32(&chunk[pmgl_NextChunk])) + { + if (!(chunk = read_chunk(self, chm, fh, n))) { + err = self->error; + break; + } + + /* search PMGL chunk. exit if file found */ + if ((result = search_chunk(chm, chunk, filename, &p, &end)) > 0) { + break; + } + + /* stop simple infinite loops: can't visit the same chunk twice */ + if ((int)n == EndGetI32(&chunk[pmgl_NextChunk])) { + break; + } + } + } + + /* if we found a file, read it */ + if (result > 0) { + READ_ENCINT(sec); + f_ptr->section = (sec == 0) ? (struct mschmd_section *) &chm->sec0 + : (struct mschmd_section *) &chm->sec1; + READ_ENCINT(f_ptr->offset); + READ_ENCINT(f_ptr->length); + } + else if (result < 0) { + err = MSPACK_ERR_DATAFORMAT; + } + + sys->close(fh); + return self->error = err; + + chunk_end: + D(("read beyond end of chunk entries")) + sys->close(fh); + return self->error = MSPACK_ERR_DATAFORMAT; +} + +/* reads the given chunk into memory, storing it in a chunk cache + * so it doesn't need to be read from disk more than once + */ +static unsigned char *read_chunk(struct mschm_decompressor_p *self, + struct mschmd_header *chm, + struct mspack_file *fh, + unsigned int chunk_num) +{ + struct mspack_system *sys = self->system; + unsigned char *buf; + + /* check arguments - most are already checked by chmd_fast_find */ + if (chunk_num > chm->num_chunks) return NULL; + + /* ensure chunk cache is available */ + if (!chm->chunk_cache) { + size_t size = sizeof(unsigned char *) * chm->num_chunks; + if (!(chm->chunk_cache = (unsigned char **) sys->alloc(sys, size))) { + self->error = MSPACK_ERR_NOMEMORY; + return NULL; + } + memset(chm->chunk_cache, 0, size); + } + + /* try to answer out of chunk cache */ + if (chm->chunk_cache[chunk_num]) return chm->chunk_cache[chunk_num]; + + /* need to read chunk - allocate memory for it */ + if (!(buf = (unsigned char *) sys->alloc(sys, chm->chunk_size))) { + self->error = MSPACK_ERR_NOMEMORY; + return NULL; + } + + /* seek to block and read it */ + if (sys->seek(fh, (off_t) (chm->dir_offset + (chunk_num * chm->chunk_size)), + MSPACK_SYS_SEEK_START)) + { + self->error = MSPACK_ERR_SEEK; + sys->free(buf); + return NULL; + } + if (sys->read(fh, buf, (int)chm->chunk_size) != (int)chm->chunk_size) { + self->error = MSPACK_ERR_READ; + sys->free(buf); + return NULL; + } + + /* check the signature. Is is PMGL or PMGI? */ + if (!((buf[0] == 0x50) && (buf[1] == 0x4D) && (buf[2] == 0x47) && + ((buf[3] == 0x4C) || (buf[3] == 0x49)))) + { + self->error = MSPACK_ERR_SEEK; + sys->free(buf); + return NULL; + } + + /* all OK. Store chunk in cache and return it */ + return chm->chunk_cache[chunk_num] = buf; +} + +/* searches a PMGI/PMGL chunk for a given filename entry. Returns -1 on + * data format error, 0 if entry definitely not found, 1 if entry + * found. In the latter case, *result and *result_end are set pointing + * to that entry's data (either the "next chunk" ENCINT for a PMGI or + * the section, offset and length ENCINTs for a PMGL). + * + * In the case of PMGL chunks, the entry has definitely been + * found. In the case of PMGI chunks, the entry which points to the + * chunk that may eventually contain that entry has been found. + */ +static int search_chunk(struct mschmd_header *chm, + const unsigned char *chunk, + const char *filename, + const unsigned char **result, + const unsigned char **result_end) +{ + const unsigned char *start, *end, *p; + unsigned int qr_size, num_entries, qr_entries, qr_density, name_len; + unsigned int L, R, M, fname_len, entries_off, is_pmgl; + int cmp; + + fname_len = strlen(filename); + + /* PMGL chunk or PMGI chunk? (note: read_chunk() has already + * checked the rest of the characters in the chunk signature) */ + if (chunk[3] == 0x4C) { + is_pmgl = 1; + entries_off = pmgl_Entries; + } + else { + is_pmgl = 0; + entries_off = pmgi_Entries; + } + + /* Step 1: binary search first filename of each QR entry + * - target filename == entry + * found file + * - target filename < all entries + * file not found + * - target filename > all entries + * proceed to step 2 using final entry + * - target filename between two searched entries + * proceed to step 2 + */ + qr_size = EndGetI32(&chunk[pmgl_QuickRefSize]); + start = &chunk[chm->chunk_size - 2]; + end = &chunk[chm->chunk_size - qr_size]; + num_entries = EndGetI16(start); + qr_density = 1 + (1 << chm->density); + qr_entries = (num_entries + qr_density-1) / qr_density; + + if (num_entries == 0) { + D(("chunk has no entries")) + return -1; + } + + if (qr_size > chm->chunk_size) { + D(("quickref size > chunk size")) + return -1; + } + + *result_end = end; + + if (((int)qr_entries * 2) > (start - end)) { + D(("WARNING; more quickrefs than quickref space")) + qr_entries = 0; /* but we can live with it */ + } + + if (qr_entries > 0) { + L = 0; + R = qr_entries - 1; + do { + /* pick new midpoint */ + M = (L + R) >> 1; + + /* compare filename with entry QR points to */ + p = &chunk[entries_off + (M ? EndGetI16(start - (M << 1)) : 0)]; + READ_ENCINT(name_len); + if (name_len > (unsigned int) (end - p)) goto chunk_end; + cmp = compare(filename, (char *)p, fname_len, name_len); + + if (cmp == 0) break; + else if (cmp < 0) { if (M) R = M - 1; else return 0; } + else if (cmp > 0) L = M + 1; + } while (L <= R); + M = (L + R) >> 1; + + if (cmp == 0) { + /* exact match! */ + p += name_len; + *result = p; + return 1; + } + + /* otherwise, read the group of entries for QR entry M */ + p = &chunk[entries_off + (M ? EndGetI16(start - (M << 1)) : 0)]; + num_entries -= (M * qr_density); + if (num_entries > qr_density) num_entries = qr_density; + } + else { + p = &chunk[entries_off]; + } + + /* Step 2: linear search through the set of entries reached in step 1. + * - filename == any entry + * found entry + * - filename < all entries (PMGI) or any entry (PMGL) + * entry not found, stop now + * - filename > all entries + * entry not found (PMGL) / maybe found (PMGI) + * - + */ + *result = NULL; + while (num_entries-- > 0) { + READ_ENCINT(name_len); + if (name_len > (unsigned int) (end - p)) goto chunk_end; + cmp = compare(filename, (char *)p, fname_len, name_len); + p += name_len; + + if (cmp == 0) { + /* entry found */ + *result = p; + return 1; + } + + if (cmp < 0) { + /* entry not found (PMGL) / maybe found (PMGI) */ + break; + } + + /* read and ignore the rest of this entry */ + if (is_pmgl) { + READ_ENCINT(R); /* skip section */ + READ_ENCINT(R); /* skip offset */ + READ_ENCINT(R); /* skip length */ + } + else { + *result = p; /* store potential final result */ + READ_ENCINT(R); /* skip chunk number */ + } + } + + /* PMGL? not found. PMGI? maybe found */ + return (is_pmgl) ? 0 : (*result ? 1 : 0); + + chunk_end: + D(("reached end of chunk data while searching")) + return -1; +} + +#if HAVE_TOWLOWER +# if HAVE_WCTYPE_H +# include +# endif +# define TOLOWER(x) towlower(x) +#elif HAVE_TOLOWER +# if HAVE_CTYPE_H +# include +# endif +# define TOLOWER(x) tolower(x) +#else +# define TOLOWER(x) (((x)<0||(x)>256)?(x):mspack_tolower_map[(x)]) +/* Map of char -> lowercase char for the first 256 chars. Generated with: + * LC_CTYPE=en_GB.utf-8 perl -Mlocale -le 'print map{ord(lc chr).","} 0..255' + */ +static const unsigned char mspack_tolower_map[256] = { + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27, + 28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52, + 53,54,55,56,57,58,59,60,61,62,63,64,97,98,99,100,101,102,103,104,105,106, + 107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,91,92,93,94, + 95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114, + 115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133, + 134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152, + 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171, + 172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190, + 191,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241, + 242,243,244,245,246,215,248,249,250,251,252,253,254,223,224,225,226,227,228, + 229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247, + 248,249,250,251,252,253,254,255 +}; +#endif + +/* decodes a UTF-8 character from s[] into c. Will not read past e. + * doesn't test that extension bytes are %10xxxxxx. + * allows some overlong encodings. + */ +#define GET_UTF8_CHAR(s, e, c) do { \ + unsigned char x = *s++; \ + if (x < 0x80) c = x; \ + else if (x >= 0xC2 && x < 0xE0 && s < e) { \ + c = (x & 0x1F) << 6 | (*s++ & 0x3F); \ + } \ + else if (x >= 0xE0 && x < 0xF0 && s+1 < e) { \ + c = (x & 0x0F) << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); \ + s += 2; \ + } \ + else if (x >= 0xF0 && x <= 0xF5 && s+2 < e) { \ + c = (x & 0x07) << 18 | (s[0] & 0x3F) << 12 | \ + (s[1] & 0x3F) << 6 | (s[2] & 0x3F); \ + if (c > 0x10FFFF) c = 0xFFFD; \ + s += 3; \ + } \ + else c = 0xFFFD; \ +} while (0) + +/* case-insensitively compares two UTF8 encoded strings. String length for + * both strings must be provided, null bytes are not terminators */ +static inline int compare(const char *s1, const char *s2, int l1, int l2) { + register const unsigned char *p1 = (const unsigned char *) s1; + register const unsigned char *p2 = (const unsigned char *) s2; + register const unsigned char *e1 = p1 + l1, *e2 = p2 + l2; + int c1, c2; + + while (p1 < e1 && p2 < e2) { + GET_UTF8_CHAR(p1, e1, c1); + GET_UTF8_CHAR(p2, e2, c2); + if (c1 == c2) continue; + c1 = TOLOWER(c1); + c2 = TOLOWER(c2); + if (c1 != c2) return c1 - c2; + } + return l1 - l2; +} + + +/*************************************** + * CHMD_EXTRACT + *************************************** + * extracts a file from a CHM helpfile + */ +static int chmd_extract(struct mschm_decompressor *base, + struct mschmd_file *file, const char *filename) +{ + struct mschm_decompressor_p *self = (struct mschm_decompressor_p *) base; + struct mspack_system *sys; + struct mschmd_header *chm; + struct mspack_file *fh; + off_t bytes; + + if (!self) return MSPACK_ERR_ARGS; + if (!file || !file->section) return self->error = MSPACK_ERR_ARGS; + sys = self->system; + chm = file->section->chm; + + /* create decompression state if it doesn't exist */ + if (!self->d) { + self->d = (struct mschmd_decompress_state *) sys->alloc(sys, sizeof(struct mschmd_decompress_state)); + if (!self->d) return self->error = MSPACK_ERR_NOMEMORY; + self->d->chm = chm; + self->d->offset = 0; + self->d->state = NULL; + self->d->sys = *sys; + self->d->sys.write = &chmd_sys_write; + self->d->infh = NULL; + self->d->outfh = NULL; + } + + /* open input chm file if not open, or the open one is a different chm */ + if (!self->d->infh || (self->d->chm != chm)) { + if (self->d->infh) sys->close(self->d->infh); + if (self->d->state) lzxd_free(self->d->state); + self->d->chm = chm; + self->d->offset = 0; + self->d->state = NULL; + self->d->infh = sys->open(sys, chm->filename, MSPACK_SYS_OPEN_READ); + if (!self->d->infh) return self->error = MSPACK_ERR_OPEN; + } + + /* open file for output */ + if (!(fh = sys->open(sys, filename, MSPACK_SYS_OPEN_WRITE))) { + return self->error = MSPACK_ERR_OPEN; + } + + /* if file is empty, simply creating it is enough */ + if (!file->length) { + sys->close(fh); + return self->error = MSPACK_ERR_OK; + } + + self->error = MSPACK_ERR_OK; + + switch (file->section->id) { + case 0: /* Uncompressed section file */ + /* simple seek + copy */ + if (sys->seek(self->d->infh, file->section->chm->sec0.offset + + file->offset, MSPACK_SYS_SEEK_START)) + { + self->error = MSPACK_ERR_SEEK; + } + else { + unsigned char buf[512]; + off_t length = file->length; + while (length > 0) { + int run = sizeof(buf); + if ((off_t)run > length) run = (int)length; + if (sys->read(self->d->infh, &buf[0], run) != run) { + self->error = MSPACK_ERR_READ; + break; + } + if (sys->write(fh, &buf[0], run) != run) { + self->error = MSPACK_ERR_WRITE; + break; + } + length -= run; + } + } + break; + + case 1: /* MSCompressed section file */ + /* (re)initialise compression state if we it is not yet initialised, + * or we have advanced too far and have to backtrack + */ + if (!self->d->state || (file->offset < self->d->offset)) { + if (self->d->state) { + lzxd_free(self->d->state); + self->d->state = NULL; + } + if (chmd_init_decomp(self, file)) break; + } + + /* seek to input data */ + if (sys->seek(self->d->infh, self->d->inoffset, MSPACK_SYS_SEEK_START)) { + self->error = MSPACK_ERR_SEEK; + break; + } + + /* get to correct offset. */ + self->d->outfh = NULL; + if ((bytes = file->offset - self->d->offset)) { + self->error = lzxd_decompress(self->d->state, bytes); + } + + /* if getting to the correct offset was error free, unpack file */ + if (!self->error) { + self->d->outfh = fh; + self->error = lzxd_decompress(self->d->state, file->length); + } + + /* save offset in input source stream, in case there is a section 0 + * file between now and the next section 1 file extracted */ + self->d->inoffset = sys->tell(self->d->infh); + + /* if an LZX error occured, the LZX decompressor is now useless */ + if (self->error) { + if (self->d->state) lzxd_free(self->d->state); + self->d->state = NULL; + } + break; + } + + sys->close(fh); + return self->error; +} + +/*************************************** + * CHMD_SYS_WRITE + *************************************** + * chmd_sys_write is the internal writer function which the decompressor + * uses. If either writes data to disk (self->d->outfh) with the real + * sys->write() function, or does nothing with the data when + * self->d->outfh == NULL. advances self->d->offset. + */ +static int chmd_sys_write(struct mspack_file *file, void *buffer, int bytes) { + struct mschm_decompressor_p *self = (struct mschm_decompressor_p *) file; + self->d->offset += bytes; + if (self->d->outfh) { + return self->system->write(self->d->outfh, buffer, bytes); + } + return bytes; +} + +/*************************************** + * CHMD_INIT_DECOMP + *************************************** + * Initialises the LZX decompressor to decompress the compressed stream, + * from the nearest reset offset and length that is needed for the given + * file. + */ +static int chmd_init_decomp(struct mschm_decompressor_p *self, + struct mschmd_file *file) +{ + int window_size, window_bits, reset_interval, entry, err; + struct mspack_system *sys = self->system; + struct mschmd_sec_mscompressed *sec; + unsigned char *data; + off_t length, offset; + + sec = (struct mschmd_sec_mscompressed *) file->section; + + /* ensure we have a mscompressed content section */ + err = find_sys_file(self, sec, &sec->content, content_name); + if (err) return self->error = err; + + /* ensure we have a ControlData file */ + err = find_sys_file(self, sec, &sec->control, control_name); + if (err) return self->error = err; + + /* read ControlData */ + if (sec->control->length < lzxcd_SIZEOF) { + D(("ControlData file is too short")) + return self->error = MSPACK_ERR_DATAFORMAT; + } + if (!(data = read_sys_file(self, sec->control))) { + D(("can't read mscompressed control data file")) + return self->error; + } + + /* check LZXC signature */ + if (EndGetI32(&data[lzxcd_Signature]) != 0x43585A4C) { + sys->free(data); + return self->error = MSPACK_ERR_SIGNATURE; + } + + /* read reset_interval and window_size and validate version number */ + switch (EndGetI32(&data[lzxcd_Version])) { + case 1: + reset_interval = EndGetI32(&data[lzxcd_ResetInterval]); + window_size = EndGetI32(&data[lzxcd_WindowSize]); + break; + case 2: + reset_interval = EndGetI32(&data[lzxcd_ResetInterval]) * LZX_FRAME_SIZE; + window_size = EndGetI32(&data[lzxcd_WindowSize]) * LZX_FRAME_SIZE; + break; + default: + D(("bad controldata version")) + sys->free(data); + return self->error = MSPACK_ERR_DATAFORMAT; + } + + /* free ControlData */ + sys->free(data); + + /* find window_bits from window_size */ + switch (window_size) { + case 0x008000: window_bits = 15; break; + case 0x010000: window_bits = 16; break; + case 0x020000: window_bits = 17; break; + case 0x040000: window_bits = 18; break; + case 0x080000: window_bits = 19; break; + case 0x100000: window_bits = 20; break; + case 0x200000: window_bits = 21; break; + default: + D(("bad controldata window size")) + return self->error = MSPACK_ERR_DATAFORMAT; + } + + /* validate reset_interval */ + if (reset_interval == 0 || reset_interval % LZX_FRAME_SIZE) { + D(("bad controldata reset interval")) + return self->error = MSPACK_ERR_DATAFORMAT; + } + + /* which reset table entry would we like? */ + entry = file->offset / reset_interval; + /* convert from reset interval multiple (usually 64k) to 32k frames */ + entry *= reset_interval / LZX_FRAME_SIZE; + + /* read the reset table entry */ + if (read_reset_table(self, sec, entry, &length, &offset)) { + /* the uncompressed length given in the reset table is dishonest. + * the uncompressed data is always padded out from the given + * uncompressed length up to the next reset interval */ + length += reset_interval - 1; + length &= -reset_interval; + } + else { + /* if we can't read the reset table entry, just start from + * the beginning. Use spaninfo to get the uncompressed length */ + entry = 0; + offset = 0; + err = read_spaninfo(self, sec, &length); + } + if (err) return self->error = err; + + /* get offset of compressed data stream: + * = offset of uncompressed section from start of file + * + offset of compressed stream from start of uncompressed section + * + offset of chosen reset interval from start of compressed stream */ + self->d->inoffset = file->section->chm->sec0.offset + sec->content->offset + offset; + + /* set start offset and overall remaining stream length */ + self->d->offset = entry * LZX_FRAME_SIZE; + length -= self->d->offset; + + /* initialise LZX stream */ + self->d->state = lzxd_init(&self->d->sys, self->d->infh, + (struct mspack_file *) self, window_bits, + reset_interval / LZX_FRAME_SIZE, + 4096, length, 0); + if (!self->d->state) self->error = MSPACK_ERR_NOMEMORY; + return self->error; +} + +/*************************************** + * READ_RESET_TABLE + *************************************** + * Reads one entry out of the reset table. Also reads the uncompressed + * data length. Writes these to offset_ptr and length_ptr respectively. + * Returns non-zero for success, zero for failure. + */ +static int read_reset_table(struct mschm_decompressor_p *self, + struct mschmd_sec_mscompressed *sec, + int entry, off_t *length_ptr, off_t *offset_ptr) +{ + struct mspack_system *sys = self->system; + unsigned char *data; + unsigned int pos, entrysize; + + /* do we have a ResetTable file? */ + int err = find_sys_file(self, sec, &sec->rtable, rtable_name); + if (err) return 0; + + /* read ResetTable file */ + if (sec->rtable->length < lzxrt_headerSIZEOF) { + D(("ResetTable file is too short")) + return 0; + } + if (!(data = read_sys_file(self, sec->rtable))) { + D(("can't read reset table")) + return 0; + } + + /* check sanity of reset table */ + if (EndGetI32(&data[lzxrt_FrameLen]) != LZX_FRAME_SIZE) { + D(("bad reset table frame length")) + sys->free(data); + return 0; + } + + /* get the uncompressed length of the LZX stream */ + if (read_off64(length_ptr, &data[lzxrt_UncompLen], sys, self->d->infh)) { + sys->free(data); + return 0; + } + + entrysize = EndGetI32(&data[lzxrt_EntrySize]); + pos = EndGetI32(&data[lzxrt_TableOffset]) + (entry * entrysize); + + /* ensure reset table entry for this offset exists */ + if (entry < EndGetI32(&data[lzxrt_NumEntries]) && + pos <= (sec->rtable->length - entrysize)) + { + switch (entrysize) { + case 4: + *offset_ptr = EndGetI32(&data[pos]); + err = 0; + break; + case 8: + err = read_off64(offset_ptr, &data[pos], sys, self->d->infh); + break; + default: + D(("reset table entry size neither 4 nor 8")) + err = 1; + break; + } + } + else { + D(("bad reset interval")) + err = 1; + } + + /* free the reset table */ + sys->free(data); + + /* return success */ + return (err == 0); +} + +/*************************************** + * READ_SPANINFO + *************************************** + * Reads the uncompressed data length from the spaninfo file. + * Returns zero for success or a non-zero error code for failure. + */ +static int read_spaninfo(struct mschm_decompressor_p *self, + struct mschmd_sec_mscompressed *sec, + off_t *length_ptr) +{ + struct mspack_system *sys = self->system; + unsigned char *data; + + /* find SpanInfo file */ + int err = find_sys_file(self, sec, &sec->spaninfo, spaninfo_name); + if (err) return MSPACK_ERR_DATAFORMAT; + + /* check it's large enough */ + if (sec->spaninfo->length != 8) { + D(("SpanInfo file is wrong size")) + return MSPACK_ERR_DATAFORMAT; + } + + /* read the SpanInfo file */ + if (!(data = read_sys_file(self, sec->spaninfo))) { + D(("can't read SpanInfo file")) + return self->error; + } + + /* get the uncompressed length of the LZX stream */ + err = read_off64(length_ptr, data, sys, self->d->infh); + + sys->free(data); + return (err) ? MSPACK_ERR_DATAFORMAT : MSPACK_ERR_OK; +} + +/*************************************** + * FIND_SYS_FILE + *************************************** + * Uses chmd_fast_find to locate a system file, and fills out that system + * file's entry and links it into the list of system files. Returns zero + * for success, non-zero for both failure and the file not existing. + */ +static int find_sys_file(struct mschm_decompressor_p *self, + struct mschmd_sec_mscompressed *sec, + struct mschmd_file **f_ptr, const char *name) +{ + struct mspack_system *sys = self->system; + struct mschmd_file result; + + /* already loaded */ + if (*f_ptr) return MSPACK_ERR_OK; + + /* try using fast_find to find the file - return DATAFORMAT error if + * it fails, or successfully doesn't find the file */ + if (chmd_fast_find((struct mschm_decompressor *) self, sec->base.chm, + name, &result, (int)sizeof(result)) || !result.section) + { + return MSPACK_ERR_DATAFORMAT; + } + + if (!(*f_ptr = (struct mschmd_file *) sys->alloc(sys, sizeof(result)))) { + return MSPACK_ERR_NOMEMORY; + } + + /* copy result */ + *(*f_ptr) = result; + (*f_ptr)->filename = (char *) name; + + /* link file into sysfiles list */ + (*f_ptr)->next = sec->base.chm->sysfiles; + sec->base.chm->sysfiles = *f_ptr; + return MSPACK_ERR_OK; +} + +/*************************************** + * READ_SYS_FILE + *************************************** + * Allocates memory for a section 0 (uncompressed) file and reads it into + * memory. + */ +static unsigned char *read_sys_file(struct mschm_decompressor_p *self, + struct mschmd_file *file) +{ + struct mspack_system *sys = self->system; + unsigned char *data = NULL; + int len; + + if (!file || !file->section || (file->section->id != 0)) { + self->error = MSPACK_ERR_DATAFORMAT; + return NULL; + } + + len = (int) file->length; + + if (!(data = (unsigned char *) sys->alloc(sys, (size_t) len))) { + self->error = MSPACK_ERR_NOMEMORY; + return NULL; + } + if (sys->seek(self->d->infh, file->section->chm->sec0.offset + + file->offset, MSPACK_SYS_SEEK_START)) + { + self->error = MSPACK_ERR_SEEK; + sys->free(data); + return NULL; + } + if (sys->read(self->d->infh, data, len) != len) { + self->error = MSPACK_ERR_READ; + sys->free(data); + return NULL; + } + return data; +} + +/*************************************** + * CHMD_ERROR + *************************************** + * returns the last error that occurred + */ +static int chmd_error(struct mschm_decompressor *base) { + struct mschm_decompressor_p *self = (struct mschm_decompressor_p *) base; + return (self) ? self->error : MSPACK_ERR_ARGS; +} + +/*************************************** + * READ_OFF64 + *************************************** + * Reads a 64-bit signed integer from memory in Intel byte order. + * If running on a system with a 64-bit off_t, this is simply done. + * If running on a system with a 32-bit off_t, offsets up to 0x7FFFFFFF + * are accepted, offsets beyond that cause an error message. + */ +static int read_off64(off_t *var, unsigned char *mem, + struct mspack_system *sys, struct mspack_file *fh) +{ +#ifdef LARGEFILE_SUPPORT + *var = EndGetI64(mem); +#else + *var = EndGetI32(mem); + if ((*var & 0x80000000) || EndGetI32(mem+4)) { + sys->message(fh, (char *)largefile_msg); + return 1; + } +#endif + return 0; +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/chm.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/chm.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/chm.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/chm.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,122 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_CHM_H +#define MSPACK_CHM_H 1 + +#include + +/* generic CHM definitions */ + +#define chmhead_Signature (0x0000) +#define chmhead_Version (0x0004) +#define chmhead_HeaderLen (0x0008) +#define chmhead_Unknown1 (0x000C) +#define chmhead_Timestamp (0x0010) +#define chmhead_LanguageID (0x0014) +#define chmhead_GUID1 (0x0018) +#define chmhead_GUID2 (0x0028) +#define chmhead_SIZEOF (0x0038) + +#define chmhst_OffsetHS0 (0x0000) +#define chmhst_LengthHS0 (0x0008) +#define chmhst_OffsetHS1 (0x0010) +#define chmhst_LengthHS1 (0x0018) +#define chmhst_SIZEOF (0x0020) +#define chmhst3_OffsetCS0 (0x0020) +#define chmhst3_SIZEOF (0x0028) + +#define chmhs0_Unknown1 (0x0000) +#define chmhs0_Unknown2 (0x0004) +#define chmhs0_FileLen (0x0008) +#define chmhs0_Unknown3 (0x0010) +#define chmhs0_Unknown4 (0x0014) +#define chmhs0_SIZEOF (0x0018) + +#define chmhs1_Signature (0x0000) +#define chmhs1_Version (0x0004) +#define chmhs1_HeaderLen (0x0008) +#define chmhs1_Unknown1 (0x000C) +#define chmhs1_ChunkSize (0x0010) +#define chmhs1_Density (0x0014) +#define chmhs1_Depth (0x0018) +#define chmhs1_IndexRoot (0x001C) +#define chmhs1_FirstPMGL (0x0020) +#define chmhs1_LastPMGL (0x0024) +#define chmhs1_Unknown2 (0x0028) +#define chmhs1_NumChunks (0x002C) +#define chmhs1_LanguageID (0x0030) +#define chmhs1_GUID (0x0034) +#define chmhs1_Unknown3 (0x0044) +#define chmhs1_Unknown4 (0x0048) +#define chmhs1_Unknown5 (0x004C) +#define chmhs1_Unknown6 (0x0050) +#define chmhs1_SIZEOF (0x0054) + +#define pmgl_Signature (0x0000) +#define pmgl_QuickRefSize (0x0004) +#define pmgl_Unknown1 (0x0008) +#define pmgl_PrevChunk (0x000C) +#define pmgl_NextChunk (0x0010) +#define pmgl_Entries (0x0014) +#define pmgl_headerSIZEOF (0x0014) + +#define pmgi_Signature (0x0000) +#define pmgi_QuickRefSize (0x0004) +#define pmgi_Entries (0x0008) +#define pmgi_headerSIZEOF (0x000C) + +#define lzxcd_Length (0x0000) +#define lzxcd_Signature (0x0004) +#define lzxcd_Version (0x0008) +#define lzxcd_ResetInterval (0x000C) +#define lzxcd_WindowSize (0x0010) +#define lzxcd_CacheSize (0x0014) +#define lzxcd_Unknown1 (0x0018) +#define lzxcd_SIZEOF (0x001C) + +#define lzxrt_Unknown1 (0x0000) +#define lzxrt_NumEntries (0x0004) +#define lzxrt_EntrySize (0x0008) +#define lzxrt_TableOffset (0x000C) +#define lzxrt_UncompLen (0x0010) +#define lzxrt_CompLen (0x0018) +#define lzxrt_FrameLen (0x0020) +#define lzxrt_Entries (0x0028) +#define lzxrt_headerSIZEOF (0x0028) + +/* CHM compression definitions */ + +struct mschm_compressor_p { + struct mschm_compressor base; + struct mspack_system *system; + char *temp_file; + int use_temp_file; + int error; +}; + +/* CHM decompression definitions */ +struct mschmd_decompress_state { + struct mschmd_header *chm; /* CHM file being decompressed */ + off_t offset; /* uncompressed offset within folder */ + off_t inoffset; /* offset in input file */ + struct lzxd_stream *state; /* LZX decompressor state */ + struct mspack_system sys; /* special I/O code for decompressor */ + struct mspack_file *infh; /* input file handle */ + struct mspack_file *outfh; /* output file handle */ +}; + +struct mschm_decompressor_p { + struct mschm_decompressor base; + struct mspack_system *system; + struct mschmd_decompress_state *d; + int error; +}; + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/crc32.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/crc32.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/crc32.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/crc32.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,95 @@ +/* + * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or + * code or tables extracted from it, as desired without restriction. + * + * First, the polynomial itself and its table of feedback terms. The + * polynomial is + * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 + * + * Note that we take it "backwards" and put the highest-order term in + * the lowest-order bit. The X^32 term is "implied"; the LSB is the + * X^31 term, etc. The X^0 term (usually shown as "+1") results in + * the MSB being 1 + * + * Note that the usual hardware shift register implementation, which + * is what we're using (we're merely optimizing it by doing eight-bit + * chunks at a time) shifts bits into the lowest-order term. In our + * implementation, that means shifting towards the right. Why do we + * do it this way? Because the calculated CRC must be transmitted in + * order from highest-order term to lowest-order term. UARTs transmit + * characters in order from LSB to MSB. By storing the CRC this way + * we hand it to the UART in the order low-byte to high-byte; the UART + * sends each low-bit to hight-bit; and the result is transmission bit + * by bit from highest- to lowest-order term without requiring any bit + * shuffling on our part. Reception works similarly + * + * The feedback terms table consists of 256, 32-bit entries. Notes + * + * The table can be generated at runtime if desired; code to do so + * is shown later. It might not be obvious, but the feedback + * terms simply represent the results of eight shift/xor opera + * tions for all combinations of data and CRC register values + * + * The values must be right-shifted by eight bits by the "updcrc + * logic; the shift must be unsigned (bring in zeroes). On some + * hardware you could probably optimize the shift in assembler by + * using byte-swap instructions + * polynomial $edb88320 + */ + +#include "crc32.h" + +const unsigned int crc32_table[256] = { + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, + 0x2d02ef8dL +}; diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/crc32.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/crc32.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/crc32.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/crc32.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,17 @@ +#ifndef CRC32_H +#define CRC32_H + +extern const unsigned int crc32_table[256]; + +/* Return a 32-bit CRC of the contents of the buffer. */ + +static inline unsigned int +crc32(unsigned int val, const void *ss, int len) +{ + const unsigned char *s = ss; + while (--len >= 0) + val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8); + return val; +} + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/des.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/des.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/des.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/des.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,15 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_DES_H +#define MSPACK_DES_H 1 + +/* DES encryption / decryption definitions */ + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/hlpc.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/hlpc.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/hlpc.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/hlpc.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,24 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* HLP compression implementation */ + +#include +#include + +struct mshlp_compressor * + mspack_create_hlp_compressor(struct mspack_system *sys) +{ + /* todo */ + return NULL; +} + +void mspack_destroy_hlp_compressor(struct mshlp_compressor *self) { + /* todo */ +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/hlpd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/hlpd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/hlpd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/hlpd.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,24 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* HLP decompression implementation */ + +#include +#include + +struct mshlp_decompressor * + mspack_create_hlp_decompressor(struct mspack_system *sys) +{ + /* todo */ + return NULL; +} + +void mspack_destroy_hlp_decompressor(struct mshlp_decompressor *self) { + /* todo */ +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/hlp.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/hlp.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/hlp.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/hlp.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,33 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_HLP_H +#define MSPACK_HLP_H 1 + +#include + +/* generic HLP definitions */ + +/* HLP compression definitions */ + +struct mshlp_compressor_p { + struct mshlp_compressor base; + struct mspack_system *system; + /* todo */ +}; + +/* HLP decompression definitions */ + +struct mshlp_decompressor_p { + struct mshlp_decompressor base; + struct mspack_system *system; + /* todo */ +}; + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/kwajc.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/kwajc.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/kwajc.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/kwajc.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,24 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* KWAJ compression implementation */ + +#include +#include + +struct mskwaj_compressor * + mspack_create_kwaj_compressor(struct mspack_system *sys) +{ + /* todo */ + return NULL; +} + +void mspack_destroy_kwaj_compressor(struct mskwaj_compressor *self) { + /* todo */ +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/kwajd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/kwajd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/kwajd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/kwajd.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,560 @@ +/* This file is part of libmspack. + * (C) 2003-2011 Stuart Caie. + * + * KWAJ is a format very similar to SZDD. KWAJ method 3 (LZH) was + * written by Jeff Johnson. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* KWAJ decompression implementation */ + +#include +#include +#include + +/* prototypes */ +static struct mskwajd_header *kwajd_open( + struct mskwaj_decompressor *base, const char *filename); +static void kwajd_close( + struct mskwaj_decompressor *base, struct mskwajd_header *hdr); +static int kwajd_read_headers( + struct mspack_system *sys, struct mspack_file *fh, + struct mskwajd_header *hdr); +static int kwajd_extract( + struct mskwaj_decompressor *base, struct mskwajd_header *hdr, + const char *filename); +static int kwajd_decompress( + struct mskwaj_decompressor *base, const char *input, const char *output); +static int kwajd_error( + struct mskwaj_decompressor *base); + +static struct kwajd_stream *lzh_init( + struct mspack_system *sys, struct mspack_file *in, struct mspack_file *out); +static int lzh_decompress( + struct kwajd_stream *kwaj); +static void lzh_free( + struct kwajd_stream *kwaj); +static int lzh_read_lens( + struct kwajd_stream *kwaj, + unsigned int type, unsigned int numsyms, + unsigned char *lens); +static int lzh_read_input( + struct kwajd_stream *kwaj); + + +/*************************************** + * MSPACK_CREATE_KWAJ_DECOMPRESSOR + *************************************** + * constructor + */ +struct mskwaj_decompressor * + mspack_create_kwaj_decompressor(struct mspack_system *sys) +{ + struct mskwaj_decompressor_p *self = NULL; + + if (!sys) sys = mspack_default_system; + if (!mspack_valid_system(sys)) return NULL; + + if ((self = (struct mskwaj_decompressor_p *) sys->alloc(sys, sizeof(struct mskwaj_decompressor_p)))) { + self->base.open = &kwajd_open; + self->base.close = &kwajd_close; + self->base.extract = &kwajd_extract; + self->base.decompress = &kwajd_decompress; + self->base.last_error = &kwajd_error; + self->system = sys; + self->error = MSPACK_ERR_OK; + } + return (struct mskwaj_decompressor *) self; +} + +/*************************************** + * MSPACK_DESTROY_KWAJ_DECOMPRESSOR + *************************************** + * destructor + */ +void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *base) +{ + struct mskwaj_decompressor_p *self = (struct mskwaj_decompressor_p *) base; + if (self) { + struct mspack_system *sys = self->system; + sys->free(self); + } +} + +/*************************************** + * KWAJD_OPEN + *************************************** + * opens a KWAJ file without decompressing, reads header + */ +static struct mskwajd_header *kwajd_open(struct mskwaj_decompressor *base, + const char *filename) +{ + struct mskwaj_decompressor_p *self = (struct mskwaj_decompressor_p *) base; + struct mskwajd_header *hdr; + struct mspack_system *sys; + struct mspack_file *fh; + + if (!self) return NULL; + sys = self->system; + + fh = sys->open(sys, filename, MSPACK_SYS_OPEN_READ); + hdr = (struct mskwajd_header *) sys->alloc(sys, sizeof(struct mskwajd_header_p)); + if (fh && hdr) { + ((struct mskwajd_header_p *) hdr)->fh = fh; + self->error = kwajd_read_headers(sys, fh, hdr); + } + else { + if (!fh) self->error = MSPACK_ERR_OPEN; + if (!hdr) self->error = MSPACK_ERR_NOMEMORY; + } + + if (self->error) { + if (fh) sys->close(fh); + if (hdr) sys->free(hdr); + hdr = NULL; + } + + return hdr; +} + +/*************************************** + * KWAJD_CLOSE + *************************************** + * closes a KWAJ file + */ +static void kwajd_close(struct mskwaj_decompressor *base, + struct mskwajd_header *hdr) +{ + struct mskwaj_decompressor_p *self = (struct mskwaj_decompressor_p *) base; + struct mskwajd_header_p *hdr_p = (struct mskwajd_header_p *) hdr; + + if (!self || !self->system) return; + + /* close the file handle associated */ + self->system->close(hdr_p->fh); + + /* free the memory associated */ + self->system->free(hdr); + + self->error = MSPACK_ERR_OK; +} + +/*************************************** + * KWAJD_READ_HEADERS + *************************************** + * reads the headers of a KWAJ format file + */ +static int kwajd_read_headers(struct mspack_system *sys, + struct mspack_file *fh, + struct mskwajd_header *hdr) +{ + unsigned char buf[16]; + int i; + + /* read in the header */ + if (sys->read(fh, &buf[0], kwajh_SIZEOF) != kwajh_SIZEOF) { + return MSPACK_ERR_READ; + } + + /* check for "KWAJ" signature */ + if (((unsigned int) EndGetI32(&buf[kwajh_Signature1]) != 0x4A41574B) || + ((unsigned int) EndGetI32(&buf[kwajh_Signature2]) != 0xD127F088)) + { + return MSPACK_ERR_SIGNATURE; + } + + /* basic header fields */ + hdr->comp_type = EndGetI16(&buf[kwajh_CompMethod]); + hdr->data_offset = EndGetI16(&buf[kwajh_DataOffset]); + hdr->headers = EndGetI16(&buf[kwajh_Flags]); + hdr->length = 0; + hdr->filename = NULL; + hdr->extra = NULL; + hdr->extra_length = 0; + + /* optional headers */ + + /* 4 bytes: length of unpacked file */ + if (hdr->headers & MSKWAJ_HDR_HASLENGTH) { + if (sys->read(fh, &buf[0], 4) != 4) return MSPACK_ERR_READ; + hdr->length = EndGetI32(&buf[0]); + } + + /* 2 bytes: unknown purpose */ + if (hdr->headers & MSKWAJ_HDR_HASUNKNOWN1) { + if (sys->read(fh, &buf[0], 2) != 2) return MSPACK_ERR_READ; + } + + /* 2 bytes: length of section, then [length] bytes: unknown purpose */ + if (hdr->headers & MSKWAJ_HDR_HASUNKNOWN2) { + if (sys->read(fh, &buf[0], 2) != 2) return MSPACK_ERR_READ; + i = EndGetI16(&buf[0]); + if (sys->seek(fh, (off_t)i, MSPACK_SYS_SEEK_CUR)) return MSPACK_ERR_SEEK; + } + + /* filename and extension */ + if (hdr->headers & (MSKWAJ_HDR_HASFILENAME | MSKWAJ_HDR_HASFILEEXT)) { + off_t pos = sys->tell(fh); + char *fn = (char *) sys->alloc(sys, (size_t) 13); + + /* allocate memory for maximum length filename */ + if (! fn) return MSPACK_ERR_NOMEMORY; + hdr->filename = fn; + + /* copy filename if present */ + if (hdr->headers & MSKWAJ_HDR_HASFILENAME) { + if (sys->read(fh, &buf[0], 9) != 9) return MSPACK_ERR_READ; + for (i = 0; i < 9; i++, fn++) if (!(*fn = buf[i])) break; + pos += (i < 9) ? i+1 : 9; + if (sys->seek(fh, pos, MSPACK_SYS_SEEK_START)) + return MSPACK_ERR_SEEK; + } + + /* copy extension if present */ + if (hdr->headers & MSKWAJ_HDR_HASFILEEXT) { + *fn++ = '.'; + if (sys->read(fh, &buf[0], 4) != 4) return MSPACK_ERR_READ; + for (i = 0; i < 4; i++, fn++) if (!(*fn = buf[i])) break; + pos += (i < 4) ? i+1 : 4; + if (sys->seek(fh, pos, MSPACK_SYS_SEEK_START)) + return MSPACK_ERR_SEEK; + } + *fn = '\0'; + } + + /* 2 bytes: extra text length then [length] bytes of extra text data */ + if (hdr->headers & MSKWAJ_HDR_HASEXTRATEXT) { + if (sys->read(fh, &buf[0], 2) != 2) return MSPACK_ERR_READ; + i = EndGetI16(&buf[0]); + hdr->extra = (char *) sys->alloc(sys, (size_t)i+1); + if (! hdr->extra) return MSPACK_ERR_NOMEMORY; + if (sys->read(fh, hdr->extra, i) != i) return MSPACK_ERR_READ; + hdr->extra[i] = '\0'; + hdr->extra_length = i; + } + return MSPACK_ERR_OK; +} + +/*************************************** + * KWAJD_EXTRACT + *************************************** + * decompresses a KWAJ file + */ +static int kwajd_extract(struct mskwaj_decompressor *base, + struct mskwajd_header *hdr, const char *filename) +{ + struct mskwaj_decompressor_p *self = (struct mskwaj_decompressor_p *) base; + struct mspack_system *sys; + struct mspack_file *fh, *outfh; + + if (!self) return MSPACK_ERR_ARGS; + if (!hdr) return self->error = MSPACK_ERR_ARGS; + + sys = self->system; + fh = ((struct mskwajd_header_p *) hdr)->fh; + + /* seek to the compressed data */ + if (sys->seek(fh, hdr->data_offset, MSPACK_SYS_SEEK_START)) { + return self->error = MSPACK_ERR_SEEK; + } + + /* open file for output */ + if (!(outfh = sys->open(sys, filename, MSPACK_SYS_OPEN_WRITE))) { + return self->error = MSPACK_ERR_OPEN; + } + + self->error = MSPACK_ERR_OK; + + /* decompress based on format */ + if (hdr->comp_type == MSKWAJ_COMP_NONE || + hdr->comp_type == MSKWAJ_COMP_XOR) + { + /* NONE is a straight copy. XOR is a copy xored with 0xFF */ + unsigned char *buf = (unsigned char *) sys->alloc(sys, (size_t) KWAJ_INPUT_SIZE); + if (buf) { + int read, i; + while ((read = sys->read(fh, buf, KWAJ_INPUT_SIZE)) > 0) { + if (hdr->comp_type == MSKWAJ_COMP_XOR) { + for (i = 0; i < read; i++) buf[i] ^= 0xFF; + } + if (sys->write(outfh, buf, read) != read) { + self->error = MSPACK_ERR_WRITE; + break; + } + } + if (read < 0) self->error = MSPACK_ERR_READ; + sys->free(buf); + } + else { + self->error = MSPACK_ERR_NOMEMORY; + } + } + else if (hdr->comp_type == MSKWAJ_COMP_SZDD) { + self->error = lzss_decompress(sys, fh, outfh, KWAJ_INPUT_SIZE, + LZSS_MODE_EXPAND); + } + else if (hdr->comp_type == MSKWAJ_COMP_LZH) { + struct kwajd_stream *lzh = lzh_init(sys, fh, outfh); + self->error = (lzh) ? lzh_decompress(lzh) : MSPACK_ERR_NOMEMORY; + lzh_free(lzh); + } + else if (hdr->comp_type == MSKWAJ_COMP_MSZIP) { + struct mszipd_stream *zip = mszipd_init(sys,fh,outfh,KWAJ_INPUT_SIZE,0); + self->error = (zip) ? mszipd_decompress_kwaj(zip) : MSPACK_ERR_NOMEMORY; + mszipd_free(zip); + } + else { + self->error = MSPACK_ERR_DATAFORMAT; + } + + /* close output file */ + sys->close(outfh); + + return self->error; +} + +/*************************************** + * KWAJD_DECOMPRESS + *************************************** + * unpacks directly from input to output + */ +static int kwajd_decompress(struct mskwaj_decompressor *base, + const char *input, const char *output) +{ + struct mskwaj_decompressor_p *self = (struct mskwaj_decompressor_p *) base; + struct mskwajd_header *hdr; + int error; + + if (!self) return MSPACK_ERR_ARGS; + + if (!(hdr = kwajd_open(base, input))) return self->error; + error = kwajd_extract(base, hdr, output); + kwajd_close(base, hdr); + return self->error = error; +} + +/*************************************** + * KWAJD_ERROR + *************************************** + * returns the last error that occurred + */ +static int kwajd_error(struct mskwaj_decompressor *base) +{ + struct mskwaj_decompressor_p *self = (struct mskwaj_decompressor_p *) base; + return (self) ? self->error : MSPACK_ERR_ARGS; +} + +/*************************************** + * LZH_INIT, LZH_DECOMPRESS, LZH_FREE + *************************************** + * unpacks KWAJ method 3 files + */ + +/* import bit-reading macros and code */ +#define BITS_TYPE struct kwajd_stream +#define BITS_VAR lzh +#define BITS_ORDER_MSB +#define BITS_NO_READ_INPUT +#define READ_BYTES do { \ + if (i_ptr >= i_end) { \ + if ((err = lzh_read_input(lzh))) return err; \ + i_ptr = lzh->i_ptr; \ + i_end = lzh->i_end; \ + } \ + INJECT_BITS(*i_ptr++, 8); \ +} while (0) +#include + +/* import huffman-reading macros and code */ +#define TABLEBITS(tbl) KWAJ_TABLEBITS +#define MAXSYMBOLS(tbl) KWAJ_##tbl##_SYMS +#define HUFF_TABLE(tbl,idx) lzh->tbl##_table[idx] +#define HUFF_LEN(tbl,idx) lzh->tbl##_len[idx] +#define HUFF_ERROR return MSPACK_ERR_DATAFORMAT +#include + +/* In the KWAJ LZH format, there is no special 'eof' marker, it just + * ends. Depending on how many bits are left in the final byte when + * the stream ends, that might be enough to start another literal or + * match. The only easy way to detect that we've come to an end is to + * guard all bit-reading. We allow fake bits to be read once we reach + * the end of the stream, but we check if we then consumed any of + * those fake bits, after doing the READ_BITS / READ_HUFFSYM. This + * isn't how the default readbits.h read_input() works (it simply lets + * 2 fake bytes in then stops), so we implement our own. + */ +#define READ_BITS_SAFE(val, n) do { \ + READ_BITS(val, n); \ + if (lzh->input_end && bits_left < lzh->input_end) \ + return MSPACK_ERR_OK; \ +} while (0) + +#define READ_HUFFSYM_SAFE(tbl, val) do { \ + READ_HUFFSYM(tbl, val); \ + if (lzh->input_end && bits_left < lzh->input_end) \ + return MSPACK_ERR_OK; \ +} while (0) + +#define BUILD_TREE(tbl, type) \ + STORE_BITS; \ + err = lzh_read_lens(lzh, type, MAXSYMBOLS(tbl), &HUFF_LEN(tbl,0)); \ + if (err) return err; \ + RESTORE_BITS; \ + if (make_decode_table(MAXSYMBOLS(tbl), TABLEBITS(tbl), \ + &HUFF_LEN(tbl,0), &HUFF_TABLE(tbl,0))) \ + return MSPACK_ERR_DATAFORMAT; + +#define WRITE_BYTE do { \ + if (lzh->sys->write(lzh->output, &lzh->window[pos], 1) != 1) \ + return MSPACK_ERR_WRITE; \ +} while (0) + +static struct kwajd_stream *lzh_init(struct mspack_system *sys, + struct mspack_file *in, struct mspack_file *out) +{ + struct kwajd_stream *lzh; + + if (!sys || !in || !out) return NULL; + if (!(lzh = (struct kwajd_stream *) sys->alloc(sys, sizeof(struct kwajd_stream)))) return NULL; + + lzh->sys = sys; + lzh->input = in; + lzh->output = out; + return lzh; +} + +static int lzh_decompress(struct kwajd_stream *lzh) +{ + register unsigned int bit_buffer; + register int bits_left, i; + register unsigned short sym; + unsigned char *i_ptr, *i_end, lit_run = 0; + int j, pos = 0, len, offset, err; + unsigned int types[6]; + + /* reset global state */ + INIT_BITS; + RESTORE_BITS; + memset(&lzh->window[0], LZSS_WINDOW_FILL, (size_t) LZSS_WINDOW_SIZE); + + /* read 6 encoding types (for byte alignment) but only 5 are needed */ + for (i = 0; i < 6; i++) READ_BITS_SAFE(types[i], 4); + + /* read huffman table symbol lengths and build huffman trees */ + BUILD_TREE(MATCHLEN1, types[0]); + BUILD_TREE(MATCHLEN2, types[1]); + BUILD_TREE(LITLEN, types[2]); + BUILD_TREE(OFFSET, types[3]); + BUILD_TREE(LITERAL, types[4]); + + while (!lzh->input_end) { + if (lit_run) READ_HUFFSYM_SAFE(MATCHLEN2, len); + else READ_HUFFSYM_SAFE(MATCHLEN1, len); + + if (len > 0) { + len += 2; + lit_run = 0; /* not the end of a literal run */ + READ_HUFFSYM_SAFE(OFFSET, j); offset = j << 6; + READ_BITS_SAFE(j, 6); offset |= j; + + /* copy match as output and into the ring buffer */ + while (len-- > 0) { + lzh->window[pos] = lzh->window[(pos+4096-offset) & 4095]; + WRITE_BYTE; + pos++; pos &= 4095; + } + } + else { + READ_HUFFSYM_SAFE(LITLEN, len); len++; + lit_run = (len == 32) ? 0 : 1; /* end of a literal run? */ + while (len-- > 0) { + READ_HUFFSYM_SAFE(LITERAL, j); + /* copy as output and into the ring buffer */ + lzh->window[pos] = j; + WRITE_BYTE; + pos++; pos &= 4095; + } + } + } + return MSPACK_ERR_OK; +} + +static void lzh_free(struct kwajd_stream *lzh) +{ + struct mspack_system *sys; + if (!lzh || !lzh->sys) return; + sys = lzh->sys; + sys->free(lzh); +} + +static int lzh_read_lens(struct kwajd_stream *lzh, + unsigned int type, unsigned int numsyms, + unsigned char *lens) +{ + register unsigned int bit_buffer; + register int bits_left; + unsigned char *i_ptr, *i_end; + unsigned int i, c, sel; + int err; + + RESTORE_BITS; + switch (type) { + case 0: + i = numsyms; c = (i==16)?4: (i==32)?5: (i==64)?6: (i==256)?8 :0; + for (i = 0; i < numsyms; i++) lens[i] = c; + break; + + case 1: + READ_BITS_SAFE(c, 4); lens[0] = c; + for (i = 1; i < numsyms; i++) { + READ_BITS_SAFE(sel, 1); if (sel == 0) lens[i] = c; + else { READ_BITS_SAFE(sel, 1); if (sel == 0) lens[i] = ++c; + else { READ_BITS_SAFE(c, 4); lens[i] = c; }} + } + break; + + case 2: + READ_BITS_SAFE(c, 4); lens[0] = c; + for (i = 1; i < numsyms; i++) { + READ_BITS_SAFE(sel, 2); + if (sel == 3) READ_BITS_SAFE(c, 4); else c += (char) sel-1; + lens[i] = c; + } + break; + + case 3: + for (i = 0; i < numsyms; i++) { + READ_BITS_SAFE(c, 4); lens[i] = c; + } + break; + } + STORE_BITS; + return MSPACK_ERR_OK; +} + +static int lzh_read_input(struct kwajd_stream *lzh) { + int read; + if (lzh->input_end) { + lzh->input_end += 8; + lzh->inbuf[0] = 0; + read = 1; + } + else { + read = lzh->sys->read(lzh->input, &lzh->inbuf[0], KWAJ_INPUT_SIZE); + if (read < 0) return MSPACK_ERR_READ; + if (read == 0) { + lzh->input_end = 8; + lzh->inbuf[0] = 0; + read = 1; + } + } + + /* update i_ptr and i_end */ + lzh->i_ptr = &lzh->inbuf[0]; + lzh->i_end = &lzh->inbuf[read]; + return MSPACK_ERR_OK; +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/kwaj.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/kwaj.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/kwaj.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/kwaj.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,118 @@ +/* This file is part of libmspack. + * (C) 2003-2010 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_KWAJ_H +#define MSPACK_KWAJ_H 1 + +#include + +/* generic KWAJ definitions */ +#define kwajh_Signature1 (0x00) +#define kwajh_Signature2 (0x04) +#define kwajh_CompMethod (0x08) +#define kwajh_DataOffset (0x0a) +#define kwajh_Flags (0x0c) +#define kwajh_SIZEOF (0x0e) + +/* KWAJ compression definitions */ + +struct mskwaj_compressor_p { + struct mskwaj_compressor base; + struct mspack_system *system; + /* todo */ + int param[2]; /* !!! MATCH THIS TO NUM OF PARAMS IN MSPACK.H !!! */ + int error; +}; + +/* KWAJ decompression definitions */ + +struct mskwaj_decompressor_p { + struct mskwaj_decompressor base; + struct mspack_system *system; + int error; +}; + +struct mskwajd_header_p { + struct mskwajd_header base; + struct mspack_file *fh; +}; + +/* input buffer size during decompression - not worth parameterising IMHO */ +#define KWAJ_INPUT_SIZE (2048) + +/* huffman codes that are 9 bits or less are decoded immediately */ +#define KWAJ_TABLEBITS (9) + +/* number of codes in each huffman table */ +#define KWAJ_MATCHLEN1_SYMS (16) +#define KWAJ_MATCHLEN2_SYMS (16) +#define KWAJ_LITLEN_SYMS (32) +#define KWAJ_OFFSET_SYMS (64) +#define KWAJ_LITERAL_SYMS (256) + +/* define decoding table sizes */ +#define KWAJ_TABLESIZE (1 << KWAJ_TABLEBITS) +#if KWAJ_TABLESIZE < (KWAJ_MATCHLEN1_SYMS * 2) +# define KWAJ_MATCHLEN1_TBLSIZE (KWAJ_MATCHLEN1_SYMS * 4) +#else +# define KWAJ_MATCHLEN1_TBLSIZE (KWAJ_TABLESIZE + (KWAJ_MATCHLEN1_SYMS * 2)) +#endif +#if KWAJ_TABLESIZE < (KWAJ_MATCHLEN2_SYMS * 2) +# define KWAJ_MATCHLEN2_TBLSIZE (KWAJ_MATCHLEN2_SYMS * 4) +#else +# define KWAJ_MATCHLEN2_TBLSIZE (KWAJ_TABLESIZE + (KWAJ_MATCHLEN2_SYMS * 2)) +#endif +#if KWAJ_TABLESIZE < (KWAJ_LITLEN_SYMS * 2) +# define KWAJ_LITLEN_TBLSIZE (KWAJ_LITLEN_SYMS * 4) +#else +# define KWAJ_LITLEN_TBLSIZE (KWAJ_TABLESIZE + (KWAJ_LITLEN_SYMS * 2)) +#endif +#if KWAJ_TABLESIZE < (KWAJ_OFFSET_SYMS * 2) +# define KWAJ_OFFSET_TBLSIZE (KWAJ_OFFSET_SYMS * 4) +#else +# define KWAJ_OFFSET_TBLSIZE (KWAJ_TABLESIZE + (KWAJ_OFFSET_SYMS * 2)) +#endif +#if KWAJ_TABLESIZE < (KWAJ_LITERAL_SYMS * 2) +# define KWAJ_LITERAL_TBLSIZE (KWAJ_LITERAL_SYMS * 4) +#else +# define KWAJ_LITERAL_TBLSIZE (KWAJ_TABLESIZE + (KWAJ_LITERAL_SYMS * 2)) +#endif + +struct kwajd_stream { + /* I/O buffering */ + struct mspack_system *sys; + struct mspack_file *input; + struct mspack_file *output; + unsigned char *i_ptr, *i_end; + unsigned int bit_buffer, bits_left; + int input_end; + + /* huffman code lengths */ + unsigned char MATCHLEN1_len [KWAJ_MATCHLEN1_SYMS]; + unsigned char MATCHLEN2_len [KWAJ_MATCHLEN2_SYMS]; + unsigned char LITLEN_len [KWAJ_LITLEN_SYMS]; + unsigned char OFFSET_len [KWAJ_OFFSET_SYMS]; + unsigned char LITERAL_len [KWAJ_LITERAL_SYMS]; + + /* huffman decoding tables */ + unsigned short MATCHLEN1_table [KWAJ_MATCHLEN1_TBLSIZE]; + unsigned short MATCHLEN2_table [KWAJ_MATCHLEN2_TBLSIZE]; + unsigned short LITLEN_table [KWAJ_LITLEN_TBLSIZE]; + unsigned short OFFSET_table [KWAJ_OFFSET_TBLSIZE]; + unsigned short LITERAL_table [KWAJ_LITERAL_TBLSIZE]; + + /* input buffer */ + unsigned char inbuf[KWAJ_INPUT_SIZE]; + + /* history window */ + unsigned char window[LZSS_WINDOW_SIZE]; +}; + + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/litc.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/litc.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/litc.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/litc.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,24 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* LIT compression implementation */ + +#include +#include + +struct mslit_compressor * + mspack_create_lit_compressor(struct mspack_system *sys) +{ + /* todo */ + return NULL; +} + +void mspack_destroy_lit_compressor(struct mslit_compressor *self) { + /* todo */ +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/litd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/litd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/litd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/litd.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,24 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* LIT decompression implementation */ + +#include +#include + +struct mslit_decompressor * + mspack_create_lit_decompressor(struct mspack_system *sys) +{ + /* todo */ + return NULL; +} + +void mspack_destroy_lit_decompressor(struct mslit_decompressor *self) { + /* todo */ +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lit.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lit.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lit.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lit.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,35 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_LIT_H +#define MSPACK_LIT_H 1 + +#include +#include +#include + +/* generic LIT definitions */ + +/* LIT compression definitions */ + +struct mslit_compressor_p { + struct mslit_compressor base; + struct mspack_system *system; + /* todo */ +}; + +/* LIT decompression definitions */ + +struct mslit_decompressor_p { + struct mslit_decompressor base; + struct mspack_system *system; + /* todo */ +}; + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lzssd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lzssd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lzssd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lzssd.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,93 @@ +/* This file is part of libmspack. + * (C) 2003-2010 Stuart Caie. + * + * LZSS is a derivative of LZ77 and was created by James Storer and + * Thomas Szymanski in 1982. Haruhiko Okumura wrote a very popular C + * implementation. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#include +#include + +#define ENSURE_BYTES do { \ + if (i_ptr >= i_end) { \ + read = system->read(input, &inbuf[0], \ + input_buffer_size); \ + if (read <= 0) { \ + system->free(window); \ + return (read < 0) ? MSPACK_ERR_READ \ + : MSPACK_ERR_OK; \ + } \ + i_ptr = &inbuf[0]; i_end = &inbuf[read]; \ + } \ +} while (0) + +#define WRITE_BYTE do { \ + if (system->write(output, &window[pos], 1) != 1) { \ + system->free(window); \ + return MSPACK_ERR_WRITE; \ + } \ +} while (0) + +int lzss_decompress(struct mspack_system *system, + struct mspack_file *input, + struct mspack_file *output, + int input_buffer_size, + int mode) +{ + unsigned char *window, *inbuf, *i_ptr, *i_end; + unsigned int pos, i, c, invert, mpos, len; + int read; + + /* check parameters */ + if (!system || input_buffer_size < 1 || (mode != LZSS_MODE_EXPAND && + mode != LZSS_MODE_MSHELP && mode != LZSS_MODE_QBASIC)) + { + return MSPACK_ERR_ARGS; + } + + /* allocate memory */ + window = (unsigned char *) system->alloc(system, LZSS_WINDOW_SIZE + input_buffer_size); + if (!window) return MSPACK_ERR_NOMEMORY; + + /* initialise decompression */ + inbuf = &window[LZSS_WINDOW_SIZE]; + memset(window, LZSS_WINDOW_FILL, (size_t) LZSS_WINDOW_SIZE); + pos = LZSS_WINDOW_SIZE - ((mode == LZSS_MODE_QBASIC) ? 18 : 16); + invert = (mode == LZSS_MODE_MSHELP) ? ~0 : 0; + i_ptr = i_end = &inbuf[0]; + + /* loop forever; exit condition is in ENSURE_BYTES macro */ + for (;;) { + ENSURE_BYTES; c = *i_ptr++ ^ invert; + for (i = 0x01; i & 0xFF; i <<= 1) { + if (c & i) { + /* literal */ + ENSURE_BYTES; window[pos] = *i_ptr++; + WRITE_BYTE; + pos++; pos &= LZSS_WINDOW_SIZE - 1; + } + else { + /* match */ + ENSURE_BYTES; mpos = *i_ptr++; + ENSURE_BYTES; mpos |= (*i_ptr & 0xF0) << 4; + len = (*i_ptr++ & 0x0F) + 3; + while (len--) { + window[pos] = window[mpos]; + WRITE_BYTE; + pos++; pos &= LZSS_WINDOW_SIZE - 1; + mpos++; mpos &= LZSS_WINDOW_SIZE - 1; + } + } + } + } + + /* not reached */ + system->free(window); + return MSPACK_ERR_OK; +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lzss.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lzss.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lzss.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lzss.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,66 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_LZSS_H +#define MSPACK_LZSS_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* LZSS compression / decompression definitions */ + +#define LZSS_WINDOW_SIZE (4096) +#define LZSS_WINDOW_FILL (0x20) + +#define LZSS_MODE_EXPAND (0) +#define LZSS_MODE_MSHELP (1) +#define LZSS_MODE_QBASIC (2) + +/** + * Decompresses an LZSS stream. + * + * Input bytes will be read in as necessary using the system->read() + * function with the input file handle given. This will continue until + * system->read() returns 0 bytes, or an error. Errors will be passed + * out of the function as MSPACK_ERR_READ errors. Input streams should + * convey an "end of input stream" by refusing to supply all the bytes + * that LZSS asks for when they reach the end of the stream, rather + * than return an error code. + * + * Output bytes will be passed to the system->write() function, using + * the output file handle given. More than one call may be made to + * system->write(). + * + * As EXPAND.EXE (SZDD/KWAJ), Microsoft Help and QBasic have slightly + * different encodings for the control byte and matches, a "mode" + * parameter is allowed, to choose the encoding. + * + * @param system an mspack_system structure used to read from + * the input stream and write to the output + * stream, also to allocate and free memory. + * @param input an input stream with the LZSS data. + * @param output an output stream to write the decoded data to. + * @param input_buffer_size the number of bytes to use as an input + * bitstream buffer. + * @param mode one of #LZSS_MODE_EXPAND, #LZSS_MODE_MSHELP or + * #LZSS_MODE_QBASIC + * @return an error code, or MSPACK_ERR_OK if successful + */ +extern int lzss_decompress(struct mspack_system *system, + struct mspack_file *input, + struct mspack_file *output, + int input_buffer_size, + int mode); + +#ifdef __cplusplus +} +#endif + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lzxc.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lzxc.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lzxc.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lzxc.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,18 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted + * by Microsoft Corporation. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* LZX compression implementation */ + +#include +#include + +/* todo */ diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lzxd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lzxd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lzxd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lzxd.c 2017-04-20 22:19:13.000000000 +0000 @@ -0,0 +1,902 @@ +/* This file is part of libmspack. + * (C) 2003-2013 Stuart Caie. + * + * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted + * by Microsoft Corporation. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* LZX decompression implementation */ + +#include +#include + +/* Microsoft's LZX document (in cab-sdk.exe) and their implementation + * of the com.ms.util.cab Java package do not concur. + * + * In the LZX document, there is a table showing the correlation between + * window size and the number of position slots. It states that the 1MB + * window = 40 slots and the 2MB window = 42 slots. In the implementation, + * 1MB = 42 slots, 2MB = 50 slots. The actual calculation is 'find the + * first slot whose position base is equal to or more than the required + * window size'. This would explain why other tables in the document refer + * to 50 slots rather than 42. + * + * The constant NUM_PRIMARY_LENGTHS used in the decompression pseudocode + * is not defined in the specification. + * + * The LZX document does not state the uncompressed block has an + * uncompressed length field. Where does this length field come from, so + * we can know how large the block is? The implementation has it as the 24 + * bits following after the 3 blocktype bits, before the alignment + * padding. + * + * The LZX document states that aligned offset blocks have their aligned + * offset huffman tree AFTER the main and length trees. The implementation + * suggests that the aligned offset tree is BEFORE the main and length + * trees. + * + * The LZX document decoding algorithm states that, in an aligned offset + * block, if an extra_bits value is 1, 2 or 3, then that number of bits + * should be read and the result added to the match offset. This is + * correct for 1 and 2, but not 3, where just a huffman symbol (using the + * aligned tree) should be read. + * + * Regarding the E8 preprocessing, the LZX document states 'No translation + * may be performed on the last 6 bytes of the input block'. This is + * correct. However, the pseudocode provided checks for the *E8 leader* + * up to the last 6 bytes. If the leader appears between -10 and -7 bytes + * from the end, this would cause the next four bytes to be modified, at + * least one of which would be in the last 6 bytes, which is not allowed + * according to the spec. + * + * The specification states that the huffman trees must always contain at + * least one element. However, many CAB files contain blocks where the + * length tree is completely empty (because there are no matches), and + * this is expected to succeed. + * + * The errors in LZX documentation appear have been corrected in the + * new documentation for the LZX DELTA format. + * + * http://msdn.microsoft.com/en-us/library/cc483133.aspx + * + * However, this is a different format, an extension of regular LZX. + * I have noticed the following differences, there may be more: + * + * The maximum window size has increased from 2MB to 32MB. This also + * increases the maximum number of position slots, etc. + * + * If the match length is 257 (the maximum possible), this signals + * a further length decoding step, that allows for matches up to + * 33024 bytes long. + * + * The format now allows for "reference data", supplied by the caller. + * If match offsets go further back than the number of bytes + * decompressed so far, that is them accessing the reference data. + */ + +/* import bit-reading macros and code */ +#define BITS_TYPE struct lzxd_stream +#define BITS_VAR lzx +#define BITS_ORDER_MSB +#define READ_BYTES do { \ + unsigned char b0, b1; \ + READ_IF_NEEDED; b0 = *i_ptr++; \ + READ_IF_NEEDED; b1 = *i_ptr++; \ + INJECT_BITS((b1 << 8) | b0, 16); \ +} while (0) +#include + +/* import huffman-reading macros and code */ +#define TABLEBITS(tbl) LZX_##tbl##_TABLEBITS +#define MAXSYMBOLS(tbl) LZX_##tbl##_MAXSYMBOLS +#define HUFF_TABLE(tbl,idx) lzx->tbl##_table[idx] +#define HUFF_LEN(tbl,idx) lzx->tbl##_len[idx] +#define HUFF_ERROR return lzx->error = MSPACK_ERR_DECRUNCH +#include + +/* BUILD_TABLE(tbl) builds a huffman lookup table from code lengths */ +#define BUILD_TABLE(tbl) \ + if (make_decode_table(MAXSYMBOLS(tbl), TABLEBITS(tbl), \ + &HUFF_LEN(tbl,0), &HUFF_TABLE(tbl,0))) \ + { \ + D(("failed to build %s table", #tbl)) \ + return lzx->error = MSPACK_ERR_DECRUNCH; \ + } + +#define BUILD_TABLE_MAYBE_EMPTY(tbl) do { \ + lzx->tbl##_empty = 0; \ + if (make_decode_table(MAXSYMBOLS(tbl), TABLEBITS(tbl), \ + &HUFF_LEN(tbl,0), &HUFF_TABLE(tbl,0))) \ + { \ + for (i = 0; i < MAXSYMBOLS(tbl); i++) { \ + if (HUFF_LEN(tbl, i) > 0) { \ + D(("failed to build %s table", #tbl)) \ + return lzx->error = MSPACK_ERR_DECRUNCH; \ + } \ + } \ + /* empty tree - allow it, but don't decode symbols with it */ \ + lzx->tbl##_empty = 1; \ + } \ +} while (0) + +/* READ_LENGTHS(tablename, first, last) reads in code lengths for symbols + * first to last in the given table. The code lengths are stored in their + * own special LZX way. + */ +#define READ_LENGTHS(tbl, first, last) do { \ + STORE_BITS; \ + if (lzxd_read_lens(lzx, &HUFF_LEN(tbl, 0), (first), \ + (unsigned int)(last))) return lzx->error; \ + RESTORE_BITS; \ +} while (0) + +static int lzxd_read_lens(struct lzxd_stream *lzx, unsigned char *lens, + unsigned int first, unsigned int last) +{ + /* bit buffer and huffman symbol decode variables */ + register unsigned int bit_buffer; + register int bits_left, i; + register unsigned short sym; + unsigned char *i_ptr, *i_end; + + unsigned int x, y; + int z; + + RESTORE_BITS; + + /* read lengths for pretree (20 symbols, lengths stored in fixed 4 bits) */ + for (x = 0; x < 20; x++) { + READ_BITS(y, 4); + lzx->PRETREE_len[x] = y; + } + BUILD_TABLE(PRETREE); + + for (x = first; x < last; ) { + READ_HUFFSYM(PRETREE, z); + if (z == 17) { + /* code = 17, run of ([read 4 bits]+4) zeros */ + READ_BITS(y, 4); y += 4; + while (y--) lens[x++] = 0; + } + else if (z == 18) { + /* code = 18, run of ([read 5 bits]+20) zeros */ + READ_BITS(y, 5); y += 20; + while (y--) lens[x++] = 0; + } + else if (z == 19) { + /* code = 19, run of ([read 1 bit]+4) [read huffman symbol] */ + READ_BITS(y, 1); y += 4; + READ_HUFFSYM(PRETREE, z); + z = lens[x] - z; if (z < 0) z += 17; + while (y--) lens[x++] = z; + } + else { + /* code = 0 to 16, delta current length entry */ + z = lens[x] - z; if (z < 0) z += 17; + lens[x++] = z; + } + } + + STORE_BITS; + + return MSPACK_ERR_OK; +} + +/* LZX static data tables: + * + * LZX uses 'position slots' to represent match offsets. For every match, + * a small 'position slot' number and a small offset from that slot are + * encoded instead of one large offset. + * + * The number of slots is decided by how many are needed to encode the + * largest offset for a given window size. This is easy when the gap between + * slots is less than 128Kb, it's a linear relationship. But when extra_bits + * reaches its limit of 17 (because LZX can only ensure reading 17 bits of + * data at a time), we can only jump 128Kb at a time and have to start + * using more and more position slots as each window size doubles. + * + * position_base[] is an index to the position slot bases + * + * extra_bits[] states how many bits of offset-from-base data is needed. + * + * They are calculated as follows: + * extra_bits[i] = 0 where i < 4 + * extra_bits[i] = floor(i/2)-1 where i >= 4 && i < 36 + * extra_bits[i] = 17 where i >= 36 + * position_base[0] = 0 + * position_base[i] = position_base[i-1] + (1 << extra_bits[i-1]) + */ +static const unsigned int position_slots[11] = { + 30, 32, 34, 36, 38, 42, 50, 66, 98, 162, 290 +}; +static const unsigned char extra_bits[36] = { + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, + 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16 +}; +static const unsigned int position_base[290] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, + 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576, 32768, + 49152, 65536, 98304, 131072, 196608, 262144, 393216, 524288, 655360, + 786432, 917504, 1048576, 1179648, 1310720, 1441792, 1572864, 1703936, + 1835008, 1966080, 2097152, 2228224, 2359296, 2490368, 2621440, 2752512, + 2883584, 3014656, 3145728, 3276800, 3407872, 3538944, 3670016, 3801088, + 3932160, 4063232, 4194304, 4325376, 4456448, 4587520, 4718592, 4849664, + 4980736, 5111808, 5242880, 5373952, 5505024, 5636096, 5767168, 5898240, + 6029312, 6160384, 6291456, 6422528, 6553600, 6684672, 6815744, 6946816, + 7077888, 7208960, 7340032, 7471104, 7602176, 7733248, 7864320, 7995392, + 8126464, 8257536, 8388608, 8519680, 8650752, 8781824, 8912896, 9043968, + 9175040, 9306112, 9437184, 9568256, 9699328, 9830400, 9961472, 10092544, + 10223616, 10354688, 10485760, 10616832, 10747904, 10878976, 11010048, + 11141120, 11272192, 11403264, 11534336, 11665408, 11796480, 11927552, + 12058624, 12189696, 12320768, 12451840, 12582912, 12713984, 12845056, + 12976128, 13107200, 13238272, 13369344, 13500416, 13631488, 13762560, + 13893632, 14024704, 14155776, 14286848, 14417920, 14548992, 14680064, + 14811136, 14942208, 15073280, 15204352, 15335424, 15466496, 15597568, + 15728640, 15859712, 15990784, 16121856, 16252928, 16384000, 16515072, + 16646144, 16777216, 16908288, 17039360, 17170432, 17301504, 17432576, + 17563648, 17694720, 17825792, 17956864, 18087936, 18219008, 18350080, + 18481152, 18612224, 18743296, 18874368, 19005440, 19136512, 19267584, + 19398656, 19529728, 19660800, 19791872, 19922944, 20054016, 20185088, + 20316160, 20447232, 20578304, 20709376, 20840448, 20971520, 21102592, + 21233664, 21364736, 21495808, 21626880, 21757952, 21889024, 22020096, + 22151168, 22282240, 22413312, 22544384, 22675456, 22806528, 22937600, + 23068672, 23199744, 23330816, 23461888, 23592960, 23724032, 23855104, + 23986176, 24117248, 24248320, 24379392, 24510464, 24641536, 24772608, + 24903680, 25034752, 25165824, 25296896, 25427968, 25559040, 25690112, + 25821184, 25952256, 26083328, 26214400, 26345472, 26476544, 26607616, + 26738688, 26869760, 27000832, 27131904, 27262976, 27394048, 27525120, + 27656192, 27787264, 27918336, 28049408, 28180480, 28311552, 28442624, + 28573696, 28704768, 28835840, 28966912, 29097984, 29229056, 29360128, + 29491200, 29622272, 29753344, 29884416, 30015488, 30146560, 30277632, + 30408704, 30539776, 30670848, 30801920, 30932992, 31064064, 31195136, + 31326208, 31457280, 31588352, 31719424, 31850496, 31981568, 32112640, + 32243712, 32374784, 32505856, 32636928, 32768000, 32899072, 33030144, + 33161216, 33292288, 33423360 +}; + +static void lzxd_reset_state(struct lzxd_stream *lzx) { + int i; + + lzx->R0 = 1; + lzx->R1 = 1; + lzx->R2 = 1; + lzx->header_read = 0; + lzx->block_remaining = 0; + lzx->block_type = LZX_BLOCKTYPE_INVALID; + + /* initialise tables to 0 (because deltas will be applied to them) */ + for (i = 0; i < LZX_MAINTREE_MAXSYMBOLS; i++) lzx->MAINTREE_len[i] = 0; + for (i = 0; i < LZX_LENGTH_MAXSYMBOLS; i++) lzx->LENGTH_len[i] = 0; +} + +/*-------- main LZX code --------*/ + +struct lzxd_stream *lzxd_init(struct mspack_system *system, + struct mspack_file *input, + struct mspack_file *output, + int window_bits, + int reset_interval, + int input_buffer_size, + off_t output_length, + char is_delta) +{ + unsigned int window_size = 1 << window_bits; + struct lzxd_stream *lzx; + + if (!system) return NULL; + + /* LZX DELTA window sizes are between 2^17 (128KiB) and 2^25 (32MiB), + * regular LZX windows are between 2^15 (32KiB) and 2^21 (2MiB) + */ + if (is_delta) { + if (window_bits < 17 || window_bits > 25) return NULL; + } + else { + if (window_bits < 15 || window_bits > 21) return NULL; + } + + input_buffer_size = (input_buffer_size + 1) & -2; + if (!input_buffer_size) return NULL; + + /* allocate decompression state */ + if (!(lzx = (struct lzxd_stream *) system->alloc(system, sizeof(struct lzxd_stream)))) { + return NULL; + } + + /* allocate decompression window and input buffer */ + lzx->window = (unsigned char *) system->alloc(system, (size_t) window_size); + lzx->inbuf = (unsigned char *) system->alloc(system, (size_t) input_buffer_size); + if (!lzx->window || !lzx->inbuf) { + system->free(lzx->window); + system->free(lzx->inbuf); + system->free(lzx); + return NULL; + } + + /* initialise decompression state */ + lzx->sys = system; + lzx->input = input; + lzx->output = output; + lzx->offset = 0; + lzx->length = output_length; + + lzx->inbuf_size = input_buffer_size; + lzx->window_size = 1 << window_bits; + lzx->ref_data_size = 0; + lzx->window_posn = 0; + lzx->frame_posn = 0; + lzx->frame = 0; + lzx->reset_interval = reset_interval; + lzx->intel_filesize = 0; + lzx->intel_curpos = 0; + lzx->intel_started = 0; + lzx->error = MSPACK_ERR_OK; + lzx->num_offsets = position_slots[window_bits - 15] << 3; + lzx->is_delta = is_delta; + + lzx->o_ptr = lzx->o_end = &lzx->e8_buf[0]; + lzxd_reset_state(lzx); + INIT_BITS; + return lzx; +} + +int lzxd_set_reference_data(struct lzxd_stream *lzx, + struct mspack_system *system, + struct mspack_file *input, + unsigned int length) +{ + if (!lzx) return MSPACK_ERR_ARGS; + + if (!lzx->is_delta) { + D(("only LZX DELTA streams support reference data")) + return MSPACK_ERR_ARGS; + } + if (lzx->offset) { + D(("too late to set reference data after decoding starts")) + return MSPACK_ERR_ARGS; + } + if (length > lzx->window_size) { + D(("reference length (%u) is longer than the window", length)) + return MSPACK_ERR_ARGS; + } + if (length > 0 && (!system || !input)) { + D(("length > 0 but no system or input")) + return MSPACK_ERR_ARGS; + } + + lzx->ref_data_size = length; + if (length > 0) { + /* copy reference data */ + unsigned char *pos = &lzx->window[lzx->window_size - length]; + int bytes = system->read(input, pos, length); + /* length can't be more than 2^25, so no signedness problem */ + if (bytes < (int)length) return MSPACK_ERR_READ; + } + lzx->ref_data_size = length; + return MSPACK_ERR_OK; +} + +void lzxd_set_output_length(struct lzxd_stream *lzx, off_t out_bytes) { + if (lzx) lzx->length = out_bytes; +} + +int lzxd_decompress(struct lzxd_stream *lzx, off_t out_bytes) { + /* bitstream and huffman reading variables */ + register unsigned int bit_buffer; + register int bits_left, i=0; + unsigned char *i_ptr, *i_end; + register unsigned short sym; + + int match_length, length_footer, extra, verbatim_bits, bytes_todo; + int this_run, main_element, aligned_bits, j; + unsigned char *window, *runsrc, *rundest, buf[12]; + unsigned int frame_size=0, end_frame, match_offset, window_posn; + unsigned int R0, R1, R2; + + /* easy answers */ + if (!lzx || (out_bytes < 0)) return MSPACK_ERR_ARGS; + if (lzx->error) return lzx->error; + + /* flush out any stored-up bytes before we begin */ + i = lzx->o_end - lzx->o_ptr; + if ((off_t) i > out_bytes) i = (int) out_bytes; + if (i) { + if (lzx->sys->write(lzx->output, lzx->o_ptr, i) != i) { + return lzx->error = MSPACK_ERR_WRITE; + } + lzx->o_ptr += i; + lzx->offset += i; + out_bytes -= i; + } + if (out_bytes == 0) return MSPACK_ERR_OK; + + /* restore local state */ + RESTORE_BITS; + window = lzx->window; + window_posn = lzx->window_posn; + R0 = lzx->R0; + R1 = lzx->R1; + R2 = lzx->R2; + + end_frame = (unsigned int)((lzx->offset + out_bytes) / LZX_FRAME_SIZE) + 1; + + while (lzx->frame < end_frame) { + /* have we reached the reset interval? (if there is one?) */ + if (lzx->reset_interval && ((lzx->frame % lzx->reset_interval) == 0)) { + if (lzx->block_remaining) { + D(("%d bytes remaining at reset interval", lzx->block_remaining)) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + + /* re-read the intel header and reset the huffman lengths */ + lzxd_reset_state(lzx); + R0 = lzx->R0; + R1 = lzx->R1; + R2 = lzx->R2; + } + + /* LZX DELTA format has chunk_size, not present in LZX format */ + if (lzx->is_delta) { + ENSURE_BITS(16); + REMOVE_BITS(16); + } + + /* read header if necessary */ + if (!lzx->header_read) { + /* read 1 bit. if bit=0, intel filesize = 0. + * if bit=1, read intel filesize (32 bits) */ + j = 0; READ_BITS(i, 1); if (i) { READ_BITS(i, 16); READ_BITS(j, 16); } + lzx->intel_filesize = (i << 16) | j; + lzx->header_read = 1; + } + + /* calculate size of frame: all frames are 32k except the final frame + * which is 32kb or less. this can only be calculated when lzx->length + * has been filled in. */ + frame_size = LZX_FRAME_SIZE; + if (lzx->length && (lzx->length - lzx->offset) < (off_t)frame_size) { + frame_size = lzx->length - lzx->offset; + } + + /* decode until one more frame is available */ + bytes_todo = lzx->frame_posn + frame_size - window_posn; + while (bytes_todo > 0) { + /* initialise new block, if one is needed */ + if (lzx->block_remaining == 0) { + /* realign if previous block was an odd-sized UNCOMPRESSED block */ + if ((lzx->block_type == LZX_BLOCKTYPE_UNCOMPRESSED) && + (lzx->block_length & 1)) + { + READ_IF_NEEDED; + i_ptr++; + } + + /* read block type (3 bits) and block length (24 bits) */ + READ_BITS(lzx->block_type, 3); + READ_BITS(i, 16); READ_BITS(j, 8); + lzx->block_remaining = lzx->block_length = (i << 8) | j; + /*D(("new block t%d len %u", lzx->block_type, lzx->block_length))*/ + + /* read individual block headers */ + switch (lzx->block_type) { + case LZX_BLOCKTYPE_ALIGNED: + /* read lengths of and build aligned huffman decoding tree */ + for (i = 0; i < 8; i++) { READ_BITS(j, 3); lzx->ALIGNED_len[i] = j; } + BUILD_TABLE(ALIGNED); + /* no break -- rest of aligned header is same as verbatim */ + case LZX_BLOCKTYPE_VERBATIM: + /* read lengths of and build main huffman decoding tree */ + READ_LENGTHS(MAINTREE, 0, 256); + READ_LENGTHS(MAINTREE, 256, LZX_NUM_CHARS + lzx->num_offsets); + BUILD_TABLE(MAINTREE); + /* if the literal 0xE8 is anywhere in the block... */ + if (lzx->MAINTREE_len[0xE8] != 0) lzx->intel_started = 1; + /* read lengths of and build lengths huffman decoding tree */ + READ_LENGTHS(LENGTH, 0, LZX_NUM_SECONDARY_LENGTHS); + BUILD_TABLE_MAYBE_EMPTY(LENGTH); + break; + + case LZX_BLOCKTYPE_UNCOMPRESSED: + /* because we can't assume otherwise */ + lzx->intel_started = 1; + + /* read 1-16 (not 0-15) bits to align to bytes */ + if (bits_left == 0) ENSURE_BITS(16); + bits_left = 0; bit_buffer = 0; + + /* read 12 bytes of stored R0 / R1 / R2 values */ + for (rundest = &buf[0], i = 0; i < 12; i++) { + READ_IF_NEEDED; + *rundest++ = *i_ptr++; + } + R0 = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); + R1 = buf[4] | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24); + R2 = buf[8] | (buf[9] << 8) | (buf[10] << 16) | (buf[11] << 24); + break; + + default: + D(("bad block type")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + } + + /* decode more of the block: + * run = min(what's available, what's needed) */ + this_run = lzx->block_remaining; + if (this_run > bytes_todo) this_run = bytes_todo; + + /* assume we decode exactly this_run bytes, for now */ + bytes_todo -= this_run; + lzx->block_remaining -= this_run; + + /* decode at least this_run bytes */ + switch (lzx->block_type) { + case LZX_BLOCKTYPE_VERBATIM: + while (this_run > 0) { + READ_HUFFSYM(MAINTREE, main_element); + if (main_element < LZX_NUM_CHARS) { + /* literal: 0 to LZX_NUM_CHARS-1 */ + window[window_posn++] = main_element; + this_run--; + } + else { + /* match: LZX_NUM_CHARS + ((slot<<3) | length_header (3 bits)) */ + main_element -= LZX_NUM_CHARS; + + /* get match length */ + match_length = main_element & LZX_NUM_PRIMARY_LENGTHS; + if (match_length == LZX_NUM_PRIMARY_LENGTHS) { + if (lzx->LENGTH_empty) { + D(("LENGTH symbol needed but tree is empty")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + READ_HUFFSYM(LENGTH, length_footer); + match_length += length_footer; + } + match_length += LZX_MIN_MATCH; + + /* get match offset */ + switch ((match_offset = (main_element >> 3))) { + case 0: match_offset = R0; break; + case 1: match_offset = R1; R1=R0; R0 = match_offset; break; + case 2: match_offset = R2; R2=R0; R0 = match_offset; break; + case 3: match_offset = 1; R2=R1; R1=R0; R0 = match_offset; break; + default: + extra = (match_offset >= 36) ? 17 : extra_bits[match_offset]; + READ_BITS(verbatim_bits, extra); + match_offset = position_base[match_offset] - 2 + verbatim_bits; + R2 = R1; R1 = R0; R0 = match_offset; + } + + /* LZX DELTA uses max match length to signal even longer match */ + if (match_length == LZX_MAX_MATCH && lzx->is_delta) { + int extra_len = 0; + ENSURE_BITS(3); /* 4 entry huffman tree */ + if (PEEK_BITS(1) == 0) { + REMOVE_BITS(1); /* '0' -> 8 extra length bits */ + READ_BITS(extra_len, 8); + } + else if (PEEK_BITS(2) == 2) { + REMOVE_BITS(2); /* '10' -> 10 extra length bits + 0x100 */ + READ_BITS(extra_len, 10); + extra_len += 0x100; + } + else if (PEEK_BITS(3) == 6) { + REMOVE_BITS(3); /* '110' -> 12 extra length bits + 0x500 */ + READ_BITS(extra_len, 12); + extra_len += 0x500; + } + else { + REMOVE_BITS(3); /* '111' -> 15 extra length bits */ + READ_BITS(extra_len, 15); + } + match_length += extra_len; + } + + if ((window_posn + match_length) > lzx->window_size) { + D(("match ran over window wrap")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + + /* copy match */ + rundest = &window[window_posn]; + i = match_length; + /* does match offset wrap the window? */ + if (match_offset > window_posn) { + if (match_offset > lzx->offset && + (match_offset - window_posn) > lzx->ref_data_size) + { + D(("match offset beyond LZX stream")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + /* j = length from match offset to end of window */ + j = match_offset - window_posn; + if (j > (int) lzx->window_size) { + D(("match offset beyond window boundaries")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + runsrc = &window[lzx->window_size - j]; + if (j < i) { + /* if match goes over the window edge, do two copy runs */ + i -= j; while (j-- > 0) *rundest++ = *runsrc++; + runsrc = window; + } + while (i-- > 0) *rundest++ = *runsrc++; + } + else { + runsrc = rundest - match_offset; + while (i-- > 0) *rundest++ = *runsrc++; + } + + this_run -= match_length; + window_posn += match_length; + } + } /* while (this_run > 0) */ + break; + + case LZX_BLOCKTYPE_ALIGNED: + while (this_run > 0) { + READ_HUFFSYM(MAINTREE, main_element); + if (main_element < LZX_NUM_CHARS) { + /* literal: 0 to LZX_NUM_CHARS-1 */ + window[window_posn++] = main_element; + this_run--; + } + else { + /* match: LZX_NUM_CHARS + ((slot<<3) | length_header (3 bits)) */ + main_element -= LZX_NUM_CHARS; + + /* get match length */ + match_length = main_element & LZX_NUM_PRIMARY_LENGTHS; + if (match_length == LZX_NUM_PRIMARY_LENGTHS) { + if (lzx->LENGTH_empty) { + D(("LENGTH symbol needed but tree is empty")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + READ_HUFFSYM(LENGTH, length_footer); + match_length += length_footer; + } + match_length += LZX_MIN_MATCH; + + /* get match offset */ + switch ((match_offset = (main_element >> 3))) { + case 0: match_offset = R0; break; + case 1: match_offset = R1; R1 = R0; R0 = match_offset; break; + case 2: match_offset = R2; R2 = R0; R0 = match_offset; break; + default: + extra = (match_offset >= 36) ? 17 : extra_bits[match_offset]; + match_offset = position_base[match_offset] - 2; + if (extra > 3) { + /* verbatim and aligned bits */ + extra -= 3; + READ_BITS(verbatim_bits, extra); + match_offset += (verbatim_bits << 3); + READ_HUFFSYM(ALIGNED, aligned_bits); + match_offset += aligned_bits; + } + else if (extra == 3) { + /* aligned bits only */ + READ_HUFFSYM(ALIGNED, aligned_bits); + match_offset += aligned_bits; + } + else if (extra > 0) { /* extra==1, extra==2 */ + /* verbatim bits only */ + READ_BITS(verbatim_bits, extra); + match_offset += verbatim_bits; + } + else /* extra == 0 */ { + /* ??? not defined in LZX specification! */ + match_offset = 1; + } + /* update repeated offset LRU queue */ + R2 = R1; R1 = R0; R0 = match_offset; + } + + /* LZX DELTA uses max match length to signal even longer match */ + if (match_length == LZX_MAX_MATCH && lzx->is_delta) { + int extra_len = 0; + ENSURE_BITS(3); /* 4 entry huffman tree */ + if (PEEK_BITS(1) == 0) { + REMOVE_BITS(1); /* '0' -> 8 extra length bits */ + READ_BITS(extra_len, 8); + } + else if (PEEK_BITS(2) == 2) { + REMOVE_BITS(2); /* '10' -> 10 extra length bits + 0x100 */ + READ_BITS(extra_len, 10); + extra_len += 0x100; + } + else if (PEEK_BITS(3) == 6) { + REMOVE_BITS(3); /* '110' -> 12 extra length bits + 0x500 */ + READ_BITS(extra_len, 12); + extra_len += 0x500; + } + else { + REMOVE_BITS(3); /* '111' -> 15 extra length bits */ + READ_BITS(extra_len, 15); + } + match_length += extra_len; + } + + if ((window_posn + match_length) > lzx->window_size) { + D(("match ran over window wrap")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + + /* copy match */ + rundest = &window[window_posn]; + i = match_length; + /* does match offset wrap the window? */ + if (match_offset > window_posn) { + if (match_offset > lzx->offset && + (match_offset - window_posn) > lzx->ref_data_size) + { + D(("match offset beyond LZX stream")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + /* j = length from match offset to end of window */ + j = match_offset - window_posn; + if (j > (int) lzx->window_size) { + D(("match offset beyond window boundaries")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + runsrc = &window[lzx->window_size - j]; + if (j < i) { + /* if match goes over the window edge, do two copy runs */ + i -= j; while (j-- > 0) *rundest++ = *runsrc++; + runsrc = window; + } + while (i-- > 0) *rundest++ = *runsrc++; + } + else { + runsrc = rundest - match_offset; + while (i-- > 0) *rundest++ = *runsrc++; + } + + this_run -= match_length; + window_posn += match_length; + } + } /* while (this_run > 0) */ + break; + + case LZX_BLOCKTYPE_UNCOMPRESSED: + /* as this_run is limited not to wrap a frame, this also means it + * won't wrap the window (as the window is a multiple of 32k) */ + if (window_posn + this_run > lzx->window_size) { + D(("match ran over window boundary")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + rundest = &window[window_posn]; + window_posn += this_run; + + while (this_run > 0) { + if ((i = i_end - i_ptr) == 0) { + READ_IF_NEEDED; + } + else { + if (i > this_run) i = this_run; + lzx->sys->copy(i_ptr, rundest, (size_t) i); + rundest += i; + i_ptr += i; + this_run -= i; + } + } + break; + + default: + return lzx->error = MSPACK_ERR_DECRUNCH; /* might as well */ + } + + /* did the final match overrun our desired this_run length? */ + if (this_run < 0) { + if ((unsigned int)(-this_run) > lzx->block_remaining) { + D(("overrun went past end of block by %d (%d remaining)", + -this_run, lzx->block_remaining )) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + lzx->block_remaining -= -this_run; + } + } /* while (bytes_todo > 0) */ + + /* streams don't extend over frame boundaries */ + if ((window_posn - lzx->frame_posn) != frame_size) { + D(("decode beyond output frame limits! %d != %d", + window_posn - lzx->frame_posn, frame_size)) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + + /* re-align input bitstream */ + if (bits_left > 0) ENSURE_BITS(16); + if (bits_left & 15) REMOVE_BITS(bits_left & 15); + + /* check that we've used all of the previous frame first */ + if (lzx->o_ptr != lzx->o_end) { + D(("%ld avail bytes, new %d frame", + (long)(lzx->o_end - lzx->o_ptr), frame_size)) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + + /* does this intel block _really_ need decoding? */ + if (lzx->intel_started && lzx->intel_filesize && + (lzx->frame <= 32768) && (frame_size > 10)) + { + unsigned char *data = &lzx->e8_buf[0]; + unsigned char *dataend = &lzx->e8_buf[frame_size - 10]; + signed int curpos = lzx->intel_curpos; + signed int filesize = lzx->intel_filesize; + signed int abs_off, rel_off; + + /* copy e8 block to the e8 buffer and tweak if needed */ + lzx->o_ptr = data; + lzx->sys->copy(&lzx->window[lzx->frame_posn], data, frame_size); + + while (data < dataend) { + if (*data++ != 0xE8) { curpos++; continue; } + abs_off = data[0] | (data[1]<<8) | (data[2]<<16) | (data[3]<<24); + if ((abs_off >= -curpos) && (abs_off < filesize)) { + rel_off = (abs_off >= 0) ? abs_off - curpos : abs_off + filesize; + data[0] = (unsigned char) rel_off; + data[1] = (unsigned char) (rel_off >> 8); + data[2] = (unsigned char) (rel_off >> 16); + data[3] = (unsigned char) (rel_off >> 24); + } + data += 4; + curpos += 5; + } + lzx->intel_curpos += frame_size; + } + else { + lzx->o_ptr = &lzx->window[lzx->frame_posn]; + if (lzx->intel_filesize) lzx->intel_curpos += frame_size; + } + lzx->o_end = &lzx->o_ptr[frame_size]; + + /* write a frame */ + i = (out_bytes < (off_t)frame_size) ? (unsigned int)out_bytes : frame_size; + if (lzx->sys->write(lzx->output, lzx->o_ptr, i) != i) { + return lzx->error = MSPACK_ERR_WRITE; + } + lzx->o_ptr += i; + lzx->offset += i; + out_bytes -= i; + + /* advance frame start position */ + lzx->frame_posn += frame_size; + lzx->frame++; + + /* wrap window / frame position pointers */ + if (window_posn == lzx->window_size) window_posn = 0; + if (lzx->frame_posn == lzx->window_size) lzx->frame_posn = 0; + + } /* while (lzx->frame < end_frame) */ + + if (out_bytes) { + D(("bytes left to output")) + return lzx->error = MSPACK_ERR_DECRUNCH; + } + + /* store local state */ + STORE_BITS; + lzx->window_posn = window_posn; + lzx->R0 = R0; + lzx->R1 = R1; + lzx->R2 = R2; + + return MSPACK_ERR_OK; +} + +void lzxd_free(struct lzxd_stream *lzx) { + struct mspack_system *sys; + if (lzx) { + sys = lzx->sys; + if(lzx->inbuf) + sys->free(lzx->inbuf); + if(lzx->window) + sys->free(lzx->window); + sys->free(lzx); + } +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lzx.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lzx.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/lzx.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/lzx.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,221 @@ +/* This file is part of libmspack. + * (C) 2003-2013 Stuart Caie. + * + * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted + * by Microsoft Corporation. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_LZX_H +#define MSPACK_LZX_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* LZX compression / decompression definitions */ + +/* some constants defined by the LZX specification */ +#define LZX_MIN_MATCH (2) +#define LZX_MAX_MATCH (257) +#define LZX_NUM_CHARS (256) +#define LZX_BLOCKTYPE_INVALID (0) /* also blocktypes 4-7 invalid */ +#define LZX_BLOCKTYPE_VERBATIM (1) +#define LZX_BLOCKTYPE_ALIGNED (2) +#define LZX_BLOCKTYPE_UNCOMPRESSED (3) +#define LZX_PRETREE_NUM_ELEMENTS (20) +#define LZX_ALIGNED_NUM_ELEMENTS (8) /* aligned offset tree #elements */ +#define LZX_NUM_PRIMARY_LENGTHS (7) /* this one missing from spec! */ +#define LZX_NUM_SECONDARY_LENGTHS (249) /* length tree #elements */ + +/* LZX huffman defines: tweak tablebits as desired */ +#define LZX_PRETREE_MAXSYMBOLS (LZX_PRETREE_NUM_ELEMENTS) +#define LZX_PRETREE_TABLEBITS (6) +#define LZX_MAINTREE_MAXSYMBOLS (LZX_NUM_CHARS + 290*8) +#define LZX_MAINTREE_TABLEBITS (12) +#define LZX_LENGTH_MAXSYMBOLS (LZX_NUM_SECONDARY_LENGTHS+1) +#define LZX_LENGTH_TABLEBITS (12) +#define LZX_ALIGNED_MAXSYMBOLS (LZX_ALIGNED_NUM_ELEMENTS) +#define LZX_ALIGNED_TABLEBITS (7) +#define LZX_LENTABLE_SAFETY (64) /* table decoding overruns are allowed */ + +#define LZX_FRAME_SIZE (32768) /* the size of a frame in LZX */ + +struct lzxd_stream { + struct mspack_system *sys; /* I/O routines */ + struct mspack_file *input; /* input file handle */ + struct mspack_file *output; /* output file handle */ + + off_t offset; /* number of bytes actually output */ + off_t length; /* overall decompressed length of stream */ + + unsigned char *window; /* decoding window */ + unsigned int window_size; /* window size */ + unsigned int ref_data_size; /* LZX DELTA reference data size */ + unsigned int num_offsets; /* number of match_offset entries in table */ + unsigned int window_posn; /* decompression offset within window */ + unsigned int frame_posn; /* current frame offset within in window */ + unsigned int frame; /* the number of 32kb frames processed */ + unsigned int reset_interval; /* which frame do we reset the compressor? */ + + unsigned int R0, R1, R2; /* for the LRU offset system */ + unsigned int block_length; /* uncompressed length of this LZX block */ + unsigned int block_remaining; /* uncompressed bytes still left to decode */ + + signed int intel_filesize; /* magic header value used for transform */ + signed int intel_curpos; /* current offset in transform space */ + + unsigned char intel_started; /* has intel E8 decoding started? */ + unsigned char block_type; /* type of the current block */ + unsigned char header_read; /* have we started decoding at all yet? */ + unsigned char input_end; /* have we reached the end of input? */ + unsigned char is_delta; /* does stream follow LZX DELTA spec? */ + + int error; + + /* I/O buffering */ + unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end; + unsigned int bit_buffer, bits_left, inbuf_size; + + /* huffman code lengths */ + unsigned char PRETREE_len [LZX_PRETREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; + unsigned char MAINTREE_len [LZX_MAINTREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; + unsigned char LENGTH_len [LZX_LENGTH_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; + unsigned char ALIGNED_len [LZX_ALIGNED_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; + + /* huffman decoding tables */ + unsigned short PRETREE_table [(1 << LZX_PRETREE_TABLEBITS) + + (LZX_PRETREE_MAXSYMBOLS * 2)]; + unsigned short MAINTREE_table[(1 << LZX_MAINTREE_TABLEBITS) + + (LZX_MAINTREE_MAXSYMBOLS * 2)]; + unsigned short LENGTH_table [(1 << LZX_LENGTH_TABLEBITS) + + (LZX_LENGTH_MAXSYMBOLS * 2)]; + unsigned short ALIGNED_table [(1 << LZX_ALIGNED_TABLEBITS) + + (LZX_ALIGNED_MAXSYMBOLS * 2)]; + unsigned char LENGTH_empty; + + /* this is used purely for doing the intel E8 transform */ + unsigned char e8_buf[LZX_FRAME_SIZE]; +}; + +/** + * Allocates and initialises LZX decompression state for decoding an LZX + * stream. + * + * This routine uses system->alloc() to allocate memory. If memory + * allocation fails, or the parameters to this function are invalid, + * NULL is returned. + * + * @param system an mspack_system structure used to read from + * the input stream and write to the output + * stream, also to allocate and free memory. + * @param input an input stream with the LZX data. + * @param output an output stream to write the decoded data to. + * @param window_bits the size of the decoding window, which must be + * between 15 and 21 inclusive for regular LZX + * data, or between 17 and 25 inclusive for + * LZX DELTA data. + * @param reset_interval the interval at which the LZX bitstream is + * reset, in multiples of LZX frames (32678 + * bytes), e.g. a value of 2 indicates the input + * stream resets after every 65536 output bytes. + * A value of 0 indicates that the bitstream never + * resets, such as in CAB LZX streams. + * @param input_buffer_size the number of bytes to use as an input + * bitstream buffer. + * @param output_length the length in bytes of the entirely + * decompressed output stream, if known in + * advance. It is used to correctly perform the + * Intel E8 transformation, which must stop 6 + * bytes before the very end of the + * decompressed stream. It is not otherwise used + * or adhered to. If the full decompressed + * length is known in advance, set it here. + * If it is NOT known, use the value 0, and call + * lzxd_set_output_length() once it is + * known. If never set, 4 of the final 6 bytes + * of the output stream may be incorrect. + * @param is_delta should be zero for all regular LZX data, + * non-zero for LZX DELTA encoded data. + * @return a pointer to an initialised lzxd_stream structure, or NULL if + * there was not enough memory or parameters to the function were wrong. + */ +extern struct lzxd_stream *lzxd_init(struct mspack_system *system, + struct mspack_file *input, + struct mspack_file *output, + int window_bits, + int reset_interval, + int input_buffer_size, + off_t output_length, + char is_delta); + +/* see description of output_length in lzxd_init() */ +extern void lzxd_set_output_length(struct lzxd_stream *lzx, + off_t output_length); + +/** + * Reads LZX DELTA reference data into the window and allows + * lzxd_decompress() to reference it. + * + * Call this before the first call to lzxd_decompress(). + + * @param lzx the LZX stream to apply this reference data to + * @param system an mspack_system implementation to use with the + * input param. Only read() will be called. + * @param input an input file handle to read reference data using + * system->read(). + * @param length the length of the reference data. Cannot be longer + * than the LZX window size. + * @return an error code, or MSPACK_ERR_OK if successful + */ +extern int lzxd_set_reference_data(struct lzxd_stream *lzx, + struct mspack_system *system, + struct mspack_file *input, + unsigned int length); + +/** + * Decompresses entire or partial LZX streams. + * + * The number of bytes of data that should be decompressed is given as the + * out_bytes parameter. If more bytes are decoded than are needed, they + * will be kept over for a later invocation. + * + * The output bytes will be passed to the system->write() function given in + * lzxd_init(), using the output file handle given in lzxd_init(). More than + * one call may be made to system->write(). + + * Input bytes will be read in as necessary using the system->read() + * function given in lzxd_init(), using the input file handle given in + * lzxd_init(). This will continue until system->read() returns 0 bytes, + * or an error. Errors will be passed out of the function as + * MSPACK_ERR_READ errors. Input streams should convey an "end of input + * stream" by refusing to supply all the bytes that LZX asks for when they + * reach the end of the stream, rather than return an error code. + * + * If any error code other than MSPACK_ERR_OK is returned, the stream + * should be considered unusable and lzxd_decompress() should not be + * called again on this stream. + * + * @param lzx LZX decompression state, as allocated by lzxd_init(). + * @param out_bytes the number of bytes of data to decompress. + * @return an error code, or MSPACK_ERR_OK if successful + */ +extern int lzxd_decompress(struct lzxd_stream *lzx, off_t out_bytes); + +/** + * Frees all state associated with an LZX data stream. This will call + * system->free() using the system pointer given in lzxd_init(). + * + * @param lzx LZX decompression state to free. + */ +void lzxd_free(struct lzxd_stream *lzx); + +#ifdef __cplusplus +} +#endif + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/mspack.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/mspack.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/mspack.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/mspack.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,2353 @@ +/* libmspack -- a library for working with Microsoft compression formats. + * (C) 2003-2013 Stuart Caie + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** \mainpage + * + * \section intro Introduction + * + * libmspack is a library which provides compressors and decompressors, + * archivers and dearchivers for Microsoft compression formats. + * + * \section formats Formats supported + * + * The following file formats are supported: + * - SZDD files, which use LZSS compression + * - KWAJ files, which use LZSS, LZSS+Huffman or deflate compression + * - .HLP (MS Help) files, which use LZSS compression + * - .CAB (MS Cabinet) files, which use deflate, LZX or Quantum compression + * - .CHM (HTML Help) files, which use LZX compression + * - .LIT (MS EBook) files, which use LZX compression and DES encryption + * - .LZX (Exchange Offline Addressbook) files, which use LZX compression + * + * To determine the capabilities of the library, and the binary + * compatibility version of any particular compressor or decompressor, use + * the mspack_version() function. The UNIX library interface version is + * defined as the highest-versioned library component. + * + * \section starting Getting started + * + * The macro MSPACK_SYS_SELFTEST() should be used to ensure the library can + * be used. In particular, it checks if the caller is using 32-bit file I/O + * when the library is compiled for 64-bit file I/O and vice versa. + * + * If compiled normally, the library includes basic file I/O and memory + * management functionality using the standard C library. This can be + * customised and replaced entirely by creating a mspack_system structure. + * + * A compressor or decompressor for the required format must be + * instantiated before it can be used. Each construction function takes + * one parameter, which is either a pointer to a custom mspack_system + * structure, or NULL to use the default. The instantiation returned, if + * not NULL, contains function pointers (methods) to work with the given + * file format. + * + * For compression: + * - mspack_create_cab_compressor() creates a mscab_compressor + * - mspack_create_chm_compressor() creates a mschm_compressor + * - mspack_create_lit_compressor() creates a mslit_compressor + * - mspack_create_hlp_compressor() creates a mshlp_compressor + * - mspack_create_szdd_compressor() creates a msszdd_compressor + * - mspack_create_kwaj_compressor() creates a mskwaj_compressor + * - mspack_create_oab_compressor() creates a msoab_compressor + * + * For decompression: + * - mspack_create_cab_decompressor() creates a mscab_decompressor + * - mspack_create_chm_decompressor() creates a mschm_decompressor + * - mspack_create_lit_decompressor() creates a mslit_decompressor + * - mspack_create_hlp_decompressor() creates a mshlp_decompressor + * - mspack_create_szdd_decompressor() creates a msszdd_decompressor + * - mspack_create_kwaj_decompressor() creates a mskwaj_decompressor + * - mspack_create_oab_decompressor() creates a msoab_decompressor + * + * Once finished working with a format, each kind of + * compressor/decompressor has its own specific destructor: + * - mspack_destroy_cab_compressor() + * - mspack_destroy_cab_decompressor() + * - mspack_destroy_chm_compressor() + * - mspack_destroy_chm_decompressor() + * - mspack_destroy_lit_compressor() + * - mspack_destroy_lit_decompressor() + * - mspack_destroy_hlp_compressor() + * - mspack_destroy_hlp_decompressor() + * - mspack_destroy_szdd_compressor() + * - mspack_destroy_szdd_decompressor() + * - mspack_destroy_kwaj_compressor() + * - mspack_destroy_kwaj_decompressor() + * - mspack_destroy_oab_compressor() + * - mspack_destroy_oab_decompressor() + * + * Destroying a compressor or decompressor does not destroy any objects, + * structures or handles that have been created using that compressor or + * decompressor. Ensure that everything created or opened is destroyed or + * closed before compressor/decompressor is itself destroyed. + * + * \section errors Error codes + * + * All compressors and decompressors use the same set of error codes. Most + * methods return an error code directly. For methods which do not + * return error codes directly, the error code can be obtained with the + * last_error() method. + * + * - #MSPACK_ERR_OK is used to indicate success. This error code is defined + * as zero, all other code are non-zero. + * - #MSPACK_ERR_ARGS indicates that a method was called with inappropriate + * arguments. + * - #MSPACK_ERR_OPEN indicates that mspack_system::open() failed. + * - #MSPACK_ERR_READ indicates that mspack_system::read() failed. + * - #MSPACK_ERR_WRITE indicates that mspack_system::write() failed. + * - #MSPACK_ERR_SEEK indicates that mspack_system::seek() failed. + * - #MSPACK_ERR_NOMEMORY indicates that mspack_system::alloc() failed. + * - #MSPACK_ERR_SIGNATURE indicates that the file being read does not + * have the correct "signature". It is probably not a valid file for + * whatever format is being read. + * - #MSPACK_ERR_DATAFORMAT indicates that the file being used or read + * is corrupt. + * - #MSPACK_ERR_CHECKSUM indicates that a data checksum has failed. + * - #MSPACK_ERR_CRUNCH indicates an error occured during compression. + * - #MSPACK_ERR_DECRUNCH indicates an error occured during decompression. + * + * \section threading Multi-threading + * + * libmspack methods are reentrant and multithreading-safe when each + * thread has its own compressor or decompressor. + + * You should not call multiple methods simultaneously on a single + * compressor or decompressor instance. + * + * If this may happen, you can either use one compressor or + * decompressor per thread, or you can use your preferred lock, + * semaphore or mutex library to ensure no more than one method on a + * compressor/decompressor is called simultaneously. libmspack will + * not do this locking for you. + * + * Example of incorrect behaviour: + * - thread 1 calls mspack_create_cab_decompressor() + * - thread 1 calls open() + * - thread 1 calls extract() for one file + * - thread 2 simultaneously calls extract() for another file + * + * Correct behaviour: + * - thread 1 calls mspack_create_cab_decompressor() + * - thread 2 calls mspack_create_cab_decompressor() + * - thread 1 calls its own open() / extract() + * - thread 2 simultaneously calls its own open() / extract() + * + * Also correct behaviour: + * - thread 1 calls mspack_create_cab_decompressor() + * - thread 1 locks a mutex for with the decompressor before + * calling any methods on it, and unlocks the mutex after each + * method returns. + * - thread 1 can share the results of open() with thread 2, and both + * can call extract(), provided they both guard against simultaneous + * use of extract(), and any other methods, with the mutex + */ + +#ifndef LIB_MSPACK_H +#define LIB_MSPACK_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * System self-test function, to ensure both library and calling program + * can use one another. + * + * A result of MSPACK_ERR_OK means the library and caller are + * compatible. Any other result indicates that the library and caller are + * not compatible and should not be used. In particular, a value of + * MSPACK_ERR_SEEK means the library and caller use different off_t + * datatypes. + * + * It should be used like so: + * + * @code + * int selftest_result; + * MSPACK_SYS_SELFTEST(selftest_result); + * if (selftest_result != MSPACK_ERR_OK) { + * fprintf(stderr, "incompatible with this build of libmspack\n"); + * exit(0); + * } + * @endcode + * + * @param result an int variable to store the result of the self-test + */ +#define MSPACK_SYS_SELFTEST(result) do { \ + (result) = mspack_sys_selftest_internal(sizeof(off_t)); \ +} while (0) + +/** Part of the MSPACK_SYS_SELFTEST() macro, must not be used directly. */ +extern int mspack_sys_selftest_internal(int); + +/** + * Enquire about the binary compatibility version of a specific interface in + * the library. Currently, the following interfaces are defined: + * + * - #MSPACK_VER_LIBRARY: the overall library + * - #MSPACK_VER_SYSTEM: the mspack_system interface + * - #MSPACK_VER_MSCABD: the mscab_decompressor interface + * - #MSPACK_VER_MSCABC: the mscab_compressor interface + * - #MSPACK_VER_MSCHMD: the mschm_decompressor interface + * - #MSPACK_VER_MSCHMC: the mschm_compressor interface + * - #MSPACK_VER_MSLITD: the mslit_decompressor interface + * - #MSPACK_VER_MSLITC: the mslit_compressor interface + * - #MSPACK_VER_MSHLPD: the mshlp_decompressor interface + * - #MSPACK_VER_MSHLPC: the mshlp_compressor interface + * - #MSPACK_VER_MSSZDDD: the msszdd_decompressor interface + * - #MSPACK_VER_MSSZDDC: the msszdd_compressor interface + * - #MSPACK_VER_MSKWAJD: the mskwaj_decompressor interface + * - #MSPACK_VER_MSKWAJC: the mskwaj_compressor interface + * - #MSPACK_VER_MSOABD: the msoab_decompressor interface + * - #MSPACK_VER_MSOABC: the msoab_compressor interface + * + * The result of the function should be interpreted as follows: + * - -1: this interface is completely unknown to the library + * - 0: this interface is known, but non-functioning + * - 1: this interface has all basic functionality + * - 2, 3, ...: this interface has additional functionality, clearly marked + * in the documentation as "version 2", "version 3" and so on. + * + * @param entity the interface to request current version of + * @return the version of the requested interface + */ +extern int mspack_version(int entity); + +/** Pass to mspack_version() to get the overall library version */ +#define MSPACK_VER_LIBRARY (0) +/** Pass to mspack_version() to get the mspack_system version */ +#define MSPACK_VER_SYSTEM (1) +/** Pass to mspack_version() to get the mscab_decompressor version */ +#define MSPACK_VER_MSCABD (2) +/** Pass to mspack_version() to get the mscab_compressor version */ +#define MSPACK_VER_MSCABC (3) +/** Pass to mspack_version() to get the mschm_decompressor version */ +#define MSPACK_VER_MSCHMD (4) +/** Pass to mspack_version() to get the mschm_compressor version */ +#define MSPACK_VER_MSCHMC (5) +/** Pass to mspack_version() to get the mslit_decompressor version */ +#define MSPACK_VER_MSLITD (6) +/** Pass to mspack_version() to get the mslit_compressor version */ +#define MSPACK_VER_MSLITC (7) +/** Pass to mspack_version() to get the mshlp_decompressor version */ +#define MSPACK_VER_MSHLPD (8) +/** Pass to mspack_version() to get the mshlp_compressor version */ +#define MSPACK_VER_MSHLPC (9) +/** Pass to mspack_version() to get the msszdd_decompressor version */ +#define MSPACK_VER_MSSZDDD (10) +/** Pass to mspack_version() to get the msszdd_compressor version */ +#define MSPACK_VER_MSSZDDC (11) +/** Pass to mspack_version() to get the mskwaj_decompressor version */ +#define MSPACK_VER_MSKWAJD (12) +/** Pass to mspack_version() to get the mskwaj_compressor version */ +#define MSPACK_VER_MSKWAJC (13) +/** Pass to mspack_version() to get the msoab_decompressor version */ +#define MSPACK_VER_MSOABD (14) +/** Pass to mspack_version() to get the msoab_compressor version */ +#define MSPACK_VER_MSOABC (15) + +/* --- file I/O abstraction ------------------------------------------------ */ + +/** + * A structure which abstracts file I/O and memory management. + * + * The library always uses the mspack_system structure for interaction + * with the file system and to allocate, free and copy all memory. It also + * uses it to send literal messages to the library user. + * + * When the library is compiled normally, passing NULL to a compressor or + * decompressor constructor will result in a default mspack_system being + * used, where all methods are implemented with the standard C library. + * However, all constructors support being given a custom created + * mspack_system structure, with the library user's own methods. This + * allows for more abstract interaction, such as reading and writing files + * directly to memory, or from a network socket or pipe. + * + * Implementors of an mspack_system structure should read all + * documentation entries for every structure member, and write methods + * which conform to those standards. + */ +struct mspack_system { + /** + * Opens a file for reading, writing, appending or updating. + * + * @param self a self-referential pointer to the mspack_system + * structure whose open() method is being called. If + * this pointer is required by close(), read(), write(), + * seek() or tell(), it should be stored in the result + * structure at this time. + * @param filename the file to be opened. It is passed directly from the + * library caller without being modified, so it is up to + * the caller what this parameter actually represents. + * @param mode one of #MSPACK_SYS_OPEN_READ (open an existing file + * for reading), #MSPACK_SYS_OPEN_WRITE (open a new file + * for writing), #MSPACK_SYS_OPEN_UPDATE (open an existing + * file for reading/writing from the start of the file) or + * #MSPACK_SYS_OPEN_APPEND (open an existing file for + * reading/writing from the end of the file) + * @return a pointer to a mspack_file structure. This structure officially + * contains no members, its true contents are up to the + * mspack_system implementor. It should contain whatever is needed + * for other mspack_system methods to operate. Returning the NULL + * pointer indicates an error condition. + * @see close(), read(), write(), seek(), tell(), message() + */ + struct mspack_file * (*open)(struct mspack_system *self, + const char *filename, + int mode); + + /** + * Closes a previously opened file. If any memory was allocated for this + * particular file handle, it should be freed at this time. + * + * @param file the file to close + * @see open() + */ + void (*close)(struct mspack_file *file); + + /** + * Reads a given number of bytes from an open file. + * + * @param file the file to read from + * @param buffer the location where the read bytes should be stored + * @param bytes the number of bytes to read from the file. + * @return the number of bytes successfully read (this can be less than + * the number requested), zero to mark the end of file, or less + * than zero to indicate an error. + * @see open(), write() + */ + int (*read)(struct mspack_file *file, + void *buffer, + int bytes); + + /** + * Writes a given number of bytes to an open file. + * + * @param file the file to write to + * @param buffer the location where the written bytes should be read from + * @param bytes the number of bytes to write to the file. + * @return the number of bytes successfully written, this can be less + * than the number requested. Zero or less can indicate an error + * where no bytes at all could be written. All cases where less + * bytes were written than requested are considered by the library + * to be an error. + * @see open(), read() + */ + int (*write)(struct mspack_file *file, + void *buffer, + int bytes); + + /** + * Seeks to a specific file offset within an open file. + * + * Sometimes the library needs to know the length of a file. It does + * this by seeking to the end of the file with seek(file, 0, + * MSPACK_SYS_SEEK_END), then calling tell(). Implementations may want + * to make a special case for this. + * + * Due to the potentially varying 32/64 bit datatype off_t on some + * architectures, the #MSPACK_SYS_SELFTEST macro MUST be used before + * using the library. If not, the error caused by the library passing an + * inappropriate stackframe to seek() is subtle and hard to trace. + * + * @param file the file to be seeked + * @param offset an offset to seek, measured in bytes + * @param mode one of #MSPACK_SYS_SEEK_START (the offset should be + * measured from the start of the file), #MSPACK_SYS_SEEK_CUR + * (the offset should be measured from the current file offset) + * or #MSPACK_SYS_SEEK_END (the offset should be measured from + * the end of the file) + * @return zero for success, non-zero for an error + * @see open(), tell() + */ + int (*seek)(struct mspack_file *file, + off_t offset, + int mode); + + /** + * Returns the current file position (in bytes) of the given file. + * + * @param file the file whose file position is wanted + * @return the current file position of the file + * @see open(), seek() + */ + off_t (*tell)(struct mspack_file *file); + + /** + * Used to send messages from the library to the user. + * + * Occasionally, the library generates warnings or other messages in + * plain english to inform the human user. These are informational only + * and can be ignored if not wanted. + * + * @param file may be a file handle returned from open() if this message + * pertains to a specific open file, or NULL if not related to + * a specific file. + * @param format a printf() style format string. It does NOT include a + * trailing newline. + * @see open() + */ + void (*message)(struct mspack_file *file, + const char *format, + ...); + + /** + * Allocates memory. + * + * @param self a self-referential pointer to the mspack_system + * structure whose alloc() method is being called. + * @param bytes the number of bytes to allocate + * @result a pointer to the requested number of bytes, or NULL if + * not enough memory is available + * @see free() + */ + void * (*alloc)(struct mspack_system *self, + size_t bytes); + + /** + * Frees memory. + * + * @param ptr the memory to be freed. + * @see alloc() + */ + void (*free)(void *ptr); + + /** + * Copies from one region of memory to another. + * + * The regions of memory are guaranteed not to overlap, are usually less + * than 256 bytes, and may not be aligned. Please note that the source + * parameter comes before the destination parameter, unlike the standard + * C function memcpy(). + * + * @param src the region of memory to copy from + * @param dest the region of memory to copy to + * @param bytes the size of the memory region, in bytes + */ + void (*copy)(void *src, + void *dest, + size_t bytes); + + /** + * A null pointer to mark the end of mspack_system. It must equal NULL. + * + * Should the mspack_system structure extend in the future, this NULL + * will be seen, rather than have an invalid method pointer called. + */ + void *null_ptr; +}; + +/** mspack_system::open() mode: open existing file for reading. */ +#define MSPACK_SYS_OPEN_READ (0) +/** mspack_system::open() mode: open new file for writing */ +#define MSPACK_SYS_OPEN_WRITE (1) +/** mspack_system::open() mode: open existing file for writing */ +#define MSPACK_SYS_OPEN_UPDATE (2) +/** mspack_system::open() mode: open existing file for writing */ +#define MSPACK_SYS_OPEN_APPEND (3) + +/** mspack_system::seek() mode: seek relative to start of file */ +#define MSPACK_SYS_SEEK_START (0) +/** mspack_system::seek() mode: seek relative to current offset */ +#define MSPACK_SYS_SEEK_CUR (1) +/** mspack_system::seek() mode: seek relative to end of file */ +#define MSPACK_SYS_SEEK_END (2) + +/** + * A structure which represents an open file handle. The contents of this + * structure are determined by the implementation of the + * mspack_system::open() method. + */ +struct mspack_file { + int dummy; +}; + +/* --- error codes --------------------------------------------------------- */ + +/** Error code: no error */ +#define MSPACK_ERR_OK (0) +/** Error code: bad arguments to method */ +#define MSPACK_ERR_ARGS (1) +/** Error code: error opening file */ +#define MSPACK_ERR_OPEN (2) +/** Error code: error reading file */ +#define MSPACK_ERR_READ (3) +/** Error code: error writing file */ +#define MSPACK_ERR_WRITE (4) +/** Error code: seek error */ +#define MSPACK_ERR_SEEK (5) +/** Error code: out of memory */ +#define MSPACK_ERR_NOMEMORY (6) +/** Error code: bad "magic id" in file */ +#define MSPACK_ERR_SIGNATURE (7) +/** Error code: bad or corrupt file format */ +#define MSPACK_ERR_DATAFORMAT (8) +/** Error code: bad checksum or CRC */ +#define MSPACK_ERR_CHECKSUM (9) +/** Error code: error during compression */ +#define MSPACK_ERR_CRUNCH (10) +/** Error code: error during decompression */ +#define MSPACK_ERR_DECRUNCH (11) + +/* --- functions available in library -------------------------------------- */ + +/** Creates a new CAB compressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #mscab_compressor or NULL + */ +extern struct mscab_compressor * + mspack_create_cab_compressor(struct mspack_system *sys); + +/** Creates a new CAB decompressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #mscab_decompressor or NULL + */ +extern struct mscab_decompressor * + mspack_create_cab_decompressor(struct mspack_system *sys); + +/** Destroys an existing CAB compressor. + * @param self the #mscab_compressor to destroy + */ +extern void mspack_destroy_cab_compressor(struct mscab_compressor *self); + +/** Destroys an existing CAB decompressor. + * @param self the #mscab_decompressor to destroy + */ +extern void mspack_destroy_cab_decompressor(struct mscab_decompressor *self); + + +/** Creates a new CHM compressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #mschm_compressor or NULL + */ +extern struct mschm_compressor * + mspack_create_chm_compressor(struct mspack_system *sys); + +/** Creates a new CHM decompressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #mschm_decompressor or NULL + */ +extern struct mschm_decompressor * + mspack_create_chm_decompressor(struct mspack_system *sys); + +/** Destroys an existing CHM compressor. + * @param self the #mschm_compressor to destroy + */ +extern void mspack_destroy_chm_compressor(struct mschm_compressor *self); + +/** Destroys an existing CHM decompressor. + * @param self the #mschm_decompressor to destroy + */ +extern void mspack_destroy_chm_decompressor(struct mschm_decompressor *self); + + +/** Creates a new LIT compressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #mslit_compressor or NULL + */ +extern struct mslit_compressor * + mspack_create_lit_compressor(struct mspack_system *sys); + +/** Creates a new LIT decompressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #mslit_decompressor or NULL + */ +extern struct mslit_decompressor * + mspack_create_lit_decompressor(struct mspack_system *sys); + +/** Destroys an existing LIT compressor. + * @param self the #mslit_compressor to destroy + */ +extern void mspack_destroy_lit_compressor(struct mslit_compressor *self); + +/** Destroys an existing LIT decompressor. + * @param self the #mslit_decompressor to destroy + */ +extern void mspack_destroy_lit_decompressor(struct mslit_decompressor *self); + + +/** Creates a new HLP compressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #mshlp_compressor or NULL + */ +extern struct mshlp_compressor * + mspack_create_hlp_compressor(struct mspack_system *sys); + +/** Creates a new HLP decompressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #mshlp_decompressor or NULL + */ +extern struct mshlp_decompressor * + mspack_create_hlp_decompressor(struct mspack_system *sys); + +/** Destroys an existing hlp compressor. + * @param self the #mshlp_compressor to destroy + */ +extern void mspack_destroy_hlp_compressor(struct mshlp_compressor *self); + +/** Destroys an existing hlp decompressor. + * @param self the #mshlp_decompressor to destroy + */ +extern void mspack_destroy_hlp_decompressor(struct mshlp_decompressor *self); + + +/** Creates a new SZDD compressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #msszdd_compressor or NULL + */ +extern struct msszdd_compressor * + mspack_create_szdd_compressor(struct mspack_system *sys); + +/** Creates a new SZDD decompressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #msszdd_decompressor or NULL + */ +extern struct msszdd_decompressor * + mspack_create_szdd_decompressor(struct mspack_system *sys); + +/** Destroys an existing SZDD compressor. + * @param self the #msszdd_compressor to destroy + */ +extern void mspack_destroy_szdd_compressor(struct msszdd_compressor *self); + +/** Destroys an existing SZDD decompressor. + * @param self the #msszdd_decompressor to destroy + */ +extern void mspack_destroy_szdd_decompressor(struct msszdd_decompressor *self); + + +/** Creates a new KWAJ compressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #mskwaj_compressor or NULL + */ +extern struct mskwaj_compressor * + mspack_create_kwaj_compressor(struct mspack_system *sys); + +/** Creates a new KWAJ decompressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #mskwaj_decompressor or NULL + */ +extern struct mskwaj_decompressor * + mspack_create_kwaj_decompressor(struct mspack_system *sys); + +/** Destroys an existing KWAJ compressor. + * @param self the #mskwaj_compressor to destroy + */ +extern void mspack_destroy_kwaj_compressor(struct mskwaj_compressor *self); + +/** Destroys an existing KWAJ decompressor. + * @param self the #mskwaj_decompressor to destroy + */ +extern void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *self); + + +/** Creates a new OAB compressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #msoab_compressor or NULL + */ +extern struct msoab_compressor * + mspack_create_oab_compressor(struct mspack_system *sys); + +/** Creates a new OAB decompressor. + * @param sys a custom mspack_system structure, or NULL to use the default + * @return a #msoab_decompressor or NULL + */ +extern struct msoab_decompressor * + mspack_create_oab_decompressor(struct mspack_system *sys); + +/** Destroys an existing OAB compressor. + * @param self the #msoab_compressor to destroy + */ +extern void mspack_destroy_oab_compressor(struct msoab_compressor *self); + +/** Destroys an existing OAB decompressor. + * @param self the #msoab_decompressor to destroy + */ +extern void mspack_destroy_oab_decompressor(struct msoab_decompressor *self); + + +/* --- support for .CAB (MS Cabinet) file format --------------------------- */ + +/** + * A structure which represents a single cabinet file. + * + * All fields are READ ONLY. + * + * If this cabinet is part of a merged cabinet set, the #files and #folders + * fields are common to all cabinets in the set, and will be identical. + * + * @see mscab_decompressor::open(), mscab_decompressor::close(), + * mscab_decompressor::search() + */ +struct mscabd_cabinet { + /** + * The next cabinet in a chained list, if this cabinet was opened with + * mscab_decompressor::search(). May be NULL to mark the end of the + * list. + */ + struct mscabd_cabinet *next; + + /** + * The filename of the cabinet. More correctly, the filename of the + * physical file that the cabinet resides in. This is given by the + * library user and may be in any format. + */ + const char *filename; + + /** The file offset of cabinet within the physical file it resides in. */ + off_t base_offset; + + /** The length of the cabinet file in bytes. */ + unsigned int length; + + /** The previous cabinet in a cabinet set, or NULL. */ + struct mscabd_cabinet *prevcab; + + /** The next cabinet in a cabinet set, or NULL. */ + struct mscabd_cabinet *nextcab; + + /** The filename of the previous cabinet in a cabinet set, or NULL. */ + char *prevname; + + /** The filename of the next cabinet in a cabinet set, or NULL. */ + char *nextname; + + /** The name of the disk containing the previous cabinet in a cabinet + * set, or NULL. + */ + char *previnfo; + + /** The name of the disk containing the next cabinet in a cabinet set, + * or NULL. + */ + char *nextinfo; + + /** A list of all files in the cabinet or cabinet set. */ + struct mscabd_file *files; + + /** A list of all folders in the cabinet or cabinet set. */ + struct mscabd_folder *folders; + + /** + * The set ID of the cabinet. All cabinets in the same set should have + * the same set ID. + */ + unsigned short set_id; + + /** + * The index number of the cabinet within the set. Numbering should + * start from 0 for the first cabinet in the set, and increment by 1 for + * each following cabinet. + */ + unsigned short set_index; + + /** + * The number of bytes reserved in the header area of the cabinet. + * + * If this is non-zero and flags has MSCAB_HDR_RESV set, this data can + * be read by the calling application. It is of the given length, + * located at offset (base_offset + MSCAB_HDR_RESV_OFFSET) in the + * cabinet file. + * + * @see flags + */ + unsigned short header_resv; + + /** + * Header flags. + * + * - MSCAB_HDR_PREVCAB indicates the cabinet is part of a cabinet set, and + * has a predecessor cabinet. + * - MSCAB_HDR_NEXTCAB indicates the cabinet is part of a cabinet set, and + * has a successor cabinet. + * - MSCAB_HDR_RESV indicates the cabinet has reserved header space. + * + * @see prevname, previnfo, nextname, nextinfo, header_resv + */ + int flags; +}; + +/** Offset from start of cabinet to the reserved header data (if present). */ +#define MSCAB_HDR_RESV_OFFSET (0x28) + +/** Cabinet header flag: cabinet has a predecessor */ +#define MSCAB_HDR_PREVCAB (0x01) +/** Cabinet header flag: cabinet has a successor */ +#define MSCAB_HDR_NEXTCAB (0x02) +/** Cabinet header flag: cabinet has reserved header space */ +#define MSCAB_HDR_RESV (0x04) + +/** + * A structure which represents a single folder in a cabinet or cabinet set. + * + * All fields are READ ONLY. + * + * A folder is a single compressed stream of data. When uncompressed, it + * holds the data of one or more files. A folder may be split across more + * than one cabinet. + */ +struct mscabd_folder { + /** + * A pointer to the next folder in this cabinet or cabinet set, or NULL + * if this is the final folder. + */ + struct mscabd_folder *next; + + /** + * The compression format used by this folder. + * + * The macro MSCABD_COMP_METHOD() should be used on this field to get + * the algorithm used. The macro MSCABD_COMP_LEVEL() should be used to get + * the "compression level". + * + * @see MSCABD_COMP_METHOD(), MSCABD_COMP_LEVEL() + */ + int comp_type; + + /** + * The total number of data blocks used by this folder. This includes + * data blocks present in other files, if this folder spans more than + * one cabinet. + */ + unsigned int num_blocks; +}; + +/** + * Returns the compression method used by a folder. + * + * @param comp_type a mscabd_folder::comp_type value + * @return one of #MSCAB_COMP_NONE, #MSCAB_COMP_MSZIP, #MSCAB_COMP_QUANTUM + * or #MSCAB_COMP_LZX + */ +#define MSCABD_COMP_METHOD(comp_type) ((comp_type) & 0x0F) +/** + * Returns the compression level used by a folder. + * + * @param comp_type a mscabd_folder::comp_type value + * @return the compression level. This is only defined by LZX and Quantum + * compression + */ +#define MSCABD_COMP_LEVEL(comp_type) (((comp_type) >> 8) & 0x1F) + +/** Compression mode: no compression. */ +#define MSCAB_COMP_NONE (0) +/** Compression mode: MSZIP (deflate) compression. */ +#define MSCAB_COMP_MSZIP (1) +/** Compression mode: Quantum compression */ +#define MSCAB_COMP_QUANTUM (2) +/** Compression mode: LZX compression */ +#define MSCAB_COMP_LZX (3) + +/** + * A structure which represents a single file in a cabinet or cabinet set. + * + * All fields are READ ONLY. + */ +struct mscabd_file { + /** + * The next file in the cabinet or cabinet set, or NULL if this is the + * final file. + */ + struct mscabd_file *next; + + /** + * The filename of the file. + * + * A null terminated string of up to 255 bytes in length, it may be in + * either ISO-8859-1 or UTF8 format, depending on the file attributes. + * + * @see attribs + */ + char *filename; + + /** The uncompressed length of the file, in bytes. */ + unsigned int length; + + /** + * File attributes. + * + * The following attributes are defined: + * - #MSCAB_ATTRIB_RDONLY indicates the file is write protected. + * - #MSCAB_ATTRIB_HIDDEN indicates the file is hidden. + * - #MSCAB_ATTRIB_SYSTEM indicates the file is a operating system file. + * - #MSCAB_ATTRIB_ARCH indicates the file is "archived". + * - #MSCAB_ATTRIB_EXEC indicates the file is an executable program. + * - #MSCAB_ATTRIB_UTF_NAME indicates the filename is in UTF8 format rather + * than ISO-8859-1. + */ + int attribs; + + /** File's last modified time, hour field. */ + char time_h; + /** File's last modified time, minute field. */ + char time_m; + /** File's last modified time, second field. */ + char time_s; + + /** File's last modified date, day field. */ + char date_d; + /** File's last modified date, month field. */ + char date_m; + /** File's last modified date, year field. */ + int date_y; + + /** A pointer to the folder that contains this file. */ + struct mscabd_folder *folder; + + /** The uncompressed offset of this file in its folder. */ + unsigned int offset; +}; + +/** mscabd_file::attribs attribute: file is read-only. */ +#define MSCAB_ATTRIB_RDONLY (0x01) +/** mscabd_file::attribs attribute: file is hidden. */ +#define MSCAB_ATTRIB_HIDDEN (0x02) +/** mscabd_file::attribs attribute: file is an operating system file. */ +#define MSCAB_ATTRIB_SYSTEM (0x04) +/** mscabd_file::attribs attribute: file is "archived". */ +#define MSCAB_ATTRIB_ARCH (0x20) +/** mscabd_file::attribs attribute: file is an executable program. */ +#define MSCAB_ATTRIB_EXEC (0x40) +/** mscabd_file::attribs attribute: filename is UTF8, not ISO-8859-1. */ +#define MSCAB_ATTRIB_UTF_NAME (0x80) + +/** mscab_decompressor::set_param() parameter: search buffer size. */ +#define MSCABD_PARAM_SEARCHBUF (0) +/** mscab_decompressor::set_param() parameter: repair MS-ZIP streams? */ +#define MSCABD_PARAM_FIXMSZIP (1) +/** mscab_decompressor::set_param() parameter: size of decompression buffer */ +#define MSCABD_PARAM_DECOMPBUF (2) + +/** TODO */ +struct mscab_compressor { + int dummy; +}; + +/** + * A decompressor for .CAB (Microsoft Cabinet) files + * + * All fields are READ ONLY. + * + * @see mspack_create_cab_decompressor(), mspack_destroy_cab_decompressor() + */ +struct mscab_decompressor { + /** + * Opens a cabinet file and reads its contents. + * + * If the file opened is a valid cabinet file, all headers will be read + * and a mscabd_cabinet structure will be returned, with a full list of + * folders and files. + * + * In the case of an error occuring, NULL is returned and the error code + * is available from last_error(). + * + * The filename pointer should be considered "in use" until close() is + * called on the cabinet. + * + * @param self a self-referential pointer to the mscab_decompressor + * instance being called + * @param filename the filename of the cabinet file. This is passed + * directly to mspack_system::open(). + * @return a pointer to a mscabd_cabinet structure, or NULL on failure + * @see close(), search(), last_error() + */ + struct mscabd_cabinet * (*open) (struct mscab_decompressor *self, + const char *filename); + + /** + * Closes a previously opened cabinet or cabinet set. + * + * This closes a cabinet, all cabinets associated with it via the + * mscabd_cabinet::next, mscabd_cabinet::prevcab and + * mscabd_cabinet::nextcab pointers, and all folders and files. All + * memory used by these entities is freed. + * + * The cabinet pointer is now invalid and cannot be used again. All + * mscabd_folder and mscabd_file pointers from that cabinet or cabinet + * set are also now invalid, and cannot be used again. + * + * If the cabinet pointer given was created using search(), it MUST be + * the cabinet pointer returned by search() and not one of the later + * cabinet pointers further along the mscabd_cabinet::next chain. + + * If extra cabinets have been added using append() or prepend(), these + * will all be freed, even if the cabinet pointer given is not the first + * cabinet in the set. Do NOT close() more than one cabinet in the set. + * + * The mscabd_cabinet::filename is not freed by the library, as it is + * not allocated by the library. The caller should free this itself if + * necessary, before it is lost forever. + * + * @param self a self-referential pointer to the mscab_decompressor + * instance being called + * @param cab the cabinet to close + * @see open(), search(), append(), prepend() + */ + void (*close)(struct mscab_decompressor *self, + struct mscabd_cabinet *cab); + + /** + * Searches a regular file for embedded cabinets. + * + * This opens a normal file with the given filename and will search the + * entire file for embedded cabinet files + * + * If any cabinets are found, the equivalent of open() is called on each + * potential cabinet file at the offset it was found. All successfully + * open()ed cabinets are kept in a list. + * + * The first cabinet found will be returned directly as the result of + * this method. Any further cabinets found will be chained in a list + * using the mscabd_cabinet::next field. + * + * In the case of an error occuring anywhere other than the simulated + * open(), NULL is returned and the error code is available from + * last_error(). + * + * If no error occurs, but no cabinets can be found in the file, NULL is + * returned and last_error() returns MSPACK_ERR_OK. + * + * The filename pointer should be considered in use until close() is + * called on the cabinet. + * + * close() should only be called on the result of search(), not on any + * subsequent cabinets in the mscabd_cabinet::next chain. + * + * @param self a self-referential pointer to the mscab_decompressor + * instance being called + * @param filename the filename of the file to search for cabinets. This + * is passed directly to mspack_system::open(). + * @return a pointer to a mscabd_cabinet structure, or NULL + * @see close(), open(), last_error() + */ + struct mscabd_cabinet * (*search) (struct mscab_decompressor *self, + const char *filename); + + /** + * Appends one mscabd_cabinet to another, forming or extending a cabinet + * set. + * + * This will attempt to append one cabinet to another such that + * (cab->nextcab == nextcab) && (nextcab->prevcab == cab) and + * any folders split between the two cabinets are merged. + * + * The cabinets MUST be part of a cabinet set -- a cabinet set is a + * cabinet that spans more than one physical cabinet file on disk -- and + * must be appropriately matched. + * + * It can be determined if a cabinet has further parts to load by + * examining the mscabd_cabinet::flags field: + * + * - if (flags & MSCAB_HDR_PREVCAB) is non-zero, there is a + * predecessor cabinet to open() and prepend(). Its MS-DOS + * case-insensitive filename is mscabd_cabinet::prevname + * - if (flags & MSCAB_HDR_NEXTCAB) is non-zero, there is a + * successor cabinet to open() and append(). Its MS-DOS case-insensitive + * filename is mscabd_cabinet::nextname + * + * If the cabinets do not match, an error code will be returned. Neither + * cabinet has been altered, and both should be closed seperately. + * + * Files and folders in a cabinet set are a single entity. All cabinets + * in a set use the same file list, which is updated as cabinets in the + * set are added. All pointers to mscabd_folder and mscabd_file + * structures in either cabinet must be discarded and re-obtained after + * merging. + * + * @param self a self-referential pointer to the mscab_decompressor + * instance being called + * @param cab the cabinet which will be appended to, + * predecessor of nextcab + * @param nextcab the cabinet which will be appended, + * successor of cab + * @return an error code, or MSPACK_ERR_OK if successful + * @see prepend(), open(), close() + */ + int (*append) (struct mscab_decompressor *self, + struct mscabd_cabinet *cab, + struct mscabd_cabinet *nextcab); + + /** + * Prepends one mscabd_cabinet to another, forming or extending a + * cabinet set. + * + * This will attempt to prepend one cabinet to another, such that + * (cab->prevcab == prevcab) && (prevcab->nextcab == cab). In + * all other respects, it is identical to append(). See append() for the + * full documentation. + * + * @param self a self-referential pointer to the mscab_decompressor + * instance being called + * @param cab the cabinet which will be prepended to, + * successor of prevcab + * @param prevcab the cabinet which will be prepended, + * predecessor of cab + * @return an error code, or MSPACK_ERR_OK if successful + * @see append(), open(), close() + */ + int (*prepend) (struct mscab_decompressor *self, + struct mscabd_cabinet *cab, + struct mscabd_cabinet *prevcab); + + /** + * Extracts a file from a cabinet or cabinet set. + * + * This extracts a compressed file in a cabinet and writes it to the given + * filename. + * + * The MS-DOS filename of the file, mscabd_file::filename, is NOT USED + * by extract(). The caller must examine this MS-DOS filename, copy and + * change it as necessary, create directories as necessary, and provide + * the correct filename as a parameter, which will be passed unchanged + * to the decompressor's mspack_system::open() + * + * If the file belongs to a split folder in a multi-part cabinet set, + * and not enough parts of the cabinet set have been loaded and appended + * or prepended, an error will be returned immediately. + * + * @param self a self-referential pointer to the mscab_decompressor + * instance being called + * @param file the file to be decompressed + * @param filename the filename of the file being written to + * @return an error code, or MSPACK_ERR_OK if successful + */ + int (*extract)(struct mscab_decompressor *self, + struct mscabd_file *file, + const char *filename); + + /** + * Sets a CAB decompression engine parameter. + * + * The following parameters are defined: + * - #MSCABD_PARAM_SEARCHBUF: How many bytes should be allocated as a + * buffer when using search()? The minimum value is 4. The default + * value is 32768. + * - #MSCABD_PARAM_FIXMSZIP: If non-zero, extract() will ignore bad + * checksums and recover from decompression errors in MS-ZIP + * compressed folders. The default value is 0 (don't recover). + * - #MSCABD_PARAM_DECOMPBUF: How many bytes should be used as an input + * bit buffer by decompressors? The minimum value is 4. The default + * value is 4096. + * + * @param self a self-referential pointer to the mscab_decompressor + * instance being called + * @param param the parameter to set + * @param value the value to set the parameter to + * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if there + * is a problem with either parameter or value. + * @see search(), extract() + */ + int (*set_param)(struct mscab_decompressor *self, + int param, + int value); + + /** + * Returns the error code set by the most recently called method. + * + * This is useful for open() and search(), which do not return an error + * code directly. + * + * @param self a self-referential pointer to the mscab_decompressor + * instance being called + * @return the most recent error code + * @see open(), search() + */ + int (*last_error)(struct mscab_decompressor *self); +}; + +/* --- support for .CHM (HTMLHelp) file format ----------------------------- */ + +/** + * A structure which represents a file to be placed in a CHM helpfile. + * + * A contiguous array of these structures should be passed to + * mschm_compressor::generate(). The array list is terminated with an + * entry whose mschmc_file::section field is set to #MSCHMC_ENDLIST, the + * other fields in this entry are ignored. + */ +struct mschmc_file { + /** One of #MSCHMC_ENDLIST, #MSCHMC_UNCOMP or #MSCHMC_MSCOMP. */ + int section; + + /** The filename of the source file that will be added to the CHM. This + * is passed directly to mspack_system::open(). */ + const char *filename; + + /** The full path and filename of the file within the CHM helpfile, a + * UTF-1 encoded null-terminated string. */ + char *chm_filename; + + /** The length of the file, in bytes. This will be adhered to strictly + * and a read error will be issued if this many bytes cannot be read + * from the real file at CHM generation time. */ + off_t length; +}; + +/** + * A structure which represents a section of a CHM helpfile. + * + * All fields are READ ONLY. + * + * Not used directly, but used as a generic base type for + * mschmd_sec_uncompressed and mschmd_sec_mscompressed. + */ +struct mschmd_section { + /** A pointer to the CHM helpfile that contains this section. */ + struct mschmd_header *chm; + + /** + * The section ID. Either 0 for the uncompressed section + * mschmd_sec_uncompressed, or 1 for the LZX compressed section + * mschmd_sec_mscompressed. No other section IDs are known. + */ + unsigned int id; +}; + +/** + * A structure which represents the uncompressed section of a CHM helpfile. + * + * All fields are READ ONLY. + */ +struct mschmd_sec_uncompressed { + /** Generic section data. */ + struct mschmd_section base; + + /** The file offset of where this section begins in the CHM helpfile. */ + off_t offset; +}; + +/** + * A structure which represents the LZX compressed section of a CHM helpfile. + * + * All fields are READ ONLY. + */ +struct mschmd_sec_mscompressed { + /** Generic section data. */ + struct mschmd_section base; + + /** A pointer to the meta-file which represents all LZX compressed data. */ + struct mschmd_file *content; + + /** A pointer to the file which contains the LZX control data. */ + struct mschmd_file *control; + + /** A pointer to the file which contains the LZX reset table. */ + struct mschmd_file *rtable; + + /** A pointer to the file which contains the LZX span information. + * Available only in CHM decoder version 2 and above. + */ + struct mschmd_file *spaninfo; +}; + +/** + * A structure which represents a CHM helpfile. + * + * All fields are READ ONLY. + */ +struct mschmd_header { + /** The version of the CHM file format used in this file. */ + unsigned int version; + + /** + * The "timestamp" of the CHM helpfile. + * + * It is the lower 32 bits of a 64-bit value representing the number of + * centiseconds since 1601-01-01 00:00:00 UTC, plus 42. It is not useful + * as a timestamp, but it is useful as a semi-unique ID. + */ + unsigned int timestamp; + + /** + * The default Language and Country ID (LCID) of the user who ran the + * HTMLHelp Compiler. This is not the language of the CHM file itself. + */ + unsigned int language; + + /** + * The filename of the CHM helpfile. This is given by the library user + * and may be in any format. + */ + const char *filename; + + /** The length of the CHM helpfile, in bytes. */ + off_t length; + + /** A list of all non-system files in the CHM helpfile. */ + struct mschmd_file *files; + + /** + * A list of all system files in the CHM helpfile. + * + * System files are files which begin with "::". They are meta-files + * generated by the CHM creation process. + */ + struct mschmd_file *sysfiles; + + /** The section 0 (uncompressed) data in this CHM helpfile. */ + struct mschmd_sec_uncompressed sec0; + + /** The section 1 (MSCompressed) data in this CHM helpfile. */ + struct mschmd_sec_mscompressed sec1; + + /** The file offset of the first PMGL/PMGI directory chunk. */ + off_t dir_offset; + + /** The number of PMGL/PMGI directory chunks in this CHM helpfile. */ + unsigned int num_chunks; + + /** The size of each PMGL/PMGI chunk, in bytes. */ + unsigned int chunk_size; + + /** The "density" of the quick-reference section in PMGL/PMGI chunks. */ + unsigned int density; + + /** The depth of the index tree. + * + * - if 1, there are no PMGI chunks, only PMGL chunks. + * - if 2, there is 1 PMGI chunk. All chunk indices point to PMGL chunks. + * - if 3, the root PMGI chunk points to secondary PMGI chunks, which in + * turn point to PMGL chunks. + * - and so on... + */ + unsigned int depth; + + /** + * The number of the root PMGI chunk. + * + * If there is no index in the CHM helpfile, this will be 0xFFFFFFFF. + */ + unsigned int index_root; + + /** + * The number of the first PMGL chunk. Usually zero. + * Available only in CHM decoder version 2 and above. + */ + unsigned int first_pmgl; + + /** + * The number of the last PMGL chunk. Usually num_chunks-1. + * Available only in CHM decoder version 2 and above. + */ + unsigned int last_pmgl; + + /** + * A cache of loaded chunks, filled in by mschm_decoder::fast_find(). + * Available only in CHM decoder version 2 and above. + */ + unsigned char **chunk_cache; +}; + +/** + * A structure which represents a file stored in a CHM helpfile. + * + * All fields are READ ONLY. + */ +struct mschmd_file { + /** + * A pointer to the next file in the list, or NULL if this is the final + * file. + */ + struct mschmd_file *next; + + /** + * A pointer to the section that this file is located in. Indirectly, + * it also points to the CHM helpfile the file is located in. + */ + struct mschmd_section *section; + + /** The offset within the section data that this file is located at. */ + off_t offset; + + /** The length of this file, in bytes */ + off_t length; + + /** The filename of this file -- a null terminated string in UTF-8. */ + char *filename; +}; + +/** mschmc_file::section value: end of CHM file list */ +#define MSCHMC_ENDLIST (0) +/** mschmc_file::section value: this file is in the Uncompressed section */ +#define MSCHMC_UNCOMP (1) +/** mschmc_file::section value: this file is in the MSCompressed section */ +#define MSCHMC_MSCOMP (2) + +/** mschm_compressor::set_param() parameter: "timestamp" header */ +#define MSCHMC_PARAM_TIMESTAMP (0) +/** mschm_compressor::set_param() parameter: "language" header */ +#define MSCHMC_PARAM_LANGUAGE (1) +/** mschm_compressor::set_param() parameter: LZX window size */ +#define MSCHMC_PARAM_LZXWINDOW (2) +/** mschm_compressor::set_param() parameter: intra-chunk quickref density */ +#define MSCHMC_PARAM_DENSITY (3) +/** mschm_compressor::set_param() parameter: whether to create indices */ +#define MSCHMC_PARAM_INDEX (4) + +/** + * A compressor for .CHM (Microsoft HTMLHelp) files. + * + * All fields are READ ONLY. + * + * @see mspack_create_chm_compressor(), mspack_destroy_chm_compressor() + */ +struct mschm_compressor { + /** + * Generates a CHM help file. + * + * The help file will contain up to two sections, an Uncompressed + * section and potentially an MSCompressed (LZX compressed) + * section. + * + * While the contents listing of a CHM file is always in lexical order, + * the file list passed in will be taken as the correct order for files + * within the sections. It is in your interest to place similar files + * together for better compression. + * + * There are two modes of generation, to use a temporary file or not to + * use one. See use_temporary_file() for the behaviour of generate() in + * these two different modes. + * + * @param self a self-referential pointer to the mschm_compressor + * instance being called + * @param file_list an array of mschmc_file structures, terminated + * with an entry whose mschmc_file::section field is + * #MSCHMC_ENDLIST. The order of the list is + * preserved within each section. The length of any + * mschmc_file::chm_filename string cannot exceed + * roughly 4096 bytes. Each source file must be able + * to supply as many bytes as given in the + * mschmc_file::length field. + * @param output_file the file to write the generated CHM helpfile to. + * This is passed directly to mspack_system::open() + * @return an error code, or MSPACK_ERR_OK if successful + * @see use_temporary_file() set_param() + */ + int (*generate)(struct mschm_compressor *self, + struct mschmc_file file_list[], + const char *output_file); + + /** + * Specifies whether a temporary file is used during CHM generation. + * + * The CHM file format includes data about the compressed section (such + * as its overall size) that is stored in the output CHM file prior to + * the compressed section itself. This unavoidably requires that the + * compressed section has to be generated, before these details can be + * set. There are several ways this can be handled. Firstly, the + * compressed section could be generated entirely in memory before + * writing any of the output CHM file. This approach is not used in + * libmspack, as the compressed section can exceed the addressable + * memory space on most architectures. + * + * libmspack has two options, either to write these unknowable sections + * with blank data, generate the compressed section, then re-open the + * output file for update once the compressed section has been + * completed, or to write the compressed section to a temporary file, + * then write the entire output file at once, performing a simple + * file-to-file copy for the compressed section. + * + * The simple solution of buffering the entire compressed section in + * memory can still be used, if desired. As the temporary file's + * filename is passed directly to mspack_system::open(), it is possible + * for a custom mspack_system implementation to hold this file in memory, + * without writing to a disk. + * + * If a temporary file is set, generate() performs the following + * sequence of events: the temporary file is opened for writing, the + * compression algorithm writes to the temporary file, the temporary + * file is closed. Then the output file is opened for writing and the + * temporary file is re-opened for reading. The output file is written + * and the temporary file is read from. Both files are then closed. The + * temporary file itself is not deleted. If that is desired, the + * temporary file should be deleted after the completion of generate(), + * if it exists. + * + * If a temporary file is set not to be used, generate() performs the + * following sequence of events: the output file is opened for writing, + * then it is written and closed. The output file is then re-opened for + * update, the appropriate sections are seek()ed to and re-written, then + * the output file is closed. + * + * @param self a self-referential pointer to the + * mschm_compressor instance being called + * @param use_temp_file non-zero if the temporary file should be used, + * zero if the temporary file should not be used. + * @param temp_file a file to temporarily write compressed data to, + * before opening it for reading and copying the + * contents to the output file. This is passed + * directly to mspack_system::open(). + * @return an error code, or MSPACK_ERR_OK if successful + * @see generate() + */ + int (*use_temporary_file)(struct mschm_compressor *self, + int use_temp_file, + const char *temp_file); + /** + * Sets a CHM compression engine parameter. + * + * The following parameters are defined: + + * - #MSCHMC_PARAM_TIMESTAMP: Sets the "timestamp" of the CHM file + * generated. This is not a timestamp, see mschmd_header::timestamp + * for a description. If this timestamp is 0, generate() will use its + * own algorithm for making a unique ID, based on the lengths and + * names of files in the CHM itself. Defaults to 0, any value between + * 0 and (2^32)-1 is valid. + * - #MSCHMC_PARAM_LANGUAGE: Sets the "language" of the CHM file + * generated. This is not the language used in the CHM file, but the + * language setting of the user who ran the HTMLHelp compiler. It + * defaults to 0x0409. The valid range is between 0x0000 and 0x7F7F. + * - #MSCHMC_PARAM_LZXWINDOW: Sets the size of the LZX history window, + * which is also the interval at which the compressed data stream can be + * randomly accessed. The value is not a size in bytes, but a power of + * two. The default value is 16 (which makes the window 2^16 bytes, or + * 64 kilobytes), the valid range is from 15 (32 kilobytes) to 21 (2 + * megabytes). + * - #MSCHMC_PARAM_DENSITY: Sets the "density" of quick reference + * entries stored at the end of directory listing chunk. Each chunk is + * 4096 bytes in size, and contains as many file entries as there is + * room for. At the other end of the chunk, a list of "quick reference" + * pointers is included. The offset of every 'N'th file entry is given a + * quick reference, where N = (2^density) + 1. The default density is + * 2. The smallest density is 0 (N=2), the maximum is 10 (N=1025). As + * each file entry requires at least 5 bytes, the maximum number of + * entries in a single chunk is roughly 800, so the maximum value 10 + * can be used to indicate there are no quickrefs at all. + * - #MSCHMC_PARAM_INDEX: Sets whether or not to include quick lookup + * index chunk(s), in addition to normal directory listing chunks. A + * value of zero means no index chunks will be created, a non-zero value + * means index chunks will be created. The default is zero, "don't + * create an index". + * + * @param self a self-referential pointer to the mschm_compressor + * instance being called + * @param param the parameter to set + * @param value the value to set the parameter to + * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if there + * is a problem with either parameter or value. + * @see generate() + */ + int (*set_param)(struct mschm_compressor *self, + int param, + unsigned int value); + + /** + * Returns the error code set by the most recently called method. + * + * @param self a self-referential pointer to the mschm_compressor + * instance being called + * @return the most recent error code + * @see set_param(), generate() + */ + int (*last_error)(struct mschm_compressor *self); +}; + +/** + * A decompressor for .CHM (Microsoft HTMLHelp) files + * + * All fields are READ ONLY. + * + * @see mspack_create_chm_decompressor(), mspack_destroy_chm_decompressor() + */ +struct mschm_decompressor { + /** + * Opens a CHM helpfile and reads its contents. + * + * If the file opened is a valid CHM helpfile, all headers will be read + * and a mschmd_header structure will be returned, with a full list of + * files. + * + * In the case of an error occuring, NULL is returned and the error code + * is available from last_error(). + * + * The filename pointer should be considered "in use" until close() is + * called on the CHM helpfile. + * + * @param self a self-referential pointer to the mschm_decompressor + * instance being called + * @param filename the filename of the CHM helpfile. This is passed + * directly to mspack_system::open(). + * @return a pointer to a mschmd_header structure, or NULL on failure + * @see close() + */ + struct mschmd_header *(*open)(struct mschm_decompressor *self, + const char *filename); + + /** + * Closes a previously opened CHM helpfile. + * + * This closes a CHM helpfile, frees the mschmd_header and all + * mschmd_file structures associated with it (if any). This works on + * both helpfiles opened with open() and helpfiles opened with + * fast_open(). + * + * The CHM header pointer is now invalid and cannot be used again. All + * mschmd_file pointers referencing that CHM are also now invalid, and + * cannot be used again. + * + * @param self a self-referential pointer to the mschm_decompressor + * instance being called + * @param chm the CHM helpfile to close + * @see open(), fast_open() + */ + void (*close)(struct mschm_decompressor *self, + struct mschmd_header *chm); + + /** + * Extracts a file from a CHM helpfile. + * + * This extracts a file from a CHM helpfile and writes it to the given + * filename. The filename of the file, mscabd_file::filename, is not + * used by extract(), but can be used by the caller as a guide for + * constructing an appropriate filename. + * + * This method works both with files found in the mschmd_header::files + * and mschmd_header::sysfiles list and mschmd_file structures generated + * on the fly by fast_find(). + * + * @param self a self-referential pointer to the mschm_decompressor + * instance being called + * @param file the file to be decompressed + * @param filename the filename of the file being written to + * @return an error code, or MSPACK_ERR_OK if successful + */ + int (*extract)(struct mschm_decompressor *self, + struct mschmd_file *file, + const char *filename); + + /** + * Returns the error code set by the most recently called method. + * + * This is useful for open() and fast_open(), which do not return an + * error code directly. + * + * @param self a self-referential pointer to the mschm_decompressor + * instance being called + * @return the most recent error code + * @see open(), extract() + */ + int (*last_error)(struct mschm_decompressor *self); + + /** + * Opens a CHM helpfile quickly. + * + * If the file opened is a valid CHM helpfile, only essential headers + * will be read. A mschmd_header structure will be still be returned, as + * with open(), but the mschmd_header::files field will be NULL. No + * files details will be automatically read. The fast_find() method + * must be used to obtain file details. + * + * In the case of an error occuring, NULL is returned and the error code + * is available from last_error(). + * + * The filename pointer should be considered "in use" until close() is + * called on the CHM helpfile. + * + * @param self a self-referential pointer to the mschm_decompressor + * instance being called + * @param filename the filename of the CHM helpfile. This is passed + * directly to mspack_system::open(). + * @return a pointer to a mschmd_header structure, or NULL on failure + * @see open(), close(), fast_find(), extract() + */ + struct mschmd_header *(*fast_open)(struct mschm_decompressor *self, + const char *filename); + + /** + * Finds file details quickly. + * + * Instead of reading all CHM helpfile headers and building a list of + * files, fast_open() and fast_find() are intended for finding file + * details only when they are needed. The CHM file format includes an + * on-disk file index to allow this. + * + * Given a case-sensitive filename, fast_find() will search the on-disk + * index for that file. + * + * If the file was found, the caller-provided mschmd_file structure will + * be filled out like so: + * - section: the correct value for the found file + * - offset: the correct value for the found file + * - length: the correct value for the found file + * - all other structure elements: NULL or 0 + * + * If the file was not found, MSPACK_ERR_OK will still be returned as the + * result, but the caller-provided structure will be filled out like so: + * - section: NULL + * - offset: 0 + * - length: 0 + * - all other structure elements: NULL or 0 + * + * This method is intended to be used in conjunction with CHM helpfiles + * opened with fast_open(), but it also works with helpfiles opened + * using the regular open(). + * + * @param self a self-referential pointer to the mschm_decompressor + * instance being called + * @param chm the CHM helpfile to search for the file + * @param filename the filename of the file to search for + * @param f_ptr a pointer to a caller-provded mschmd_file structure + * @param f_size sizeof(struct mschmd_file) + * @return an error code, or MSPACK_ERR_OK if successful + * @see open(), close(), fast_find(), extract() + */ + int (*fast_find)(struct mschm_decompressor *self, + struct mschmd_header *chm, + const char *filename, + struct mschmd_file *f_ptr, + int f_size); +}; + +/* --- support for .LIT (EBook) file format -------------------------------- */ + +/** TODO */ +struct mslit_compressor { + int dummy; +}; + +/** TODO */ +struct mslit_decompressor { + int dummy; +}; + + +/* --- support for .HLP (MS Help) file format ------------------------------ */ + +/** TODO */ +struct mshlp_compressor { + int dummy; +}; + +/** TODO */ +struct mshlp_decompressor { + int dummy; +}; + + +/* --- support for SZDD file format ---------------------------------------- */ + +/** msszdd_compressor::set_param() parameter: the missing character */ +#define MSSZDDC_PARAM_MISSINGCHAR (0) + +/** msszddd_header::format value - a regular SZDD file */ +#define MSSZDD_FMT_NORMAL (0) + +/** msszddd_header::format value - a special QBasic SZDD file */ +#define MSSZDD_FMT_QBASIC (1) + +/** + * A structure which represents an SZDD compressed file. + * + * All fields are READ ONLY. + */ +struct msszddd_header { + /** The file format; either #MSSZDD_FMT_NORMAL or #MSSZDD_FMT_QBASIC */ + int format; + + /** The amount of data in the SZDD file once uncompressed. */ + off_t length; + + /** + * The last character in the filename, traditionally replaced with an + * underscore to show the file is compressed. The null character is used + * to show that this character has not been stored (e.g. because the + * filename is not known). Generally, only characters that may appear in + * an MS-DOS filename (except ".") are valid. + */ + char missing_char; +}; + +/** + * A compressor for the SZDD file format. + * + * All fields are READ ONLY. + * + * @see mspack_create_szdd_compressor(), mspack_destroy_szdd_compressor() + */ +struct msszdd_compressor { + /** + * Reads an input file and creates a compressed output file in the + * SZDD compressed file format. The SZDD compression format is quick + * but gives poor compression. It is possible for the compressed output + * file to be larger than the input file. + * + * Conventionally, SZDD compressed files have the final character in + * their filename replaced with an underscore, to show they are + * compressed. The missing character is stored in the compressed file + * itself. This is due to the restricted filename conventions of MS-DOS, + * most operating systems, such as UNIX, simply append another file + * extension to the existing filename. As mspack does not deal with + * filenames, this is left up to you. If you wish to set the missing + * character stored in the file header, use set_param() with the + * #MSSZDDC_PARAM_MISSINGCHAR parameter. + * + * "Stream" compression (where the length of the input data is not + * known) is not possible. The length of the input data is stored in the + * header of the SZDD file and must therefore be known before any data + * is compressed. Due to technical limitations of the file format, the + * maximum size of uncompressed file that will be accepted is 2147483647 + * bytes. + * + * @param self a self-referential pointer to the msszdd_compressor + * instance being called + * @param input the name of the file to compressed. This is passed + * passed directly to mspack_system::open() + * @param output the name of the file to write compressed data to. + * This is passed directly to mspack_system::open(). + * @param length the length of the uncompressed file, or -1 to indicate + * that this should be determined automatically by using + * mspack_system::seek() on the input file. + * @return an error code, or MSPACK_ERR_OK if successful + * @see set_param() + */ + int (*compress)(struct msszdd_compressor *self, + const char *input, + const char *output, + off_t length); + + /** + * Sets an SZDD compression engine parameter. + * + * The following parameters are defined: + + * - #MSSZDDC_PARAM_CHARACTER: the "missing character", the last character + * in the uncompressed file's filename, which is traditionally replaced + * with an underscore to show the file is compressed. Traditionally, + * this can only be a character that is a valid part of an MS-DOS, + * filename, but libmspack permits any character between 0x00 and 0xFF + * to be stored. 0x00 is the default, and it represents "no character + * stored". + * + * @param self a self-referential pointer to the msszdd_compressor + * instance being called + * @param param the parameter to set + * @param value the value to set the parameter to + * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if there + * is a problem with either parameter or value. + * @see compress() + */ + int (*set_param)(struct msszdd_compressor *self, + int param, + unsigned int value); + + /** + * Returns the error code set by the most recently called method. + * + * @param self a self-referential pointer to the msszdd_compressor + * instance being called + * @return the most recent error code + * @see compress() + */ + int (*last_error)(struct mschm_decompressor *self); +}; + +/** + * A decompressor for SZDD compressed files. + * + * All fields are READ ONLY. + * + * @see mspack_create_szdd_decompressor(), mspack_destroy_szdd_decompressor() + */ +struct msszdd_decompressor { + /** + * Opens a SZDD file and reads the header. + * + * If the file opened is a valid SZDD file, all headers will be read and + * a msszddd_header structure will be returned. + * + * In the case of an error occuring, NULL is returned and the error code + * is available from last_error(). + * + * The filename pointer should be considered "in use" until close() is + * called on the SZDD file. + * + * @param self a self-referential pointer to the msszdd_decompressor + * instance being called + * @param filename the filename of the SZDD compressed file. This is + * passed directly to mspack_system::open(). + * @return a pointer to a msszddd_header structure, or NULL on failure + * @see close() + */ + struct msszddd_header *(*open)(struct msszdd_decompressor *self, + const char *filename); + + /** + * Closes a previously opened SZDD file. + * + * This closes a SZDD file and frees the msszddd_header associated with + * it. + * + * The SZDD header pointer is now invalid and cannot be used again. + * + * @param self a self-referential pointer to the msszdd_decompressor + * instance being called + * @param szdd the SZDD file to close + * @see open() + */ + void (*close)(struct msszdd_decompressor *self, + struct msszddd_header *szdd); + + /** + * Extracts the compressed data from a SZDD file. + * + * This decompresses the compressed SZDD data stream and writes it to + * an output file. + * + * @param self a self-referential pointer to the msszdd_decompressor + * instance being called + * @param szdd the SZDD file to extract data from + * @param filename the filename to write the decompressed data to. This + * is passed directly to mspack_system::open(). + * @return an error code, or MSPACK_ERR_OK if successful + */ + int (*extract)(struct msszdd_decompressor *self, + struct msszddd_header *szdd, + const char *filename); + + /** + * Decompresses an SZDD file to an output file in one step. + * + * This opens an SZDD file as input, reads the header, then decompresses + * the compressed data immediately to an output file, finally closing + * both the input and output file. It is more convenient to use than + * open() then extract() then close(), if you do not need to know the + * SZDD output size or missing character. + * + * @param self a self-referential pointer to the msszdd_decompressor + * instance being called + * @param input the filename of the input SZDD file. This is passed + * directly to mspack_system::open(). + * @param output the filename to write the decompressed data to. This + * is passed directly to mspack_system::open(). + * @return an error code, or MSPACK_ERR_OK if successful + */ + int (*decompress)(struct msszdd_decompressor *self, + const char *input, + const char *output); + + /** + * Returns the error code set by the most recently called method. + * + * This is useful for open() which does not return an + * error code directly. + * + * @param self a self-referential pointer to the msszdd_decompressor + * instance being called + * @return the most recent error code + * @see open(), extract(), decompress() + */ + int (*last_error)(struct msszdd_decompressor *self); +}; + +/* --- support for KWAJ file format ---------------------------------------- */ + +/** mskwaj_compressor::set_param() parameter: compression type */ +#define MSKWAJC_PARAM_COMP_TYPE (0) + +/** mskwaj_compressor::set_param() parameter: include the length of the + * uncompressed file in the header? + */ +#define MSKWAJC_PARAM_INCLUDE_LENGTH (1) + +/** KWAJ compression type: no compression. */ +#define MSKWAJ_COMP_NONE (0) +/** KWAJ compression type: no compression, 0xFF XOR "encryption". */ +#define MSKWAJ_COMP_XOR (1) +/** KWAJ compression type: LZSS (same method as SZDD) */ +#define MSKWAJ_COMP_SZDD (2) +/** KWAJ compression type: LZ+Huffman compression */ +#define MSKWAJ_COMP_LZH (3) +/** KWAJ compression type: MSZIP */ +#define MSKWAJ_COMP_MSZIP (4) + +/** KWAJ optional header flag: decompressed file length is included */ +#define MSKWAJ_HDR_HASLENGTH (0x01) + +/** KWAJ optional header flag: unknown 2-byte structure is included */ +#define MSKWAJ_HDR_HASUNKNOWN1 (0x02) + +/** KWAJ optional header flag: unknown multi-sized structure is included */ +#define MSKWAJ_HDR_HASUNKNOWN2 (0x04) + +/** KWAJ optional header flag: file name (no extension) is included */ +#define MSKWAJ_HDR_HASFILENAME (0x08) + +/** KWAJ optional header flag: file extension is included */ +#define MSKWAJ_HDR_HASFILEEXT (0x10) + +/** KWAJ optional header flag: extra text is included */ +#define MSKWAJ_HDR_HASEXTRATEXT (0x20) + +/** + * A structure which represents an KWAJ compressed file. + * + * All fields are READ ONLY. + */ +struct mskwajd_header { + /** The compression type; should be one of #MSKWAJ_COMP_NONE, + * #MSKWAJ_COMP_XOR, #MSKWAJ_COMP_SZDD or #MSKWAJ_COMP_LZH + */ + unsigned short comp_type; + + /** The offset in the file where the compressed data stream begins */ + off_t data_offset; + + /** Flags indicating which optional headers were included. */ + int headers; + + /** The amount of uncompressed data in the file, or 0 if not present. */ + off_t length; + + /** output filename, or NULL if not present */ + char *filename; + + /** extra uncompressed data (usually text) in the header. + * This data can contain nulls so use extra_length to get the size. + */ + char *extra; + + /** length of extra uncompressed data in the header */ + unsigned short extra_length; +}; + +/** + * A compressor for the KWAJ file format. + * + * All fields are READ ONLY. + * + * @see mspack_create_kwaj_compressor(), mspack_destroy_kwaj_compressor() + */ +struct mskwaj_compressor { + /** + * Reads an input file and creates a compressed output file in the + * KWAJ compressed file format. The KWAJ compression format is quick + * but gives poor compression. It is possible for the compressed output + * file to be larger than the input file. + * + * @param self a self-referential pointer to the mskwaj_compressor + * instance being called + * @param input the name of the file to compressed. This is passed + * passed directly to mspack_system::open() + * @param output the name of the file to write compressed data to. + * This is passed directly to mspack_system::open(). + * @param length the length of the uncompressed file, or -1 to indicate + * that this should be determined automatically by using + * mspack_system::seek() on the input file. + * @return an error code, or MSPACK_ERR_OK if successful + * @see set_param() + */ + int (*compress)(struct mskwaj_compressor *self, + const char *input, + const char *output, + off_t length); + + /** + * Sets an KWAJ compression engine parameter. + * + * The following parameters are defined: + * + * - #MSKWAJC_PARAM_COMP_TYPE: the compression method to use. Must + * be one of #MSKWAJC_COMP_NONE, #MSKWAJC_COMP_XOR, #MSKWAJ_COMP_SZDD + * or #MSKWAJ_COMP_LZH. The default is #MSKWAJ_COMP_LZH. + * + * - #MSKWAJC_PARAM_INCLUDE_LENGTH: a boolean; should the compressed + * output file should include the uncompressed length of the input + * file in the header? This adds 4 bytes to the size of the output + * file. A value of zero says "no", non-zero says "yes". The default + * is "no". + * + * @param self a self-referential pointer to the mskwaj_compressor + * instance being called + * @param param the parameter to set + * @param value the value to set the parameter to + * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if there + * is a problem with either parameter or value. + * @see generate() + */ + int (*set_param)(struct mskwaj_compressor *self, + int param, + unsigned int value); + + + /** + * Sets the original filename of the file before compression, + * which will be stored in the header of the output file. + * + * The filename should be a null-terminated string, it must be an + * MS-DOS "8.3" type filename (up to 8 bytes for the filename, then + * optionally a "." and up to 3 bytes for a filename extension). + * + * If NULL is passed as the filename, no filename is included in the + * header. This is the default. + * + * @param self a self-referential pointer to the mskwaj_compressor + * instance being called + * @param filename the original filename to use + * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if the + * filename is too long + */ + int (*set_filename)(struct mskwaj_compressor *self, + const char *filename); + + /** + * Sets arbitrary data that will be stored in the header of the + * output file, uncompressed. It can be up to roughly 64 kilobytes, + * as the overall size of the header must not exceed 65535 bytes. + * The data can contain null bytes if desired. + * + * If NULL is passed as the data pointer, or zero is passed as the + * length, no extra data is included in the header. This is the + * default. + * + * @param self a self-referential pointer to the mskwaj_compressor + * instance being called + * @param data a pointer to the data to be stored in the header + * @param bytes the length of the data in bytes + * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS extra data + * is too long + */ + int (*set_extra_data)(struct mskwaj_compressor *self, + void *data, + size_t bytes); + + /** + * Returns the error code set by the most recently called method. + * + * @param self a self-referential pointer to the mskwaj_compressor + * instance being called + * @return the most recent error code + * @see compress() + */ + int (*last_error)(struct mschm_decompressor *self); +}; + +/** + * A decompressor for KWAJ compressed files. + * + * All fields are READ ONLY. + * + * @see mspack_create_kwaj_decompressor(), mspack_destroy_kwaj_decompressor() + */ +struct mskwaj_decompressor { + /** + * Opens a KWAJ file and reads the header. + * + * If the file opened is a valid KWAJ file, all headers will be read and + * a mskwajd_header structure will be returned. + * + * In the case of an error occuring, NULL is returned and the error code + * is available from last_error(). + * + * The filename pointer should be considered "in use" until close() is + * called on the KWAJ file. + * + * @param self a self-referential pointer to the mskwaj_decompressor + * instance being called + * @param filename the filename of the KWAJ compressed file. This is + * passed directly to mspack_system::open(). + * @return a pointer to a mskwajd_header structure, or NULL on failure + * @see close() + */ + struct mskwajd_header *(*open)(struct mskwaj_decompressor *self, + const char *filename); + + /** + * Closes a previously opened KWAJ file. + * + * This closes a KWAJ file and frees the mskwajd_header associated + * with it. The KWAJ header pointer is now invalid and cannot be + * used again. + * + * @param self a self-referential pointer to the mskwaj_decompressor + * instance being called + * @param kwaj the KWAJ file to close + * @see open() + */ + void (*close)(struct mskwaj_decompressor *self, + struct mskwajd_header *kwaj); + + /** + * Extracts the compressed data from a KWAJ file. + * + * This decompresses the compressed KWAJ data stream and writes it to + * an output file. + * + * @param self a self-referential pointer to the mskwaj_decompressor + * instance being called + * @param kwaj the KWAJ file to extract data from + * @param filename the filename to write the decompressed data to. This + * is passed directly to mspack_system::open(). + * @return an error code, or MSPACK_ERR_OK if successful + */ + int (*extract)(struct mskwaj_decompressor *self, + struct mskwajd_header *kwaj, + const char *filename); + + /** + * Decompresses an KWAJ file to an output file in one step. + * + * This opens an KWAJ file as input, reads the header, then decompresses + * the compressed data immediately to an output file, finally closing + * both the input and output file. It is more convenient to use than + * open() then extract() then close(), if you do not need to know the + * KWAJ output size or output filename. + * + * @param self a self-referential pointer to the mskwaj_decompressor + * instance being called + * @param input the filename of the input KWAJ file. This is passed + * directly to mspack_system::open(). + * @param output the filename to write the decompressed data to. This + * is passed directly to mspack_system::open(). + * @return an error code, or MSPACK_ERR_OK if successful + */ + int (*decompress)(struct mskwaj_decompressor *self, + const char *input, + const char *output); + + /** + * Returns the error code set by the most recently called method. + * + * This is useful for open() which does not return an + * error code directly. + * + * @param self a self-referential pointer to the mskwaj_decompressor + * instance being called + * @return the most recent error code + * @see open(), search() + */ + int (*last_error)(struct mskwaj_decompressor *self); +}; + +/* --- support for .LZX (Offline Address Book) file format ----------------- */ + +/** + * A compressor for the Offline Address Book (OAB) format. + * + * All fields are READ ONLY. + * + * @see mspack_create_oab_compressor(), mspack_destroy_oab_compressor() + */ +struct msoab_compressor { + /** + * Compress a full OAB file. + * + * The input file will be read and the compressed contents written to the + * output file. + * + * @param self a self-referential pointer to the msoab_decompressor + * instance being called + * @param input the filename of the input file. This is passed + * directly to mspack_system::open(). + * @param output the filename of the output file. This is passed + * directly to mspack_system::open(). + * @return an error code, or MSPACK_ERR_OK if successful + */ + int (*compress) (struct msoab_compressor *self, + const char *input, + const char *output); + + /** + * Generate a compressed incremental OAB patch file. + * + * The two uncompressed files "input" and "base" will be read, and an + * incremental patch to generate "input" from "base" will be written to + * the output file. + * + * @param self a self-referential pointer to the msoab_compressor + * instance being called + * @param input the filename of the input file containing the new + * version of its contents. This is passed directly + * to mspack_system::open(). + * @param base the filename of the original base file containing + * the old version of its contents, against which the + * incremental patch shall generated. This is passed + * directly to mspack_system::open(). + * @param output the filename of the output file. This is passed + * directly to mspack_system::open(). + * @return an error code, or MSPACK_ERR_OK if successful + */ + int (*compress_incremental) (struct msoab_compressor *self, + const char *input, + const char *base, + const char *output); +}; + +/** + * A decompressor for .LZX (Offline Address Book) files + * + * All fields are READ ONLY. + * + * @see mspack_create_oab_decompressor(), mspack_destroy_oab_decompressor() + */ +struct msoab_decompressor { + /** + * Decompresses a full Offline Address Book file. + * + * If the input file is a valid compressed Offline Address Book file, + * it will be read and the decompressed contents will be written to + * the output file. + * + * @param self a self-referential pointer to the msoab_decompressor + * instance being called + * @param input the filename of the input file. This is passed + * directly to mspack_system::open(). + * @param output the filename of the output file. This is passed + * directly to mspack_system::open(). + * @return an error code, or MSPACK_ERR_OK if successful + */ + int (*decompress) (struct msoab_decompressor *self, + const char *input, + const char *output); + + /** + * Decompresses an Offline Address Book with an incremental patch file. + * + * This requires both a full UNCOMPRESSED Offline Address Book file to + * act as the "base", and a compressed incremental patch file as input. + * If the input file is valid, it will be decompressed with reference to + * the base file, and the decompressed contents will be written to the + * output file. + * + * There is no way to tell what the right base file is for the given + * incremental patch, but if you get it wrong, this will usually result + * in incorrect data being decompressed, which will then fail a checksum + * test. + * + * @param self a self-referential pointer to the msoab_decompressor + * instance being called + * @param input the filename of the input file. This is passed + * directly to mspack_system::open(). + * @param base the filename of the base file to which the + * incremental patch shall be applied. This is passed + * directly to mspack_system::open(). + * @param output the filename of the output file. This is passed + * directly to mspack_system::open(). + * @return an error code, or MSPACK_ERR_OK if successful + */ + int (*decompress_incremental) (struct msoab_decompressor *self, + const char *input, + const char *base, + const char *output); +}; + +#ifdef __cplusplus +} +#endif + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/mszipc.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/mszipc.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/mszipc.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/mszipc.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,18 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * The deflate method was created by Phil Katz. MSZIP is equivalent to the + * deflate method. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* MS-ZIP compression implementation */ + +#include +#include + +/* todo */ diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/mszipd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/mszipd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/mszipd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/mszipd.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,514 @@ +/* This file is part of libmspack. + * (C) 2003-2010 Stuart Caie. + * + * The deflate method was created by Phil Katz. MSZIP is equivalent to the + * deflate method. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* MS-ZIP decompression implementation. */ + +#include +#include + +/* import bit-reading macros and code */ +#define BITS_TYPE struct mszipd_stream +#define BITS_VAR zip +#define BITS_ORDER_LSB +#define BITS_LSB_TABLE +#define READ_BYTES do { \ + READ_IF_NEEDED; \ + INJECT_BITS(*i_ptr++, 8); \ +} while (0) +#include + +/* import huffman macros and code */ +#define TABLEBITS(tbl) MSZIP_##tbl##_TABLEBITS +#define MAXSYMBOLS(tbl) MSZIP_##tbl##_MAXSYMBOLS +#define HUFF_TABLE(tbl,idx) zip->tbl##_table[idx] +#define HUFF_LEN(tbl,idx) zip->tbl##_len[idx] +#define HUFF_ERROR return INF_ERR_HUFFSYM +#include + +#define FLUSH_IF_NEEDED do { \ + if (zip->window_posn == MSZIP_FRAME_SIZE) { \ + if (zip->flush_window(zip, MSZIP_FRAME_SIZE)) { \ + return INF_ERR_FLUSH; \ + } \ + zip->window_posn = 0; \ + } \ +} while (0) + +/* match lengths for literal codes 257.. 285 */ +static const unsigned short lit_lengths[29] = { + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, + 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 +}; + +/* match offsets for distance codes 0 .. 29 */ +static const unsigned short dist_offsets[30] = { + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, + 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 +}; + +/* extra bits required for literal codes 257.. 285 */ +static const unsigned char lit_extrabits[29] = { + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, + 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 +}; + +/* extra bits required for distance codes 0 .. 29 */ +static const unsigned char dist_extrabits[30] = { + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, + 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 +}; + +/* the order of the bit length Huffman code lengths */ +static const unsigned char bitlen_order[19] = { + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 +}; + +/* inflate() error codes */ +#define INF_ERR_BLOCKTYPE (-1) /* unknown block type */ +#define INF_ERR_COMPLEMENT (-2) /* block size complement mismatch */ +#define INF_ERR_FLUSH (-3) /* error from flush_window() callback */ +#define INF_ERR_BITBUF (-4) /* too many bits in bit buffer */ +#define INF_ERR_SYMLENS (-5) /* too many symbols in blocktype 2 header */ +#define INF_ERR_BITLENTBL (-6) /* failed to build bitlens huffman table */ +#define INF_ERR_LITERALTBL (-7) /* failed to build literals huffman table */ +#define INF_ERR_DISTANCETBL (-8) /* failed to build distance huffman table */ +#define INF_ERR_BITOVERRUN (-9) /* bitlen RLE code goes over table size */ +#define INF_ERR_BADBITLEN (-10) /* invalid bit-length code */ +#define INF_ERR_LITCODE (-11) /* out-of-range literal code */ +#define INF_ERR_DISTCODE (-12) /* out-of-range distance code */ +#define INF_ERR_DISTANCE (-13) /* somehow, distance is beyond 32k */ +#define INF_ERR_HUFFSYM (-14) /* out of bits decoding huffman symbol */ + +static int zip_read_lens(struct mszipd_stream *zip) { + /* for the bit buffer and huffman decoding */ + register unsigned int bit_buffer; + register int bits_left; + unsigned char *i_ptr, *i_end; + + /* bitlen Huffman codes -- immediate lookup, 7 bit max code length */ + unsigned short bl_table[(1 << 7)]; + unsigned char bl_len[19]; + + unsigned char lens[MSZIP_LITERAL_MAXSYMBOLS + MSZIP_DISTANCE_MAXSYMBOLS]; + unsigned int lit_codes, dist_codes, code, last_code=0, bitlen_codes, i, run; + + RESTORE_BITS; + + /* read the number of codes */ + READ_BITS(lit_codes, 5); lit_codes += 257; + READ_BITS(dist_codes, 5); dist_codes += 1; + READ_BITS(bitlen_codes, 4); bitlen_codes += 4; + if (lit_codes > MSZIP_LITERAL_MAXSYMBOLS) return INF_ERR_SYMLENS; + if (dist_codes > MSZIP_DISTANCE_MAXSYMBOLS) return INF_ERR_SYMLENS; + + /* read in the bit lengths in their unusual order */ + for (i = 0; i < bitlen_codes; i++) READ_BITS(bl_len[bitlen_order[i]], 3); + while (i < 19) bl_len[bitlen_order[i++]] = 0; + + /* create decoding table with an immediate lookup */ + if (make_decode_table(19, 7, &bl_len[0], &bl_table[0])) { + return INF_ERR_BITLENTBL; + } + + /* read literal / distance code lengths */ + for (i = 0; i < (lit_codes + dist_codes); i++) { + /* single-level huffman lookup */ + ENSURE_BITS(7); + code = bl_table[PEEK_BITS(7)]; + REMOVE_BITS(bl_len[code]); + + if (code < 16) lens[i] = last_code = code; + else { + switch (code) { + case 16: READ_BITS(run, 2); run += 3; code = last_code; break; + case 17: READ_BITS(run, 3); run += 3; code = 0; break; + case 18: READ_BITS(run, 7); run += 11; code = 0; break; + default: D(("bad code!: %u", code)) return INF_ERR_BADBITLEN; + } + if ((i + run) > (lit_codes + dist_codes)) return INF_ERR_BITOVERRUN; + while (run--) lens[i++] = code; + i--; + } + } + + /* copy LITERAL code lengths and clear any remaining */ + i = lit_codes; + zip->sys->copy(&lens[0], &zip->LITERAL_len[0], i); + while (i < MSZIP_LITERAL_MAXSYMBOLS) zip->LITERAL_len[i++] = 0; + + i = dist_codes; + zip->sys->copy(&lens[lit_codes], &zip->DISTANCE_len[0], i); + while (i < MSZIP_DISTANCE_MAXSYMBOLS) zip->DISTANCE_len[i++] = 0; + + STORE_BITS; + return 0; +} + +/* a clean implementation of RFC 1951 / inflate */ +static int inflate(struct mszipd_stream *zip) { + unsigned int last_block, block_type, distance, length, this_run, i; + + /* for the bit buffer and huffman decoding */ + register unsigned int bit_buffer; + register int bits_left; + register unsigned short sym; + unsigned char *i_ptr, *i_end; + + RESTORE_BITS; + + do { + /* read in last block bit */ + READ_BITS(last_block, 1); + + /* read in block type */ + READ_BITS(block_type, 2); + + if (block_type == 0) { + /* uncompressed block */ + unsigned char lens_buf[4]; + + /* go to byte boundary */ + i = bits_left & 7; REMOVE_BITS(i); + + /* read 4 bytes of data, emptying the bit-buffer if necessary */ + for (i = 0; (bits_left >= 8); i++) { + if (i == 4) return INF_ERR_BITBUF; + lens_buf[i] = PEEK_BITS(8); + REMOVE_BITS(8); + } + if (bits_left != 0) return INF_ERR_BITBUF; + while (i < 4) { + READ_IF_NEEDED; + lens_buf[i++] = *i_ptr++; + } + + /* get the length and its complement */ + length = lens_buf[0] | (lens_buf[1] << 8); + i = lens_buf[2] | (lens_buf[3] << 8); + if (length != (~i & 0xFFFF)) return INF_ERR_COMPLEMENT; + + /* read and copy the uncompressed data into the window */ + while (length > 0) { + READ_IF_NEEDED; + + this_run = length; + if (this_run > (unsigned int)(i_end - i_ptr)) this_run = i_end - i_ptr; + if (this_run > (MSZIP_FRAME_SIZE - zip->window_posn)) + this_run = MSZIP_FRAME_SIZE - zip->window_posn; + + zip->sys->copy(i_ptr, &zip->window[zip->window_posn], this_run); + zip->window_posn += this_run; + i_ptr += this_run; + length -= this_run; + FLUSH_IF_NEEDED; + } + } + else if ((block_type == 1) || (block_type == 2)) { + /* Huffman-compressed LZ77 block */ + unsigned int match_posn, code; + + if (block_type == 1) { + /* block with fixed Huffman codes */ + i = 0; + while (i < 144) zip->LITERAL_len[i++] = 8; + while (i < 256) zip->LITERAL_len[i++] = 9; + while (i < 280) zip->LITERAL_len[i++] = 7; + while (i < 288) zip->LITERAL_len[i++] = 8; + for (i = 0; i < 32; i++) zip->DISTANCE_len[i] = 5; + } + else { + /* block with dynamic Huffman codes */ + STORE_BITS; + if ((i = zip_read_lens(zip))) return i; + RESTORE_BITS; + } + + /* now huffman lengths are read for either kind of block, + * create huffman decoding tables */ + if (make_decode_table(MSZIP_LITERAL_MAXSYMBOLS, MSZIP_LITERAL_TABLEBITS, + &zip->LITERAL_len[0], &zip->LITERAL_table[0])) + { + return INF_ERR_LITERALTBL; + } + + if (make_decode_table(MSZIP_DISTANCE_MAXSYMBOLS,MSZIP_DISTANCE_TABLEBITS, + &zip->DISTANCE_len[0], &zip->DISTANCE_table[0])) + { + return INF_ERR_DISTANCETBL; + } + + /* decode forever until end of block code */ + for (;;) { + READ_HUFFSYM(LITERAL, code); + if (code < 256) { + zip->window[zip->window_posn++] = (unsigned char) code; + FLUSH_IF_NEEDED; + } + else if (code == 256) { + /* END OF BLOCK CODE: loop break point */ + break; + } + else { + code -= 257; /* codes 257-285 are matches */ + if (code >= 29) return INF_ERR_LITCODE; /* codes 286-287 are illegal */ + READ_BITS_T(length, lit_extrabits[code]); + length += lit_lengths[code]; + + READ_HUFFSYM(DISTANCE, code); + if (code >= 30) return INF_ERR_DISTCODE; + READ_BITS_T(distance, dist_extrabits[code]); + distance += dist_offsets[code]; + + /* match position is window position minus distance. If distance + * is more than window position numerically, it must 'wrap + * around' the frame size. */ + match_posn = ((distance > zip->window_posn) ? MSZIP_FRAME_SIZE : 0) + + zip->window_posn - distance; + + /* copy match */ + if (length < 12) { + /* short match, use slower loop but no loop setup code */ + while (length--) { + zip->window[zip->window_posn++] = zip->window[match_posn++]; + match_posn &= MSZIP_FRAME_SIZE - 1; + FLUSH_IF_NEEDED; + } + } + else { + /* longer match, use faster loop but with setup expense */ + unsigned char *runsrc, *rundest; + do { + this_run = length; + if ((match_posn + this_run) > MSZIP_FRAME_SIZE) + this_run = MSZIP_FRAME_SIZE - match_posn; + if ((zip->window_posn + this_run) > MSZIP_FRAME_SIZE) + this_run = MSZIP_FRAME_SIZE - zip->window_posn; + + rundest = &zip->window[zip->window_posn]; zip->window_posn += this_run; + runsrc = &zip->window[match_posn]; match_posn += this_run; + length -= this_run; + while (this_run--) *rundest++ = *runsrc++; + if (match_posn == MSZIP_FRAME_SIZE) match_posn = 0; + FLUSH_IF_NEEDED; + } while (length > 0); + } + + } /* else (code >= 257) */ + + } /* for(;;) -- break point at 'code == 256' */ + } + else { + /* block_type == 3 -- bad block type */ + return INF_ERR_BLOCKTYPE; + } + } while (!last_block); + + /* flush the remaining data */ + if (zip->window_posn) { + if (zip->flush_window(zip, zip->window_posn)) return INF_ERR_FLUSH; + } + STORE_BITS; + + /* return success */ + return 0; +} + +/* inflate() calls this whenever the window should be flushed. As + * MSZIP only expands to the size of the window, the implementation used + * simply keeps track of the amount of data flushed, and if more than 32k + * is flushed, an error is raised. + */ +static int mszipd_flush_window(struct mszipd_stream *zip, + unsigned int data_flushed) +{ + zip->bytes_output += data_flushed; + if (zip->bytes_output > MSZIP_FRAME_SIZE) { + D(("overflow: %u bytes flushed, total is now %u", + data_flushed, zip->bytes_output)) + return 1; + } + return 0; +} + +struct mszipd_stream *mszipd_init(struct mspack_system *system, + struct mspack_file *input, + struct mspack_file *output, + int input_buffer_size, + int repair_mode) +{ + struct mszipd_stream *zip; + + if (!system) return NULL; + + input_buffer_size = (input_buffer_size + 1) & -2; + if (!input_buffer_size) return NULL; + + /* allocate decompression state */ + if (!(zip = (struct mszipd_stream *) system->alloc(system, sizeof(struct mszipd_stream)))) { + return NULL; + } + + /* allocate input buffer */ + zip->inbuf = (unsigned char *) system->alloc(system, (size_t) input_buffer_size); + if (!zip->inbuf) { + system->free(zip); + return NULL; + } + + /* initialise decompression state */ + zip->sys = system; + zip->input = input; + zip->output = output; + zip->inbuf_size = input_buffer_size; + zip->input_end = 0; + zip->error = MSPACK_ERR_OK; + zip->repair_mode = repair_mode; + zip->flush_window = &mszipd_flush_window; + + zip->i_ptr = zip->i_end = &zip->inbuf[0]; + zip->o_ptr = zip->o_end = NULL; + zip->bit_buffer = 0; zip->bits_left = 0; + return zip; +} + +int mszipd_decompress(struct mszipd_stream *zip, off_t out_bytes) { + /* for the bit buffer */ + register unsigned int bit_buffer; + register int bits_left; + unsigned char *i_ptr, *i_end; + + int i, state, error; + + /* easy answers */ + if (!zip || (out_bytes < 0)) return MSPACK_ERR_ARGS; + if (zip->error) return zip->error; + + /* flush out any stored-up bytes before we begin */ + i = zip->o_end - zip->o_ptr; + if ((off_t) i > out_bytes) i = (int) out_bytes; + if (i) { + if (zip->sys->write(zip->output, zip->o_ptr, i) != i) { + return zip->error = MSPACK_ERR_WRITE; + } + zip->o_ptr += i; + out_bytes -= i; + } + if (out_bytes == 0) return MSPACK_ERR_OK; + + + while (out_bytes > 0) { + /* unpack another block */ + RESTORE_BITS; + + /* skip to next read 'CK' header */ + i = bits_left & 7; REMOVE_BITS(i); /* align to bytestream */ + state = 0; + do { + READ_BITS(i, 8); + if (i == 'C') state = 1; + else if ((state == 1) && (i == 'K')) state = 2; + else state = 0; + } while (state != 2); + + /* inflate a block, repair and realign if necessary */ + zip->window_posn = 0; + zip->bytes_output = 0; + STORE_BITS; + if ((error = inflate(zip))) { + D(("inflate error %d", error)) + if (zip->repair_mode) { + /* recover partially-inflated buffers */ + if (zip->bytes_output == 0 && zip->window_posn > 0) { + zip->flush_window(zip, zip->window_posn); + } + zip->sys->message(NULL, "MSZIP error, %u bytes of data lost.", + MSZIP_FRAME_SIZE - zip->bytes_output); + for (i = zip->bytes_output; i < MSZIP_FRAME_SIZE; i++) { + zip->window[i] = '\0'; + } + zip->bytes_output = MSZIP_FRAME_SIZE; + } + else { + return zip->error = (error > 0) ? error : MSPACK_ERR_DECRUNCH; + } + } + zip->o_ptr = &zip->window[0]; + zip->o_end = &zip->o_ptr[zip->bytes_output]; + + /* write a frame */ + i = (out_bytes < (off_t)zip->bytes_output) ? + (int)out_bytes : zip->bytes_output; + if (zip->sys->write(zip->output, zip->o_ptr, i) != i) { + return zip->error = MSPACK_ERR_WRITE; + } + + /* mspack errors (i.e. read errors) are fatal and can't be recovered */ + if ((error > 0) && zip->repair_mode) return error; + + zip->o_ptr += i; + out_bytes -= i; + } + + if (out_bytes) { + D(("bytes left to output")) + return zip->error = MSPACK_ERR_DECRUNCH; + } + return MSPACK_ERR_OK; +} + +int mszipd_decompress_kwaj(struct mszipd_stream *zip) { + /* for the bit buffer */ + register unsigned int bit_buffer; + register int bits_left; + unsigned char *i_ptr, *i_end; + + int i, error, block_len; + + /* unpack blocks until block_len == 0 */ + for (;;) { + RESTORE_BITS; + + /* align to bytestream, read block_len */ + i = bits_left & 7; REMOVE_BITS(i); + READ_BITS(block_len, 8); + READ_BITS(i, 8); block_len |= i << 8; + + if (block_len == 0) break; + + /* read "CK" header */ + READ_BITS(i, 8); if (i != 'C') return MSPACK_ERR_DATAFORMAT; + READ_BITS(i, 8); if (i != 'K') return MSPACK_ERR_DATAFORMAT; + + /* inflate block */ + zip->window_posn = 0; + zip->bytes_output = 0; + STORE_BITS; + if ((error = inflate(zip))) { + D(("inflate error %d", error)) + return zip->error = (error > 0) ? error : MSPACK_ERR_DECRUNCH; + } + + /* write inflated block */ + if (zip->sys->write(zip->output, &zip->window[0], zip->bytes_output) + != zip->bytes_output) return zip->error = MSPACK_ERR_WRITE; + } + return MSPACK_ERR_OK; +} + +void mszipd_free(struct mszipd_stream *zip) { + struct mspack_system *sys; + if (zip) { + sys = zip->sys; + sys->free(zip->inbuf); + sys->free(zip); + } +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/mszip.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/mszip.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/mszip.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/mszip.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,126 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * The deflate method was created by Phil Katz. MSZIP is equivalent to the + * deflate method. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_MSZIP_H +#define MSPACK_MSZIP_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* MSZIP (deflate) compression / (inflate) decompression definitions */ + +#define MSZIP_FRAME_SIZE (32768) /* size of LZ history window */ +#define MSZIP_LITERAL_MAXSYMBOLS (288) /* literal/length huffman tree */ +#define MSZIP_LITERAL_TABLEBITS (9) +#define MSZIP_DISTANCE_MAXSYMBOLS (32) /* distance huffman tree */ +#define MSZIP_DISTANCE_TABLEBITS (6) + +/* if there are less direct lookup entries than symbols, the longer + * code pointers will be <= maxsymbols. This must not happen, or we + * will decode entries badly */ +#if (1 << MSZIP_LITERAL_TABLEBITS) < (MSZIP_LITERAL_MAXSYMBOLS * 2) +# define MSZIP_LITERAL_TABLESIZE (MSZIP_LITERAL_MAXSYMBOLS * 4) +#else +# define MSZIP_LITERAL_TABLESIZE ((1 << MSZIP_LITERAL_TABLEBITS) + \ + (MSZIP_LITERAL_MAXSYMBOLS * 2)) +#endif + +#if (1 << MSZIP_DISTANCE_TABLEBITS) < (MSZIP_DISTANCE_MAXSYMBOLS * 2) +# define MSZIP_DISTANCE_TABLESIZE (MSZIP_DISTANCE_MAXSYMBOLS * 4) +#else +# define MSZIP_DISTANCE_TABLESIZE ((1 << MSZIP_DISTANCE_TABLEBITS) + \ + (MSZIP_DISTANCE_MAXSYMBOLS * 2)) +#endif + +struct mszipd_stream { + struct mspack_system *sys; /* I/O routines */ + struct mspack_file *input; /* input file handle */ + struct mspack_file *output; /* output file handle */ + unsigned int window_posn; /* offset within window */ + + /* inflate() will call this whenever the window should be emptied. */ + int (*flush_window)(struct mszipd_stream *, unsigned int); + + int error, repair_mode, bytes_output; + + /* I/O buffering */ + unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end, input_end; + unsigned int bit_buffer, bits_left, inbuf_size; + + + /* huffman code lengths */ + unsigned char LITERAL_len[MSZIP_LITERAL_MAXSYMBOLS]; + unsigned char DISTANCE_len[MSZIP_DISTANCE_MAXSYMBOLS]; + + /* huffman decoding tables */ + unsigned short LITERAL_table [MSZIP_LITERAL_TABLESIZE]; + unsigned short DISTANCE_table[MSZIP_DISTANCE_TABLESIZE]; + + /* 32kb history window */ + unsigned char window[MSZIP_FRAME_SIZE]; +}; + +/* allocates MS-ZIP decompression stream for decoding the given stream. + * + * - uses system->alloc() to allocate memory + * + * - returns NULL if not enough memory + * + * - input_buffer_size is how many bytes to use as an input bitstream buffer + * + * - if repair_mode is non-zero, errors in decompression will be skipped + * and 'holes' left will be filled with zero bytes. This allows at least + * a partial recovery of erroneous data. + */ +extern struct mszipd_stream *mszipd_init(struct mspack_system *system, + struct mspack_file *input, + struct mspack_file *output, + int input_buffer_size, + int repair_mode); + +/* decompresses, or decompresses more of, an MS-ZIP stream. + * + * - out_bytes of data will be decompressed and the function will return + * with an MSPACK_ERR_OK return code. + * + * - decompressing will stop as soon as out_bytes is reached. if the true + * amount of bytes decoded spills over that amount, they will be kept for + * a later invocation of mszipd_decompress(). + * + * - the output bytes will be passed to the system->write() function given in + * mszipd_init(), using the output file handle given in mszipd_init(). More + * than one call may be made to system->write() + * + * - MS-ZIP will read input bytes as necessary using the system->read() + * function given in mszipd_init(), using the input file handle given in + * mszipd_init(). This will continue until system->read() returns 0 bytes, + * or an error. + */ +extern int mszipd_decompress(struct mszipd_stream *zip, off_t out_bytes); + +/* decompresses an entire MS-ZIP stream in a KWAJ file. Acts very much + * like mszipd_decompress(), but doesn't take an out_bytes parameter + */ +extern int mszipd_decompress_kwaj(struct mszipd_stream *zip); + +/* frees all stream associated with an MS-ZIP data stream + * + * - calls system->free() using the system pointer given in mszipd_init() + */ +void mszipd_free(struct mszipd_stream *zip); + +#ifdef __cplusplus +} +#endif + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/oabc.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/oabc.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/oabc.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/oabc.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,24 @@ +/* This file is part of libmspack. + * © 2013 Intel Corporation + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* OAB compression implementation */ + +#include +#include + +struct msoab_compressor * + mspack_create_oab_compressor(struct mspack_system *sys) +{ + /* todo */ + return NULL; +} + +void mspack_destroy_oab_compressor(struct msoab_compressor *self) { + /* todo */ +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/oabd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/oabd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/oabd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/oabd.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,405 @@ +/* This file is part of libmspack. + * © 2013 Intel Corporation + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* The Exchange Online Addressbook (OAB or sometimes OAL) is distributed + * as a .LZX file in one of two forms. Either a "full download" containing + * the entire address list, or an incremental binary patch which should be + * applied to a previous version of the full decompressed data. + * + * The contents and format of the decompressed OAB are not handled here. + * + * For a complete description of the format, see the MSDN site: + * + * http://msdn.microsoft.com/en-us/library/cc463914 - [MS-OXOAB].pdf + * http://msdn.microsoft.com/en-us/library/cc483133 - [MS-PATCH].pdf + */ + +/* OAB decompression implementation */ + +#include +#include +#include +#include + +/* prototypes */ +static int oabd_decompress(struct msoab_decompressor *self, const char *input, + const char *output); +static int oabd_decompress_incremental(struct msoab_decompressor *self, + const char *input, const char *base, + const char *output); + +struct msoab_decompressor * + mspack_create_oab_decompressor(struct mspack_system *sys) +{ + struct msoab_decompressor_p *self = NULL; + + if (!sys) sys = mspack_default_system; + if (!mspack_valid_system(sys)) return NULL; + + if ((self = (struct msoab_decompressor_p *) sys->alloc(sys, sizeof(struct msoab_decompressor_p)))) { + self->base.decompress = &oabd_decompress; + self->base.decompress_incremental = &oabd_decompress_incremental; + self->system = sys; + } + return (struct msoab_decompressor *) self; +} + +void mspack_destroy_oab_decompressor(struct msoab_decompressor *base) { + struct msoab_decompressor_p *self = (struct msoab_decompressor_p *)base; + if (self) { + struct mspack_system *sys = self->system; + sys->free(self); + } +} + +struct oabd_file { + struct mspack_system *orig_sys; + struct mspack_file *orig_file; + unsigned int crc; + size_t available; +}; + + +static int oabd_sys_read (struct mspack_file *base_file, void *buf, int size) +{ + struct oabd_file *file = (struct oabd_file *)base_file; + int bytes_read; + + if ((size_t)size > file->available) + size = file->available; + + bytes_read = file->orig_sys->read(file->orig_file, buf, size); + if (bytes_read < 0) + return bytes_read; + + file->available -= bytes_read; + return bytes_read; +} + +static int oabd_sys_write (struct mspack_file *base_file, void *buf, int size) +{ + struct oabd_file *file = (struct oabd_file *)base_file; + int bytes_written = file->orig_sys->write(file->orig_file, buf, size); + + if (bytes_written > 0) + file->crc = crc32(file->crc, buf, bytes_written); + + return bytes_written; +} + +static int oabd_decompress(struct msoab_decompressor *_self, const char *input, + const char *output) +{ + struct msoab_decompressor_p *self = (struct msoab_decompressor_p *) _self; + struct mspack_system *sys; + struct mspack_file *infh = NULL; + struct mspack_file *outfh = NULL; + unsigned char *buf = NULL; + unsigned char hdrbuf[oabhead_SIZEOF]; + unsigned int block_max, target_size; + struct lzxd_stream *lzx = NULL; + struct mspack_system oabd_sys; + struct oabd_file in_ofh, out_ofh; + unsigned int window_bits; + int ret = MSPACK_ERR_OK; + + if (!self) return MSPACK_ERR_ARGS; + sys = self->system; + + infh = sys->open(sys, input, MSPACK_SYS_OPEN_READ); + if (!infh) { + ret = MSPACK_ERR_OPEN; + goto out; + } + + if (sys->read(infh, hdrbuf, oabhead_SIZEOF) != oabhead_SIZEOF) { + ret = MSPACK_ERR_READ; + goto out; + } + + if (EndGetI32(&hdrbuf[oabhead_VersionHi]) != 3 || + EndGetI32(&hdrbuf[oabhead_VersionLo]) != 1) { + ret = MSPACK_ERR_SIGNATURE; + goto out; + } + + block_max = EndGetI32(&hdrbuf[oabhead_BlockMax]); + target_size = EndGetI32(&hdrbuf[oabhead_TargetSize]); + + /* We use it for reading block headers too */ + if (block_max < oabblk_SIZEOF) + block_max = oabblk_SIZEOF; + + outfh = sys->open(sys, output, MSPACK_SYS_OPEN_WRITE); + if (!outfh) { + ret = MSPACK_ERR_OPEN; + goto out; + } + + buf = sys->alloc(sys, block_max); + if (!buf) { + ret = MSPACK_ERR_NOMEMORY; + goto out; + } + + oabd_sys = *sys; + oabd_sys.read = oabd_sys_read; + oabd_sys.write = oabd_sys_write; + + in_ofh.orig_sys = sys; + in_ofh.orig_file = infh; + + out_ofh.orig_sys = sys; + out_ofh.orig_file = outfh; + + while (target_size) { + unsigned int blk_csize, blk_dsize, blk_crc, blk_flags; + + if (sys->read(infh, buf, oabblk_SIZEOF) != oabblk_SIZEOF) { + ret = MSPACK_ERR_READ; + goto out; + } + blk_flags = EndGetI32(&buf[oabblk_Flags]); + blk_csize = EndGetI32(&buf[oabblk_CompSize]); + blk_dsize = EndGetI32(&buf[oabblk_UncompSize]); + blk_crc = EndGetI32(&buf[oabblk_CRC]); + + if (blk_dsize > block_max || blk_dsize > target_size || blk_flags > 1) { + ret = MSPACK_ERR_DATAFORMAT; + goto out; + } + + if (!blk_flags) { + /* Uncompressed block */ + if (blk_dsize != blk_csize) { + ret = MSPACK_ERR_DATAFORMAT; + goto out; + } + if (sys->read(infh, buf, blk_dsize) != (int)blk_dsize) { + ret = MSPACK_ERR_READ; + goto out; + } + if (sys->write(outfh, buf, blk_dsize) != (int)blk_dsize) { + ret = MSPACK_ERR_WRITE; + goto out; + } + } else { + /* LZX compressed block */ + window_bits = 17; + + while (window_bits < 25 && (1U << window_bits) < blk_dsize) + window_bits++; + + in_ofh.available = blk_csize; + out_ofh.crc = 0xffffffff; + + lzx = lzxd_init(&oabd_sys, (void *)&in_ofh, (void *)&out_ofh, window_bits, + 0, 4096, blk_dsize, 1); + if (!lzx) { + ret = MSPACK_ERR_NOMEMORY; + goto out; + } + + ret = lzxd_decompress(lzx, blk_dsize); + if (ret != MSPACK_ERR_OK) + goto out; + + lzxd_free(lzx); + lzx = NULL; + + /* Consume any trailing padding bytes before the next block */ + while (in_ofh.available) { + int count = block_max; + if ((size_t)count > in_ofh.available) + count = in_ofh.available; + + count = sys->read(infh, buf, count); + if (count < 0) { + ret = MSPACK_ERR_READ; + goto out; + } + in_ofh.available -= count; + } + + if (out_ofh.crc != blk_crc) { + ret = MSPACK_ERR_CHECKSUM; + goto out; + } + } + target_size -= blk_dsize; + } + + out: + if (lzx) + lzxd_free(lzx); + if (buf) + sys->free(buf); + if (outfh) + sys->close(outfh); + if (infh) + sys->close(infh); + + return ret; +} + +static int oabd_decompress_incremental(struct msoab_decompressor *_self, + const char *input, const char *base, + const char *output) +{ + struct msoab_decompressor_p *self = (struct msoab_decompressor_p *) _self; + struct mspack_system *sys; + struct mspack_file *infh = NULL; + struct mspack_file *basefh = NULL; + struct mspack_file *outfh = NULL; + unsigned char *buf = NULL; + unsigned char hdrbuf[patchhead_SIZEOF]; + unsigned int block_max, target_size; + struct lzxd_stream *lzx = NULL; + struct mspack_system oabd_sys; + struct oabd_file in_ofh, out_ofh; + unsigned int window_bits, window_size; + int ret = MSPACK_ERR_OK; + + if (!self) return MSPACK_ERR_ARGS; + sys = self->system; + + infh = sys->open(sys, input, MSPACK_SYS_OPEN_READ); + if (!infh) { + ret = MSPACK_ERR_OPEN; + goto out; + } + + if (sys->read(infh, hdrbuf, patchhead_SIZEOF) != patchhead_SIZEOF) { + ret = MSPACK_ERR_READ; + goto out; + } + + if (EndGetI32(&hdrbuf[patchhead_VersionHi]) != 3 || + EndGetI32(&hdrbuf[patchhead_VersionLo]) != 2) { + ret = MSPACK_ERR_SIGNATURE; + goto out; + } + + block_max = EndGetI32(&hdrbuf[patchhead_BlockMax]); + target_size = EndGetI32(&hdrbuf[patchhead_TargetSize]); + + /* We use it for reading block headers too */ + if (block_max < patchblk_SIZEOF) + block_max = patchblk_SIZEOF; + + basefh = sys->open(sys, base, MSPACK_SYS_OPEN_READ); + if (!basefh) { + ret = MSPACK_ERR_OPEN; + goto out; + } + + outfh = sys->open(sys, output, MSPACK_SYS_OPEN_WRITE); + if (!outfh) { + ret = MSPACK_ERR_OPEN; + goto out; + } + + buf = sys->alloc(sys, block_max); + if (!buf) { + ret = MSPACK_ERR_NOMEMORY; + goto out; + } + + oabd_sys = *sys; + oabd_sys.read = oabd_sys_read; + oabd_sys.write = oabd_sys_write; + + in_ofh.orig_sys = sys; + in_ofh.orig_file = infh; + + out_ofh.orig_sys = sys; + out_ofh.orig_file = outfh; + + while (target_size) { + unsigned int blk_csize, blk_dsize, blk_ssize, blk_crc; + + if (sys->read(infh, buf, patchblk_SIZEOF) != patchblk_SIZEOF) { + ret = MSPACK_ERR_READ; + goto out; + } + blk_csize = EndGetI32(&buf[patchblk_PatchSize]); + blk_dsize = EndGetI32(&buf[patchblk_TargetSize]); + blk_ssize = EndGetI32(&buf[patchblk_SourceSize]); + blk_crc = EndGetI32(&buf[patchblk_CRC]); + + if (blk_dsize > block_max || blk_dsize > target_size || + blk_ssize > block_max) { + ret = MSPACK_ERR_DATAFORMAT; + goto out; + } + + + window_size = (blk_ssize + 32767) & ~32767; + window_size += blk_dsize; + window_bits = 17; + + while (window_bits < 25 && (1U << window_bits) < window_size) + window_bits++; + + in_ofh.available = blk_csize; + out_ofh.crc = 0xffffffff; + + lzx = lzxd_init(&oabd_sys, (void *)&in_ofh, (void *)&out_ofh, window_bits, + 0, 4096, blk_dsize, 1); + if (!lzx) { + ret = MSPACK_ERR_NOMEMORY; + goto out; + } + ret = lzxd_set_reference_data(lzx, sys, basefh, blk_ssize); + if (ret != MSPACK_ERR_OK) + goto out; + + ret = lzxd_decompress(lzx, blk_dsize); + if (ret != MSPACK_ERR_OK) + goto out; + + lzxd_free(lzx); + lzx = NULL; + + /* Consume any trailing padding bytes before the next block */ + while (in_ofh.available) { + int count = block_max; + if ((size_t)count > in_ofh.available) + count = in_ofh.available; + + count = sys->read(infh, buf, count); + if (count < 0) { + ret = MSPACK_ERR_READ; + goto out; + } + in_ofh.available -= count; + } + + if (out_ofh.crc != blk_crc) { + ret = MSPACK_ERR_CHECKSUM; + goto out; + } + + target_size -= blk_dsize; + } + + out: + if (lzx) + lzxd_free(lzx); + if (buf) + sys->free(buf); + if (outfh) + sys->close(outfh); + if (basefh) + sys->close(basefh); + if (infh) + sys->close(infh); + + return ret; +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/oab.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/oab.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/oab.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/oab.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,60 @@ +/* This file is part of libmspack. + * © 2013 Intel Corporation + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_OAB_H +#define MSPACK_OAB_H 1 + +#include + +/* generic OAB definitions */ + +/* OAB compression definitions */ + +struct msoab_compressor_p { + struct msoab_compressor base; + struct mspack_system *system; + /* todo */ +}; + +/* OAB decompression definitions */ + +struct msoab_decompressor_p { + struct msoab_decompressor base; + struct mspack_system *system; + /* todo */ +}; + +#define oabhead_VersionHi (0x0000) +#define oabhead_VersionLo (0x0004) +#define oabhead_BlockMax (0x0008) +#define oabhead_TargetSize (0x000c) +#define oabhead_SIZEOF (0x0010) + +#define oabblk_Flags (0x0000) +#define oabblk_CompSize (0x0004) +#define oabblk_UncompSize (0x0008) +#define oabblk_CRC (0x000c) +#define oabblk_SIZEOF (0x0010) + +#define patchhead_VersionHi (0x0000) +#define patchhead_VersionLo (0x0004) +#define patchhead_BlockMax (0x0008) +#define patchhead_SourceSize (0x000c) +#define patchhead_TargetSize (0x0010) +#define patchhead_SourceCRC (0x0014) +#define patchhead_TargetCRC (0x0018) +#define patchhead_SIZEOF (0x001c) + +#define patchblk_PatchSize (0x0000) +#define patchblk_TargetSize (0x0004) +#define patchblk_SourceSize (0x0008) +#define patchblk_CRC (0x000c) +#define patchblk_SIZEOF (0x0010) + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/qtmd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/qtmd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/qtmd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/qtmd.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,489 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * The Quantum method was created by David Stafford, adapted by Microsoft + * Corporation. + * + * This decompressor is based on an implementation by Matthew Russotto, used + * with permission. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* Quantum decompression implementation */ + +/* This decompressor was researched and implemented by Matthew Russotto. It + * has since been tidied up by Stuart Caie. More information can be found at + * http://www.speakeasy.org/~russotto/quantumcomp.html + */ + +#include +#include + +/* import bit-reading macros and code */ +#define BITS_TYPE struct qtmd_stream +#define BITS_VAR qtm +#define BITS_ORDER_MSB +#define READ_BYTES do { \ + unsigned char b0, b1; \ + READ_IF_NEEDED; b0 = *i_ptr++; \ + READ_IF_NEEDED; b1 = *i_ptr++; \ + INJECT_BITS((b0 << 8) | b1, 16); \ +} while (0) +#include + +/* Quantum static data tables: + * + * Quantum uses 'position slots' to represent match offsets. For every + * match, a small 'position slot' number and a small offset from that slot + * are encoded instead of one large offset. + * + * position_base[] is an index to the position slot bases + * + * extra_bits[] states how many bits of offset-from-base data is needed. + * + * length_base[] and length_extra[] are equivalent in function, but are + * used for encoding selector 6 (variable length match) match lengths, + * instead of match offsets. + * + * They are generated with the following code: + * unsigned int i, offset; + * for (i = 0, offset = 0; i < 42; i++) { + * position_base[i] = offset; + * extra_bits[i] = ((i < 2) ? 0 : (i - 2)) >> 1; + * offset += 1 << extra_bits[i]; + * } + * for (i = 0, offset = 0; i < 26; i++) { + * length_base[i] = offset; + * length_extra[i] = (i < 2 ? 0 : i - 2) >> 2; + * offset += 1 << length_extra[i]; + * } + * length_base[26] = 254; length_extra[26] = 0; + */ +static const unsigned int position_base[42] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576, 32768, 49152, + 65536, 98304, 131072, 196608, 262144, 393216, 524288, 786432, 1048576, 1572864 +}; +static const unsigned char extra_bits[42] = { + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, + 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19 +}; +static const unsigned char length_base[27] = { + 0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 14, 18, 22, 26, + 30, 38, 46, 54, 62, 78, 94, 110, 126, 158, 190, 222, 254 +}; +static const unsigned char length_extra[27] = { + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 +}; + + +/* Arithmetic decoder: + * + * GET_SYMBOL(model, var) fetches the next symbol from the stated model + * and puts it in var. + * + * If necessary, qtmd_update_model() is called. + */ +#define GET_SYMBOL(model, var) do { \ + range = ((H - L) & 0xFFFF) + 1; \ + symf = ((((C - L + 1) * model.syms[0].cumfreq)-1) / range) & 0xFFFF; \ + \ + for (i = 1; i < model.entries; i++) { \ + if (model.syms[i].cumfreq <= symf) break; \ + } \ + (var) = model.syms[i-1].sym; \ + \ + range = (H - L) + 1; \ + symf = model.syms[0].cumfreq; \ + H = L + ((model.syms[i-1].cumfreq * range) / symf) - 1; \ + L = L + ((model.syms[i].cumfreq * range) / symf); \ + \ + do { model.syms[--i].cumfreq += 8; } while (i > 0); \ + if (model.syms[0].cumfreq > 3800) qtmd_update_model(&model); \ + \ + while (1) { \ + if ((L & 0x8000) != (H & 0x8000)) { \ + if ((L & 0x4000) && !(H & 0x4000)) { \ + /* underflow case */ \ + C ^= 0x4000; L &= 0x3FFF; H |= 0x4000; \ + } \ + else break; \ + } \ + L <<= 1; H = (H << 1) | 1; \ + ENSURE_BITS(1); \ + C = (C << 1) | PEEK_BITS(1); \ + REMOVE_BITS(1); \ + } \ +} while (0) + +static void qtmd_update_model(struct qtmd_model *model) { + struct qtmd_modelsym tmp; + int i, j; + + if (--model->shiftsleft) { + for (i = model->entries - 1; i >= 0; i--) { + /* -1, not -2; the 0 entry saves this */ + model->syms[i].cumfreq >>= 1; + if (model->syms[i].cumfreq <= model->syms[i+1].cumfreq) { + model->syms[i].cumfreq = model->syms[i+1].cumfreq + 1; + } + } + } + else { + model->shiftsleft = 50; + for (i = 0; i < model->entries; i++) { + /* no -1, want to include the 0 entry */ + /* this converts cumfreqs into frequencies, then shifts right */ + model->syms[i].cumfreq -= model->syms[i+1].cumfreq; + model->syms[i].cumfreq++; /* avoid losing things entirely */ + model->syms[i].cumfreq >>= 1; + } + + /* now sort by frequencies, decreasing order -- this must be an + * inplace selection sort, or a sort with the same (in)stability + * characteristics */ + for (i = 0; i < model->entries - 1; i++) { + for (j = i + 1; j < model->entries; j++) { + if (model->syms[i].cumfreq < model->syms[j].cumfreq) { + tmp = model->syms[i]; + model->syms[i] = model->syms[j]; + model->syms[j] = tmp; + } + } + } + + /* then convert frequencies back to cumfreq */ + for (i = model->entries - 1; i >= 0; i--) { + model->syms[i].cumfreq += model->syms[i+1].cumfreq; + } + } +} + +/* Initialises a model to decode symbols from [start] to [start]+[len]-1 */ +static void qtmd_init_model(struct qtmd_model *model, + struct qtmd_modelsym *syms, int start, int len) +{ + int i; + + model->shiftsleft = 4; + model->entries = len; + model->syms = syms; + + for (i = 0; i <= len; i++) { + syms[i].sym = start + i; /* actual symbol */ + syms[i].cumfreq = len - i; /* current frequency of that symbol */ + } +} + + +/*-------- main Quantum code --------*/ + +struct qtmd_stream *qtmd_init(struct mspack_system *system, + struct mspack_file *input, + struct mspack_file *output, + int window_bits, int input_buffer_size) +{ + unsigned int window_size = 1 << window_bits; + struct qtmd_stream *qtm; + int i; + + if (!system) return NULL; + + /* Quantum supports window sizes of 2^10 (1Kb) through 2^21 (2Mb) */ + if (window_bits < 10 || window_bits > 21) return NULL; + + input_buffer_size = (input_buffer_size + 1) & -2; + if (input_buffer_size < 2) return NULL; + + /* allocate decompression state */ + if (!(qtm = (struct qtmd_stream *) system->alloc(system, sizeof(struct qtmd_stream)))) { + return NULL; + } + + /* allocate decompression window and input buffer */ + qtm->window = (unsigned char *) system->alloc(system, (size_t) window_size); + qtm->inbuf = (unsigned char *) system->alloc(system, (size_t) input_buffer_size); + if (!qtm->window || !qtm->inbuf) { + system->free(qtm->window); + system->free(qtm->inbuf); + system->free(qtm); + return NULL; + } + + /* initialise decompression state */ + qtm->sys = system; + qtm->input = input; + qtm->output = output; + qtm->inbuf_size = input_buffer_size; + qtm->window_size = window_size; + qtm->window_posn = 0; + qtm->frame_todo = QTM_FRAME_SIZE; + qtm->header_read = 0; + qtm->error = MSPACK_ERR_OK; + + qtm->i_ptr = qtm->i_end = &qtm->inbuf[0]; + qtm->o_ptr = qtm->o_end = &qtm->window[0]; + qtm->input_end = 0; + qtm->bits_left = 0; + qtm->bit_buffer = 0; + + /* initialise arithmetic coding models + * - model 4 depends on window size, ranges from 20 to 24 + * - model 5 depends on window size, ranges from 20 to 36 + * - model 6pos depends on window size, ranges from 20 to 42 + */ + i = window_bits * 2; + qtmd_init_model(&qtm->model0, &qtm->m0sym[0], 0, 64); + qtmd_init_model(&qtm->model1, &qtm->m1sym[0], 64, 64); + qtmd_init_model(&qtm->model2, &qtm->m2sym[0], 128, 64); + qtmd_init_model(&qtm->model3, &qtm->m3sym[0], 192, 64); + qtmd_init_model(&qtm->model4, &qtm->m4sym[0], 0, (i > 24) ? 24 : i); + qtmd_init_model(&qtm->model5, &qtm->m5sym[0], 0, (i > 36) ? 36 : i); + qtmd_init_model(&qtm->model6, &qtm->m6sym[0], 0, i); + qtmd_init_model(&qtm->model6len, &qtm->m6lsym[0], 0, 27); + qtmd_init_model(&qtm->model7, &qtm->m7sym[0], 0, 7); + + /* all ok */ + return qtm; +} + +int qtmd_decompress(struct qtmd_stream *qtm, off_t out_bytes) { + unsigned int frame_todo, frame_end, window_posn, match_offset, range; + unsigned char *window, *i_ptr, *i_end, *runsrc, *rundest; + int i, j, selector, extra, sym, match_length; + unsigned short H, L, C, symf; + + register unsigned int bit_buffer; + register unsigned char bits_left; + + /* easy answers */ + if (!qtm || (out_bytes < 0)) return MSPACK_ERR_ARGS; + if (qtm->error) return qtm->error; + + /* flush out any stored-up bytes before we begin */ + i = qtm->o_end - qtm->o_ptr; + if ((off_t) i > out_bytes) i = (int) out_bytes; + if (i) { + if (qtm->sys->write(qtm->output, qtm->o_ptr, i) != i) { + return qtm->error = MSPACK_ERR_WRITE; + } + qtm->o_ptr += i; + out_bytes -= i; + } + if (out_bytes == 0) return MSPACK_ERR_OK; + + /* restore local state */ + RESTORE_BITS; + window = qtm->window; + window_posn = qtm->window_posn; + frame_todo = qtm->frame_todo; + H = qtm->H; + L = qtm->L; + C = qtm->C; + + /* while we do not have enough decoded bytes in reserve: */ + while ((qtm->o_end - qtm->o_ptr) < out_bytes) { + /* read header if necessary. Initialises H, L and C */ + if (!qtm->header_read) { + H = 0xFFFF; L = 0; READ_BITS(C, 16); + qtm->header_read = 1; + } + + /* decode more, up to the number of bytes needed, the frame boundary, + * or the window boundary, whichever comes first */ + frame_end = window_posn + (out_bytes - (qtm->o_end - qtm->o_ptr)); + if ((window_posn + frame_todo) < frame_end) { + frame_end = window_posn + frame_todo; + } + if (frame_end > qtm->window_size) { + frame_end = qtm->window_size; + } + + while (window_posn < frame_end) { + GET_SYMBOL(qtm->model7, selector); + if (selector < 4) { + /* literal byte */ + struct qtmd_model *mdl = (selector == 0) ? &qtm->model0 : + ((selector == 1) ? &qtm->model1 : + ((selector == 2) ? &qtm->model2 : + &qtm->model3)); + GET_SYMBOL((*mdl), sym); + window[window_posn++] = sym; + frame_todo--; + } + else { + /* match repeated string */ + switch (selector) { + case 4: /* selector 4 = fixed length match (3 bytes) */ + GET_SYMBOL(qtm->model4, sym); + READ_MANY_BITS(extra, extra_bits[sym]); + match_offset = position_base[sym] + extra + 1; + match_length = 3; + break; + + case 5: /* selector 5 = fixed length match (4 bytes) */ + GET_SYMBOL(qtm->model5, sym); + READ_MANY_BITS(extra, extra_bits[sym]); + match_offset = position_base[sym] + extra + 1; + match_length = 4; + break; + + case 6: /* selector 6 = variable length match */ + GET_SYMBOL(qtm->model6len, sym); + READ_MANY_BITS(extra, length_extra[sym]); + match_length = length_base[sym] + extra + 5; + + GET_SYMBOL(qtm->model6, sym); + READ_MANY_BITS(extra, extra_bits[sym]); + match_offset = position_base[sym] + extra + 1; + break; + + default: + /* should be impossible, model7 can only return 0-6 */ + D(("got %d from selector", selector)) + return qtm->error = MSPACK_ERR_DECRUNCH; + } + + rundest = &window[window_posn]; + frame_todo -= match_length; + + /* does match destination wrap the window? This situation is possible + * where the window size is less than the 32k frame size, but matches + * must not go beyond a frame boundary */ + if ((window_posn + match_length) > qtm->window_size) { + /* copy first part of match, before window end */ + i = qtm->window_size - window_posn; + j = window_posn - match_offset; + while (i--) *rundest++ = window[j++ & (qtm->window_size - 1)]; + + /* flush currently stored data */ + i = (&window[qtm->window_size] - qtm->o_ptr); + + /* this should not happen, but if it does then this code + * can't handle the situation (can't flush up to the end of + * the window, but can't break out either because we haven't + * finished writing the match). bail out in this case */ + if (i > out_bytes) { + D(("during window-wrap match; %d bytes to flush but only need %d", + i, (int) out_bytes)) + return qtm->error = MSPACK_ERR_DECRUNCH; + } + if (qtm->sys->write(qtm->output, qtm->o_ptr, i) != i) { + return qtm->error = MSPACK_ERR_WRITE; + } + out_bytes -= i; + qtm->o_ptr = &window[0]; + qtm->o_end = &window[0]; + + /* copy second part of match, after window wrap */ + rundest = &window[0]; + i = match_length - (qtm->window_size - window_posn); + while (i--) *rundest++ = window[j++ & (qtm->window_size - 1)]; + window_posn = window_posn + match_length - qtm->window_size; + + break; /* because "window_posn < frame_end" has now failed */ + } + else { + /* normal match - output won't wrap window or frame end */ + i = match_length; + + /* does match _offset_ wrap the window? */ + if (match_offset > window_posn) { + /* j = length from match offset to end of window */ + j = match_offset - window_posn; + if (j > (int) qtm->window_size) { + D(("match offset beyond window boundaries")) + return qtm->error = MSPACK_ERR_DECRUNCH; + } + runsrc = &window[qtm->window_size - j]; + if (j < i) { + /* if match goes over the window edge, do two copy runs */ + i -= j; while (j-- > 0) *rundest++ = *runsrc++; + runsrc = window; + } + while (i-- > 0) *rundest++ = *runsrc++; + } + else { + runsrc = rundest - match_offset; + while (i-- > 0) *rundest++ = *runsrc++; + } + window_posn += match_length; + } + } /* if (window_posn+match_length > frame_end) */ + } /* while (window_posn < frame_end) */ + + qtm->o_end = &window[window_posn]; + + /* if we subtracted too much from frame_todo, it will + * wrap around past zero and go above its max value */ + if (frame_todo > QTM_FRAME_SIZE) { + D(("overshot frame alignment")) + return qtm->error = MSPACK_ERR_DECRUNCH; + } + + /* another frame completed? */ + if (frame_todo == 0) { + /* re-align input */ + if (bits_left & 7) REMOVE_BITS(bits_left & 7); + + /* special Quantum hack -- cabd.c injects a trailer byte to allow the + * decompressor to realign itself. CAB Quantum blocks, unlike LZX + * blocks, can have anything from 0 to 4 trailing null bytes. */ + do { READ_BITS(i, 8); } while (i != 0xFF); + + qtm->header_read = 0; + + frame_todo = QTM_FRAME_SIZE; + } + + /* window wrap? */ + if (window_posn == qtm->window_size) { + /* flush all currently stored data */ + i = (qtm->o_end - qtm->o_ptr); + /* break out if we have more than enough to finish this request */ + if (i >= out_bytes) break; + if (qtm->sys->write(qtm->output, qtm->o_ptr, i) != i) { + return qtm->error = MSPACK_ERR_WRITE; + } + out_bytes -= i; + qtm->o_ptr = &window[0]; + qtm->o_end = &window[0]; + window_posn = 0; + } + + } /* while (more bytes needed) */ + + if (out_bytes) { + i = (int) out_bytes; + if (qtm->sys->write(qtm->output, qtm->o_ptr, i) != i) { + return qtm->error = MSPACK_ERR_WRITE; + } + qtm->o_ptr += i; + } + + /* store local state */ + + STORE_BITS; + qtm->window_posn = window_posn; + qtm->frame_todo = frame_todo; + qtm->H = H; + qtm->L = L; + qtm->C = C; + + return MSPACK_ERR_OK; +} + +void qtmd_free(struct qtmd_stream *qtm) { + struct mspack_system *sys; + if (qtm) { + sys = qtm->sys; + sys->free(qtm->window); + sys->free(qtm->inbuf); + sys->free(qtm); + } +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/qtm.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/qtm.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/qtm.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/qtm.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,128 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * The Quantum method was created by David Stafford, adapted by Microsoft + * Corporation. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_QTM_H +#define MSPACK_QTM_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* Quantum compression / decompression definitions */ + +#define QTM_FRAME_SIZE (32768) + +struct qtmd_modelsym { + unsigned short sym, cumfreq; +}; + +struct qtmd_model { + int shiftsleft, entries; + struct qtmd_modelsym *syms; +}; + +struct qtmd_stream { + struct mspack_system *sys; /* I/O routines */ + struct mspack_file *input; /* input file handle */ + struct mspack_file *output; /* output file handle */ + + unsigned char *window; /* decoding window */ + unsigned int window_size; /* window size */ + unsigned int window_posn; /* decompression offset within window */ + unsigned int frame_todo; /* bytes remaining for current frame */ + + unsigned short H, L, C; /* high/low/current: arith coding state */ + unsigned char header_read; /* have we started decoding a new frame? */ + + int error; + + /* I/O buffers */ + unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end; + unsigned int bit_buffer, inbuf_size; + unsigned char bits_left, input_end; + + /* four literal models, each representing 64 symbols + * model0 for literals from 0 to 63 (selector = 0) + * model1 for literals from 64 to 127 (selector = 1) + * model2 for literals from 128 to 191 (selector = 2) + * model3 for literals from 129 to 255 (selector = 3) */ + struct qtmd_model model0, model1, model2, model3; + + /* three match models. + * model4 for match with fixed length of 3 bytes + * model5 for match with fixed length of 4 bytes + * model6 for variable length match, encoded with model6len model */ + struct qtmd_model model4, model5, model6, model6len; + + /* selector model. 0-6 to say literal (0,1,2,3) or match (4,5,6) */ + struct qtmd_model model7; + + /* symbol arrays for all models */ + struct qtmd_modelsym m0sym[64 + 1]; + struct qtmd_modelsym m1sym[64 + 1]; + struct qtmd_modelsym m2sym[64 + 1]; + struct qtmd_modelsym m3sym[64 + 1]; + struct qtmd_modelsym m4sym[24 + 1]; + struct qtmd_modelsym m5sym[36 + 1]; + struct qtmd_modelsym m6sym[42 + 1], m6lsym[27 + 1]; + struct qtmd_modelsym m7sym[7 + 1]; +}; + +/* allocates Quantum decompression state for decoding the given stream. + * + * - returns NULL if window_bits is outwith the range 10 to 21 (inclusive). + * + * - uses system->alloc() to allocate memory + * + * - returns NULL if not enough memory + * + * - window_bits is the size of the Quantum window, from 1Kb (10) to 2Mb (21). + * + * - input_buffer_size is the number of bytes to use to store bitstream data. + */ +extern struct qtmd_stream *qtmd_init(struct mspack_system *system, + struct mspack_file *input, + struct mspack_file *output, + int window_bits, + int input_buffer_size); + +/* decompresses, or decompresses more of, a Quantum stream. + * + * - out_bytes of data will be decompressed and the function will return + * with an MSPACK_ERR_OK return code. + * + * - decompressing will stop as soon as out_bytes is reached. if the true + * amount of bytes decoded spills over that amount, they will be kept for + * a later invocation of qtmd_decompress(). + * + * - the output bytes will be passed to the system->write() function given in + * qtmd_init(), using the output file handle given in qtmd_init(). More + * than one call may be made to system->write() + * + * - Quantum will read input bytes as necessary using the system->read() + * function given in qtmd_init(), using the input file handle given in + * qtmd_init(). This will continue until system->read() returns 0 bytes, + * or an error. + */ +extern int qtmd_decompress(struct qtmd_stream *qtm, off_t out_bytes); + +/* frees all state associated with a Quantum data stream + * + * - calls system->free() using the system pointer given in qtmd_init() + */ +void qtmd_free(struct qtmd_stream *qtm); + +#ifdef __cplusplus +} +#endif + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/readbits.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/readbits.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/readbits.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/readbits.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,207 @@ +/* This file is part of libmspack. + * (C) 2003-2010 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_READBITS_H +#define MSPACK_READBITS_H 1 + +/* this header defines macros that read data streams by + * the individual bits + * + * INIT_BITS initialises bitstream state in state structure + * STORE_BITS stores bitstream state in state structure + * RESTORE_BITS restores bitstream state from state structure + * ENSURE_BITS(n) ensure there are at least N bits in the bit buffer + * READ_BITS(var,n) takes N bits from the buffer and puts them in var + * PEEK_BITS(n) extracts without removing N bits from the bit buffer + * REMOVE_BITS(n) removes N bits from the bit buffer + * + * READ_BITS simply calls ENSURE_BITS, PEEK_BITS and REMOVE_BITS, + * which means it's limited to reading the number of bits you can + * ensure at any one time. It also fails if asked to read zero bits. + * If you need to read zero bits, or more bits than can be ensured in + * one go, use READ_MANY_BITS instead. + * + * These macros have variable names baked into them, so to use them + * you have to define some macros: + * - BITS_TYPE: the type name of your state structure + * - BITS_VAR: the variable that points to your state structure + * - define BITS_ORDER_MSB if bits are read from the MSB, or + * define BITS_ORDER_LSB if bits are read from the LSB + * - READ_BYTES: some code that reads more data into the bit buffer, + * it should use READ_IF_NEEDED (calls read_input if the byte buffer + * is empty), then INJECT_BITS(data,n) to put data from the byte + * buffer into the bit buffer. + * + * You also need to define some variables and structure members: + * - unsigned char *i_ptr; // current position in the byte buffer + * - unsigned char *i_end; // end of the byte buffer + * - unsigned int bit_buffer; // the bit buffer itself + * - unsigned int bits_left; // number of bits remaining + * + * If you use read_input() and READ_IF_NEEDED, they also expect these + * structure members: + * - struct mspack_system *sys; // to access sys->read() + * - unsigned int error; // to record/return read errors + * - unsigned char input_end; // to mark reaching the EOF + * - unsigned char *inbuf; // the input byte buffer + * - unsigned int inbuf_size; // the size of the input byte buffer + * + * Your READ_BYTES implementation should read data from *i_ptr and + * put them in the bit buffer. READ_IF_NEEDED will call read_input() + * if i_ptr reaches i_end, and will fill up inbuf and set i_ptr to + * the start of inbuf and i_end to the end of inbuf. + * + * If you're reading in MSB order, the routines work by using the area + * beyond the MSB and the LSB of the bit buffer as a free source of + * zeroes when shifting. This avoids having to mask any bits. So we + * have to know the bit width of the bit buffer variable. We use + * and CHAR_BIT to find the size of the bit buffer in bits. + * + * If you are reading in LSB order, bits need to be masked. Normally + * this is done by computing the mask: N bits are masked by the value + * (1< +#endif +#ifndef CHAR_BIT +# define CHAR_BIT (8) +#endif +#define BITBUF_WIDTH (sizeof(bit_buffer) * CHAR_BIT) + +#define INIT_BITS do { \ + BITS_VAR->i_ptr = &BITS_VAR->inbuf[0]; \ + BITS_VAR->i_end = &BITS_VAR->inbuf[0]; \ + BITS_VAR->bit_buffer = 0; \ + BITS_VAR->bits_left = 0; \ + BITS_VAR->input_end = 0; \ +} while (0) + +#define STORE_BITS do { \ + BITS_VAR->i_ptr = i_ptr; \ + BITS_VAR->i_end = i_end; \ + BITS_VAR->bit_buffer = bit_buffer; \ + BITS_VAR->bits_left = bits_left; \ +} while (0) + +#define RESTORE_BITS do { \ + i_ptr = BITS_VAR->i_ptr; \ + i_end = BITS_VAR->i_end; \ + bit_buffer = BITS_VAR->bit_buffer; \ + bits_left = BITS_VAR->bits_left; \ +} while (0) + +#define ENSURE_BITS(nbits) do { \ + while (bits_left < (nbits)) READ_BYTES; \ +} while (0) + +#define READ_BITS(val, nbits) do { \ + ENSURE_BITS(nbits); \ + (val) = PEEK_BITS(nbits); \ + REMOVE_BITS(nbits); \ +} while (0) + +#define READ_MANY_BITS(val, bits) do { \ + unsigned char needed = (bits), bitrun; \ + (val) = 0; \ + while (needed > 0) { \ + if (bits_left <= (BITBUF_WIDTH - 16)) READ_BYTES; \ + bitrun = (bits_left < needed) ? bits_left : needed; \ + (val) = ((val) << bitrun) | PEEK_BITS(bitrun); \ + REMOVE_BITS(bitrun); \ + needed -= bitrun; \ + } \ +} while (0) + +#ifdef BITS_ORDER_MSB +# define PEEK_BITS(nbits) (bit_buffer >> (BITBUF_WIDTH - (nbits))) +# define REMOVE_BITS(nbits) ((bit_buffer <<= (nbits)), (bits_left -= (nbits))) +# define INJECT_BITS(bitdata,nbits) ((bit_buffer |= \ + (bitdata) << (BITBUF_WIDTH - (nbits) - bits_left)), (bits_left += (nbits))) +#else /* BITS_ORDER_LSB */ +# define PEEK_BITS(nbits) (bit_buffer & ((1 << (nbits))-1)) +# define REMOVE_BITS(nbits) ((bit_buffer >>= (nbits)), (bits_left -= (nbits))) +# define INJECT_BITS(bitdata,nbits) ((bit_buffer |= \ + (bitdata) << bits_left), (bits_left += (nbits))) +#endif + +#ifdef BITS_LSB_TABLE +/* lsb_bit_mask[n] = (1 << n) - 1 */ +static const unsigned short lsb_bit_mask[17] = { + 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff +}; +# define PEEK_BITS_T(nbits) (bit_buffer & lsb_bit_mask[(nbits)]) +# define READ_BITS_T(val, nbits) do { \ + ENSURE_BITS(nbits); \ + (val) = PEEK_BITS_T(nbits); \ + REMOVE_BITS(nbits); \ +} while (0) +#endif + +#ifndef BITS_NO_READ_INPUT +# define READ_IF_NEEDED do { \ + if (i_ptr >= i_end) { \ + if (read_input(BITS_VAR)) \ + return BITS_VAR->error; \ + i_ptr = BITS_VAR->i_ptr; \ + i_end = BITS_VAR->i_end; \ + } \ +} while (0) + +static int read_input(BITS_TYPE *p) { + int read = p->sys->read(p->input, &p->inbuf[0], (int)p->inbuf_size); + if (read < 0) return p->error = MSPACK_ERR_READ; + + /* we might overrun the input stream by asking for bits we don't use, + * so fake 2 more bytes at the end of input */ + if (read == 0) { + if (p->input_end) { + D(("out of input bytes")) + return p->error = MSPACK_ERR_READ; + } + else { + read = 2; + p->inbuf[0] = p->inbuf[1] = 0; + p->input_end = 1; + } + } + + /* update i_ptr and i_end */ + p->i_ptr = &p->inbuf[0]; + p->i_end = &p->inbuf[read]; + return MSPACK_ERR_OK; +} +#endif +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/readhuff.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/readhuff.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/readhuff.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/readhuff.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,172 @@ +/* This file is part of libmspack. + * (C) 2003-2014 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_READHUFF_H +#define MSPACK_READHUFF_H 1 + +/* This implements a fast Huffman tree decoding system. */ + +#if !(defined(BITS_ORDER_MSB) || defined(BITS_ORDER_LSB)) +# error "readhuff.h is used in conjunction with readbits.h, include that first" +#endif +#if !(defined(TABLEBITS) && defined(MAXSYMBOLS)) +# error "define TABLEBITS(tbl) and MAXSYMBOLS(tbl) before using readhuff.h" +#endif +#if !(defined(HUFF_TABLE) && defined(HUFF_LEN)) +# error "define HUFF_TABLE(tbl) and HUFF_LEN(tbl) before using readhuff.h" +#endif +#ifndef HUFF_ERROR +# error "define HUFF_ERROR before using readhuff.h" +#endif +#ifndef HUFF_MAXBITS +# define HUFF_MAXBITS 16 +#endif + +/* Decodes the next huffman symbol from the input bitstream into var. + * Do not use this macro on a table unless build_decode_table() succeeded. + */ +#define READ_HUFFSYM(tbl, var) do { \ + ENSURE_BITS(HUFF_MAXBITS); \ + sym = HUFF_TABLE(tbl, PEEK_BITS(TABLEBITS(tbl))); \ + if (sym >= MAXSYMBOLS(tbl)) HUFF_TRAVERSE(tbl); \ + (var) = sym; \ + i = HUFF_LEN(tbl, sym); \ + REMOVE_BITS(i); \ +} while (0) + +#ifdef BITS_ORDER_LSB +# define HUFF_TRAVERSE(tbl) do { \ + i = TABLEBITS(tbl) - 1; \ + do { \ + if (i++ > HUFF_MAXBITS) HUFF_ERROR; \ + sym = HUFF_TABLE(tbl, \ + (sym << 1) | ((bit_buffer >> i) & 1)); \ + } while (sym >= MAXSYMBOLS(tbl)); \ +} while (0) +#else +#define HUFF_TRAVERSE(tbl) do { \ + i = 1 << (BITBUF_WIDTH - TABLEBITS(tbl)); \ + do { \ + if ((i >>= 1) == 0) HUFF_ERROR; \ + sym = HUFF_TABLE(tbl, \ + (sym << 1) | ((bit_buffer & i) ? 1 : 0)); \ + } while (sym >= MAXSYMBOLS(tbl)); \ +} while (0) +#endif + +/* make_decode_table(nsyms, nbits, length[], table[]) + * + * This function was originally coded by David Tritscher. + * It builds a fast huffman decoding table from + * a canonical huffman code lengths table. + * + * nsyms = total number of symbols in this huffman tree. + * nbits = any symbols with a code length of nbits or less can be decoded + * in one lookup of the table. + * length = A table to get code lengths from [0 to nsyms-1] + * table = The table to fill up with decoded symbols and pointers. + * Should be ((1<> 1; /* don't do 0 length codes */ + + /* fill entries for codes short enough for a direct mapping */ + for (bit_num = 1; bit_num <= nbits; bit_num++) { + for (sym = 0; sym < nsyms; sym++) { + if (length[sym] != bit_num) continue; +#ifdef BITS_ORDER_MSB + leaf = pos; +#else + /* reverse the significant bits */ + fill = length[sym]; reverse = pos >> (nbits - fill); leaf = 0; + do {leaf <<= 1; leaf |= reverse & 1; reverse >>= 1;} while (--fill); +#endif + + if((pos += bit_mask) > table_mask) return 1; /* table overrun */ + + /* fill all possible lookups of this symbol with the symbol itself */ +#ifdef BITS_ORDER_MSB + for (fill = bit_mask; fill-- > 0;) table[leaf++] = sym; +#else + fill = bit_mask; next_symbol = 1 << bit_num; + do { table[leaf] = sym; leaf += next_symbol; } while (--fill); +#endif + } + bit_mask >>= 1; + } + + /* exit with success if table is now complete */ + if (pos == table_mask) return 0; + + /* mark all remaining table entries as unused */ + for (sym = pos; sym < table_mask; sym++) { +#ifdef BITS_ORDER_MSB + table[sym] = 0xFFFF; +#else + reverse = sym; leaf = 0; fill = nbits; + do { leaf <<= 1; leaf |= reverse & 1; reverse >>= 1; } while (--fill); + table[leaf] = 0xFFFF; +#endif + } + + /* next_symbol = base of allocation for long codes */ + next_symbol = ((table_mask >> 1) < nsyms) ? nsyms : (table_mask >> 1); + + /* give ourselves room for codes to grow by up to 16 more bits. + * codes now start at bit nbits+16 and end at (nbits+16-codelength) */ + pos <<= 16; + table_mask <<= 16; + bit_mask = 1 << 15; + + for (bit_num = nbits+1; bit_num <= HUFF_MAXBITS; bit_num++) { + for (sym = 0; sym < nsyms; sym++) { + if (length[sym] != bit_num) continue; + if (pos >= table_mask) return 1; /* table overflow */ + +#ifdef BITS_ORDER_MSB + leaf = pos >> 16; +#else + /* leaf = the first nbits of the code, reversed */ + reverse = pos >> 16; leaf = 0; fill = nbits; + do {leaf <<= 1; leaf |= reverse & 1; reverse >>= 1;} while (--fill); +#endif + for (fill = 0; fill < (bit_num - nbits); fill++) { + /* if this path hasn't been taken yet, 'allocate' two entries */ + if (table[leaf] == 0xFFFF) { + table[(next_symbol << 1) ] = 0xFFFF; + table[(next_symbol << 1) + 1 ] = 0xFFFF; + table[leaf] = next_symbol++; + } + + /* follow the path and select either left or right for next bit */ + leaf = table[leaf] << 1; + if ((pos >> (15-fill)) & 1) leaf++; + } + table[leaf] = sym; + pos += bit_mask; + } + bit_mask >>= 1; + } + + /* full table? */ + return (pos == table_mask) ? 0 : 1; +} +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/sha.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/sha.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/sha.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/sha.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,15 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_LZSS_H +#define MSPACK_LZSS_H 1 + +/* SHA-1 message digest definitions */ + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/system.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/system.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/system.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/system.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,239 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#ifndef LARGEFILE_SUPPORT +const char *largefile_msg = "library not compiled to support large files."; +#endif + + +int mspack_version(int entity) { + switch (entity) { + /* CHM decoder version 1 -> 2 changes: + * - added mschmd_sec_mscompressed::spaninfo + * - added mschmd_header::first_pmgl + * - added mschmd_header::last_pmgl + * - added mschmd_header::chunk_cache; + */ + case MSPACK_VER_MSCHMD: + return 2; + case MSPACK_VER_LIBRARY: + case MSPACK_VER_SYSTEM: + case MSPACK_VER_MSCABD: + case MSPACK_VER_MSSZDDD: + case MSPACK_VER_MSKWAJD: + case MSPACK_VER_MSOABD: + return 1; + case MSPACK_VER_MSCABC: + case MSPACK_VER_MSCHMC: + case MSPACK_VER_MSLITD: + case MSPACK_VER_MSLITC: + case MSPACK_VER_MSHLPD: + case MSPACK_VER_MSHLPC: + case MSPACK_VER_MSSZDDC: + case MSPACK_VER_MSKWAJC: + case MSPACK_VER_MSOABC: + return 0; + } + return -1; +} + +int mspack_sys_selftest_internal(int offt_size) { + return (sizeof(off_t) == offt_size) ? MSPACK_ERR_OK : MSPACK_ERR_SEEK; +} + +/* validates a system structure */ +int mspack_valid_system(struct mspack_system *sys) { + return (sys != NULL) && (sys->open != NULL) && (sys->close != NULL) && + (sys->read != NULL) && (sys->write != NULL) && (sys->seek != NULL) && + (sys->tell != NULL) && (sys->message != NULL) && (sys->alloc != NULL) && + (sys->free != NULL) && (sys->copy != NULL) && (sys->null_ptr == NULL); +} + +/* returns the length of a file opened for reading */ +int mspack_sys_filelen(struct mspack_system *system, + struct mspack_file *file, off_t *length) +{ + off_t current; + + if (!system || !file || !length) return MSPACK_ERR_OPEN; + + /* get current offset */ + current = system->tell(file); + + /* seek to end of file */ + if (system->seek(file, (off_t) 0, MSPACK_SYS_SEEK_END)) { + return MSPACK_ERR_SEEK; + } + + /* get offset of end of file */ + *length = system->tell(file); + + /* seek back to original offset */ + if (system->seek(file, current, MSPACK_SYS_SEEK_START)) { + return MSPACK_ERR_SEEK; + } + + return MSPACK_ERR_OK; +} + + + +/* definition of mspack_default_system -- if the library is compiled with + * MSPACK_NO_DEFAULT_SYSTEM, no default system will be provided. Otherwise, + * an appropriate default system (e.g. the standard C library, or some native + * API calls) + */ + +#ifdef MSPACK_NO_DEFAULT_SYSTEM +struct mspack_system *mspack_default_system = NULL; +#else + +/* implementation of mspack_default_system for standard C library */ + +#include +#include +#include +#include + +struct mspack_file_p { + FILE *fh; + const char *name; +}; + +static struct mspack_file *msp_open(struct mspack_system *self, + const char *filename, int mode) +{ + struct mspack_file_p *fh; + const char *fmode; + + switch (mode) { + case MSPACK_SYS_OPEN_READ: fmode = "rb"; break; + case MSPACK_SYS_OPEN_WRITE: fmode = "wb"; break; + case MSPACK_SYS_OPEN_UPDATE: fmode = "r+b"; break; + case MSPACK_SYS_OPEN_APPEND: fmode = "ab"; break; + default: return NULL; + } + + if ((fh = (struct mspack_file_p *) malloc(sizeof(struct mspack_file_p)))) { + fh->name = filename; + if ((fh->fh = fopen(filename, fmode))) return (struct mspack_file *) fh; + free(fh); + } + return NULL; +} + +static void msp_close(struct mspack_file *file) { + struct mspack_file_p *self = (struct mspack_file_p *) file; + if (self) { + fclose(self->fh); + free(self); + } +} + +static int msp_read(struct mspack_file *file, void *buffer, int bytes) { + struct mspack_file_p *self = (struct mspack_file_p *) file; + if (self && buffer && bytes >= 0) { + size_t count = fread(buffer, 1, (size_t) bytes, self->fh); + if (!ferror(self->fh)) return (int) count; + } + return -1; +} + +static int msp_write(struct mspack_file *file, void *buffer, int bytes) { + struct mspack_file_p *self = (struct mspack_file_p *) file; + if (self && buffer && bytes >= 0) { + size_t count = fwrite(buffer, 1, (size_t) bytes, self->fh); + if (!ferror(self->fh)) return (int) count; + } + return -1; +} + +static int msp_seek(struct mspack_file *file, off_t offset, int mode) { + struct mspack_file_p *self = (struct mspack_file_p *) file; + if (self) { + switch (mode) { + case MSPACK_SYS_SEEK_START: mode = SEEK_SET; break; + case MSPACK_SYS_SEEK_CUR: mode = SEEK_CUR; break; + case MSPACK_SYS_SEEK_END: mode = SEEK_END; break; + default: return -1; + } +#ifdef HAVE_FSEEKO + return fseeko(self->fh, offset, mode); +#else + return fseek(self->fh, offset, mode); +#endif + } + return -1; +} + +static off_t msp_tell(struct mspack_file *file) { + struct mspack_file_p *self = (struct mspack_file_p *) file; +#ifdef HAVE_FSEEKO + return (self) ? (off_t) ftello(self->fh) : 0; +#else + return (self) ? (off_t) ftell(self->fh) : 0; +#endif +} + +static void msp_msg(struct mspack_file *file, const char *format, ...) { + va_list ap; + if (file) fprintf(stderr, "%s: ", ((struct mspack_file_p *) file)->name); + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + fputc((int) '\n', stderr); + fflush(stderr); +} + +static void *msp_alloc(struct mspack_system *self, size_t bytes) { +#ifdef DEBUG + /* make uninitialised data obvious */ + char *buf = malloc(bytes + 8); + if (buf) memset(buf, 0xDC, bytes); + *((size_t *)buf) = bytes; + return &buf[8]; +#else + return malloc(bytes); +#endif +} + +static void msp_free(void *buffer) { +#ifdef DEBUG + char *buf = buffer; + size_t bytes; + if (buf) { + buf -= 8; + bytes = *((size_t *)buf); + /* make freed data obvious */ + memset(buf, 0xED, bytes); + free(buf); + } +#else + free(buffer); +#endif +} + +static void msp_copy(void *src, void *dest, size_t bytes) { + memcpy(dest, src, bytes); +} + +static struct mspack_system msp_system = { + &msp_open, &msp_close, &msp_read, &msp_write, &msp_seek, + &msp_tell, &msp_msg, &msp_alloc, &msp_free, &msp_copy, NULL +}; + +struct mspack_system *mspack_default_system = &msp_system; + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/system.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/system.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/system.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/system.h 2017-06-23 21:16:39.000000000 +0000 @@ -0,0 +1,136 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_SYSTEM_H +#define MSPACK_SYSTEM_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* ensure config.h is read before mspack.h */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +/* fix for problem with GCC 4 and glibc (thanks to Ville Skytta) + * http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=150429 + */ +#ifdef read +# undef read +#endif + + + + + +#ifdef DEBUG +# include +# include + +extern uint8_t cli_debug_flag; +/* Old GCCs don't have __func__, but __FUNCTION__: + * http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html + */ +# if __STDC_VERSION__ < 199901L +# if __GNUC__ >= 2 +# define __func__ __FUNCTION__ +# else +# define __func__ "" +# endif +# endif +/* Adding custom clamav debug code. */ +# define D(x) do { if(cli_debug_flag) { \ + printf("LibClamAV debug: %s:%d (%s)", __FILE__, __LINE__, __func__); \ + printf x ; fputc('\n', stdout); fflush(stdout); \ + } \ + } while (0); + +#else +# define D(x) +#endif + +/* CAB supports searching through files over 4GB in size, and the CHM file + * format actively uses 64-bit offsets. These can only be fully supported + * if the system the code runs on supports large files. If not, the library + * will work as normal using only 32-bit arithmetic, but if an offset + * greater than 2GB is detected, an error message indicating the library + * can't support the file should be printed. + */ +#ifdef HAVE_LIMITS_H +# include +#endif + +#if ((defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS >= 64) || \ + (defined(FILESIZEBITS) && FILESIZEBITS >= 64) || \ + (defined(SIZEOF_OFF_T) && SIZEOF_OFF_T >= 8) || \ + defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE)) +# define LARGEFILE_SUPPORT +# define LD "lld" +# define LU "llu" +#else +extern const char *largefile_msg; +# define LD "ld" +# define LU "lu" +#endif + +/* endian-neutral reading of little-endian data */ +#define __egi32(a,n) ( ((((unsigned char *) a)[n+3]) << 24) | \ + ((((unsigned char *) a)[n+2]) << 16) | \ + ((((unsigned char *) a)[n+1]) << 8) | \ + ((((unsigned char *) a)[n+0]))) +#define EndGetI64(a) ((((unsigned long long int) __egi32(a,4)) << 32) | \ + ((unsigned int) __egi32(a,0))) +#define EndGetI32(a) __egi32(a,0) +#define EndGetI16(a) ((((a)[1])<<8)|((a)[0])) + +/* endian-neutral reading of big-endian data */ +#define EndGetM32(a) (((((unsigned char *) a)[0]) << 24) | \ + ((((unsigned char *) a)[1]) << 16) | \ + ((((unsigned char *) a)[2]) << 8) | \ + ((((unsigned char *) a)[3]))) +#define EndGetM16(a) ((((a)[0])<<8)|((a)[1])) + +extern struct mspack_system *mspack_default_system; + +/* returns the length of a file opened for reading */ +extern int mspack_sys_filelen(struct mspack_system *system, + struct mspack_file *file, off_t *length); + +/* validates a system structure */ +extern int mspack_valid_system(struct mspack_system *sys); + +#if HAVE_STRINGS_H +# include +#endif + +#if HAVE_STRING_H +# include +#endif + +#if HAVE_MEMCMP +# define mspack_memcmp memcmp +#else +/* inline memcmp() */ +static inline int mspack_memcmp(const void *s1, const void *s2, size_t n) { + unsigned char *c1 = (unsigned char *) s1; + unsigned char *c2 = (unsigned char *) s2; + if (n == 0) return 0; + while (--n && (*c1 == *c2)) c1++, c2++; + return *c1 - *c2; +} +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/szddc.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/szddc.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/szddc.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/szddc.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,24 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* SZDD compression implementation */ + +#include +#include + +struct msszdd_compressor * + mspack_create_szdd_compressor(struct mspack_system *sys) +{ + /* todo */ + return NULL; +} + +void mspack_destroy_szdd_compressor(struct msszdd_compressor *self) { + /* todo */ +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/szddd.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/szddd.c --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/szddd.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/szddd.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,247 @@ +/* This file is part of libmspack. + * (C) 2003-2010 Stuart Caie. + * + * SZDD is a format used in the MS-DOS commands COMPRESS.EXE and + * EXPAND.EXE. The compression method is attributed to Steven Zeck, + * however it's pretty much identical to LZSS. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +/* SZDD decompression implementation */ + +#include +#include + +/* prototypes */ +static struct msszddd_header *szddd_open( + struct msszdd_decompressor *base, const char *filename); +static void szddd_close( + struct msszdd_decompressor *base, struct msszddd_header *hdr); +static int szddd_read_headers( + struct mspack_system *sys, struct mspack_file *fh, + struct msszddd_header *hdr); +static int szddd_extract( + struct msszdd_decompressor *base, struct msszddd_header *hdr, + const char *filename); +static int szddd_decompress( + struct msszdd_decompressor *base, const char *input, const char *output); +static int szddd_error( + struct msszdd_decompressor *base); + +/*************************************** + * MSPACK_CREATE_SZDD_DECOMPRESSOR + *************************************** + * constructor + */ +struct msszdd_decompressor * + mspack_create_szdd_decompressor(struct mspack_system *sys) +{ + struct msszdd_decompressor_p *self = NULL; + + if (!sys) sys = mspack_default_system; + if (!mspack_valid_system(sys)) return NULL; + + if ((self = (struct msszdd_decompressor_p *) sys->alloc(sys, sizeof(struct msszdd_decompressor_p)))) { + self->base.open = &szddd_open; + self->base.close = &szddd_close; + self->base.extract = &szddd_extract; + self->base.decompress = &szddd_decompress; + self->base.last_error = &szddd_error; + self->system = sys; + self->error = MSPACK_ERR_OK; + } + return (struct msszdd_decompressor *) self; +} + +/*************************************** + * MSPACK_DESTROY_SZDD_DECOMPRESSOR + *************************************** + * destructor + */ +void mspack_destroy_szdd_decompressor(struct msszdd_decompressor *base) +{ + struct msszdd_decompressor_p *self = (struct msszdd_decompressor_p *) base; + if (self) { + struct mspack_system *sys = self->system; + sys->free(self); + } +} + +/*************************************** + * SZDDD_OPEN + *************************************** + * opens an SZDD file without decompressing, reads header + */ +static struct msszddd_header *szddd_open(struct msszdd_decompressor *base, + const char *filename) +{ + struct msszdd_decompressor_p *self = (struct msszdd_decompressor_p *) base; + struct msszddd_header *hdr; + struct mspack_system *sys; + struct mspack_file *fh; + + if (!self) return NULL; + sys = self->system; + + fh = sys->open(sys, filename, MSPACK_SYS_OPEN_READ); + hdr = (struct msszddd_header *) sys->alloc(sys, sizeof(struct msszddd_header_p)); + if (fh && hdr) { + ((struct msszddd_header_p *) hdr)->fh = fh; + self->error = szddd_read_headers(sys, fh, hdr); + } + else { + if (!fh) self->error = MSPACK_ERR_OPEN; + if (!hdr) self->error = MSPACK_ERR_NOMEMORY; + } + + if (self->error) { + if (fh) sys->close(fh); + if (hdr) sys->free(hdr); + hdr = NULL; + } + + return hdr; +} + +/*************************************** + * SZDDD_CLOSE + *************************************** + * closes an SZDD file + */ +static void szddd_close(struct msszdd_decompressor *base, + struct msszddd_header *hdr) +{ + struct msszdd_decompressor_p *self = (struct msszdd_decompressor_p *) base; + struct msszddd_header_p *hdr_p = (struct msszddd_header_p *) hdr; + + if (!self || !self->system) return; + + /* close the file handle associated */ + self->system->close(hdr_p->fh); + + /* free the memory associated */ + self->system->free(hdr); + + self->error = MSPACK_ERR_OK; +} + +/*************************************** + * SZDDD_READ_HEADERS + *************************************** + * reads the headers of an SZDD format file + */ +static unsigned char szdd_signature_expand[8] = { + 0x53, 0x5A, 0x44, 0x44, 0x88, 0xF0, 0x27, 0x33 +}; +static unsigned char szdd_signature_qbasic[8] = { + 0x53, 0x5A, 0x20, 0x88, 0xF0, 0x27, 0x33, 0xD1 +}; + +static int szddd_read_headers(struct mspack_system *sys, + struct mspack_file *fh, + struct msszddd_header *hdr) +{ + unsigned char buf[8]; + + /* read and check signature */ + if (sys->read(fh, buf, 8) != 8) return MSPACK_ERR_READ; + + if ((mspack_memcmp(buf, szdd_signature_expand, 8) == 0)) { + /* common SZDD */ + hdr->format = MSSZDD_FMT_NORMAL; + + /* read the rest of the header */ + if (sys->read(fh, buf, 6) != 6) return MSPACK_ERR_READ; + if (buf[0] != 0x41) return MSPACK_ERR_DATAFORMAT; + hdr->missing_char = buf[1]; + hdr->length = EndGetI32(&buf[2]); + } + else if ((mspack_memcmp(buf, szdd_signature_qbasic, 8) == 0)) { + /* special QBasic SZDD */ + hdr->format = MSSZDD_FMT_QBASIC; + if (sys->read(fh, buf, 4) != 4) return MSPACK_ERR_READ; + hdr->missing_char = '\0'; + hdr->length = EndGetI32(buf); + } + else { + return MSPACK_ERR_SIGNATURE; + } + return MSPACK_ERR_OK; +} + +/*************************************** + * SZDDD_EXTRACT + *************************************** + * decompresses an SZDD file + */ +static int szddd_extract(struct msszdd_decompressor *base, + struct msszddd_header *hdr, const char *filename) +{ + struct msszdd_decompressor_p *self = (struct msszdd_decompressor_p *) base; + struct mspack_file *fh, *outfh; + struct mspack_system *sys; + off_t data_offset; + + if (!self) return MSPACK_ERR_ARGS; + if (!hdr) return self->error = MSPACK_ERR_ARGS; + sys = self->system; + + fh = ((struct msszddd_header_p *) hdr)->fh; + + /* seek to the compressed data */ + data_offset = (hdr->format == MSSZDD_FMT_NORMAL) ? 14 : 12; + if (sys->seek(fh, data_offset, MSPACK_SYS_SEEK_START)) { + return self->error = MSPACK_ERR_SEEK; + } + + /* open file for output */ + if (!(outfh = sys->open(sys, filename, MSPACK_SYS_OPEN_WRITE))) { + return self->error = MSPACK_ERR_OPEN; + } + + /* decompress the data */ + self->error = lzss_decompress(sys, fh, outfh, SZDD_INPUT_SIZE, + hdr->format == MSSZDD_FMT_NORMAL + ? LZSS_MODE_EXPAND + : LZSS_MODE_QBASIC); + + /* close output file */ + sys->close(outfh); + + return self->error; +} + +/*************************************** + * SZDDD_DECOMPRESS + *************************************** + * unpacks directly from input to output + */ +static int szddd_decompress(struct msszdd_decompressor *base, + const char *input, const char *output) +{ + struct msszdd_decompressor_p *self = (struct msszdd_decompressor_p *) base; + struct msszddd_header *hdr; + int error; + + if (!self) return MSPACK_ERR_ARGS; + + if (!(hdr = szddd_open(base, input))) return self->error; + error = szddd_extract(base, hdr, output); + szddd_close(base, hdr); + return self->error = error; +} + +/*************************************** + * SZDDD_ERROR + *************************************** + * returns the last error that occurred + */ +static int szddd_error(struct msszdd_decompressor *base) +{ + struct msszdd_decompressor_p *self = (struct msszdd_decompressor_p *) base; + return (self) ? self->error : MSPACK_ERR_ARGS; +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/szdd.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/szdd.h --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/mspack/szdd.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/mspack/szdd.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,39 @@ +/* This file is part of libmspack. + * (C) 2003-2004 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_SZDD_H +#define MSPACK_SZDD_H 1 + +#include + +/* input buffer size during decompression - not worth parameterising IMHO */ +#define SZDD_INPUT_SIZE (2048) + +/* SZDD compression definitions */ + +struct msszdd_compressor_p { + struct msszdd_compressor base; + struct mspack_system *system; + int error; +}; + +/* SZDD decompression definitions */ + +struct msszdd_decompressor_p { + struct msszdd_decompressor base; + struct mspack_system *system; + int error; +}; + +struct msszddd_header_p { + struct msszddd_header base; + struct mspack_file *fh; +}; + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/README clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/README --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/README 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/README 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,130 @@ +libmspack 0.5alpha + +The purpose of libmspack is to provide compressors and decompressors, +archivers and dearchivers for Microsoft compression formats: CAB, CHM, WIM, +LIT, HLP, KWAJ and SZDD. It is also designed to be easily embeddable, +stable, robust and resource-efficient. + +The library is not intended as a generalised "any archiver" interface. +Users of the library must explicitly choose the format they intend to work +with. + +All special features of the above formats will be covered as fully as +possible -- for example, CAB's multi-part cabinet sets, or CHM's fast +lookup indices. All compression methods used by the formats will be +implemented as completely as possible. + +However, other than what is required for access to these formats and their +features, no other functionality is intended. There is no file metadata +translation functionality. All file I/O is abstracted, although a default +implementation using the standard C library is provided. + + +DOCUMENTATION + +The API documentation is stored in the doc/ directory. It is generated +automatically from mspack.h with doxygen. It is also available online at +http://www.cabextract.org.uk/libmspack/doc/ + + +BUILDING / INSTALLING + +./configure +make +make install + +This will install the main libmspack library and mspack.h header file. +Some other libraries and executables are built, but not installed. + +If building from the Subversion repository, running rebuild.sh will create +all the automatically generated files like the configure script, and will +then ./configure, make and make distcheck. Running cleanup.sh will perform +a thorough clean, deleting all automatically generated files. + +In addition to gcc, you also need the following for building from Subversion: + +- at least autoconf 2.57 +- at least automake 1.7 +- libtool + +This is an alpha release. Unless you are in a position to package the +libmspack library for the environment you intend to run your application, +it is recommended that you do not rely on users of your software having +the binary library installed and instead you should include the libmspack +source files directly in your application's build environment. + + +LEGAL ISSUES + +The the best of my knowledge, libmspack does not infringe on any +compression or decompression patents. However, this is not legal +advice, and it is recommended that you perform your own patent search. + +libmspack is licensed under the LGPL - see COPYING.LIB in this directory. + +The LGPL requires you to build libmspack as a stand alone library then link +your code to it using a linker. I personally grant you some extra rights: +you can incorporate libmspack's source code wholly or partially in your own +code, without having to build and link libmspack as an independent library, +provided you meet ALL of the following conditions: + +1. ANY modifications to the existing libmspack source code are published and + distributed under the LGPL license. +2. You MUST NOT use libmspack function calls, structures or definitions unless + they are defined in the public library interface "mspack.h". +3. When distributing your code, you MUST make clear your code uses libmspack, + and either include the full libmspack distribution with your code, or + provide access to it as per clause 4 of the LGPL. + +EXAMPLE CODE + +There are a number of useful programs in the test/ directory which +exercise and demonstrate libmspack's features. + +cabd_c10 - Tests the CAB decompressor on the C10 collection. +cabd_compare - Compares the CAB decompressor with Microsoft's EXTRACT.EXE +cabd_md5 - Prints the MD5 checksums of all files within a CAB file/set. +cabd_memory - An mspack_system implementation that reads/writes to memory. +cabd_test - Regression tests for libmspack's CAB decompression. +cabrip - Extracts any CAB files embedded in another file. +chmd_compare - Compares the CHM decompressor to Microsoft's HH.EXE +chmd_find - Fast-finds a file within a CHM file. +chmd_md5 - Prints the MD5 checksums of all files within a CHM file. +chmd_order - Tests extracting files in a CHM file in four different ways. +chminfo - Prints verbose information about CHM file structures. +chmx - Extracts all files in a CHM file to disk. +expand - Extracts an SZDD or KWAJ file. +msdecompile_md5- Runs Microsoft's HH.EXE -DECOMPILE via WINE. +msexpand_md5 - Runs Microsoft's EXTRACT.EXE via WINE. +multifh - An mspack_system implementation that can simultaneously work + on in-memory images, raw file descriptors, open file handles + and regular disk files. + +Here is a simple example of usage, which will create a CAB decompressor, +then use that to open an existing Microsoft CAB file called "example.cab", +and list the names of all the files contained in that cab. + +#include +#include +#include + +int main() { + struct mscab_decompressor *cabd; + struct mscabd_cabinet *cab; + struct mscabd_file *file; + int test; + + MSPACK_SYS_SELFTEST(test); + if (test != MSPACK_ERR_OK) exit(0); + + if ((cabd = mspack_create_cab_decompressor(NULL))) { + if ((cab = cabd->open(cabd, "example.cab"))) { + for (file = cab->files; file; file = file->next) { + printf("%s\n", file->filename); + } + cabd->close(cabd, cab); + } + mspack_destroy_cab_decompressor(cabd); + } + return 0; +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/TODO clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/TODO --- clamav-0.99.2+dfsg/libclamav/libmspack-0.5alpha/TODO 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack-0.5alpha/TODO 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,8 @@ +* CAB compression +* cabd_find(): if many bytes are missing from the end of a cabinet, it should still find it +* CHM compression +* HLP: everything +* LIT: everything +* SZDD/KWAJ: compression +* WIM: everything +* chm: make chunk cache size user-controllable diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack.c clamav-0.99.3~beta1+dfsg/libclamav/libmspack.c --- clamav-0.99.2+dfsg/libclamav/libmspack.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack.c 2017-06-09 20:02:26.000000000 +0000 @@ -0,0 +1,511 @@ +/* + * Glue code for libmspack handling. + * Author: 웃 Sebastian Andrzej Siewior + * ✉ sebastian @ breakpoint Ì£cc + */ + +#include +#include +#include +#include + +#include + +#include "clamav.h" +#include "fmap.h" +#include "scanners.h" +#include "others.h" + +enum mspack_type { + FILETYPE_DUNNO, + FILETYPE_FMAP, + FILETYPE_FILENAME, +}; + +struct mspack_name { + fmap_t *fmap; + off_t org; +}; + +struct mspack_system_ex { + struct mspack_system ops; + off_t max_size; +}; + +struct mspack_handle { + enum mspack_type type; + + fmap_t *fmap; + off_t org; + off_t offset; + + FILE *f; + off_t max_size; +}; + +static struct mspack_file *mspack_fmap_open(struct mspack_system *self, + const char *filename, int mode) +{ + struct mspack_name *mspack_name; + struct mspack_handle *mspack_handle; + struct mspack_system_ex *self_ex; + const char *fmode; + const struct mspack_system *mptr = self; + + if (!filename) { + cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); + return NULL; + } + mspack_handle = malloc(sizeof(*mspack_handle)); + if (!mspack_handle) { + cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); + return NULL; + } + switch (mode) { + case MSPACK_SYS_OPEN_READ: + mspack_handle->type = FILETYPE_FMAP; + + mspack_name = (struct mspack_name *)filename; + mspack_handle->fmap = mspack_name->fmap; + mspack_handle->org = mspack_name->org; + mspack_handle->offset = 0; + + return (struct mspack_file *)mspack_handle; + + case MSPACK_SYS_OPEN_WRITE: + fmode = "wb"; + break; + case MSPACK_SYS_OPEN_UPDATE: + fmode = "r+b"; + break; + case MSPACK_SYS_OPEN_APPEND: + fmode = "ab"; + break; + default: + cli_dbgmsg("%s() wrong mode\n", __func__); + goto out_err; + } + + mspack_handle->type = FILETYPE_FILENAME; + + mspack_handle->f = fopen(filename, fmode); + if (!mspack_handle->f) { + cli_dbgmsg("%s() failed %d\n", __func__, __LINE__); + goto out_err; + } + + self_ex = (struct mspack_system_ex *)((char *)mptr - offsetof(struct mspack_system_ex,ops)); + mspack_handle->max_size = self_ex->max_size; + return (struct mspack_file *)mspack_handle; + +out_err: + free(mspack_handle); + return NULL; +} + +static void mspack_fmap_close(struct mspack_file *file) +{ + struct mspack_handle *mspack_handle = (struct mspack_handle *)file; + + if (!mspack_handle) + return; + + if (mspack_handle->type == FILETYPE_FILENAME) + fclose(mspack_handle->f); + free(mspack_handle); +} + +static int mspack_fmap_read(struct mspack_file *file, void *buffer, int bytes) +{ + struct mspack_handle *mspack_handle = (struct mspack_handle *)file; + off_t offset; + size_t count; + int ret; + + if (bytes < 0) { + cli_dbgmsg("%s() %d\n", __func__, __LINE__); + return -1; + } + if (!mspack_handle) { + cli_dbgmsg("%s() %d\n", __func__, __LINE__); + return -1; + } + + if (mspack_handle->type == FILETYPE_FMAP) { + offset = mspack_handle->offset + mspack_handle->org; + + ret = fmap_readn(mspack_handle->fmap, buffer, offset, bytes); + if (ret != bytes) { + cli_dbgmsg("%s() %d %d, %d\n", __func__, __LINE__, bytes, ret); + return ret; + } + + mspack_handle->offset += bytes; + return bytes; + } + count = fread(buffer, bytes, 1, mspack_handle->f); + if (count < 1) { + cli_dbgmsg("%s() %d %d, %zd\n", __func__, __LINE__, bytes, count); + return -1; + } + return bytes; +} + +static int mspack_fmap_write(struct mspack_file *file, void *buffer, int bytes) +{ + struct mspack_handle *mspack_handle = (struct mspack_handle *)file; + size_t count; + off_t max_size; + + if (bytes < 0 || !mspack_handle) { + cli_dbgmsg("%s() err %d\n", __func__, __LINE__); + return -1; + } + + if (mspack_handle->type == FILETYPE_FMAP) { + cli_dbgmsg("%s() err %d\n", __func__, __LINE__); + return -1; + } + + if (!bytes) + return 0; + + max_size = mspack_handle->max_size; + if (!max_size) + return bytes; + + max_size = max_size < (off_t) bytes ? max_size : (off_t) bytes; + + mspack_handle->max_size -= max_size; + + count = fwrite(buffer, max_size, 1, mspack_handle->f); + if (count < 1) { + cli_dbgmsg("%s() err %m <%zd %d>\n", __func__, count, bytes); + return -1; + } + + return bytes; +} + +static int mspack_fmap_seek(struct mspack_file *file, off_t offset, int mode) +{ + struct mspack_handle *mspack_handle = (struct mspack_handle *)file; + + if (!mspack_handle) { + cli_dbgmsg("%s() err %d\n", __func__, __LINE__); + return -1; + } + + if (mspack_handle->type == FILETYPE_FMAP) { + off_t new_pos; + + switch (mode) { + case MSPACK_SYS_SEEK_START: + new_pos = offset; + break; + case MSPACK_SYS_SEEK_CUR: + new_pos = mspack_handle->offset + offset; + break; + case MSPACK_SYS_SEEK_END: + new_pos = mspack_handle->fmap->len + offset; + break; + default: + cli_dbgmsg("%s() err %d\n", __func__, __LINE__); + return -1; + } + if (new_pos < 0 || new_pos > mspack_handle->fmap->len) { + cli_dbgmsg("%s() err %d\n", __func__, __LINE__); + return -1; + } + + mspack_handle->offset = new_pos; + return 0; + } + + switch (mode) { + case MSPACK_SYS_SEEK_START: + mode = SEEK_SET; + break; + case MSPACK_SYS_SEEK_CUR: + mode = SEEK_CUR; + break; + case MSPACK_SYS_SEEK_END: + mode = SEEK_END; + break; + default: + cli_dbgmsg("%s() err %d\n", __func__, __LINE__); + return -1; + } + + return fseek(mspack_handle->f, offset, mode); +} + +static off_t mspack_fmap_tell(struct mspack_file *file) +{ + struct mspack_handle *mspack_handle = (struct mspack_handle *)file; + + if (!mspack_handle) + return -1; + + if (mspack_handle->type == FILETYPE_FMAP) + return mspack_handle->offset; + + return (off_t) ftell(mspack_handle->f); +} + +static void mspack_fmap_message(struct mspack_file *file, const char *fmt, ...) +{ + cli_dbgmsg("%s() %s\n", __func__, fmt); +} +static void *mspack_fmap_alloc(struct mspack_system *self, size_t num) +{ + return malloc(num); +} + +static void mspack_fmap_free(void *mem) +{ + if(mem) { + free(mem); + mem = NULL; + } + return; +} + +static void mspack_fmap_copy(void *src, void *dst, size_t num) +{ + memcpy(dst, src, num); +} + +static struct mspack_system mspack_sys_fmap_ops = { + .open = mspack_fmap_open, + .close = mspack_fmap_close, + .read = mspack_fmap_read, + .write = mspack_fmap_write, + .seek = mspack_fmap_seek, + .tell = mspack_fmap_tell, + .message = mspack_fmap_message, + .alloc = mspack_fmap_alloc, + .free = mspack_fmap_free, + .copy = mspack_fmap_copy, +}; + +static int cli_scanfile(const char *filename, cli_ctx *ctx) +{ + int fd, ret = 0; + + /* internal version of cl_scanfile with arec/mrec preserved */ + fd = safe_open(filename, O_RDONLY|O_BINARY); + if (fd < 0) + return ret; + + ret = cli_magic_scandesc(fd, ctx); + + close(fd); + return ret; +} + +int cli_scanmscab(cli_ctx *ctx, off_t sfx_offset) +{ + struct mscab_decompressor *cab_d; + struct mscabd_cabinet *cab_h; + struct mscabd_file *cab_f; + int ret; + int files; + int virus_num = 0; + struct mspack_name mspack_fmap = { + .fmap = *ctx->fmap, + .org = sfx_offset, + }; + struct mspack_system_ex ops_ex; + memset(&ops_ex, 0, sizeof(struct mspack_system_ex)); + ops_ex.ops = mspack_sys_fmap_ops; + + cab_d = mspack_create_cab_decompressor(&ops_ex.ops); + if (!cab_d) { + cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); + return CL_EUNPACK; + } + + cab_h = cab_d->open(cab_d, (char *)&mspack_fmap); + if (!cab_h) { + ret = CL_EFORMAT; + cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); + goto out_dest; + } + files = 0; + for (cab_f = cab_h->files; cab_f; cab_f = cab_f->next) { + off_t max_size; + char *tmp_fname; + + ret = cli_matchmeta(ctx, cab_f->filename, 0, cab_f->length, 0, + files, 0, NULL); + if (ret) { + if (ret == CL_VIRUS) { + virus_num++; + if (!SCAN_ALL) + break; + } + goto out_close; + } + + if (ctx->engine->maxscansize) { + if (ctx->scansize >= ctx->engine->maxscansize) { + ret = CL_CLEAN; + break; + } + } + + if (ctx->engine->maxscansize && + ctx->scansize + ctx->engine->maxfilesize >= + ctx->engine->maxscansize) + max_size = ctx->engine->maxscansize - + ctx->scansize; + else + max_size = ctx->engine->maxfilesize ? + ctx->engine->maxfilesize : + 0xffffffff; + + tmp_fname = cli_gentemp(ctx->engine->tmpdir); + if (!tmp_fname) { + ret = CL_EMEM; + break; + } + + ops_ex.max_size = max_size; + /* scan */ + ret = cab_d->extract(cab_d, cab_f, tmp_fname); + if (ret) + /* Failed to extract. Try to scan what is there */ + cli_dbgmsg("%s() failed to extract %d\n", __func__, ret); + + ret = cli_scanfile(tmp_fname, ctx); + if (ret == CL_VIRUS) + virus_num++; + + if (!ctx->engine->keeptmp) { + if (!access(tmp_fname, R_OK) && cli_unlink(tmp_fname)) { + free(tmp_fname); + ret = CL_EUNLINK; + break; + } + } + free(tmp_fname); + files++; + if (ret == CL_VIRUS && SCAN_ALL) + continue; + if (ret) + break; + } + +out_close: + cab_d->close(cab_d, cab_h); +out_dest: + mspack_destroy_cab_decompressor(cab_d); + if (virus_num) + return CL_VIRUS; + return ret; +} + +int cli_scanmschm(cli_ctx *ctx) +{ + struct mschm_decompressor *mschm_d; + struct mschmd_header *mschm_h; + struct mschmd_file *mschm_f; + int ret; + int files; + int virus_num = 0; + struct mspack_name mspack_fmap = { + .fmap = *ctx->fmap, + }; + struct mspack_system_ex ops_ex; + memset(&ops_ex, 0, sizeof(struct mspack_system_ex)); + ops_ex.ops = mspack_sys_fmap_ops; + + mschm_d = mspack_create_chm_decompressor(&ops_ex.ops); + if (!mschm_d) { + cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); + return CL_EUNPACK; + } + + mschm_h = mschm_d->open(mschm_d, (char *)&mspack_fmap); + if (!mschm_h) { + ret = CL_EFORMAT; + cli_dbgmsg("%s() failed at %d\n", __func__, __LINE__); + goto out_dest; + } + files = 0; + for (mschm_f = mschm_h->files; mschm_f; mschm_f = mschm_f->next) { + off_t max_size; + char *tmp_fname; + + ret = cli_matchmeta(ctx, mschm_f->filename, 0, mschm_f->length, + 0, files, 0, NULL); + if (ret) { + if (ret == CL_VIRUS) { + virus_num++; + if (!SCAN_ALL) + break; + } + goto out_close; + } + + if (ctx->engine->maxscansize) { + if (ctx->scansize >= ctx->engine->maxscansize) { + ret = CL_CLEAN; + break; + } + } + + if (ctx->engine->maxscansize && + ctx->scansize + ctx->engine->maxfilesize >= + ctx->engine->maxscansize) + max_size = ctx->engine->maxscansize - + ctx->scansize; + else + max_size = ctx->engine->maxfilesize ? + ctx->engine->maxfilesize : + 0xffffffff; + + ops_ex.max_size = max_size; + + tmp_fname = cli_gentemp(ctx->engine->tmpdir); + if (!tmp_fname) { + ret = CL_EMEM; + break; + } + + /* scan */ + ret = mschm_d->extract(mschm_d, mschm_f, tmp_fname); + if (ret) + /* Failed to extract. Try to scan what is there */ + cli_dbgmsg("%s() failed to extract %d\n", __func__, ret); + + ret = cli_scanfile(tmp_fname, ctx); + if (ret == CL_VIRUS) + virus_num++; + + if (!ctx->engine->keeptmp) { + if (!access(tmp_fname, R_OK) && cli_unlink(tmp_fname)) { + free(tmp_fname); + ret = CL_EUNLINK; + break; + } + } + free(tmp_fname); + files++; + if (ret == CL_VIRUS && SCAN_ALL) + continue; + if (ret) + break; + } + +out_close: + mschm_d->close(mschm_d, mschm_h); +out_dest: + mspack_destroy_chm_decompressor(mschm_d); + if (virus_num) + return CL_VIRUS; + return ret; + + return 0; +} diff -Nru clamav-0.99.2+dfsg/libclamav/libmspack.h clamav-0.99.3~beta1+dfsg/libclamav/libmspack.h --- clamav-0.99.2+dfsg/libclamav/libmspack.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/libmspack.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,7 @@ +#ifndef __LIBMSPACK_H__ +#define __LIBMSPACK_H__ + +int cli_scanmscab(cli_ctx *ctx, off_t sfx_offset); +int cli_scanmschm(cli_ctx *ctx); + +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/lzw/lzwdec.c clamav-0.99.3~beta1+dfsg/libclamav/lzw/lzwdec.c --- clamav-0.99.2+dfsg/libclamav/lzw/lzwdec.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/lzw/lzwdec.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,451 @@ +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +/* + * Portions Copyright (C) 2016 Cisco and/or its affiliates. All rights reserved. + * + * Modified by: Kevin Lin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations + * including the two. + * + * You must obey the GNU General Public License in all respects + * for all of the code used other than OpenSSL. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you + * do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source + * files in the program, then also delete it here. + */ +#include + +#include +#include +#include "lzwdec.h" +#include "../others.h" + +#define MAXCODE(n) ((1L<<(n))-1) +/* + * The spec specifies that encoded bit + * strings SHOULD range from 9 to 12 bits. + */ +#define BITS_MIN 9 /* start with 9 bits */ +#define BITS_VALID 12 /* 12 bit codes are the max valid */ +#define BITS_MAX 14 /* max of 14 bit codes (2 bits extension) */ +/* predefined codes */ +#define CODE_BASIC 256 /* last basic code + 1 */ +#define CODE_CLEAR 256 /* code to clear string table */ +#define CODE_EOI 257 /* end-of-information code */ +#define CODE_FIRST 258 /* first free code entry */ +#define CODE_VALID MAXCODE(BITS_VALID) +#define CODE_MAX MAXCODE(BITS_MAX) + +#define CSIZE (MAXCODE(BITS_MAX)+1L) + +typedef uint16_t hcode_t; /* codes fit in 16 bits */ + +/* + * Decoding-specific state. + */ +typedef struct code_ent { + struct code_ent *next; + uint16_t length; /* string len, including this token */ + uint8_t value; /* data value */ + uint8_t firstchar; /* first token of string */ +} code_t; + +struct lzw_internal_state { + /* general state */ + uint16_t nbits; /* # of bits/code */ + long nextdata; /* next bits of i/o */ + long nextbits; /* # of valid bits in lzw_nextdata */ + + /* decoding-specific state */ + long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ + long dec_restart; /* restart count */ + code_t *dec_codep; /* current recognized code */ + code_t *dec_oldcodep; /* previously recognized code */ + code_t *dec_free_entp; /* next free entry */ + code_t *dec_maxcodep; /* max available entry */ + code_t *dec_codetab; /* kept separate for small machines */ +}; + +static void code_print(code_t *code); +static void dict_print(code_t *codetab, uint16_t start, uint16_t maxcode); + +#define GetNextCode(code) { \ + if (have == 0) \ + break; \ + nextdata = nextdata << 8 | *(from)++; \ + have--; \ + nextbits += 8; \ + if (nextbits < nbits) { \ + if (have == 0) \ +break; \ + nextdata = nextdata << 8 | *(from)++; \ + have--; \ + nextbits += 8; \ + } \ + code = (hcode_t)((nextdata >> (nextbits-nbits)) & nbitsmask); \ + nextbits -= nbits; \ +} + +#define CodeClear(code) { \ + free_code = CODE_FIRST; \ + free_entp = state->dec_codetab + CODE_FIRST; \ + nbits = BITS_MIN; \ + nbitsmask = MAXCODE(BITS_MIN); \ + maxcodep = state->dec_codetab + nbitsmask-1; \ + while (code == CODE_CLEAR) /* clears out consecutive CODE_CLEARs */ \ + GetNextCode(code); \ + if (code < CODE_BASIC) \ + *to++ = code, left--; \ + else if (code == CODE_EOI) \ + ret = LZW_STREAM_END; \ + else if (code >= CODE_FIRST) { \ + /* cannot reference unpopulated dictionary entries */ \ + strm->msg = "cannot reference unpopulated dictionary entries"; \ + ret = LZW_DATA_ERROR; \ + } \ + oldcodep = state->dec_codetab + code; \ +} + +int lzwInit(lzw_streamp strm) +{ + struct lzw_internal_state *state; + hcode_t code; + + state = cli_malloc(sizeof(struct lzw_internal_state)); + if (state == NULL) { + strm->msg = "failed to allocate state"; + return LZW_MEM_ERROR; + } + + /* general state setup */ + state->nbits = BITS_MIN; + state->nextdata = 0; + state->nextbits = 0; + + /* dictionary setup */ + state->dec_codetab = cli_calloc(CSIZE, sizeof(code_t)); + if (state->dec_codetab == NULL) { + free(state); + strm->msg = "failed to allocate code table"; + return LZW_MEM_ERROR; + } + + for (code = 0; code < CODE_BASIC; code++) { + state->dec_codetab[code].next = NULL; + state->dec_codetab[code].length = 1; + state->dec_codetab[code].value = code; + state->dec_codetab[code].firstchar = code; + } + + state->dec_restart = 0; + state->dec_nbitsmask = MAXCODE(BITS_MIN); + state->dec_free_entp = state->dec_codetab + CODE_FIRST; + state->dec_oldcodep = &state->dec_codetab[CODE_CLEAR]; + state->dec_maxcodep = &state->dec_codetab[state->dec_nbitsmask-1]; + + strm->state = state; + return LZW_OK; +} + +int lzwInflate(lzw_streamp strm) +{ + struct lzw_internal_state *state; + uint8_t *from, *to; + unsigned in, out; + unsigned have, left; + long nbits, nextbits, nextdata, nbitsmask; + code_t *codep, *free_entp, *maxcodep, *oldcodep; + + uint8_t *wp; + hcode_t code, free_code; + int echg, cext, ret = LZW_OK; + uint32_t flags; + + if (strm == NULL || strm->state == NULL || strm->next_out == NULL || + (strm->next_in == NULL && strm->avail_in != 0)) + return LZW_STREAM_ERROR; + + /* load state */ + to = strm->next_out; + out = left = strm->avail_out; + + from = strm->next_in; + in = have = strm->avail_in; + + flags = strm->flags; + state = strm->state; + + nbits = state->nbits; + nextdata = state->nextdata; + nextbits = state->nextbits; + nbitsmask = state->dec_nbitsmask; + oldcodep = state->dec_oldcodep; + free_entp = state->dec_free_entp; + maxcodep = state->dec_maxcodep; + + echg = flags & LZW_FLAG_EARLYCHG; + cext = flags & LZW_FLAG_EXTNCODE; + free_code = free_entp - &state->dec_codetab[0]; + + if (oldcodep == &state->dec_codetab[CODE_EOI]) + return LZW_STREAM_END; + + /* + * Restart interrupted output operation. + */ + if (state->dec_restart) { + long residue; + + codep = state->dec_codep; + residue = codep->length - state->dec_restart; + if (residue > left) { + /* + * Residue from previous decode is sufficient + * to satisfy decode request. Skip to the + * start of the decoded string, place decoded + * values in the output buffer, and return. + */ + state->dec_restart += left; + do { + codep = codep->next; + } while (--residue > left); + to = wp = to + left; + do { + *--wp = codep->value; + codep = codep->next; + } while (--left); + goto inf_end; + } + /* + * Residue satisfies only part of the decode request. + */ + to += residue, left -= residue; + wp = to; + do { + *--wp = codep->value; + codep = codep->next; + } while (--residue); + state->dec_restart = 0; + } + + /* guarentee valid initial state */ + if (left > 0 && (oldcodep == &state->dec_codetab[CODE_CLEAR])) { + code = CODE_CLEAR; + CodeClear(code); + if (ret != LZW_OK) + goto inf_end; + } + + while (left > 0) { + GetNextCode(code); + if (code == CODE_EOI) { + ret = LZW_STREAM_END; + break; + } + if (code == CODE_CLEAR) { + CodeClear(code); + if (ret != LZW_OK) + break; + continue; + } + codep = state->dec_codetab + code; + + /* cap dictionary codes to valid range (12-bits) */ + if (free_code < CODE_VALID+1 || cext) { + /* non-earlychange bit expansion */ + if (!echg && free_entp > maxcodep) { + if (++nbits > BITS_VALID) { + if (!cext) + nbits = BITS_VALID; + else if (nbits > BITS_MAX) + nbits = BITS_MAX; + } + nbitsmask = MAXCODE(nbits); + maxcodep = state->dec_codetab + nbitsmask-1; + } + /* + * Add the new entry to the code table. + */ + if (&state->dec_codetab[0] > free_entp || free_entp >= &state->dec_codetab[CSIZE]) { + cli_dbgmsg("%p <= %p, %p < %p(%ld)\n", &state->dec_codetab[0], free_entp, free_entp, &state->dec_codetab[CSIZE], CSIZE); + strm->msg = "full dictionary, cannot add new entry"; + flags |= LZW_FLAG_FULLDICT; + ret = LZW_DICT_ERROR; + break; + } + free_entp->next = oldcodep; + free_entp->firstchar = free_entp->next->firstchar; + free_entp->length = free_entp->next->length+1; + free_entp->value = (codep < free_entp) ? + codep->firstchar : free_entp->firstchar; + free_entp++; + /* earlychange bit expansion */ + if (echg && free_entp > maxcodep) { + if (++nbits > BITS_VALID) { + if (!cext) + nbits = BITS_VALID; + else if (nbits > BITS_MAX) + nbits = BITS_MAX; + } + nbitsmask = MAXCODE(nbits); + maxcodep = state->dec_codetab + nbitsmask-1; + } + if (free_code++ > CODE_VALID) + flags |= LZW_FLAG_EXTNCODEUSE; + oldcodep = codep; + } else + flags |= LZW_FLAG_FULLDICT; + if (code >= CODE_BASIC) { + /* check if code is valid */ + if (code >= free_code) { + strm->msg = "cannot reference unpopulated dictionary entries"; + flags |= LZW_FLAG_INVALIDCODE; + ret = LZW_DATA_ERROR; + break; + } + + /* + * Code maps to a string, copy string + * value to output (written in reverse). + */ + if (codep->length > left) { + /* + * String is too long for decode buffer, + * locate portion that will fit, copy to + * the decode buffer, and setup restart + * logic for the next decoding call. + */ + state->dec_codep = codep; + do { + codep = codep->next; + } while (codep->length > left); + state->dec_restart = left; + to = wp = to + left; + do { + *--wp = codep->value; + codep = codep->next; + } while (--left); + goto inf_end; + } + + to += codep->length, left -= codep->length; + wp = to; + do { + *--wp = codep->value; + codep = codep->next; + } while(codep != NULL); + } else + *to++ = code, left--; + } + +inf_end: + /* restore state */ + strm->next_out = to; + strm->avail_out = left; + strm->next_in = from; + strm->avail_in = have; + strm->flags = flags; + + state->nbits = (uint16_t)nbits; + state->nextdata = nextdata; + state->nextbits = nextbits; + state->dec_nbitsmask = nbitsmask; + state->dec_oldcodep = oldcodep; + state->dec_free_entp = free_entp; + state->dec_maxcodep = maxcodep; + + /* update state */ + in -= strm->avail_in; + out -= strm->avail_out; + strm->total_in += in; + strm->total_out += out; + + if ((in == 0 && out == 0) && ret == LZW_OK) { + strm->msg = "no data was processed"; + ret = LZW_BUF_ERROR; + } + return ret; +} + +int lzwInflateEnd(lzw_streamp strm) +{ + free(strm->state->dec_codetab); + free(strm->state); + strm->state = NULL; + return LZW_OK; +} + +static void code_print(code_t *code) +{ + code_t *cpt = code; + uint8_t *string; + int i = 0; + + string = cli_calloc(code->length+1, sizeof(uint8_t)); + if (!string) + return; + + while (cpt && (i < code->length)) { + if (isalnum(cpt->value)) + string[code->length - i - 1] = cpt->value; + else + string[code->length - i - 1] = '*'; + + i++; + cpt = cpt->next; + } + + printf("%s\n", string); + free(string); +} + +static void dict_print(code_t *codetab, uint16_t start, uint16_t maxcode) +{ + int i; + + for (i = start; i < maxcode; i++) { + printf("%d: ", i); + code_print(codetab + i); + } +} diff -Nru clamav-0.99.2+dfsg/libclamav/lzw/lzwdec.h clamav-0.99.3~beta1+dfsg/libclamav/lzw/lzwdec.h --- clamav-0.99.2+dfsg/libclamav/lzw/lzwdec.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/lzw/lzwdec.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2016 Cisco and/or its affiliates. All rights reserved. + * + * Author: Kevin Lin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations + * including the two. + * + * You must obey the GNU General Public License in all respects + * for all of the code used other than OpenSSL. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you + * do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source + * files in the program, then also delete it here. + */ + +#ifndef __LZWDEC_H__ +#define __LZWDEC_H__ + +#include + +struct lzw_internal_state; + +typedef struct lzw_stream_s { + uint8_t *next_in; + unsigned avail_in; + unsigned total_in; + + uint8_t *next_out; + unsigned avail_out; + unsigned total_out; + + char *msg; + + uint32_t flags; + struct lzw_internal_state *state; +} lzw_stream; + +typedef lzw_stream *lzw_streamp; + +#define LZW_OK 0 +#define LZW_STREAM_END 1 +#define LZW_STREAM_ERROR (-2) +#define LZW_DATA_ERROR (-3) +#define LZW_MEM_ERROR (-4) +#define LZW_BUF_ERROR (-5) +#define LZW_DICT_ERROR (-7) + +/* option flags */ +#define LZW_NOFLAGS 0x0 +#define LZW_FLAG_EARLYCHG 0x1 /* code point changes one code earlier */ +#define LZW_FLAG_EXTNCODE 0x2 /* use extended code points (12+ bits) */ +/* state flags */ +#define LZW_FLAG_FULLDICT 0x100 /* dictionary consumes all usable codes */ +#define LZW_FLAG_EXTNCODEUSE 0x200 /* extended dictionary uses 12+ bit codes */ +#define LZW_FLAG_INVALIDCODE 0x400 /* input references invalid code entry (data error) */ + +int lzwInit(lzw_streamp strm); +int lzwInflate(lzw_streamp strm); +int lzwInflateEnd(lzw_streamp strm); + +#endif /* __LZWDEC_H__ */ diff -Nru clamav-0.99.2+dfsg/libclamav/macho.c clamav-0.99.3~beta1+dfsg/libclamav/macho.c --- clamav-0.99.2+dfsg/libclamav/macho.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/macho.c 2017-04-20 22:19:13.000000000 +0000 @@ -176,8 +176,8 @@ if(matcher) \ return -1; \ if(DETECT_BROKEN) { \ - cli_append_virus(ctx, "Heuristics.Broken.Executable"); \ - return CL_VIRUS; \ + if (CL_VIRUS == cli_append_virus(ctx, "Heuristics.Broken.Executable")) \ + return CL_VIRUS; \ } \ return CL_EFORMAT diff -Nru clamav-0.99.2+dfsg/libclamav/Makefile.am clamav-0.99.3~beta1+dfsg/libclamav/Makefile.am --- clamav-0.99.2+dfsg/libclamav/Makefile.am 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/Makefile.am 2017-03-08 14:06:34.000000000 +0000 @@ -21,7 +21,8 @@ AM_CPPFLAGS = -I$(top_srcdir) -I@srcdir@/nsis $(LTDLINCL) AM_CFLAGS=@WERR_CFLAGS@ lib_LTLIBRARIES = -EXTRA_DIST = c++/Makefile.nollvm.in +COMMON_CLEANFILES = +EXTRA_DIST = c++/Makefile.nollvm.in libmspack-0.5alpha/Makefile.intmspack.in if ENABLE_UNRAR AM_CPPFLAGS += -DWARN_DLOPEN_FAIL @@ -125,11 +126,12 @@ libclamav_internal_utils_nothreads_la_LDFLAGS=-static @SSL_LDFLAGS@ @JSON_LDFLAGS@ libclamav_internal_utils_nothreads_la_CFLAGS=$(AM_CFLAGS) -DCL_NOTHREADS @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@ libclamav_internal_utils_nothreads_la_LIBADD=@SSL_LIBS@ @JSON_LIBS@ @PCRE_LIBS@ +SUBDIRS= if ENABLE_LLVM LLVMLIBADD=c++/libclamavcxx.la -lstdc++ -lm LLVMDEP=c++/libclamavcxx.la -SUBDIRS=c++ +SUBDIRS+=c++ else LLVMLIBADD=libclamav_nocxx.la LLVMDEP=libclamav_nocxx.la @@ -147,13 +149,50 @@ libclamav_la_LIBADD = @SSL_LIBS@ @JSON_LIBS@ @PCRE_LIBS@ @LIBCLAMAV_LIBS@ @LIBLTDL@ $(IFACELIBADD) $(LLVMLIBADD) libclamav_internal_utils.la @THREAD_LIBS@ @LIBM@ libclamav_la_DEPENDENCIES = @LTDLDEPS@ $(IFACEDEP) $(LLVMDEP) libclamav_internal_utils.la -libclamav_la_CFLAGS =$(AM_CFLAGS) $(XML_CPPFLAGS) $(YARA_CFLAGS) -DSEARCH_LIBDIR=\"$(libdir)\" @LIBCLAMAV_CPPFLAGS@ @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@ -libclamav_la_LDFLAGS = @SSL_LDFLAGS@ @TH_SAFE@ @JSON_LDFLAGS@ $(XML_LIBS) -version-info @LIBCLAMAV_VERSION@ -no-undefined +libclamav_la_CFLAGS =$(AM_CFLAGS) $(XML_CPPFLAGS) $(YARA_CFLAGS) -DSEARCH_LIBDIR=\"$(libdir)\" @LIBCLAMAV_CPPFLAGS@ @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @ICONV_CPPFLAGS@ @PCRE_CPPFLAGS@ +libclamav_la_LDFLAGS = @SSL_LDFLAGS@ @TH_SAFE@ @JSON_LDFLAGS@ @ICONV_LDFLAGS@ $(XML_LIBS) -version-info @LIBCLAMAV_VERSION@ -no-undefined if VERSIONSCRIPT libclamav_la_LDFLAGS += -Wl,@VERSIONSCRIPTFLAG@,@top_srcdir@/libclamav/libclamav.map endif +if USE_INTERNAL_MSPACK +SUBDIRS += libmspack-0.5alpha +libclamav_la_CFLAGS += -I@top_srcdir@/libclamav/libmspack-0.5alpha/mspack +libclamav_la_LIBADD += @top_builddir@/libclamav/libmspack-0.5alpha/cabc.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/system.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/kwajd.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/hlpc.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/chmd.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/qtmd.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/litc.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/oabc.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/lzxd.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/litd.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/crc32.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/lzssd.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/kwajc.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/cabd.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/szddd.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/lzxc.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/mszipd.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/szddc.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/oabd.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/chmc.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/mszipc.lo \ + @top_builddir@/libclamav/libmspack-0.5alpha/hlpd.lo +COMMON_CLEANFILES+=@top_builddir@/libclamav/libmspack-0.5alpha/config.h \ + @top_builddir@/libclamav/libmspack-0.5alpha/libmspack.pc \ + @top_builddir@/libclamav/libmspack-0.5alpha/autom4te.cache/* +else +libclamav_la_CFLAGS += $(LIBMSPACK_CFLAGS) +libclamav_la_LDFLAGS += $(LIBMSPACK_LIBS) +EXTRA_DIST += libmspack-0.5alpha +libmspack-0.5alpha/Makefile: libmspack-0.5alpha/Makefile.intmspack.in + $(AM_V_at) cp $< $@ +distclean-recursive distdir maintainer-clean-recursive: libmspack-0.5alpha/Makefile +endif + include_HEADERS = clamav.h libclamav_la_SOURCES = \ @@ -211,8 +250,8 @@ upx.h \ htmlnorm.c \ htmlnorm.h \ - chmunpack.c \ - chmunpack.h \ + libmspack.c \ + libmspack.h \ rebuildpe.c \ rebuildpe.h \ petite.c \ @@ -267,6 +306,8 @@ pdf.c \ pdf.h \ pdfng.c \ + pdfdecode.c \ + pdfdecode.h \ spin.c \ spin.h \ yc.c \ @@ -290,10 +331,6 @@ regex_list.h \ regex_suffix.c \ regex_suffix.h \ - mspack.c \ - mspack.h \ - cab.c \ - cab.h \ entconv.c \ entconv.h \ entitylist.h \ @@ -462,7 +499,9 @@ tiff.c \ tiff.h \ hwp.c \ - hwp.h + hwp.h \ + lzw/lzwdec.c \ + lzw/lzwdec.h if ENABLE_YARA libclamav_la_SOURCES += yara_arena.c \ @@ -592,7 +631,7 @@ EXTRA_DIST += regex/engine.c tomsfastmath/sqr/fp_sqr_comba.c tomsfastmath/mul/fp_mul_comba.c libclamav.map \ jsparse/generated/operators.h jsparse/generated/keywords.h jsparse/future_reserved_words.list\ jsparse/keywords.list jsparse/special_keywords.list jsparse/operators.gperf -COMMON_CLEANFILES=version.h version.h.tmp *.gcda *.gcno +COMMON_CLEANFILES+=version.h version.h.tmp *.gcda *.gcno if MAINTAINER_MODE BUILT_SOURCES=jsparse/generated/operators.h jsparse/generated/keywords.h jsparse-keywords.gperf diff -Nru clamav-0.99.2+dfsg/libclamav/Makefile.in clamav-0.99.3~beta1+dfsg/libclamav/Makefile.in --- clamav-0.99.2+dfsg/libclamav/Makefile.in 2016-04-22 16:19:53.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/Makefile.in 2017-06-23 21:20:58.000000000 +0000 @@ -107,8 +107,41 @@ @ENABLE_UNRAR_TRUE@ @top_srcdir@/libclamunrar/libclamunrar.map \ @ENABLE_UNRAR_TRUE@ @top_srcdir@/libclamunrar_iface/libclamunrar_iface.map @ENABLE_UNRAR_TRUE@@VERSIONSCRIPT_TRUE@am__append_5 = -Wl,@VERSIONSCRIPTFLAG@,@top_srcdir@/libclamunrar_iface/libclamunrar_iface.map -@VERSIONSCRIPT_TRUE@am__append_6 = -Wl,@VERSIONSCRIPTFLAG@,@top_srcdir@/libclamav/libclamav.map -@ENABLE_YARA_TRUE@am__append_7 = yara_arena.c \ +@ENABLE_LLVM_TRUE@am__append_6 = c++ +@VERSIONSCRIPT_TRUE@am__append_7 = -Wl,@VERSIONSCRIPTFLAG@,@top_srcdir@/libclamav/libclamav.map +@USE_INTERNAL_MSPACK_TRUE@am__append_8 = libmspack-0.5alpha +@USE_INTERNAL_MSPACK_TRUE@am__append_9 = -I@top_srcdir@/libclamav/libmspack-0.5alpha/mspack +@USE_INTERNAL_MSPACK_TRUE@am__append_10 = @top_builddir@/libclamav/libmspack-0.5alpha/cabc.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/system.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/kwajd.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/hlpc.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/chmd.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/qtmd.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/litc.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/oabc.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/lzxd.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/litd.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/crc32.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/lzssd.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/kwajc.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/cabd.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/szddd.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/lzxc.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/mszipd.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/szddc.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/oabd.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/chmc.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/mszipc.lo \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/hlpd.lo + +@USE_INTERNAL_MSPACK_TRUE@am__append_11 = @top_builddir@/libclamav/libmspack-0.5alpha/config.h \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/libmspack.pc \ +@USE_INTERNAL_MSPACK_TRUE@ @top_builddir@/libclamav/libmspack-0.5alpha/autom4te.cache/* + +@USE_INTERNAL_MSPACK_FALSE@am__append_12 = $(LIBMSPACK_CFLAGS) +@USE_INTERNAL_MSPACK_FALSE@am__append_13 = $(LIBMSPACK_LIBS) +@USE_INTERNAL_MSPACK_FALSE@am__append_14 = libmspack-0.5alpha +@ENABLE_YARA_TRUE@am__append_15 = yara_arena.c \ @ENABLE_YARA_TRUE@ yara_arena.h \ @ENABLE_YARA_TRUE@ yara_compiler.c \ @ENABLE_YARA_TRUE@ yara_compiler.h \ @@ -133,10 +166,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -191,12 +225,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -245,7 +284,7 @@ ole2_extract.c ole2_extract.h vba_extract.c vba_extract.h \ cltypes.h msexpand.c msexpand.h pe.c pe.h pe_icons.c \ pe_icons.h disasm.c disasm.h disasm-common.h disasmpriv.h \ - upx.c upx.h htmlnorm.c htmlnorm.h chmunpack.c chmunpack.h \ + upx.c upx.h htmlnorm.c htmlnorm.h libmspack.c libmspack.h \ rebuildpe.c rebuildpe.h petite.c petite.h wwunpack.c \ wwunpack.h unsp.c unsp.h aspack.c aspack.h packlibs.c \ packlibs.h fsg.c fsg.h mew.c mew.h upack.c upack.h line.c \ @@ -255,12 +294,12 @@ tnef.h autoit.c autoit.h unarj.c unarj.h nsis/bzlib.c \ nsis/bzlib_private.h nsis/nsis_bzlib.h nsis/nulsft.c \ nsis/nulsft.h nsis/infblock.c nsis/nsis_zconf.h \ - nsis/nsis_zlib.h nsis/nsis_zutil.h pdf.c pdf.h pdfng.c spin.c \ - spin.h yc.c yc.h elf.c elf.h execs.h sis.c sis.h uuencode.c \ - uuencode.h phishcheck.c phishcheck.h phish_domaincheck_db.c \ - phish_domaincheck_db.h phish_whitelist.c phish_whitelist.h \ - iana_cctld.h iana_tld.h regex_list.c regex_list.h \ - regex_suffix.c regex_suffix.h mspack.c mspack.h cab.c cab.h \ + nsis/nsis_zlib.h nsis/nsis_zutil.h pdf.c pdf.h pdfng.c \ + pdfdecode.c pdfdecode.h spin.c spin.h yc.c yc.h elf.c elf.h \ + execs.h sis.c sis.h uuencode.c uuencode.h phishcheck.c \ + phishcheck.h phish_domaincheck_db.c phish_domaincheck_db.h \ + phish_whitelist.c phish_whitelist.h iana_cctld.h iana_tld.h \ + regex_list.c regex_list.h regex_suffix.c regex_suffix.h \ entconv.c entconv.h entitylist.h encoding_aliases.h hashtab.c \ hashtab.h dconf.c dconf.h lzma_iface.c lzma_iface.h 7z_iface.c \ 7z_iface.h 7z/7z.h 7z/7zAlloc.c 7z/7zAlloc.h 7z/7zBuf.c \ @@ -291,13 +330,14 @@ stats_json.h hostid.c hostid.h openioc.c openioc.h msdoc.c \ msdoc.h matcher-pcre.c matcher-pcre.h regex_pcre.c \ regex_pcre.h msxml.c msxml.h msxml_parser.c msxml_parser.h \ - tiff.c tiff.h hwp.c hwp.h yara_arena.c yara_arena.h \ - yara_compiler.c yara_compiler.h yara_exec.c yara_exec.h \ - yara_hash.c yara_hash.h yara_grammar.y yara_lexer.l \ - yara_lexer.h yara_parser.c yara_parser.h yara_clam.h bignum.h \ - bignum_fast.h tomsfastmath/addsub/fp_add.c \ - tomsfastmath/addsub/fp_add_d.c tomsfastmath/addsub/fp_addmod.c \ - tomsfastmath/addsub/fp_cmp.c tomsfastmath/addsub/fp_cmp_d.c \ + tiff.c tiff.h hwp.c hwp.h lzw/lzwdec.c lzw/lzwdec.h \ + yara_arena.c yara_arena.h yara_compiler.c yara_compiler.h \ + yara_exec.c yara_exec.h yara_hash.c yara_hash.h yara_grammar.y \ + yara_lexer.l yara_lexer.h yara_parser.c yara_parser.h \ + yara_clam.h bignum.h bignum_fast.h \ + tomsfastmath/addsub/fp_add.c tomsfastmath/addsub/fp_add_d.c \ + tomsfastmath/addsub/fp_addmod.c tomsfastmath/addsub/fp_cmp.c \ + tomsfastmath/addsub/fp_cmp_d.c \ tomsfastmath/addsub/fp_cmp_mag.c tomsfastmath/addsub/fp_sub.c \ tomsfastmath/addsub/fp_sub_d.c tomsfastmath/addsub/fp_submod.c \ tomsfastmath/addsub/s_fp_add.c tomsfastmath/addsub/s_fp_sub.c \ @@ -377,7 +417,7 @@ libclamav_la-vba_extract.lo libclamav_la-msexpand.lo \ libclamav_la-pe.lo libclamav_la-pe_icons.lo \ libclamav_la-disasm.lo libclamav_la-upx.lo \ - libclamav_la-htmlnorm.lo libclamav_la-chmunpack.lo \ + libclamav_la-htmlnorm.lo libclamav_la-libmspack.lo \ libclamav_la-rebuildpe.lo libclamav_la-petite.lo \ libclamav_la-wwunpack.lo libclamav_la-unsp.lo \ libclamav_la-aspack.lo libclamav_la-packlibs.lo \ @@ -389,13 +429,13 @@ libclamav_la-tnef.lo libclamav_la-autoit.lo \ libclamav_la-unarj.lo libclamav_la-bzlib.lo \ libclamav_la-nulsft.lo libclamav_la-infblock.lo \ - libclamav_la-pdf.lo libclamav_la-pdfng.lo libclamav_la-spin.lo \ + libclamav_la-pdf.lo libclamav_la-pdfng.lo \ + libclamav_la-pdfdecode.lo libclamav_la-spin.lo \ libclamav_la-yc.lo libclamav_la-elf.lo libclamav_la-sis.lo \ libclamav_la-uuencode.lo libclamav_la-phishcheck.lo \ libclamav_la-phish_domaincheck_db.lo \ libclamav_la-phish_whitelist.lo libclamav_la-regex_list.lo \ - libclamav_la-regex_suffix.lo libclamav_la-mspack.lo \ - libclamav_la-cab.lo libclamav_la-entconv.lo \ + libclamav_la-regex_suffix.lo libclamav_la-entconv.lo \ libclamav_la-hashtab.lo libclamav_la-dconf.lo \ libclamav_la-lzma_iface.lo libclamav_la-7z_iface.lo \ libclamav_la-7zAlloc.lo libclamav_la-7zBuf.lo \ @@ -433,13 +473,14 @@ libclamav_la-msdoc.lo libclamav_la-matcher-pcre.lo \ libclamav_la-regex_pcre.lo libclamav_la-msxml.lo \ libclamav_la-msxml_parser.lo libclamav_la-tiff.lo \ - libclamav_la-hwp.lo $(am__objects_1) libclamav_la-fp_add.lo \ - libclamav_la-fp_add_d.lo libclamav_la-fp_addmod.lo \ - libclamav_la-fp_cmp.lo libclamav_la-fp_cmp_d.lo \ - libclamav_la-fp_cmp_mag.lo libclamav_la-fp_sub.lo \ - libclamav_la-fp_sub_d.lo libclamav_la-fp_submod.lo \ - libclamav_la-s_fp_add.lo libclamav_la-s_fp_sub.lo \ - libclamav_la-fp_radix_size.lo libclamav_la-fp_read_radix.lo \ + libclamav_la-hwp.lo libclamav_la-lzwdec.lo $(am__objects_1) \ + libclamav_la-fp_add.lo libclamav_la-fp_add_d.lo \ + libclamav_la-fp_addmod.lo libclamav_la-fp_cmp.lo \ + libclamav_la-fp_cmp_d.lo libclamav_la-fp_cmp_mag.lo \ + libclamav_la-fp_sub.lo libclamav_la-fp_sub_d.lo \ + libclamav_la-fp_submod.lo libclamav_la-s_fp_add.lo \ + libclamav_la-s_fp_sub.lo libclamav_la-fp_radix_size.lo \ + libclamav_la-fp_read_radix.lo \ libclamav_la-fp_read_signed_bin.lo \ libclamav_la-fp_read_unsigned_bin.lo \ libclamav_la-fp_reverse.lo libclamav_la-fp_s_rmap.lo \ @@ -676,7 +717,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags -DIST_SUBDIRS = c++ +DIST_SUBDIRS = c++ libmspack-0.5alpha DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -764,6 +805,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -791,7 +834,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -885,6 +937,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ @@ -917,7 +970,11 @@ $(am__append_1) AM_CFLAGS = @WERR_CFLAGS@ lib_LTLIBRARIES = $(am__append_3) libclamav.la -EXTRA_DIST = c++/Makefile.nollvm.in $(am__append_4) regex/engine.c \ +COMMON_CLEANFILES = $(am__append_11) version.h version.h.tmp *.gcda \ + *.gcno +EXTRA_DIST = c++/Makefile.nollvm.in \ + libmspack-0.5alpha/Makefile.intmspack.in $(am__append_4) \ + $(am__append_14) regex/engine.c \ tomsfastmath/sqr/fp_sqr_comba.c \ tomsfastmath/mul/fp_mul_comba.c libclamav.map \ jsparse/generated/operators.h jsparse/generated/keywords.h \ @@ -1007,20 +1064,26 @@ libclamav_internal_utils_nothreads_la_LDFLAGS = -static @SSL_LDFLAGS@ @JSON_LDFLAGS@ libclamav_internal_utils_nothreads_la_CFLAGS = $(AM_CFLAGS) -DCL_NOTHREADS @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@ libclamav_internal_utils_nothreads_la_LIBADD = @SSL_LIBS@ @JSON_LIBS@ @PCRE_LIBS@ +SUBDIRS = $(am__append_6) $(am__append_8) @ENABLE_LLVM_FALSE@LLVMLIBADD = libclamav_nocxx.la @ENABLE_LLVM_TRUE@LLVMLIBADD = c++/libclamavcxx.la -lstdc++ -lm @ENABLE_LLVM_FALSE@LLVMDEP = libclamav_nocxx.la @ENABLE_LLVM_TRUE@LLVMDEP = c++/libclamavcxx.la -@ENABLE_LLVM_TRUE@SUBDIRS = c++ @ENABLE_YARA_TRUE@YARA_CFLAGS = -DHAVE_YARA libclamav_nocxx_la_SOURCES = bytecode_nojit.c libclamav_nocxx_la_CFLAGS = $(AM_CFLAGS) @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@ -libclamav_la_LIBADD = @SSL_LIBS@ @JSON_LIBS@ @PCRE_LIBS@ @LIBCLAMAV_LIBS@ @LIBLTDL@ $(IFACELIBADD) $(LLVMLIBADD) libclamav_internal_utils.la @THREAD_LIBS@ @LIBM@ +libclamav_la_LIBADD = @SSL_LIBS@ @JSON_LIBS@ @PCRE_LIBS@ \ + @LIBCLAMAV_LIBS@ @LIBLTDL@ $(IFACELIBADD) $(LLVMLIBADD) \ + libclamav_internal_utils.la @THREAD_LIBS@ @LIBM@ \ + $(am__append_10) libclamav_la_DEPENDENCIES = @LTDLDEPS@ $(IFACEDEP) $(LLVMDEP) libclamav_internal_utils.la -libclamav_la_CFLAGS = $(AM_CFLAGS) $(XML_CPPFLAGS) $(YARA_CFLAGS) -DSEARCH_LIBDIR=\"$(libdir)\" @LIBCLAMAV_CPPFLAGS@ @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@ +libclamav_la_CFLAGS = $(AM_CFLAGS) $(XML_CPPFLAGS) $(YARA_CFLAGS) \ + -DSEARCH_LIBDIR=\"$(libdir)\" @LIBCLAMAV_CPPFLAGS@ \ + @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @ICONV_CPPFLAGS@ \ + @PCRE_CPPFLAGS@ $(am__append_9) $(am__append_12) libclamav_la_LDFLAGS = @SSL_LDFLAGS@ @TH_SAFE@ @JSON_LDFLAGS@ \ - $(XML_LIBS) -version-info @LIBCLAMAV_VERSION@ -no-undefined \ - $(am__append_6) + @ICONV_LDFLAGS@ $(XML_LIBS) -version-info @LIBCLAMAV_VERSION@ \ + -no-undefined $(am__append_7) $(am__append_13) include_HEADERS = clamav.h libclamav_la_SOURCES = matcher-ac.c matcher-ac.h matcher-bm.c \ matcher-bm.h matcher-hash.c matcher-hash.h matcher.c matcher.h \ @@ -1031,7 +1094,7 @@ ole2_extract.c ole2_extract.h vba_extract.c vba_extract.h \ cltypes.h msexpand.c msexpand.h pe.c pe.h pe_icons.c \ pe_icons.h disasm.c disasm.h disasm-common.h disasmpriv.h \ - upx.c upx.h htmlnorm.c htmlnorm.h chmunpack.c chmunpack.h \ + upx.c upx.h htmlnorm.c htmlnorm.h libmspack.c libmspack.h \ rebuildpe.c rebuildpe.h petite.c petite.h wwunpack.c \ wwunpack.h unsp.c unsp.h aspack.c aspack.h packlibs.c \ packlibs.h fsg.c fsg.h mew.c mew.h upack.c upack.h line.c \ @@ -1041,12 +1104,12 @@ tnef.h autoit.c autoit.h unarj.c unarj.h nsis/bzlib.c \ nsis/bzlib_private.h nsis/nsis_bzlib.h nsis/nulsft.c \ nsis/nulsft.h nsis/infblock.c nsis/nsis_zconf.h \ - nsis/nsis_zlib.h nsis/nsis_zutil.h pdf.c pdf.h pdfng.c spin.c \ - spin.h yc.c yc.h elf.c elf.h execs.h sis.c sis.h uuencode.c \ - uuencode.h phishcheck.c phishcheck.h phish_domaincheck_db.c \ - phish_domaincheck_db.h phish_whitelist.c phish_whitelist.h \ - iana_cctld.h iana_tld.h regex_list.c regex_list.h \ - regex_suffix.c regex_suffix.h mspack.c mspack.h cab.c cab.h \ + nsis/nsis_zlib.h nsis/nsis_zutil.h pdf.c pdf.h pdfng.c \ + pdfdecode.c pdfdecode.h spin.c spin.h yc.c yc.h elf.c elf.h \ + execs.h sis.c sis.h uuencode.c uuencode.h phishcheck.c \ + phishcheck.h phish_domaincheck_db.c phish_domaincheck_db.h \ + phish_whitelist.c phish_whitelist.h iana_cctld.h iana_tld.h \ + regex_list.c regex_list.h regex_suffix.c regex_suffix.h \ entconv.c entconv.h entitylist.h encoding_aliases.h hashtab.c \ hashtab.h dconf.c dconf.h lzma_iface.c lzma_iface.h 7z_iface.c \ 7z_iface.h 7z/7z.h 7z/7zAlloc.c 7z/7zAlloc.h 7z/7zBuf.c \ @@ -1077,10 +1140,11 @@ stats_json.c stats_json.h hostid.c hostid.h openioc.c \ openioc.h msdoc.c msdoc.h matcher-pcre.c matcher-pcre.h \ regex_pcre.c regex_pcre.h msxml.c msxml.h msxml_parser.c \ - msxml_parser.h tiff.c tiff.h hwp.c hwp.h $(am__append_7) \ - bignum.h bignum_fast.h tomsfastmath/addsub/fp_add.c \ - tomsfastmath/addsub/fp_add_d.c tomsfastmath/addsub/fp_addmod.c \ - tomsfastmath/addsub/fp_cmp.c tomsfastmath/addsub/fp_cmp_d.c \ + msxml_parser.h tiff.c tiff.h hwp.c hwp.h lzw/lzwdec.c \ + lzw/lzwdec.h $(am__append_15) bignum.h bignum_fast.h \ + tomsfastmath/addsub/fp_add.c tomsfastmath/addsub/fp_add_d.c \ + tomsfastmath/addsub/fp_addmod.c tomsfastmath/addsub/fp_cmp.c \ + tomsfastmath/addsub/fp_cmp_d.c \ tomsfastmath/addsub/fp_cmp_mag.c tomsfastmath/addsub/fp_sub.c \ tomsfastmath/addsub/fp_sub_d.c tomsfastmath/addsub/fp_submod.c \ tomsfastmath/addsub/s_fp_add.c tomsfastmath/addsub/s_fp_sub.c \ @@ -1142,7 +1206,6 @@ tomsfastmath/sqr/fp_sqr_comba_small_set.c \ tomsfastmath/sqr/fp_sqrmod.c noinst_LTLIBRARIES = libclamav_internal_utils.la libclamav_internal_utils_nothreads.la libclamav_nocxx.la -COMMON_CLEANFILES = version.h version.h.tmp *.gcda *.gcno @MAINTAINER_MODE_TRUE@BUILT_SOURCES = jsparse/generated/operators.h jsparse/generated/keywords.h jsparse-keywords.gperf @MAINTAINER_MODE_TRUE@GPERF_FLAGS = -E -t -L ANSI-C -C -F ', TOK_ERROR' -c @MAINTAINER_MODE_FALSE@CLEANFILES = $(COMMON_CLEANFILES) @@ -1318,9 +1381,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-bytecode_detect.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-bytecode_vm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-bzlib.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-cab.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-cache.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-chmunpack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-cpio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-crtmgr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-cvd.Plo@am__quote@ @@ -1431,8 +1492,10 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-jpeg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-js-norm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-json_api.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-libmspack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-line.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-lzma_iface.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-lzwdec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-macho.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-matcher-ac.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-matcher-bm.Plo@am__quote@ @@ -1446,7 +1509,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-mpool.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-msdoc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-msexpand.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-mspack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-msxml.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-msxml_parser.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-nulsft.Plo@am__quote@ @@ -1456,6 +1518,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-others.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-packlibs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-pdf.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-pdfdecode.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-pdfng.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-pe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-pe_icons.Plo@am__quote@ @@ -1719,12 +1782,12 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-htmlnorm.lo `test -f 'htmlnorm.c' || echo '$(srcdir)/'`htmlnorm.c -libclamav_la-chmunpack.lo: chmunpack.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-chmunpack.lo -MD -MP -MF $(DEPDIR)/libclamav_la-chmunpack.Tpo -c -o libclamav_la-chmunpack.lo `test -f 'chmunpack.c' || echo '$(srcdir)/'`chmunpack.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-chmunpack.Tpo $(DEPDIR)/libclamav_la-chmunpack.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='chmunpack.c' object='libclamav_la-chmunpack.lo' libtool=yes @AMDEPBACKSLASH@ +libclamav_la-libmspack.lo: libmspack.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-libmspack.lo -MD -MP -MF $(DEPDIR)/libclamav_la-libmspack.Tpo -c -o libclamav_la-libmspack.lo `test -f 'libmspack.c' || echo '$(srcdir)/'`libmspack.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-libmspack.Tpo $(DEPDIR)/libclamav_la-libmspack.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libmspack.c' object='libclamav_la-libmspack.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-chmunpack.lo `test -f 'chmunpack.c' || echo '$(srcdir)/'`chmunpack.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-libmspack.lo `test -f 'libmspack.c' || echo '$(srcdir)/'`libmspack.c libclamav_la-rebuildpe.lo: rebuildpe.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-rebuildpe.lo -MD -MP -MF $(DEPDIR)/libclamav_la-rebuildpe.Tpo -c -o libclamav_la-rebuildpe.lo `test -f 'rebuildpe.c' || echo '$(srcdir)/'`rebuildpe.c @@ -1901,6 +1964,13 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-pdfng.lo `test -f 'pdfng.c' || echo '$(srcdir)/'`pdfng.c +libclamav_la-pdfdecode.lo: pdfdecode.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-pdfdecode.lo -MD -MP -MF $(DEPDIR)/libclamav_la-pdfdecode.Tpo -c -o libclamav_la-pdfdecode.lo `test -f 'pdfdecode.c' || echo '$(srcdir)/'`pdfdecode.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-pdfdecode.Tpo $(DEPDIR)/libclamav_la-pdfdecode.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pdfdecode.c' object='libclamav_la-pdfdecode.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-pdfdecode.lo `test -f 'pdfdecode.c' || echo '$(srcdir)/'`pdfdecode.c + libclamav_la-spin.lo: spin.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-spin.lo -MD -MP -MF $(DEPDIR)/libclamav_la-spin.Tpo -c -o libclamav_la-spin.lo `test -f 'spin.c' || echo '$(srcdir)/'`spin.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-spin.Tpo $(DEPDIR)/libclamav_la-spin.Plo @@ -1971,20 +2041,6 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-regex_suffix.lo `test -f 'regex_suffix.c' || echo '$(srcdir)/'`regex_suffix.c -libclamav_la-mspack.lo: mspack.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-mspack.lo -MD -MP -MF $(DEPDIR)/libclamav_la-mspack.Tpo -c -o libclamav_la-mspack.lo `test -f 'mspack.c' || echo '$(srcdir)/'`mspack.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-mspack.Tpo $(DEPDIR)/libclamav_la-mspack.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mspack.c' object='libclamav_la-mspack.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-mspack.lo `test -f 'mspack.c' || echo '$(srcdir)/'`mspack.c - -libclamav_la-cab.lo: cab.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-cab.lo -MD -MP -MF $(DEPDIR)/libclamav_la-cab.Tpo -c -o libclamav_la-cab.lo `test -f 'cab.c' || echo '$(srcdir)/'`cab.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-cab.Tpo $(DEPDIR)/libclamav_la-cab.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cab.c' object='libclamav_la-cab.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-cab.lo `test -f 'cab.c' || echo '$(srcdir)/'`cab.c - libclamav_la-entconv.lo: entconv.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-entconv.lo -MD -MP -MF $(DEPDIR)/libclamav_la-entconv.Tpo -c -o libclamav_la-entconv.lo `test -f 'entconv.c' || echo '$(srcdir)/'`entconv.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-entconv.Tpo $(DEPDIR)/libclamav_la-entconv.Plo @@ -2552,6 +2608,13 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-hwp.lo `test -f 'hwp.c' || echo '$(srcdir)/'`hwp.c +libclamav_la-lzwdec.lo: lzw/lzwdec.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-lzwdec.lo -MD -MP -MF $(DEPDIR)/libclamav_la-lzwdec.Tpo -c -o libclamav_la-lzwdec.lo `test -f 'lzw/lzwdec.c' || echo '$(srcdir)/'`lzw/lzwdec.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-lzwdec.Tpo $(DEPDIR)/libclamav_la-lzwdec.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lzw/lzwdec.c' object='libclamav_la-lzwdec.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-lzwdec.lo `test -f 'lzw/lzwdec.c' || echo '$(srcdir)/'`lzw/lzwdec.c + libclamav_la-yara_arena.lo: yara_arena.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-yara_arena.lo -MD -MP -MF $(DEPDIR)/libclamav_la-yara_arena.Tpo -c -o libclamav_la-yara_arena.lo `test -f 'yara_arena.c' || echo '$(srcdir)/'`yara_arena.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-yara_arena.Tpo $(DEPDIR)/libclamav_la-yara_arena.Plo @@ -3732,6 +3795,9 @@ @ENABLE_LLVM_FALSE@c++/Makefile: c++/Makefile.nollvm.in @ENABLE_LLVM_FALSE@ $(AM_V_at) cp $< $@ @ENABLE_LLVM_FALSE@distclean-recursive distdir maintainer-clean-recursive: c++/Makefile +@USE_INTERNAL_MSPACK_FALSE@libmspack-0.5alpha/Makefile: libmspack-0.5alpha/Makefile.intmspack.in +@USE_INTERNAL_MSPACK_FALSE@ $(AM_V_at) cp $< $@ +@USE_INTERNAL_MSPACK_FALSE@distclean-recursive distdir maintainer-clean-recursive: libmspack-0.5alpha/Makefile .PHONY: version.h.tmp version.c: version.h diff -Nru clamav-0.99.2+dfsg/libclamav/matcher-ac.c clamav-0.99.3~beta1+dfsg/libclamav/matcher-ac.c --- clamav-0.99.2+dfsg/libclamav/matcher-ac.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/matcher-ac.c 2016-11-03 16:01:29.000000000 +0000 @@ -1761,7 +1761,10 @@ if(pt->partno != 1) { for(j = 1; j <= CLI_DEFAULT_AC_TRACKLEN + 1 && offmatrix[pt->partno - 2][j] != -1; j++) { found = j; - if(pt->maxdist) + if(realoff < offmatrix[pt->partno - 2][j]) + found = 0; + + if(found && pt->maxdist) if(realoff - offmatrix[pt->partno - 2][j] > pt->maxdist) found = 0; @@ -2138,7 +2141,7 @@ s = cli_mpool_hex2ui(root->mempool, subexpr); if (!s) { - free(newnode); + mpool_free(root->mempool, newnode); return CL_EMALFDB; } @@ -2584,8 +2587,9 @@ if (nest > ACPATT_ALTN_MAXNEST) { cli_errmsg("ac_addspecial: Expression exceeds maximum alternate nesting limit\n"); - free(hexcpy); - return CL_EMALFDB; + mpool_free(root->mempool, newspecial); + error = CL_EMALFDB; + break; } if(!strcmp(pt, "B")) { diff -Nru clamav-0.99.2+dfsg/libclamav/matcher.c clamav-0.99.3~beta1+dfsg/libclamav/matcher.c --- clamav-0.99.2+dfsg/libclamav/matcher.c 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/matcher.c 2017-06-09 20:02:26.000000000 +0000 @@ -109,7 +109,7 @@ struct cli_pcre_off *poffdata, cli_ctx *ctx) { - int ret; + int ret, saved_ret = CL_CLEAN; int32_t pos = 0; struct filter_match_info info; uint32_t orig_length, orig_offset; @@ -157,25 +157,28 @@ if (SCAN_ALL) viruses_found = 1; else { - cli_append_virus(ctx, *virname); - return ret; + ret = cli_append_virus(ctx, *virname); + if (ret != CL_CLEAN) + return ret; } } } PERF_LOG_TRIES(acmode, 0, length); ret = cli_ac_scanbuff(buffer, length, virname, NULL, acres, root, mdata, offset, ftype, ftoffset, acmode, ctx); - if (ret != CL_CLEAN) { - if (ret != CL_VIRUS) - return ret; - - /* else (ret == CL_VIRUS) */ - if (SCAN_ALL) - viruses_found = 1; - else { - cli_append_virus(ctx, *virname); - return ret; - } - } + if (ret != CL_CLEAN) { + if (ret == CL_VIRUS) { + if (SCAN_ALL) + viruses_found = 1; + else { + ret = cli_append_virus(ctx, *virname); + if (ret != CL_CLEAN) + return ret; + } + } else if (ret > CL_TYPENO && acmode & AC_SCAN_VIR) + saved_ret = ret; + else + return ret; + } /* due to logical triggered, pcres cannot be evaluated until after full subsig matching */ /* cannot save pcre execution state without possible evasion; must scan entire buffer */ @@ -226,10 +229,12 @@ /* end experimental fragment */ if (ctx && !SCAN_ALL && ret == CL_VIRUS) - cli_append_virus(ctx, *virname); + return cli_append_virus(ctx, *virname); if (ctx && SCAN_ALL && viruses_found) return CL_VIRUS; + if (saved_ret && ret == CL_CLEAN) + return saved_ret; return ret; } @@ -498,6 +503,11 @@ int cli_checkfp(unsigned char *digest, size_t size, cli_ctx *ctx) { + return cli_checkfp_virus(digest, size, ctx, NULL); +} + +int cli_checkfp_virus(unsigned char *digest, size_t size, cli_ctx *ctx, const char * vname) +{ char md5[33]; unsigned int i; const char *virname=NULL; @@ -522,11 +532,11 @@ sprintf(md5 + i * 2, "%02x", digest[i]); md5[32] = 0; cli_dbgmsg("FP SIGNATURE: %s:%u:%s\n", md5, (unsigned int) size, - cli_get_last_virus(ctx) ? cli_get_last_virus(ctx) : "Name"); + vname ? vname : "Name"); } - if(cli_get_last_virus(ctx)) - do_dsig_check = strncmp("W32S.", cli_get_last_virus(ctx), 5); + if(vname) + do_dsig_check = strncmp("W32S.", vname, 5); map = *ctx->fmap; have_sha1 = cli_hm_have_size(ctx->engine->hm_fp, CLI_HASH_SHA1, size) @@ -583,7 +593,7 @@ for(i=0; ientry_filename); + cli_errmsg("COLLECT:%s:%s:%u:%s:%s\n", shash256, shash1, size, vname?vname:"noname", ctx->entry_filename); } else cli_errmsg("can't compute sha\n!"); @@ -611,10 +621,10 @@ } if (ctx->engine->cb_hash) - ctx->engine->cb_hash(fmap_fd(*ctx->fmap), size, (const unsigned char *)md5, cli_get_last_virus(ctx), ctx->cb_ctx); + ctx->engine->cb_hash(fmap_fd(*ctx->fmap), size, (const unsigned char *)md5, vname?vname:"noname", ctx->cb_ctx); if (ctx->engine->cb_stats_add_sample) - ctx->engine->cb_stats_add_sample(cli_get_last_virus(ctx), digest, size, §ions, ctx->engine->stats_data); + ctx->engine->cb_stats_add_sample(vname?vname:"noname", digest, size, §ions, ctx->engine->stats_data); if (sections.sections) free(sections.sections); @@ -700,6 +710,23 @@ return ret; } +static int intermediates_eval(cli_ctx *ctx, struct cli_ac_lsig *ac_lsig) +{ + uint32_t i, icnt = ac_lsig->tdb.intermediates[0]; + int32_t j = -1; + + if (ctx->recursion < icnt) + return 0; + + for (i = icnt; i > 0; i--) { + if (ac_lsig->tdb.intermediates[i] == CL_TYPE_ANY) + continue; + if (ac_lsig->tdb.intermediates[i] != cli_get_container_intermediate(ctx, j--)) + return 0; + } + return 1; +} + static int lsig_eval(cli_ctx *ctx, struct cli_matcher *root, struct cli_ac_data *acdata, struct cli_target_info *target_info, const char *hash, uint32_t lsid) { unsigned evalcnt = 0; @@ -714,7 +741,9 @@ if (rc != CL_SUCCESS) return rc; if (cli_ac_chklsig(exp, exp_end, acdata->lsigcnt[lsid], &evalcnt, &evalids, 0) == 1) { - if(ac_lsig->tdb.container && ac_lsig->tdb.container[0] != ctx->container_type) + if(ac_lsig->tdb.container && ac_lsig->tdb.container[0] != cli_get_container(ctx, -1)) + return CL_CLEAN; + if(ac_lsig->tdb.intermediates && !intermediates_eval(ctx, ac_lsig)) return CL_CLEAN; if(ac_lsig->tdb.filesize && (ac_lsig->tdb.filesize[0] > map->len || ac_lsig->tdb.filesize[1] < map->len)) return CL_CLEAN; @@ -746,8 +775,9 @@ return CL_CLEAN; if(matchicon(ctx, &target_info->exeinfo, ac_lsig->tdb.icongrp1, ac_lsig->tdb.icongrp2) == CL_VIRUS) { if(!ac_lsig->bc_idx) { - cli_append_virus(ctx, ac_lsig->virname); - return CL_VIRUS; + rc = cli_append_virus(ctx, ac_lsig->virname); + if (rc != CL_CLEAN) + return rc; } else if(cli_bytecode_runlsig(ctx, target_info, &ctx->engine->bcs, ac_lsig->bc_idx, acdata->lsigcnt[lsid], acdata->lsigsuboff_first[lsid], map) == CL_VIRUS) { return CL_VIRUS; } @@ -755,8 +785,9 @@ return CL_CLEAN; } if(!ac_lsig->bc_idx) { - cli_append_virus(ctx, ac_lsig->virname); - return CL_VIRUS; + rc = cli_append_virus(ctx, ac_lsig->virname); + if (rc != CL_CLEAN) + return rc; } if(cli_bytecode_runlsig(ctx, target_info, &ctx->engine->bcs, ac_lsig->bc_idx, acdata->lsigcnt[lsid], acdata->lsigsuboff_first[lsid], map) == CL_VIRUS) { return CL_VIRUS; @@ -773,12 +804,12 @@ int rc; YR_SCAN_CONTEXT context = {0}; + context.fmap = *ctx->fmap; + context.file_size = (*ctx->fmap)->len; if (target_info != NULL) { - context.file_size = target_info->fsize; if (target_info->status == 1) context.entry_point = target_info->exeinfo.ep; } - context.fmap = *ctx->fmap; rc = yr_execute_code(ac_lsig, acdata, &context, 0, 0); @@ -786,7 +817,7 @@ if (ac_lsig->flag & CLI_LSIG_FLAG_PRIVATE) { rc = CL_CLEAN; } else { - cli_append_virus(ctx, ac_lsig->virname); + rc = cli_append_virus(ctx, ac_lsig->virname); } } return rc; @@ -978,7 +1009,8 @@ if(!ftonly && hdb) { if(!refhash) { - if(cli_hm_have_size(hdb, CLI_HASH_MD5, map->len) || cli_hm_have_size(fp, CLI_HASH_MD5, map->len)) { + if(cli_hm_have_size(hdb, CLI_HASH_MD5, map->len) || cli_hm_have_size(fp, CLI_HASH_MD5, map->len) + || cli_hm_have_wild(hdb, CLI_HASH_MD5) || cli_hm_have_wild(fp, CLI_HASH_MD5)) { compute_hash[CLI_HASH_MD5] = 1; } else { compute_hash[CLI_HASH_MD5] = 0; @@ -1149,19 +1181,18 @@ /* If matched size-based hash ... */ if (found % 2) { viruses_found = 1; - cli_append_virus(ctx, virname); - if (!SCAN_ALL) + ret = cli_append_virus(ctx, virname); + if (!SCAN_ALL || ret != CL_CLEAN) break; virname = NULL; } /* If matched size-agnostic hash ... */ if (found > 1) { viruses_found = 1; - cli_append_virus(ctx, virname_w); - - if (!SCAN_ALL) + ret = cli_append_virus(ctx, virname_w); + if (!SCAN_ALL || ret != CL_CLEAN) break; - } + } } } @@ -1205,26 +1236,27 @@ { const struct cli_cdb *cdb; unsigned int viruses_found = 0; + int ret = CL_CLEAN; cli_dbgmsg("CDBNAME:%s:%llu:%s:%llu:%llu:%d:%u:%u:%p\n", - cli_ftname(ctx->container_type), (long long unsigned)fsizec, fname, (long long unsigned)fsizec, (long long unsigned)fsizer, + cli_ftname(cli_get_container(ctx, -1)), (long long unsigned)fsizec, fname, (long long unsigned)fsizec, (long long unsigned)fsizer, encrypted, filepos, res1, res2); if (ctx->engine && ctx->engine->cb_meta) - if (ctx->engine->cb_meta(cli_ftname(ctx->container_type), fsizec, fname, fsizer, encrypted, filepos, ctx->cb_ctx) == CL_VIRUS) { + if (ctx->engine->cb_meta(cli_ftname(cli_get_container(ctx, -1)), fsizec, fname, fsizer, encrypted, filepos, ctx->cb_ctx) == CL_VIRUS) { cli_dbgmsg("inner file blacklisted by callback: %s\n", fname); - cli_append_virus(ctx, "Detected.By.Callback"); + ret = cli_append_virus(ctx, "Detected.By.Callback"); viruses_found++; - if(!SCAN_ALL) - return CL_VIRUS; + if(!SCAN_ALL || ret != CL_CLEAN) + return ret; } if(!ctx->engine || !(cdb = ctx->engine->cdb)) return CL_CLEAN; do { - if(cdb->ctype != CL_TYPE_ANY && cdb->ctype != ctx->container_type) + if(cdb->ctype != CL_TYPE_ANY && cdb->ctype != cli_get_container(ctx, -1)) continue; if(cdb->encrypted != 2 && cdb->encrypted != encrypted) @@ -1242,7 +1274,7 @@ continue; \ } - CDBRANGE(cdb->csize, ctx->container_size); + CDBRANGE(cdb->csize, cli_get_container_size(ctx, -1)); CDBRANGE(cdb->fsizec, fsizec); CDBRANGE(cdb->fsizer, fsizer); CDBRANGE(cdb->filepos, filepos); @@ -1250,10 +1282,10 @@ if(cdb->name.re_magic && (!fname || cli_regexec(&cdb->name, fname, 0, NULL, 0) == REG_NOMATCH)) continue; - cli_append_virus(ctx, cdb->virname); + ret = cli_append_virus(ctx, cdb->virname); viruses_found++; - if(!SCAN_ALL) - return CL_VIRUS; + if(!SCAN_ALL || ret != CL_CLEAN) + return ret; } while((cdb = cdb->next)); diff -Nru clamav-0.99.2+dfsg/libclamav/matcher.h clamav-0.99.3~beta1+dfsg/libclamav/matcher.h --- clamav-0.99.2+dfsg/libclamav/matcher.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/matcher.h 2017-04-20 22:19:13.000000000 +0000 @@ -54,11 +54,12 @@ #define CLI_MATCH_NIBBLE_LOW 0x0400 struct cli_lsig_tdb { -#define CLI_TDB_UINT 0 -#define CLI_TDB_RANGE 1 -#define CLI_TDB_STR 2 -#define CLI_TDB_RANGE2 3 -#define CLI_TDB_FTYPE 4 +#define CLI_TDB_UINT 0 +#define CLI_TDB_RANGE 1 +#define CLI_TDB_STR 2 +#define CLI_TDB_RANGE2 3 +#define CLI_TDB_FTYPE 4 +#define CLI_TDB_FTYPE_EXPR 5 uint32_t *val, *range; char *str; uint32_t cnt[3]; @@ -67,6 +68,7 @@ const uint32_t *target; const uint32_t *engine, *nos, *ep, *filesize; const uint32_t *container, *handlertype; + const uint32_t *intermediates; /* const uint32_t *sectoff, *sectrva, *sectvsz, *sectraw, *sectrsz, *secturva, *sectuvsz, *secturaw, *sectursz; @@ -131,6 +133,9 @@ uint32_t pcre_reloff_num, pcre_absoff_num; #endif + /* Bytecode Tracker */ + uint32_t linked_bcs; + #ifdef USE_MPOOL mpool_t *mempool; #endif @@ -203,6 +208,7 @@ int cli_caloff(const char *offstr, const struct cli_target_info *info, unsigned int target, uint32_t *offdata, uint32_t *offset_min, uint32_t *offset_max); int cli_checkfp(unsigned char *digest, size_t size, cli_ctx *ctx); +int cli_checkfp_virus(unsigned char *digest, size_t size, cli_ctx *ctx, const char * vname); int cli_matchmeta(cli_ctx *ctx, const char *fname, size_t fsizec, size_t fsizer, int encrypted, unsigned int filepos, int res1, void *res2); diff -Nru clamav-0.99.2+dfsg/libclamav/matcher-hash.c clamav-0.99.3~beta1+dfsg/libclamav/matcher-hash.c --- clamav-0.99.2+dfsg/libclamav/matcher-hash.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/matcher-hash.c 2016-10-13 15:45:44.000000000 +0000 @@ -232,6 +232,10 @@ return (root && root->hwild.hashes[type].items); } +int cli_hm_have_any(const struct cli_matcher *root, enum CLI_HASH_TYPE type) { + return (root && (root->hwild.hashes[type].items || root->hm.sizehashes[type].capacity)); +} + /* cli_hm_scan will scan only size-specific hashes, if any */ static int hm_scan(const unsigned char *digest, const char **virname, const struct cli_sz_hash *szh, enum CLI_HASH_TYPE type) { unsigned int keylen; diff -Nru clamav-0.99.2+dfsg/libclamav/matcher-hash.h clamav-0.99.3~beta1+dfsg/libclamav/matcher-hash.h --- clamav-0.99.2+dfsg/libclamav/matcher-hash.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/matcher-hash.h 2016-10-13 15:45:44.000000000 +0000 @@ -64,6 +64,7 @@ int cli_hm_scan_wild(const unsigned char *digest, const char **virname, const struct cli_matcher *root, enum CLI_HASH_TYPE type); int cli_hm_have_size(const struct cli_matcher *root, enum CLI_HASH_TYPE type, uint32_t size); int cli_hm_have_wild(const struct cli_matcher *root, enum CLI_HASH_TYPE type); +int cli_hm_have_any(const struct cli_matcher *root, enum CLI_HASH_TYPE type); void hm_free(struct cli_matcher *root); #endif diff -Nru clamav-0.99.2+dfsg/libclamav/matcher-pcre.c clamav-0.99.3~beta1+dfsg/libclamav/matcher-pcre.c --- clamav-0.99.2+dfsg/libclamav/matcher-pcre.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/matcher-pcre.c 2017-04-20 22:19:13.000000000 +0000 @@ -444,7 +444,7 @@ ret = cli_pcre_compile(&(pm->pdata), match_limit, recmatch_limit, 0, 0); } else { - /* compile the regex, options overrided and disabled */ + /* compile the regex, options overridden and disabled */ pm_dbgmsg("cli_pcre_build: Compiling regex: /%s/ (without options)\n", pm->pdata.expression); ret = cli_pcre_compile(&(pm->pdata), match_limit, recmatch_limit, 0, 1); } @@ -627,7 +627,7 @@ continue; } else { - cli_dbgmsg("cli_pcre_scanbuf: skipping %s check due to unintialized lsigid\n", pm->trigger); + cli_dbgmsg("cli_pcre_scanbuf: skipping %s check due to uninitialized lsigid\n", pm->trigger); /* fall-through to unconditional execution - sigtool-only */ } @@ -738,16 +738,15 @@ newres->offset = adjbuffer+p_res.match[0]; *res = newres; } else { - if (ctx && SCAN_ALL) { - viruses_found = 1; - cli_append_virus(ctx, (const char *)pm->virname); - } + ret = CL_CLEAN; + viruses_found = 1; + if (ctx) + ret = cli_append_virus(ctx, (const char *)pm->virname); if (virname) *virname = pm->virname; - if (!ctx || !SCAN_ALL) { - ret = CL_VIRUS; - break; - } + if (!ctx || !SCAN_ALL) + if (ret != CL_CLEAN) + break; } } } diff -Nru clamav-0.99.2+dfsg/libclamav/mbox.c clamav-0.99.3~beta1+dfsg/libclamav/mbox.c --- clamav-0.99.2+dfsg/libclamav/mbox.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/mbox.c 2017-04-20 22:19:13.000000000 +0000 @@ -70,6 +70,20 @@ #include "mbox.h" #include "dconf.h" #include "fmap.h" +#include "json_api.h" +#include "msxml_parser.h" + +#if HAVE_LIBXML2 +#ifdef _WIN32 +#ifndef LIBXML_WRITER_ENABLED +#define LIBXML_WRITER_ENABLED 1 +#endif +#endif +#include +#include +#include +#include +#endif #define DCONF_PHISHING mctx->ctx->dconf->phishing @@ -168,6 +182,9 @@ const table_t *subtypeTable; cli_ctx *ctx; unsigned int files; /* number of files extracted */ +#if HAVE_JSON + json_object *wrkobj; +#endif } mbox_ctx; /* if supported by the system, use the optimized @@ -187,6 +204,8 @@ static message *parseEmailFile(fmap_t *map, size_t *at, const table_t *rfc821Table, const char *firstLine, const char *dir); static message *parseEmailHeaders(message *m, const table_t *rfc821Table); static int parseEmailHeader(message *m, const char *line, const table_t *rfc821Table); +static int parseMHTMLComment(const char *comment, cli_ctx *ctx, void *wrkjobj, void *cbdata); +static mbox_status parseRootMHTML(mbox_ctx *mctx, message *m, text *t); static mbox_status parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int recursion_level); static int boundaryStart(const char *line, const char *boundary); static int boundaryEnd(const char *line, const char *boundary); @@ -203,6 +222,8 @@ static bool isBounceStart(mbox_ctx *mctx, const char *line); static bool exportBinhexMessage(mbox_ctx *mctx, message *m); static int exportBounceMessage(mbox_ctx *ctx, text *start); +static const char *getMimeTypeStr(mime_type mimetype); +static const char *getEncTypeStr(encoding_type enctype); static message *do_multipart(message *mainMessage, message **messages, int i, mbox_status *rc, mbox_ctx *mctx, message *messageIn, text **tptr, unsigned int recursion_level); static int count_quotes(const char *buf); static bool next_is_folded_header(const text *t); @@ -292,6 +313,28 @@ { "knowbot-code", KNOWBOT }, /* ??? */ { "knowbot-state", KNOWBOT }, /* ??? */ { NULL, 0 } +}, mimeTypeStr[] = { + { "NOMIME", NOMIME }, + { "APPLICATION", APPLICATION }, + { "AUDIO", AUDIO }, + { "IMAGE", IMAGE }, + { "MESSAGE", MESSAGE }, + { "MULTIPART", MULTIPART }, + { "TEXT", TEXT }, + { "VIDEO", VIDEO }, + { "MEXTENSION", MEXTENSION }, + { NULL, 0 } +}, encTypeStr[] = { + { "NOENCODING", NOENCODING }, + { "QUOTEDPRINTABLE", QUOTEDPRINTABLE }, + { "BASE64", BASE64 }, + { "EIGHTBIT", EIGHTBIT }, + { "BINARY", BINARY }, + { "UUENCODE", UUENCODE }, + { "YENCODE", YENCODE }, + { "EEXTENSION", EEXTENSION }, + { "BINHEX", BINHEX }, + { NULL, 0 } }; #ifdef CL_THREAD_SAFE @@ -368,6 +411,9 @@ mctx.subtypeTable = subtype; mctx.ctx = ctx; mctx.files = 0; +#if HAVE_JSON + mctx.wrkobj = ctx->wrkproperty; +#endif /* * Is it a UNIX style mbox with more than one @@ -544,9 +590,8 @@ if((retcode == CL_CLEAN) && ctx->found_possibly_unwanted && (*ctx->virname == NULL || SCAN_ALL)) { - cli_append_virus(ctx, "Heuristics.Phishing.Email"); + retcode = cli_append_virus(ctx, "Heuristics.Phishing.Email"); ctx->found_possibly_unwanted = 0; - retcode = CL_VIRUS; } cli_dbgmsg("cli_mbox returning %d\n", retcode); @@ -1000,7 +1045,7 @@ * In RFC822 the separater between the key a value is a colon, * e.g. Content-Transfer-Encoding: base64 * However some MUA's are lapse about this and virus writers exploit - * this hole, so we need to check all known possiblities + * this hole, so we need to check all known possibilities */ for(separater = ":= "; *separater; separater++) if(strchr(line, *separater) != NULL) @@ -1046,6 +1091,222 @@ return ret; } +#if HAVE_LIBXML2 +static const struct key_entry mhtml_keys[] = { + /* root html tags for microsoft office document */ + { "html", "RootHTML", MSXML_JSON_ROOT | MSXML_JSON_ATTRIB }, + + { "head", "Head", MSXML_JSON_WRKPTR | MSXML_COMMENT_CB }, + { "meta", "Meta", MSXML_JSON_WRKPTR | MSXML_JSON_MULTI | MSXML_JSON_ATTRIB }, + { "link", "Link", MSXML_JSON_WRKPTR | MSXML_JSON_MULTI | MSXML_JSON_ATTRIB }, + { "script", "Script", MSXML_JSON_WRKPTR | MSXML_JSON_MULTI | MSXML_JSON_VALUE } +}; +static size_t num_mhtml_keys = sizeof(mhtml_keys) / sizeof(struct key_entry); + +static const struct key_entry mhtml_comment_keys[] = { + /* embedded xml tags (comment) for microsoft office document */ + { "o:documentproperties", "DocumentProperties", MSXML_JSON_ROOT | MSXML_JSON_ATTRIB }, + { "o:author", "Author", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:lastauthor", "LastAuthor", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:revision", "Revision", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:totaltime", "TotalTime", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:created", "Created", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:lastsaved", "LastSaved", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:pages", "Pages", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:words", "Words", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:characters", "Characters", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:company", "Company", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:lines", "Lines", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:paragraphs", "Paragraphs", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:characterswithspaces", "CharactersWithSpaces", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + { "o:version", "Version", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE }, + + { "o:officedocumentsettings", "DocumentSettings", MSXML_IGNORE_ELEM }, + { "w:worddocument", "WordDocument", MSXML_IGNORE_ELEM }, + { "w:latentstyles", "LatentStyles", MSXML_IGNORE_ELEM } +}; +static size_t num_mhtml_comment_keys = sizeof(mhtml_comment_keys) / sizeof(struct key_entry); +#endif + +/* + * The related multipart root HTML file comment parsing wrapper. + * + * Attempts to leverage msxml parser, cannot operate without LIBXML2. + * This function is only used for Preclassification JSON. + */ +static int +parseMHTMLComment(const char *comment, cli_ctx *ctx, void *wrkjobj, void *cbdata) +{ +#if HAVE_LIBXML2 + const char *xmlsrt, *xmlend; + xmlTextReaderPtr reader; +#if HAVE_JSON + json_object *thisjobj = (json_object *)wrkjobj; +#endif + int ret = CL_SUCCESS; + + UNUSEDPARAM(cbdata); + + xmlend = comment; + while ((xmlsrt = strstr(xmlend, ""))) { + xmlend = strstr(xmlsrt, ""); + if (xmlend == NULL) { + cli_dbgmsg("parseMHTMLComment: unbounded xml tag\n"); + break; + } + + reader = xmlReaderForMemory(xmlsrt, xmlend-xmlsrt+6, "comment.xml", NULL, CLAMAV_MIN_XMLREADER_FLAGS); + if (!reader) { + cli_dbgmsg("parseMHTMLComment: cannot intialize xmlReader\n"); + +#if HAVE_JSON + ret = cli_json_parse_error(ctx->wrkproperty, "MHTML_ERROR_XML_READER_MEM"); +#endif + return ret; // libxml2 failed! + } + + /* comment callback is not set to prevent recursion */ + /* TODO: should we separate the key dictionaries? */ + /* TODO: should we use the json object pointer? */ + ret = cli_msxml_parse_document(ctx, reader, mhtml_comment_keys, num_mhtml_comment_keys, MSXML_FLAG_JSON, NULL); + + xmlTextReaderClose(reader); + xmlFreeTextReader(reader); + if (ret != CL_SUCCESS) + return ret; + } +#else + UNUSEDPARAM(comment); + UNUSEDPARAM(ctx); + UNUSEDPARAM(wrkjobj); + UNUSEDPARAM(cbdata); + + cli_dbgmsg("in parseMHTMLComment\n"); + cli_dbgmsg("parseMHTMLComment: parsing html xml-comments requires libxml2!\n"); +#endif + return CL_SUCCESS; +} + +/* + * The related multipart root HTML file parsing wrapper. + * + * Attempts to leverage msxml parser, cannot operate without LIBXML2. + * This function is only used for Preclassification JSON. + */ +static mbox_status +parseRootMHTML(mbox_ctx *mctx, message *m, text *t) +{ + cli_ctx *ctx = mctx->ctx; +#if HAVE_LIBXML2 +#ifdef LIBXML_HTML_ENABLED + struct msxml_ctx mxctx; + blob *input; + htmlDocPtr htmlDoc; + xmlTextReaderPtr reader; + int ret = CL_SUCCESS; + mbox_status rc = OK; +#if HAVE_JSON + json_object *rhtml; +#endif + + cli_dbgmsg("in parseRootMHTML\n"); + + if (ctx == NULL) + return OK; + + if (m == NULL && t == NULL) + return OK; + + if (m != NULL) + input = messageToBlob(m, 0); + else if (t != NULL) + input = textToBlob(t, NULL, 0); + if (input == NULL) + return OK; + + htmlDoc = htmlReadMemory(input->data, input->len, "mhtml.html", NULL, CLAMAV_MIN_XMLREADER_FLAGS); + if (htmlDoc == NULL) { + cli_dbgmsg("parseRootMHTML: cannot intialize read html document\n"); +#if HAVE_JSON + ret = cli_json_parse_error(ctx->wrkproperty, "MHTML_ERROR_HTML_READ"); + if (ret != CL_SUCCESS) + rc = FAIL; +#endif + blobDestroy(input); + return rc; + } + +#if HAVE_JSON + if (mctx->wrkobj) { + rhtml = cli_jsonobj(mctx->wrkobj, "RootHTML"); + if (rhtml != NULL) { + /* MHTML-specific properties */ + cli_jsonstr(rhtml, "Encoding", htmlGetMetaEncoding(htmlDoc)); + cli_jsonint(rhtml, "CompressMode", xmlGetDocCompressMode(htmlDoc)); + } + } +#endif + + reader = xmlReaderWalker(htmlDoc); + if (reader == NULL) { + cli_dbgmsg("parseRootMHTML: cannot intialize xmlTextReader\n"); +#if HAVE_JSON + ret = cli_json_parse_error(ctx->wrkproperty, "MHTML_ERROR_XML_READER_IO"); + if (ret != CL_SUCCESS) + rc = FAIL; +#endif + blobDestroy(input); + return rc; + } + + memset(&mxctx, 0, sizeof(mxctx)); + /* no scanning callback set */ + mxctx.comment_cb = parseMHTMLComment; + ret = cli_msxml_parse_document(ctx, reader, mhtml_keys, num_mhtml_keys, MSXML_FLAG_JSON | MSXML_FLAG_WALK, &mxctx); + switch (ret) { + case CL_SUCCESS: + case CL_ETIMEOUT: + case CL_BREAK: + rc = OK; + break; + + case CL_EMAXREC: + rc = MAXREC; + break; + + case CL_EMAXFILES: + rc = MAXFILES; + break; + + case CL_VIRUS: + rc = CL_VIRUS; + break; + + default: + rc = FAIL; + } + + xmlTextReaderClose(reader); + xmlFreeTextReader(reader); + xmlFreeDoc(htmlDoc); + blobDestroy(input); + return rc; +#else /* LIBXML_HTML_ENABLED */ + UNUSEDPARAM(m); + UNUSEDPARAM(t); + cli_dbgmsg("in parseRootMHTML\n"); + cli_dbgmsg("parseRootMHTML: parsing html documents disabled in libxml2!\n"); +#endif /* LIBXML_HTML_ENABLED */ +#else /* HAVE_LIBXML2 */ + UNUSEDPARAM(m); + UNUSEDPARAM(t); + cli_dbgmsg("in parseRootMHTML\n"); + cli_dbgmsg("parseRootMHTML: parsing html documents requires libxml2!\n"); + + return OK; +#endif /* HAVE_LIBXML2 */ +} + /* * This is a recursive routine. * @@ -1066,6 +1327,9 @@ bool infected = FALSE; const struct cl_engine *engine = mctx->ctx->engine; const int doPhishingScan = engine->dboptions&CL_DB_PHISHING_URLS && (DCONF_PHISHING & PHISHING_CONF_ENGINE); +#if HAVE_JSON + json_object *saveobj = mctx->wrkobj; +#endif cli_dbgmsg("in parseEmailBody, %u files saved so far\n", mctx->files); @@ -1107,6 +1371,17 @@ mimeType = messageGetMimeType(mainMessage); mimeSubtype = messageGetMimeSubtype(mainMessage); +#if HAVE_JSON + if (mctx->wrkobj != NULL) { + mctx->wrkobj = cli_jsonobj(mctx->wrkobj, "Body"); + cli_jsonstr(mctx->wrkobj, "MimeType", getMimeTypeStr(mimeType)); + cli_jsonstr(mctx->wrkobj, "MimeSubtype", mimeSubtype); + cli_jsonstr(mctx->wrkobj, "EncodingType", getEncTypeStr(messageGetEncoding(mainMessage))); + cli_jsonstr(mctx->wrkobj, "Disposition", messageGetDispositionType(mainMessage)); + cli_jsonstr(mctx->wrkobj, "Filename", messageHasFilename(mainMessage) ? + messageGetFilename(mainMessage): "(inline)"); + } +#endif /* pre-process */ subtype = tableFind(mctx->subtypeTable, mimeSubtype); @@ -1164,6 +1439,10 @@ cli_dbgmsg("Content-type 'multipart' handler\n"); boundary = messageFindArgument(mainMessage, "boundary"); +#if HAVE_JSON + cli_jsonstr(mctx->wrkobj, "Boundary", boundary); +#endif + if(boundary == NULL) { cli_dbgmsg("Multipart/%s MIME message contains no boundary header\n", mimeSubtype); @@ -1176,7 +1455,7 @@ break; } - cli_chomp(boundary); + cli_chomp(boundary); /* Perhaps it should assume mixed? */ if(mimeSubtype[0] == '\0') { @@ -1457,7 +1736,7 @@ */ while(t_line && next_is_folded_header(t_line)) { const char *data; - size_t datasz; + size_t datasz; t_line = t_line->t_next; @@ -1476,7 +1755,7 @@ break; } - datasz = strlen(fullline) + strlen(data) + 1; + datasz = strlen(fullline) + strlen(data) + 1; ptr = cli_realloc(fullline, datasz); if(ptr == NULL) @@ -1610,6 +1889,9 @@ if(aText && (textIn == NULL)) textDestroy(aText); +#if HAVE_JSON + mctx->wrkobj = saveobj; +#endif /* * Nothing to do */ @@ -1660,6 +1942,11 @@ if(htmltextPart == -1) cli_dbgmsg("No HTML code found to be scanned\n"); else { +#if HAVE_JSON + /* Send root HTML file for preclassification */ + if (mctx->ctx->wrkproperty) + parseRootMHTML(mctx, aMessage, aText); +#endif rc = parseEmailBody(aMessage, aText, mctx, recursion_level + 1); if((rc == OK) && aMessage) { assert(aMessage == messages[htmltextPart]); @@ -1790,6 +2077,9 @@ if(messages) free(messages); +#if HAVE_JSON + mctx->wrkobj = saveobj; +#endif return rc; case MESSAGE: @@ -1848,6 +2138,9 @@ messageDestroy(mainMessage); if(messages) free(messages); +#if HAVE_JSON + mctx->wrkobj = saveobj; +#endif return rc; default: @@ -2118,6 +2411,10 @@ if((rc != FAIL) && infected) rc = VIRUS; +#if HAVE_JSON + mctx->wrkobj = saveobj; +#endif + cli_dbgmsg("parseEmailBody() returning %d\n", (int)rc); return rc; @@ -2137,7 +2434,7 @@ char buf[RFC2821LENGTH + 1]; char *newline; - if(line == NULL) + if(line == NULL || *line == '\0') return 0; /* empty line */ if(boundary == NULL) return 0; @@ -2146,10 +2443,10 @@ if (!(newline)) newline = (char *)line; - if (newline != line && strlen(newline)) { + if (newline != line && strlen(line)) { char *p; /* Trim trailing spaces */ - p = newline + strlen(newline)-1; + p = newline + strlen(line); while (p >= newline && *p == ' ') *(p--) = '\0'; } @@ -2261,7 +2558,7 @@ size_t len; char *newline, *p, *p2; - if(line == NULL) + if(line == NULL || *line == '\0') return 0; p = newline = strdup(line); @@ -2270,9 +2567,9 @@ newline = (char *)line; } - if (newline != line && strlen(newline)) { + if (newline != line && strlen(line)) { /* Trim trailing spaces */ - p2 = newline + strlen(newline)-1; + p2 = newline + strlen(line); while (p2 >= newline && *p2 == ' ') *(p2--) = '\0'; } @@ -3510,6 +3807,36 @@ } /* + * Get string representation of mimetype + */ +static const char *getMimeTypeStr(mime_type mimetype) +{ + const struct tableinit *entry = mimeTypeStr; + + while (entry->key) { + if (mimetype == entry->value) + return entry->key; + entry++; + } + return "UNKNOWN"; +} + +/* + * Get string representation of encoding type + */ +static const char *getEncTypeStr(encoding_type enctype) +{ + const struct tableinit *entry = encTypeStr; + + while (entry->key) { + if (enctype == entry->value) + return entry->key; + entry++; + } + return "UNKNOWN"; +} + +/* * Handle the ith element of a number of multiparts, e.g. multipart/alternative */ static message * @@ -3522,9 +3849,39 @@ #endif message *aMessage = messages[i]; const int doPhishingScan = mctx->ctx->engine->dboptions&CL_DB_PHISHING_URLS && (DCONF_PHISHING&PHISHING_CONF_ENGINE); +#if HAVE_JSON + const char *mtype = NULL; + json_object *thisobj = NULL, *saveobj = mctx->wrkobj; + + if (mctx->wrkobj != NULL) { + json_object *multiobj = cli_jsonarray(mctx->wrkobj, "Multipart"); + if (multiobj == NULL) { + cli_errmsg("Cannot get multipart preclass array\n"); + *rc = -1; + return mainMessage; + } + + thisobj = messageGetJObj(aMessage); + if (thisobj == NULL) { + cli_errmsg("Cannot get message preclass object\n"); + *rc = -1; + return mainMessage; + } + if (cli_json_addowner(multiobj, thisobj, NULL, -1) != CL_SUCCESS) { + cli_errmsg("Cannot assign message preclass object to multipart preclass array\n"); + *rc = -1; + return mainMessage; + } + } +#endif - if(aMessage == NULL) + if(aMessage == NULL) { +#if HAVE_JSON + if (thisobj != NULL) + cli_jsonstr(thisobj, "MimeType", "NULL"); +#endif return mainMessage; + } if(*rc != OK) return mainMessage; @@ -3532,6 +3889,17 @@ cli_dbgmsg("Mixed message part %d is of type %d\n", i, messageGetMimeType(aMessage)); +#if HAVE_JSON + if (thisobj != NULL) { + cli_jsonstr(thisobj, "MimeType", getMimeTypeStr(messageGetMimeType(aMessage))); + cli_jsonstr(thisobj, "MimeSubtype", messageGetMimeSubtype(aMessage)); + cli_jsonstr(thisobj, "EncodingType", getEncTypeStr(messageGetEncoding(aMessage))); + cli_jsonstr(thisobj, "Disposition", messageGetDispositionType(aMessage)); + cli_jsonstr(thisobj, "Filename", messageHasFilename(aMessage) ? + messageGetFilename(aMessage): "(inline)"); + } +#endif + switch(messageGetMimeType(aMessage)) { case APPLICATION: case AUDIO: @@ -3666,6 +4034,9 @@ assert(aMessage == messages[i]); messageDestroy(messages[i]); messages[i] = NULL; +#if HAVE_JSON + mctx->wrkobj = thisobj; +#endif if(body) { messageSetCTX(body, mctx->ctx); *rc = parseEmailBody(body, NULL, mctx, recursion_level + 1); @@ -3673,6 +4044,9 @@ *rc = VIRUS; messageDestroy(body); } +#if HAVE_JSON + mctx->wrkobj = saveobj; +#endif #endif return mainMessage; case MULTIPART: @@ -3682,6 +4056,9 @@ * be an attachment */ cli_dbgmsg("Found multipart inside multipart\n"); +#if HAVE_JSON + mctx->wrkobj = thisobj; +#endif if(aMessage) { /* * The headers were parsed when reading in the @@ -3698,6 +4075,9 @@ messageDestroy(mainMessage); mainMessage = NULL; } +#if HAVE_JSON + mctx->wrkobj = saveobj; +#endif return mainMessage; default: cli_dbgmsg("Only text and application attachments are fully supported, type = %d\n", @@ -3707,7 +4087,17 @@ if(*rc != VIRUS) { fileblob *fb = messageToFileblob(aMessage, mctx->dir, 1); +#if HAVE_JSON + json_object *arrobj; + int arrlen = 0; + + if (thisobj != NULL) { + /* attempt to determine container size - prevents incorrect type reporting */ + if (json_object_object_get_ex(mctx->ctx->wrkproperty, "ContainedObjects", &arrobj)) + arrlen = json_object_array_length(arrobj); + } +#endif if(fb) { /* aMessage doesn't always have a ctx set */ fileblobSetCTX(fb, mctx->ctx); @@ -3716,6 +4106,24 @@ if (!addToText) mctx->files++; } +#if HAVE_JSON + if (thisobj != NULL) { + json_object *entry = NULL; + const char *dtype = NULL; + + /* attempt to acquire container type */ + if (json_object_object_get_ex(mctx->ctx->wrkproperty, "ContainedObjects", &arrobj)) + if (json_object_array_length(arrobj) > arrlen) + entry = json_object_array_get_idx(arrobj, arrlen); + if (entry) { + json_object_object_get_ex(entry, "FileType", &entry); + if (entry) + dtype = json_object_get_string(entry); + } + cli_jsonint(thisobj, "ContainedObjectsIndex", arrlen); + cli_jsonstr(thisobj, "ClamAVFileType", dtype ? dtype : "UNKNOWN"); + } +#endif if(messageContainsVirus(aMessage)) *rc = VIRUS; } diff -Nru clamav-0.99.2+dfsg/libclamav/mbr.c clamav-0.99.3~beta1+dfsg/libclamav/mbr.c --- clamav-0.99.2+dfsg/libclamav/mbr.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/mbr.c 2017-04-20 22:19:13.000000000 +0000 @@ -134,7 +134,7 @@ return mbr_check_mbr(&mbr, maplen, sectorsize); } -/* sets sectorsize to default value if specfied to be 0 */ +/* sets sectorsize to default value if specified to be 0 */ int cli_scanmbr(cli_ctx *ctx, size_t sectorsize) { struct mbr_boot_record mbr; @@ -225,7 +225,7 @@ cli_dbgmsg("cli_scanmbr: detected a master boot record " "with multiple extended partitions\n"); } - state = SEEN_EXTENDED; /* used only to detect mutiple extended partitions */ + state = SEEN_EXTENDED; /* used only to detect multiple extended partitions */ ret = mbr_scanextprtn(ctx, &prtncount, mbr.entries[i].firstLBA, mbr.entries[i].numLBA, sectorsize); @@ -502,23 +502,17 @@ tmp = prtn_intxn_list_check(&prtncheck, &pitxn, mbr.entries[i].firstLBA, mbr.entries[i].numLBA); if (tmp != CL_CLEAN) { - if ((ctx->options & CL_SCAN_ALLMATCHES) && (tmp == CL_VIRUS)) { + if (tmp == CL_VIRUS) { cli_dbgmsg("cli_scanmbr: detected intersection with partitions " "[%u, %u]\n", pitxn, i); - cli_append_virus(ctx, PRTN_INTXN_DETECTION); + ret = cli_append_virus(ctx, PRTN_INTXN_DETECTION); + if (SCAN_ALL || ret == CL_CLEAN) + tmp = 0; + else + goto leave; + } else { ret = tmp; - tmp = 0; - } - else if (tmp == CL_VIRUS) { - cli_dbgmsg("cli_scanmbr: detected intersection with partitions " - "[%u, %u]\n", pitxn, i); - cli_append_virus(ctx, PRTN_INTXN_DETECTION); - prtn_intxn_list_free(&prtncheck); - return CL_VIRUS; - } - else { - prtn_intxn_list_free(&prtncheck); - return tmp; + goto leave; } } @@ -547,6 +541,7 @@ } } +leave: prtn_intxn_list_free(&prtncheck); return ret; } @@ -559,6 +554,7 @@ unsigned i, pitxn; int ret = CL_CLEAN, tmp = CL_CLEAN, mbr_base = 0; off_t pos = 0, logiclba = 0; + int virus_found = 0; mbr_base = sectorsize - sizeof(struct mbr_boot_record); @@ -585,23 +581,19 @@ /* assume that logical record is first and extended is second */ tmp = prtn_intxn_list_check(&prtncheck, &pitxn, logiclba, ebr.entries[0].numLBA); if (tmp != CL_CLEAN) { - if ((ctx->options & CL_SCAN_ALLMATCHES) && (tmp == CL_VIRUS)) { + if (tmp == CL_VIRUS) { cli_dbgmsg("cli_scanebr: detected intersection with partitions " "[%u, %u]\n", pitxn, i); - cli_append_virus(ctx, PRTN_INTXN_DETECTION); + ret = cli_append_virus(ctx, PRTN_INTXN_DETECTION); + if (ret == CL_VIRUS) + virus_found = 1; + if (SCAN_ALL || ret == CL_CLEAN) + tmp = 0; + else + goto leave; + } else { ret = tmp; - tmp = 0; - } - else if (tmp == CL_VIRUS) { - cli_dbgmsg("cli_scanebr: detected intersection with partitions " - "[%u, %u]\n", pitxn, i); - cli_append_virus(ctx, PRTN_INTXN_DETECTION); - prtn_intxn_list_free(&prtncheck); - return CL_VIRUS; - } - else { - prtn_intxn_list_free(&prtncheck); - return tmp; + goto leave; } } @@ -616,6 +608,9 @@ ++i; } while (logiclba != 0 && (*prtncount) < ctx->engine->maxpartitions); - prtn_intxn_list_free(&prtncheck); + leave: + prtn_intxn_list_free(&prtncheck); + if (virus_found) + return CL_VIRUS; return ret; } diff -Nru clamav-0.99.2+dfsg/libclamav/message.c clamav-0.99.3~beta1+dfsg/libclamav/message.c --- clamav-0.99.2+dfsg/libclamav/message.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/message.c 2017-03-08 14:06:34.000000000 +0000 @@ -53,6 +53,7 @@ #include "mbox.h" #include "clamav.h" +#include "json_api.h" #ifndef isblank #define isblank(c) (((c) == ' ') || ((c) == '\t')) @@ -199,6 +200,11 @@ free(m->encodingTypes); } +#if HAVE_JSON + if(m->jobj) + cli_json_delobj(m->jobj); +#endif + memset(m, '\0', sizeof(message)); m->mimeType = NOMIME; } @@ -439,8 +445,12 @@ * FIXME: Bounce message handling is corrupting the in * core copies of headers */ - cli_dbgmsg("Possible data corruption fixed\n"); - p[8] = '='; + if (strlen(p) > 8) { + cli_dbgmsg("Possible data corruption fixed\n"); + p[8] = '='; + } else { + cli_dbgmsg("Possible data corruption not fixed\n"); + } } else { if(*p) cli_dbgmsg("messageAddArgument, '%s' contains no '='\n", p); @@ -676,7 +686,7 @@ cli_dbgmsg("messageFindArgument: no '=' sign found in MIME header '%s' (%s)\n", variable, messageGetArgument(m, i)); return NULL; } - if((*++ptr == '"') && (strchr(&ptr[1], '"') != NULL)) { + if((strlen(ptr) > 2) && (*++ptr == '"') && (strchr(&ptr[1], '"') != NULL)) { /* Remove any quote characters */ char *ret = cli_strdup(++ptr); char *p; @@ -2630,3 +2640,15 @@ isdigit(line[6]) && isdigit(line[7]) && isdigit(line[8]) && (line[9] == ' '); } + +#if HAVE_JSON +json_object *messageGetJObj(message *m) +{ + assert(m != NULL); + + if(m->jobj == NULL) + m->jobj = cli_jsonobj(NULL, NULL); + + return m->jobj; +} +#endif diff -Nru clamav-0.99.2+dfsg/libclamav/message.h clamav-0.99.3~beta1+dfsg/libclamav/message.h --- clamav-0.99.2+dfsg/libclamav/message.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/message.h 2016-10-13 15:45:44.000000000 +0000 @@ -22,6 +22,8 @@ #ifndef _MESSAGE_H #define _MESSAGE_H +#include "json_api.h" + /* The contents could change, ONLY access in message.c */ typedef struct message { encoding_type *encodingTypes; @@ -49,6 +51,9 @@ unsigned int isInfected : 1; unsigned int isTruncated : 1; +#if HAVE_JSON + json_object *jobj; +#endif } message; message *messageCreate(void); @@ -85,5 +90,8 @@ void messageSetCTX(message *m, cli_ctx *ctx); int messageContainsVirus(const message *m); int messageSavePartial(message *m, const char *dir, const char *id, unsigned part); +#if HAVE_JSON +json_object *messageGetJObj(message *m); +#endif #endif /*_MESSAGE_H*/ diff -Nru clamav-0.99.2+dfsg/libclamav/mpool.c clamav-0.99.3~beta1+dfsg/libclamav/mpool.c --- clamav-0.99.2+dfsg/libclamav/mpool.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/mpool.c 2017-07-31 18:34:32.000000000 +0000 @@ -364,6 +364,17 @@ 134217728, }; #endif + +#if defined(C_SOLARIS) +size_t strnlen(const char *s, size_t n) __attribute__((weak)); +size_t strnlen(const char *s, size_t n) +{ + size_t i = 0; + for(; (i < n) && s[i] != '\0'; ++i); + return i; +} +#endif + #define FRAGSBITS (sizeof(fragsz)/sizeof(fragsz[0])) struct MPMAP { @@ -785,6 +796,25 @@ return alloc; } +char *cli_mpool_strndup(mpool_t *mp, const char *s, size_t n) { + char *alloc; + size_t strsz; + + if(s == NULL) { + cli_errmsg("cli_mpool_strndup(): s == NULL. Please report to http://bugs.clamav.net\n"); + return NULL; + } + + strsz = strnlen(s, n) + 1; + alloc = mpool_malloc(mp, strsz); + if(!alloc) + cli_errmsg("cli_mpool_strndup(): Can't allocate memory (%lu bytes).\n", (unsigned long) strsz); + else + memcpy(alloc, s, strsz-1); + alloc[strsz-1] = '\0'; + return alloc; +} + /* #define EXPAND_PUA */ char *cli_mpool_virname(mpool_t *mp, const char *virname, unsigned int official) { char *newname, *pt; diff -Nru clamav-0.99.2+dfsg/libclamav/mpool.h clamav-0.99.3~beta1+dfsg/libclamav/mpool.h --- clamav-0.99.2+dfsg/libclamav/mpool.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/mpool.h 2016-10-13 15:45:44.000000000 +0000 @@ -36,6 +36,7 @@ void *mpool_realloc2(mpool_t *mpool, void *ptr, size_t size); unsigned char *cli_mpool_hex2str(mpool_t* mpool, const char *src); char *cli_mpool_strdup(mpool_t *mpool, const char *s); +char *cli_mpool_strndup(mpool_t *mpool, const char *s, size_t n); char *cli_mpool_virname(mpool_t *mpool, const char *virname, unsigned int official); uint16_t *cli_mpool_hex2ui(mpool_t *mpool, const char *hex); void mpool_flush(mpool_t *mpool); @@ -50,6 +51,7 @@ #define mpool_realloc2(a, b, c) cli_realloc2(b, c) #define cli_mpool_hex2str(mpool, src) cli_hex2str(src) #define cli_mpool_strdup(mpool, s) cli_strdup(s) +#define cli_mpool_strndup(mpool, s, n) cli_strdup(s, n) #define cli_mpool_virname(mpool, a, b) cli_virname(a, b) #define cli_mpool_hex2ui(mpool, hex) cli_hex2ui(hex) #define mpool_flush(val) diff -Nru clamav-0.99.2+dfsg/libclamav/mspack.c clamav-0.99.3~beta1+dfsg/libclamav/mspack.c --- clamav-0.99.2+dfsg/libclamav/mspack.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/mspack.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,2026 +0,0 @@ -/* - * This file includes code from libmspack adapted for libclamav by - * tkojm@clamav.net and draynor@sourcefire.com - * - * Copyright (C) 2003-2004 Stuart Caie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#if HAVE_CONFIG_H -#include "clamav-config.h" -#endif - -#include -#include - -#include "others.h" -#include "clamav.h" -#include "mspack.h" - -#if HAVE_LIMITS_H -# include -#endif -#ifndef CHAR_BIT -# define CHAR_BIT (8) -#endif - - -/*************************************************************************** - * MS-ZIP decompression implementation - *************************************************************************** - * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted - * by Microsoft Corporation. - * - * The deflate method was created by Phil Katz. MSZIP is equivalent to the - * deflate method. - * - */ - -/* match lengths for literal codes 257.. 285 */ -static const unsigned short mszip_lit_lengths[29] = { - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, - 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 -}; - -/* match offsets for distance codes 0 .. 29 */ -static const unsigned short mszip_dist_offsets[30] = { - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, - 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 -}; - -/* extra bits required for literal codes 257.. 285 */ -static const unsigned char mszip_lit_extrabits[29] = { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, - 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 -}; - -/* extra bits required for distance codes 0 .. 29 */ -static const unsigned char mszip_dist_extrabits[30] = { - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, - 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 -}; - -/* the order of the bit length Huffman code lengths */ -static const unsigned char mszip_bitlen_order[19] = { - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 -}; - -/* ANDing with mszip_bit_mask[n] masks the lower n bits */ -static const unsigned short mszip_bit_mask_tab[17] = { - 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff -}; - -#define MSZIP_STORE_BITS do { \ - zip->i_ptr = i_ptr; \ - zip->i_end = i_end; \ - zip->bit_buffer = bit_buffer; \ - zip->bits_left = bits_left; \ -} while (0) - -#define MSZIP_RESTORE_BITS do { \ - i_ptr = zip->i_ptr; \ - i_end = zip->i_end; \ - bit_buffer = zip->bit_buffer; \ - bits_left = zip->bits_left; \ -} while (0) - -#define MSZIP_ENSURE_BITS(nbits) do { \ - while (bits_left < (nbits)) { \ - if (i_ptr >= i_end) { \ - if (mszip_read_input(zip)) return zip->error; \ - i_ptr = zip->i_ptr; \ - i_end = zip->i_end; \ - if(i_ptr == i_end) break; \ - } \ - bit_buffer |= *i_ptr++ << bits_left; bits_left += 8; \ - } \ -} while (0) - -#define MSZIP_PEEK_BITS(nbits) (bit_buffer & ((1<<(nbits))-1)) -#define MSZIP_PEEK_BITS_T(nbits) (bit_buffer & mszip_bit_mask_tab[(nbits)]) - -#define MSZIP_REMOVE_BITS(nbits) ((bit_buffer >>= (nbits)), (bits_left -= (nbits))) - -#define MSZIP_READ_BITS(val, nbits) do { \ - MSZIP_ENSURE_BITS(nbits); (val) = MSZIP_PEEK_BITS(nbits); MSZIP_REMOVE_BITS(nbits); \ -} while (0) - -#define MSZIP_READ_BITS_T(val, nbits) do { \ - MSZIP_ENSURE_BITS(nbits); (val) = MSZIP_PEEK_BITS_T(nbits); MSZIP_REMOVE_BITS(nbits); \ -} while (0) - -static int mszip_read_input(struct mszip_stream *zip) { - int nread = zip->read_cb(zip->file, zip->inbuf, (int)zip->inbuf_size); - if (nread < 0) { - if (zip->file->error == CL_BREAK) { - if ((unsigned int)nread == zip->last) { - cli_dbgmsg("mszip_read_input: Two consecutive CL_BREAKs reached.\n"); - return CL_BREAK; - } - // Need short circuit to ensure scanning small files - cli_dbgmsg("mszip_read_input: First CL_BREAK reached.\n"); - zip->i_ptr = zip->i_end; - zip->last = nread; - return CL_SUCCESS; - } - else - return zip->error = CL_EFORMAT; - } - - zip->last = nread; - zip->i_ptr = &zip->inbuf[0]; - zip->i_end = &zip->inbuf[nread]; - - return CL_SUCCESS; -} - -/* inflate() error codes */ -#define INF_ERR_BLOCKTYPE (-1) /* unknown block type */ -#define INF_ERR_COMPLEMENT (-2) /* block size complement mismatch */ -#define INF_ERR_FLUSH (-3) /* error from flush_window() callback */ -#define INF_ERR_BITBUF (-4) /* too many bits in bit buffer */ -#define INF_ERR_SYMLENS (-5) /* too many symbols in blocktype 2 header */ -#define INF_ERR_BITLENTBL (-6) /* failed to build bitlens huffman table */ -#define INF_ERR_LITERALTBL (-7) /* failed to build literals huffman table */ -#define INF_ERR_DISTANCETBL (-8) /* failed to build distance huffman table */ -#define INF_ERR_BITOVERRUN (-9) /* bitlen RLE code goes over table size */ -#define INF_ERR_BADBITLEN (-10) /* invalid bit-length code */ -#define INF_ERR_LITCODE (-11) /* out-of-range literal code */ -#define INF_ERR_DISTCODE (-12) /* out-of-range distance code */ -#define INF_ERR_DISTANCE (-13) /* somehow, distance is beyond 32k */ -#define INF_ERR_HUFFSYM (-14) /* out of bits decoding huffman symbol */ - -/* mszip_make_decode_table(nsyms, nbits, length[], table[]) - * - * This function was coded by David Tritscher. It builds a fast huffman - * decoding table out of just a canonical huffman code lengths table. - * - * NOTE: this is NOT identical to the mszip_make_decode_table() in lzxd.c. This - * one reverses the quick-lookup bit pattern. Bits are read MSB to LSB in LZX, - * but LSB to MSB in MSZIP. - * - * nsyms = total number of symbols in this huffman tree. - * nbits = any symbols with a code length of nbits or less can be decoded - * in one lookup of the table. - * length = A table to get code lengths from [0 to nsyms-1] - * table = The table to fill up with decoded symbols and pointers. - * - * Returns 0 for OK or 1 for error - */ -static int mszip_make_decode_table(unsigned int nsyms, unsigned int nbits, - unsigned char *length, unsigned short *table) -{ - register unsigned int leaf, reverse, fill; - register unsigned short sym, next_sym; - register unsigned char bit_num; - unsigned int pos = 0; /* the current position in the decode table */ - unsigned int table_mask = 1 << nbits; - unsigned int mszip_bit_mask = table_mask >> 1; /* don't do 0 length codes */ - - /* fill entries for codes short enough for a direct mapping */ - for (bit_num = 1; bit_num <= nbits; bit_num++) { - for (sym = 0; sym < nsyms; sym++) { - if (length[sym] != bit_num) continue; - - /* reverse the significant bits */ - fill = length[sym]; reverse = pos >> (nbits - fill); leaf = 0; - do {leaf <<= 1; leaf |= reverse & 1; reverse >>= 1;} while (--fill); - - if((pos += mszip_bit_mask) > table_mask) return 1; /* table overrun */ - - /* fill all possible lookups of this symbol with the symbol itself */ - fill = mszip_bit_mask; next_sym = 1 << bit_num; - do { table[leaf] = sym; leaf += next_sym; } while (--fill); - } - mszip_bit_mask >>= 1; - } - - /* exit with success if table is now complete */ - if (pos == table_mask) return 0; - - /* mark all remaining table entries as unused */ - for (sym = pos; sym < table_mask; sym++) { - reverse = sym; leaf = 0; fill = nbits; - do { leaf <<= 1; leaf |= reverse & 1; reverse >>= 1; } while (--fill); - table[leaf] = 0xFFFF; - } - - /* where should the longer codes be allocated from? */ - next_sym = ((table_mask >> 1) < nsyms) ? nsyms : (table_mask >> 1); - - /* give ourselves room for codes to grow by up to 16 more bits. - * codes now start at bit nbits+16 and end at (nbits+16-codelength) */ - pos <<= 16; - table_mask <<= 16; - mszip_bit_mask = 1 << 15; - - for (bit_num = nbits+1; bit_num <= MSZIP_MAX_HUFFBITS; bit_num++) { - for (sym = 0; sym < nsyms; sym++) { - if (length[sym] != bit_num) continue; - - /* leaf = the first nbits of the code, reversed */ - reverse = pos >> 16; leaf = 0; fill = nbits; - do {leaf <<= 1; leaf |= reverse & 1; reverse >>= 1;} while (--fill); - - for (fill = 0; fill < (bit_num - nbits); fill++) { - /* if this path hasn't been taken yet, 'allocate' two entries */ - if (table[leaf] == 0xFFFF) { - table[(next_sym << 1) ] = 0xFFFF; - table[(next_sym << 1) + 1 ] = 0xFFFF; - table[leaf] = next_sym++; - } - /* follow the path and select either left or right for next bit */ - leaf = (table[leaf] << 1) | ((pos >> (15 - fill)) & 1); - } - table[leaf] = sym; - - if ((pos += mszip_bit_mask) > table_mask) return 1; /* table overflow */ - } - mszip_bit_mask >>= 1; - } - - /* full table? */ - return (pos != table_mask) ? 1 : 0; -} - -/* MSZIP_READ_HUFFSYM(tablename, var) decodes one huffman symbol from the - * bitstream using the stated table and puts it in var. - */ -#define MSZIP_READ_HUFFSYM(tbl, var) do { \ - /* huffman symbols can be up to 16 bits long */ \ - MSZIP_ENSURE_BITS(MSZIP_MAX_HUFFBITS); \ - /* immediate table lookup of [tablebits] bits of the code */ \ - sym = zip->tbl##_table[MSZIP_PEEK_BITS(MSZIP_##tbl##_TABLEBITS)]; \ - /* is the symbol is longer than [tablebits] bits? (i=node index) */ \ - if (sym >= MSZIP_##tbl##_MAXSYMBOLS) { \ - /* decode remaining bits by tree traversal */ \ - i = MSZIP_##tbl##_TABLEBITS - 1; \ - do { \ - /* check next bit. error if we run out of bits before decode */ \ - if (i++ > MSZIP_MAX_HUFFBITS) { \ - cli_dbgmsg("zip_inflate: out of bits in huffman decode\n"); \ - return INF_ERR_HUFFSYM; \ - } \ - sym = (sym << 1) | ((bit_buffer >> i) & 1); \ - if(sym >= MSZIP_##tbl##_TABLESIZE) { \ - cli_dbgmsg("zip_inflate: index out of table\n"); \ - return INF_ERR_HUFFSYM; \ - } \ - /* double node index and add 0 (left branch) or 1 (right) */ \ - sym = zip->tbl##_table[sym]; \ - /* while we are still in node indicies, not decoded symbols */ \ - } while (sym >= MSZIP_##tbl##_MAXSYMBOLS); \ - } \ - /* result */ \ - (var) = sym; \ - /* look up the code length of that symbol and discard those bits */ \ - i = zip->tbl##_len[sym]; \ - MSZIP_REMOVE_BITS(i); \ -} while (0) - -static int mszip_read_lens(struct mszip_stream *zip) { - /* for the bit buffer and huffman decoding */ - register unsigned int bit_buffer; - register int bits_left; - unsigned char *i_ptr, *i_end; - - /* bitlen Huffman codes -- immediate lookup, 7 bit max code length */ - unsigned short bl_table[(1 << 7)]; - unsigned char bl_len[19]; - - unsigned char lens[MSZIP_LITERAL_MAXSYMBOLS + MSZIP_DISTANCE_MAXSYMBOLS]; - unsigned int lit_codes, dist_codes, code, last_code=0, bitlen_codes, i, run; - - MSZIP_RESTORE_BITS; - - /* read the number of codes */ - MSZIP_READ_BITS(lit_codes, 5); lit_codes += 257; - MSZIP_READ_BITS(dist_codes, 5); dist_codes += 1; - MSZIP_READ_BITS(bitlen_codes, 4); bitlen_codes += 4; - if (lit_codes > MSZIP_LITERAL_MAXSYMBOLS) return INF_ERR_SYMLENS; - if (dist_codes > MSZIP_DISTANCE_MAXSYMBOLS) return INF_ERR_SYMLENS; - - /* read in the bit lengths in their unusual order */ - for (i = 0; i < bitlen_codes; i++) MSZIP_READ_BITS(bl_len[mszip_bitlen_order[i]], 3); - while (i < 19) bl_len[mszip_bitlen_order[i++]] = 0; - - /* create decoding table with an immediate lookup */ - if (mszip_make_decode_table(19, 7, &bl_len[0], &bl_table[0])) { - return INF_ERR_BITLENTBL; - } - - /* read literal / distance code lengths */ - for (i = 0; i < (lit_codes + dist_codes); i++) { - /* single-level huffman lookup */ - MSZIP_ENSURE_BITS(7); - code = bl_table[MSZIP_PEEK_BITS(7)]; - MSZIP_REMOVE_BITS(bl_len[code]); - - if (code < 16) lens[i] = last_code = code; - else { - switch (code) { - case 16: MSZIP_READ_BITS(run, 2); run += 3; code = last_code; break; - case 17: MSZIP_READ_BITS(run, 3); run += 3; code = 0; break; - case 18: MSZIP_READ_BITS(run, 7); run += 11; code = 0; break; - default: cli_dbgmsg("zip_read_lens: bad code!: %u\n", code); return INF_ERR_BADBITLEN; - } - if ((i + run) > (lit_codes + dist_codes)) return INF_ERR_BITOVERRUN; - while (run--) lens[i++] = code; - i--; - } - } - - /* copy LITERAL code lengths and clear any remaining */ - i = lit_codes; - memcpy(&zip->LITERAL_len[0], &lens[0], i); - while (i < MSZIP_LITERAL_MAXSYMBOLS) zip->LITERAL_len[i++] = 0; - - i = dist_codes; - memcpy(&zip->DISTANCE_len[0], &lens[lit_codes], i); - while (i < MSZIP_DISTANCE_MAXSYMBOLS) zip->DISTANCE_len[i++] = 0; - - MSZIP_STORE_BITS; - return 0; -} - -static int mspack_write(int fd, const void *buff, unsigned int count, struct cab_file *file) -{ - int ret; - - if(file->max_size) { - if(file->written_size >= file->max_size) - return CL_BREAK; - - if(file->written_size + count > file->max_size) - count = file->max_size - file->written_size; - } - if((ret = cli_writen(fd, buff, count)) > 0) - file->written_size += ret; - - return (ret == -1) ? CL_EWRITE : CL_SUCCESS; -} - -/* a clean implementation of RFC 1951 / inflate */ -static int mszip_inflate(struct mszip_stream *zip) { - unsigned int last_block, block_type, distance, length, this_run, i; - - /* for the bit buffer and huffman decoding */ - register unsigned int bit_buffer; - register int bits_left; - register unsigned short sym; - unsigned char *i_ptr, *i_end; - - MSZIP_RESTORE_BITS; - - do { - /* read in last block bit */ - MSZIP_READ_BITS(last_block, 1); - - /* read in block type */ - MSZIP_READ_BITS(block_type, 2); - - if (block_type == 0) { - /* uncompressed block */ - unsigned char lens_buf[4]; - - /* go to byte boundary */ - i = bits_left & 7; MSZIP_REMOVE_BITS(i); - - /* read 4 bytes of data, emptying the bit-buffer if necessary */ - for (i = 0; (bits_left >= 8); i++) { - if (i == 4) return INF_ERR_BITBUF; - lens_buf[i] = MSZIP_PEEK_BITS(8); - MSZIP_REMOVE_BITS(8); - } - if (bits_left != 0) return INF_ERR_BITBUF; - while (i < 4) { - if (i_ptr >= i_end) { - if (mszip_read_input(zip)) return zip->error; - i_ptr = zip->i_ptr; - i_end = zip->i_end; - if(i_ptr == i_end) break; - } - lens_buf[i++] = *i_ptr++; - } - if (i < 4) return INF_ERR_BITBUF; - - /* get the length and its complement */ - length = lens_buf[0] | (lens_buf[1] << 8); - i = lens_buf[2] | (lens_buf[3] << 8); - if (length != (~i & 0xFFFF)) return INF_ERR_COMPLEMENT; - - /* read and copy the uncompressed data into the window */ - while (length > 0) { - if (i_ptr >= i_end) { - if (mszip_read_input(zip)) return zip->error; - i_ptr = zip->i_ptr; - i_end = zip->i_end; - if(i_ptr == i_end) break; - } - - this_run = length; - if (this_run > (unsigned int)(i_end - i_ptr)) this_run = i_end - i_ptr; - if (this_run > (MSZIP_FRAME_SIZE - zip->window_posn)) - this_run = MSZIP_FRAME_SIZE - zip->window_posn; - - memcpy(&zip->window[zip->window_posn], i_ptr, this_run); - zip->window_posn += this_run; - i_ptr += this_run; - length -= this_run; - - if (zip->window_posn == MSZIP_FRAME_SIZE) { - if (zip->flush_window(zip, MSZIP_FRAME_SIZE)) return INF_ERR_FLUSH; - zip->window_posn = 0; - } - } - } - else if ((block_type == 1) || (block_type == 2)) { - /* Huffman-compressed LZ77 block */ - unsigned int window_posn, match_posn, code; - - if (block_type == 1) { - /* block with fixed Huffman codes */ - i = 0; - while (i < 144) zip->LITERAL_len[i++] = 8; - while (i < 256) zip->LITERAL_len[i++] = 9; - while (i < 280) zip->LITERAL_len[i++] = 7; - while (i < 288) zip->LITERAL_len[i++] = 8; - for (i = 0; i < 32; i++) zip->DISTANCE_len[i] = 5; - } - else { - /* block with dynamic Huffman codes */ - MSZIP_STORE_BITS; - if ((i = mszip_read_lens(zip))) return i; - MSZIP_RESTORE_BITS; - } - - /* now huffman lengths are read for either kind of block, - * create huffman decoding tables */ - if (mszip_make_decode_table(MSZIP_LITERAL_MAXSYMBOLS, MSZIP_LITERAL_TABLEBITS, - &zip->LITERAL_len[0], &zip->LITERAL_table[0])) - { - return INF_ERR_LITERALTBL; - } - - if (mszip_make_decode_table(MSZIP_DISTANCE_MAXSYMBOLS,MSZIP_DISTANCE_TABLEBITS, - &zip->DISTANCE_len[0], &zip->DISTANCE_table[0])) - { - return INF_ERR_DISTANCETBL; - } - - /* decode forever until end of block code */ - window_posn = zip->window_posn; - while (1) { - MSZIP_READ_HUFFSYM(LITERAL, code); - if (code < 256) { - zip->window[window_posn++] = (unsigned char) code; - if (window_posn == MSZIP_FRAME_SIZE) { - if (zip->flush_window(zip, MSZIP_FRAME_SIZE)) return INF_ERR_FLUSH; - window_posn = 0; - } - } - else if (code == 256) { - /* END OF BLOCK CODE: loop break point */ - break; - } - else { - code -= 257; - if (code >= 29) return INF_ERR_LITCODE; - MSZIP_READ_BITS_T(length, mszip_lit_extrabits[code]); - length += mszip_lit_lengths[code]; - - MSZIP_READ_HUFFSYM(DISTANCE, code); - if (code >= 30) return INF_ERR_DISTCODE; - MSZIP_READ_BITS_T(distance, mszip_dist_extrabits[code]); - distance += mszip_dist_offsets[code]; - - /* match position is window position minus distance. If distance - * is more than window position numerically, it must 'wrap - * around' the frame size. */ - match_posn = ((distance > window_posn) ? MSZIP_FRAME_SIZE : 0) - + window_posn - distance; - - /* copy match */ - if (length < 12) { - /* short match, use slower loop but no loop setup code */ - while (length--) { - zip->window[window_posn++] = zip->window[match_posn++]; - match_posn &= MSZIP_FRAME_SIZE - 1; - - if (window_posn == MSZIP_FRAME_SIZE) { - if (zip->flush_window(zip, MSZIP_FRAME_SIZE)) - return INF_ERR_FLUSH; - window_posn = 0; - } - } - } - else { - /* longer match, use faster loop but with setup expense */ - unsigned char *runsrc, *rundest; - do { - this_run = length; - if ((match_posn + this_run) > MSZIP_FRAME_SIZE) - this_run = MSZIP_FRAME_SIZE - match_posn; - if ((window_posn + this_run) > MSZIP_FRAME_SIZE) - this_run = MSZIP_FRAME_SIZE - window_posn; - - rundest = &zip->window[window_posn]; window_posn += this_run; - runsrc = &zip->window[match_posn]; match_posn += this_run; - length -= this_run; - while (this_run--) *rundest++ = *runsrc++; - - /* flush if necessary */ - if (window_posn == MSZIP_FRAME_SIZE) { - if (zip->flush_window(zip, MSZIP_FRAME_SIZE)) - return INF_ERR_FLUSH; - window_posn = 0; - } - if (match_posn == MSZIP_FRAME_SIZE) match_posn = 0; - } while (length > 0); - } - - } /* else (code >= 257) */ - - } /* while (forever) -- break point at 'code == 256' */ - zip->window_posn = window_posn; - } - else { - /* block_type == 3 -- bad block type */ - return INF_ERR_BLOCKTYPE; - } - } while (!last_block); - - /* flush the remaining data */ - if (zip->window_posn) { - if (zip->flush_window(zip, zip->window_posn)) return INF_ERR_FLUSH; - } - MSZIP_STORE_BITS; - - /* return success */ - return 0; -} - -/* inflate() calls this whenever the window should be flushed. As - * MSZIP only expands to the size of the window, the implementation used - * simply keeps track of the amount of data flushed, and if more than 32k - * is flushed, an error is raised. - */ -static int mszip_flush_window(struct mszip_stream *zip, - unsigned int data_flushed) -{ - zip->bytes_output += data_flushed; - if (zip->bytes_output > MSZIP_FRAME_SIZE) { - cli_dbgmsg("mszip_flush_window: overflow: %u bytes flushed, total is now %u\n", data_flushed, zip->bytes_output); - return 1; - } - return 0; -} - -struct mszip_stream *mszip_init(int ofd, - int input_buffer_size, - int repair_mode, - struct cab_file *file, - int (*read_cb)(struct cab_file *, unsigned char *, int)) -{ - struct mszip_stream *zip; - - input_buffer_size = (input_buffer_size + 1) & -2; - if (!input_buffer_size) return NULL; - - /* allocate decompression state */ - if (!(zip = cli_calloc(1, sizeof(struct mszip_stream)))) { - cli_errmsg("mszip_stream: Unable to allocate zip buffer\n"); - return NULL; - } - - /* allocate input buffer */ - zip->inbuf = cli_malloc((size_t) input_buffer_size); - if (!zip->inbuf) { - cli_errmsg("mszip_stream: Unable to allocate input buffer\n"); - free(zip); - return NULL; - } - - /* initialise decompression state */ - zip->ofd = ofd; - zip->wflag = 1; - zip->inbuf_size = input_buffer_size; - zip->error = CL_SUCCESS; - zip->repair_mode = repair_mode; - zip->flush_window = &mszip_flush_window; - zip->input_end = 0; - - zip->i_ptr = zip->i_end = &zip->inbuf[0]; - zip->o_ptr = zip->o_end = NULL; - zip->bit_buffer = 0; zip->bits_left = 0; - - zip->file = file; - zip->read_cb = read_cb; - - return zip; -} - -int mszip_decompress(struct mszip_stream *zip, uint32_t out_bytes) { - /* for the bit buffer */ - register unsigned int bit_buffer; - register int bits_left; - unsigned char *i_ptr, *i_end; - - int i, ret, state, error; - - /* easy answers */ - if (!zip) return CL_ENULLARG; - if (zip->error) return zip->error; - - /* flush out any stored-up bytes before we begin */ - i = zip->o_end - zip->o_ptr; - if (((off_t) i > out_bytes) && ((int) out_bytes >= 0)) i = (int) out_bytes; - if (i) { - if (zip->wflag && (ret = mspack_write(zip->ofd, zip->o_ptr, i, zip->file)) != CL_SUCCESS) { - return zip->error = ret; - } - zip->o_ptr += i; - out_bytes -= i; - } - if (out_bytes == 0) return CL_SUCCESS; - - while (out_bytes > 0) { - /* unpack another block */ - MSZIP_RESTORE_BITS; - - /* skip to next read 'CK' header */ - i = bits_left & 7; MSZIP_REMOVE_BITS(i); /* align to bytestream */ - state = 0; - do { - MSZIP_READ_BITS(i, 8); - if (i == 'C') state = 1; - else if ((state == 1) && (i == 'K')) state = 2; - else state = 0; - } while (state != 2); - - /* inflate a block, repair and realign if necessary */ - zip->window_posn = 0; - zip->bytes_output = 0; - MSZIP_STORE_BITS; - if ((error = mszip_inflate(zip))) { - cli_dbgmsg("mszip_decompress: inflate error %d\n", error); - if (zip->repair_mode) { - cli_dbgmsg("mszip_decompress: MSZIP error, %u bytes of data lost\n", - MSZIP_FRAME_SIZE - zip->bytes_output); - for (i = zip->bytes_output; i < MSZIP_FRAME_SIZE; i++) { - zip->window[i] = '\0'; - } - zip->bytes_output = MSZIP_FRAME_SIZE; - } - else { - return zip->error = (error > 0) ? error : CL_EFORMAT; - } - } - zip->o_ptr = &zip->window[0]; - zip->o_end = &zip->o_ptr[zip->bytes_output]; - - /* write a frame */ - i = (out_bytes < (off_t)zip->bytes_output) ? - (int)out_bytes : zip->bytes_output; - if (zip->wflag && (ret = mspack_write(zip->ofd, zip->o_ptr, i, zip->file)) != CL_SUCCESS) { - return zip->error = ret; - } - - /* mspack errors (i.e. read errors) are fatal and can't be recovered */ - if ((error > 0) && zip->repair_mode) return error; - - zip->o_ptr += i; - out_bytes -= i; - } - - if (out_bytes) - cli_dbgmsg("mszip_decompress: bytes left to output\n"); - - return CL_SUCCESS; -} - -void mszip_free(struct mszip_stream *zip) { - if (zip) { - free(zip->inbuf); - free(zip); - } -} - -/*************************************************************************** - * LZX decompression implementation - *************************************************************************** - * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted - * by Microsoft Corporation. - * - */ - -/* LZX decompressor input macros - * - * LZX_STORE_BITS stores bitstream state in lzx_stream structure - * LZX_RESTORE_BITS restores bitstream state from lzx_stream structure - * LZX_READ_BITS(var,n) takes N bits from the buffer and puts them in var - * LZX_ENSURE_BITS(n) ensures there are at least N bits in the bit buffer. - * LZX_PEEK_BITS(n) extracts without removing N bits from the bit buffer - * LZX_REMOVE_BITS(n) removes N bits from the bit buffer - * - */ - -#define LZX_BITBUF_WIDTH (sizeof(bit_buffer) * CHAR_BIT) - -#define LZX_STORE_BITS do { \ - lzx->i_ptr = i_ptr; \ - lzx->i_end = i_end; \ - lzx->bit_buffer = bit_buffer; \ - lzx->bits_left = bits_left; \ -} while (0) - -#define LZX_RESTORE_BITS do { \ - i_ptr = lzx->i_ptr; \ - i_end = lzx->i_end; \ - bit_buffer = lzx->bit_buffer; \ - bits_left = lzx->bits_left; \ -} while (0) - -#define LZX_ENSURE_BITS(nbits) \ - while (bits_left < (nbits)) { \ - if (i_ptr + 1 >= i_end) { \ - if (lzx_read_input(lzx)) return lzx->error; \ - i_ptr = lzx->i_ptr; \ - i_end = lzx->i_end; \ - } \ - bit_buffer |= ((i_ptr[1] << 8) | i_ptr[0]) \ - << (LZX_BITBUF_WIDTH - 16 - bits_left); \ - bits_left += 16; \ - i_ptr += 2; \ - } - -#define LZX_PEEK_BITS(nbits) (bit_buffer >> (LZX_BITBUF_WIDTH - (nbits))) - -#define LZX_REMOVE_BITS(nbits) ((bit_buffer <<= (nbits)), (bits_left -= (nbits))) - -#define LZX_READ_BITS(val, nbits) do { \ - LZX_ENSURE_BITS(nbits); \ - (val) = LZX_PEEK_BITS(nbits); \ - LZX_REMOVE_BITS(nbits); \ -} while (0) - -static int lzx_read_input(struct lzx_stream *lzx) { - int bread = lzx->read_cb(lzx->file, &lzx->inbuf[0], (int)lzx->inbuf_size); - if (bread < 0) { - if (lzx->file->error == CL_BREAK) - return lzx->error = CL_BREAK; - else - return lzx->error = CL_EFORMAT; - } - - /* huff decode's ENSURE_BYTES(16) might overrun the input stream, even - * if those bits aren't used, so fake 2 more bytes */ - if (bread == 0) { - if (lzx->input_end) { - cli_dbgmsg("lzx_read_input: out of input bytes\n"); - return lzx->error = CL_EREAD; - } - else { - bread = 2; - lzx->inbuf[0] = lzx->inbuf[1] = 0; - lzx->input_end = 1; - } - } - - lzx->i_ptr = &lzx->inbuf[0]; - lzx->i_end = &lzx->inbuf[bread]; - - return CL_SUCCESS; -} - -/* Huffman decoding macros */ - -/* LZX_READ_HUFFSYM(tablename, var) decodes one huffman symbol from the - * bitstream using the stated table and puts it in var. - */ -#define LZX_READ_HUFFSYM(tbl, var) do { \ - /* huffman symbols can be up to 16 bits long */ \ - LZX_ENSURE_BITS(16); \ - /* immediate table lookup of [tablebits] bits of the code */ \ - sym = lzx->tbl##_table[LZX_PEEK_BITS(LZX_##tbl##_TABLEBITS)]; \ - /* is the symbol is longer than [tablebits] bits? (i=node index) */ \ - if (sym >= LZX_##tbl##_MAXSYMBOLS) { \ - /* decode remaining bits by tree traversal */ \ - i = 1 << (LZX_BITBUF_WIDTH - LZX_##tbl##_TABLEBITS); \ - do { \ - /* one less bit. error if we run out of bits before decode */ \ - i >>= 1; \ - if (i == 0) { \ - cli_dbgmsg("lzx: out of bits in huffman decode\n"); \ - return lzx->error = CL_EFORMAT; \ - } \ - /* double node index and add 0 (left branch) or 1 (right) */ \ - sym <<= 1; sym |= (bit_buffer & i) ? 1 : 0; \ - /* hop to next node index / decoded symbol */ \ - if(sym >= (1 << LZX_##tbl##_TABLEBITS) + (LZX_##tbl##_MAXSYMBOLS * 2)) { \ - cli_dbgmsg("lzx: index out of table\n"); \ - return lzx->error = CL_EFORMAT; \ - } \ - sym = lzx->tbl##_table[sym]; \ - /* while we are still in node indicies, not decoded symbols */ \ - } while (sym >= LZX_##tbl##_MAXSYMBOLS); \ - } \ - /* result */ \ - (var) = sym; \ - /* look up the code length of that symbol and discard those bits */ \ - i = lzx->tbl##_len[sym]; \ - LZX_REMOVE_BITS(i); \ -} while (0) - -/* LZX_BUILD_TABLE(tbl) builds a huffman lookup table from code lengths */ -#define LZX_BUILD_TABLE(tbl) \ - if (lzx_make_decode_table(LZX_##tbl##_MAXSYMBOLS, LZX_##tbl##_TABLEBITS, \ - &lzx->tbl##_len[0], &lzx->tbl##_table[0])) \ - { \ - cli_dbgmsg("lzx: failed to build %s table\n", #tbl); \ - return lzx->error = CL_EFORMAT; \ - } - -/* lzx_make_decode_table(nsyms, nbits, length[], table[]) - * - * This function was coded by David Tritscher. It builds a fast huffman - * decoding table from a canonical huffman code lengths table. - * - * nsyms = total number of symbols in this huffman tree. - * nbits = any symbols with a code length of nbits or less can be decoded - * in one lookup of the table. - * length = A table to get code lengths from [0 to syms-1] - * table = The table to fill up with decoded symbols and pointers. - * - * Returns 0 for OK or 1 for error - */ - -static int lzx_make_decode_table(unsigned int nsyms, unsigned int nbits, - unsigned char *length, unsigned short *table) -{ - register unsigned short sym; - register unsigned int leaf, fill; - register unsigned char bit_num; - unsigned int pos = 0; /* the current position in the decode table */ - unsigned int table_mask = 1 << nbits; - unsigned int bit_mask = table_mask >> 1; /* don't do 0 length codes */ - unsigned int next_symbol = bit_mask; /* base of allocation for long codes */ - - /* fill entries for codes short enough for a direct mapping */ - for (bit_num = 1; bit_num <= nbits; bit_num++) { - for (sym = 0; sym < nsyms; sym++) { - if (length[sym] != bit_num) continue; - leaf = pos; - if((pos += bit_mask) > table_mask) return 1; /* table overrun */ - /* fill all possible lookups of this symbol with the symbol itself */ - for (fill = bit_mask; fill-- > 0;) table[leaf++] = sym; - } - bit_mask >>= 1; - } - - /* full table already? */ - if (pos == table_mask) return 0; - - /* clear the remainder of the table */ - for (sym = pos; sym < table_mask; sym++) table[sym] = 0xFFFF; - - /* allow codes to be up to nbits+16 long, instead of nbits */ - pos <<= 16; - table_mask <<= 16; - bit_mask = 1 << 15; - - for (bit_num = nbits+1; bit_num <= 16; bit_num++) { - for (sym = 0; sym < nsyms; sym++) { - if (length[sym] != bit_num) continue; - - leaf = pos >> 16; - for (fill = 0; fill < bit_num - nbits; fill++) { - /* if this path hasn't been taken yet, 'allocate' two entries */ - if (table[leaf] == 0xFFFF) { - table[(next_symbol << 1)] = 0xFFFF; - table[(next_symbol << 1) + 1] = 0xFFFF; - table[leaf] = next_symbol++; - } - /* follow the path and select either left or right for next bit */ - leaf = table[leaf] << 1; - if ((pos >> (15-fill)) & 1) leaf++; - } - table[leaf] = sym; - - if ((pos += bit_mask) > table_mask) return 1; /* table overflow */ - } - bit_mask >>= 1; - } - - /* full table? */ - if (pos == table_mask) return 0; - - /* either erroneous table, or all elements are 0 - let's find out. */ - for (sym = 0; sym < nsyms; sym++) if (length[sym]) return 1; - return 0; -} - -/* LZX_READ_LENGTHS(tablename, first, last) reads in code lengths for symbols - * first to last in the given table. The code lengths are stored in their - * own special LZX way. - */ -#define LZX_READ_LENGTHS(tbl, first, last) do { \ - LZX_STORE_BITS; \ - if (lzx_read_lens(lzx, &lzx->tbl##_len[0], (first), \ - (unsigned int)(last))) return lzx->error; \ - LZX_RESTORE_BITS; \ -} while (0) - -static int lzx_read_lens(struct lzx_stream *lzx, unsigned char *lens, - unsigned int first, unsigned int last) -{ - /* bit buffer and huffman symbol decode variables */ - register unsigned int bit_buffer; - register int bits_left, i; - register unsigned short sym; - unsigned char *i_ptr, *i_end; - - unsigned int x, y; - int z; - - LZX_RESTORE_BITS; - - /* read lengths for pretree (20 symbols, lengths stored in fixed 4 bits) */ - for (x = 0; x < 20; x++) { - LZX_READ_BITS(y, 4); - lzx->PRETREE_len[x] = y; - } - LZX_BUILD_TABLE(PRETREE); - - for (x = first; x < last; ) { - LZX_READ_HUFFSYM(PRETREE, z); - if (z == 17) { - /* code = 17, run of ([read 4 bits]+4) zeros */ - LZX_READ_BITS(y, 4); y += 4; - while (y--) lens[x++] = 0; - } - else if (z == 18) { - /* code = 18, run of ([read 5 bits]+20) zeros */ - LZX_READ_BITS(y, 5); y += 20; - while (y--) lens[x++] = 0; - } - else if (z == 19) { - /* code = 19, run of ([read 1 bit]+4) [read huffman symbol] */ - LZX_READ_BITS(y, 1); y += 4; - LZX_READ_HUFFSYM(PRETREE, z); - z = lens[x] - z; if (z < 0) z += 17; - while (y--) lens[x++] = z; - } - else { - /* code = 0 to 16, delta current length entry */ - z = lens[x] - z; if (z < 0) z += 17; - lens[x++] = z; - } - } - - LZX_STORE_BITS; - - return CL_SUCCESS; -} - -static void lzx_reset_state(struct lzx_stream *lzx) { - int i; - - lzx->R0 = 1; - lzx->R1 = 1; - lzx->R2 = 1; - lzx->header_read = 0; - lzx->block_remaining = 0; - lzx->block_type = LZX_BLOCKTYPE_INVALID; - - /* initialise tables to 0 (because deltas will be applied to them) */ - for (i = 0; i < LZX_MAINTREE_MAXSYMBOLS; i++) lzx->MAINTREE_len[i] = 0; - for (i = 0; i < LZX_LENGTH_MAXSYMBOLS; i++) lzx->LENGTH_len[i] = 0; -} - -/*-------- main LZX code --------*/ - -struct lzx_stream *lzx_init(int ofd, - int window_bits, - int reset_interval, - int input_buffer_size, - off_t output_length, - struct cab_file *file, - int (*read_cb)(struct cab_file *, unsigned char *, int)) -{ - unsigned int window_size = 1 << window_bits; - struct lzx_stream *lzx; - int i, j; - - /* LZX supports window sizes of 2^15 (32Kb) through 2^21 (2Mb) */ - if (window_bits < 15 || window_bits > 21) return NULL; - - input_buffer_size = (input_buffer_size + 1) & -2; - if (!input_buffer_size) return NULL; - - /* allocate decompression state */ - if (!(lzx = cli_calloc(1, sizeof(struct lzx_stream)))) { - return NULL; - } - - for (i = 0, j = 0; i < 51; i += 2) { - lzx->extra_bits[i] = j; /* 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7... */ - if(i < 50) - lzx->extra_bits[i+1] = j; - if ((i != 0) && (j < 17)) j++; /* 0,0,1,2,3,4...15,16,17,17,17,17... */ - } - - for (i = 0, j = 0; i < 51; i++) { - lzx->position_base[i] = j; /* 0,1,2,3,4,6,8,12,16,24,32,... */ - j += 1 << lzx->extra_bits[i]; /* 1,1,1,1,2,2,4,4,8,8,16,16,32,32,... */ - } - - /* allocate decompression window and input buffer */ - lzx->window = cli_calloc(1, (size_t) window_size); - if(!lzx->window) { - free(lzx); - return NULL; - } - - lzx->inbuf = cli_calloc(1, (size_t) input_buffer_size); - if (!lzx->inbuf) { - free(lzx->window); - free(lzx); - return NULL; - } - - /* initialise decompression state */ - lzx->ofd = ofd; - lzx->wflag = 1; - lzx->offset = 0; - lzx->length = output_length; - lzx->file = file; - lzx->read_cb = read_cb; - - lzx->inbuf_size = input_buffer_size; - lzx->window_size = 1 << window_bits; - lzx->window_posn = 0; - lzx->frame_posn = 0; - lzx->frame = 0; - lzx->reset_interval = reset_interval; - lzx->intel_filesize = 0; - lzx->intel_curpos = 0; - - /* window bits: 15 16 17 18 19 20 21 - * position slots: 30 32 34 36 38 42 50 */ - lzx->posn_slots = ((window_bits == 21) ? 50 : - ((window_bits == 20) ? 42 : (window_bits << 1))); - lzx->intel_started = 0; - lzx->input_end = 0; - - lzx->error = CL_SUCCESS; - - lzx->i_ptr = lzx->i_end = &lzx->inbuf[0]; - lzx->o_ptr = lzx->o_end = &lzx->e8_buf[0]; - lzx->bit_buffer = lzx->bits_left = 0; - - lzx_reset_state(lzx); - return lzx; -} - -void lzx_set_output_length(struct lzx_stream *lzx, off_t out_bytes) { - if (lzx) lzx->length = out_bytes; -} - -int lzx_decompress(struct lzx_stream *lzx, uint32_t out_bytes) { - /* bitstream reading and huffman variables */ - register unsigned int bit_buffer; - register int bits_left, i=0; - register unsigned short sym; - unsigned char *i_ptr, *i_end; - - int match_length, length_footer, extra, verbatim_bits, bytes_todo; - int this_run, main_element, aligned_bits, j, ret, warned=0; - unsigned char *window, *runsrc, *rundest, buf[12]; - unsigned int frame_size=0, end_frame, match_offset, window_posn; - unsigned int R0, R1, R2; - - /* easy answers */ - if (!lzx) return CL_ENULLARG; - if (lzx->error) return lzx->error; - - /* flush out any stored-up bytes before we begin */ - i = lzx->o_end - lzx->o_ptr; - if (((off_t) i > out_bytes) && ((int) out_bytes >= 0)) i = (int) out_bytes; - if (i) { - if (lzx->wflag && (ret = mspack_write(lzx->ofd, lzx->o_ptr, i, lzx->file)) != CL_SUCCESS) { - return lzx->error = ret; - } - lzx->o_ptr += i; - lzx->offset += i; - out_bytes -= i; - } - if (out_bytes == 0) return CL_SUCCESS; - - /* restore local state */ - LZX_RESTORE_BITS; - window = lzx->window; - window_posn = lzx->window_posn; - R0 = lzx->R0; - R1 = lzx->R1; - R2 = lzx->R2; - - end_frame = (unsigned int)((lzx->offset + out_bytes) / LZX_FRAME_SIZE) + 1; - cli_dbgmsg("lzx_decompress: end frame = %u\n", end_frame); - - while (lzx->frame < end_frame) { - cli_dbgmsg("lzx_decompress: current frame = %u\n", lzx->frame); - /* have we reached the reset interval? (if there is one?) */ - if (lzx->reset_interval && ((lzx->frame % lzx->reset_interval) == 0)) { - if (lzx->block_remaining) { - /* this is a file format error, but we need to extract what we can and scan that */ - cli_dbgmsg("lzx_decompress: %d bytes remaining at reset interval\n", lzx->block_remaining); - if (!warned) { - cli_dbgmsg("Detected an invalid reset interval during decompression.\n"); - warned++; - } - if (!lzx->header_read) { - /* cannot continue if no header at all */ - return lzx->error = CL_EFORMAT; - } - } else { - /* re-read the intel header and reset the huffman lengths */ - lzx_reset_state(lzx); - } - } - - /* read header if necessary */ - if (!lzx->header_read) { - /* read 1 bit. if bit=0, intel filesize = 0. - * if bit=1, read intel filesize (32 bits) */ - j = 0; LZX_READ_BITS(i, 1); if (i) { LZX_READ_BITS(i, 16); LZX_READ_BITS(j, 16); } - lzx->intel_filesize = (i << 16) | j; - lzx->header_read = 1; - } - - /* calculate size of frame: all frames are 32k except the final frame - * which is 32kb or less. this can only be calculated when lzx->length - * has been filled in. */ - frame_size = LZX_FRAME_SIZE; - if (lzx->length && (lzx->length - lzx->offset) < (off_t)frame_size) { - frame_size = lzx->length - lzx->offset; - } - - /* decode until one more frame is available */ - bytes_todo = lzx->frame_posn + frame_size - window_posn; - while (bytes_todo > 0) { - /* initialise new block, if one is needed */ - if (lzx->block_remaining == 0) { - /* realign if previous block was an odd-sized UNCOMPRESSED block */ - if ((lzx->block_type == LZX_BLOCKTYPE_UNCOMPRESSED) && - (lzx->block_length & 1)) - { - if (i_ptr == i_end) { - if (lzx_read_input(lzx)) return lzx->error; - i_ptr = lzx->i_ptr; - i_end = lzx->i_end; - } - i_ptr++; - } - - /* read block type (3 bits) and block length (24 bits) */ - LZX_READ_BITS(lzx->block_type, 3); - LZX_READ_BITS(i, 16); LZX_READ_BITS(j, 8); - lzx->block_remaining = lzx->block_length = (i << 8) | j; - - /* read individual block headers */ - switch (lzx->block_type) { - case LZX_BLOCKTYPE_ALIGNED: - /* read lengths of and build aligned huffman decoding tree */ - for (i = 0; i < 8; i++) { LZX_READ_BITS(j, 3); lzx->ALIGNED_len[i] = j; } - LZX_BUILD_TABLE(ALIGNED); - /* no break -- rest of aligned header is same as verbatim */ - case LZX_BLOCKTYPE_VERBATIM: - /* read lengths of and build main huffman decoding tree */ - LZX_READ_LENGTHS(MAINTREE, 0, 256); - LZX_READ_LENGTHS(MAINTREE, 256, LZX_NUM_CHARS + (lzx->posn_slots << 3)); - LZX_BUILD_TABLE(MAINTREE); - /* if the literal 0xE8 is anywhere in the block... */ - if (lzx->MAINTREE_len[0xE8] != 0) lzx->intel_started = 1; - /* read lengths of and build lengths huffman decoding tree */ - LZX_READ_LENGTHS(LENGTH, 0, LZX_NUM_SECONDARY_LENGTHS); - LZX_BUILD_TABLE(LENGTH); - break; - - case LZX_BLOCKTYPE_UNCOMPRESSED: - /* because we can't assume otherwise */ - lzx->intel_started = 1; - - /* read 1-16 (not 0-15) bits to align to bytes */ - LZX_ENSURE_BITS(16); - if (bits_left > 16) i_ptr -= 2; - bits_left = 0; bit_buffer = 0; - - /* read 12 bytes of stored R0 / R1 / R2 values */ - for (rundest = &buf[0], i = 0; i < 12; i++) { - if (i_ptr == i_end) { - if (lzx_read_input(lzx)) return lzx->error; - i_ptr = lzx->i_ptr; - i_end = lzx->i_end; - } - *rundest++ = *i_ptr++; - } - R0 = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); - R1 = buf[4] | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24); - R2 = buf[8] | (buf[9] << 8) | (buf[10] << 16) | (buf[11] << 24); - break; - - default: - cli_dbgmsg("lzx_decompress: bad block type (0x%x)\n", lzx->block_type); - return lzx->error = CL_EFORMAT; - } - } - - /* decode more of the block: - * run = min(what's available, what's needed) */ - this_run = lzx->block_remaining; - if (this_run > bytes_todo) this_run = bytes_todo; - - /* assume we decode exactly this_run bytes, for now */ - bytes_todo -= this_run; - lzx->block_remaining -= this_run; - - /* decode at least this_run bytes */ - switch (lzx->block_type) { - case LZX_BLOCKTYPE_VERBATIM: - while (this_run > 0) { - LZX_READ_HUFFSYM(MAINTREE, main_element); - if (main_element < LZX_NUM_CHARS) { - /* literal: 0 to LZX_NUM_CHARS-1 */ - window[window_posn++] = main_element; - this_run--; - } - else { - /* match: LZX_NUM_CHARS + ((slot<<3) | length_header (3 bits)) */ - main_element -= LZX_NUM_CHARS; - - /* get match length */ - match_length = main_element & LZX_NUM_PRIMARY_LENGTHS; - if (match_length == LZX_NUM_PRIMARY_LENGTHS) { - LZX_READ_HUFFSYM(LENGTH, length_footer); - match_length += length_footer; - } - match_length += LZX_MIN_MATCH; - - /* get match offset */ - switch ((match_offset = (main_element >> 3))) { - case 0: match_offset = R0; break; - case 1: match_offset = R1; R1=R0; R0 = match_offset; break; - case 2: match_offset = R2; R2=R0; R0 = match_offset; break; - case 3: match_offset = 1; R2=R1; R1=R0; R0 = match_offset; break; - default: - extra = lzx->extra_bits[match_offset]; - LZX_READ_BITS(verbatim_bits, extra); - match_offset = lzx->position_base[match_offset] - 2 + verbatim_bits; - R2 = R1; R1 = R0; R0 = match_offset; - } - - if ((window_posn + match_length) > lzx->window_size) { - cli_dbgmsg("lzx_decompress: match ran over window wrap\n"); - return lzx->error = CL_EFORMAT; - } - - /* copy match */ - rundest = &window[window_posn]; - i = match_length; - /* does match offset wrap the window? */ - if (match_offset > window_posn) { - /* j = length from match offset to end of window */ - j = match_offset - window_posn; - if (j > (int) lzx->window_size) { - cli_dbgmsg("lzx_decompress: match offset beyond window boundaries\n"); - return lzx->error = CL_EFORMAT; - } - runsrc = &window[lzx->window_size - j]; - if (j < i) { - /* if match goes over the window edge, do two copy runs */ - i -= j; while (j-- > 0) *rundest++ = *runsrc++; - runsrc = window; - } - while (i-- > 0) *rundest++ = *runsrc++; - } - else { - runsrc = rundest - match_offset; - if(i > (int) (lzx->window_size - window_posn)) - i = lzx->window_size - window_posn; - while (i-- > 0) *rundest++ = *runsrc++; - } - - this_run -= match_length; - window_posn += match_length; - } - } /* while (this_run > 0) */ - break; - - case LZX_BLOCKTYPE_ALIGNED: - while (this_run > 0) { - LZX_READ_HUFFSYM(MAINTREE, main_element); - if (main_element < LZX_NUM_CHARS) { - /* literal: 0 to LZX_NUM_CHARS-1 */ - window[window_posn++] = main_element; - this_run--; - } - else { - /* match: LZX_NUM_CHARS + ((slot<<3) | length_header (3 bits)) */ - main_element -= LZX_NUM_CHARS; - - /* get match length */ - match_length = main_element & LZX_NUM_PRIMARY_LENGTHS; - if (match_length == LZX_NUM_PRIMARY_LENGTHS) { - LZX_READ_HUFFSYM(LENGTH, length_footer); - match_length += length_footer; - } - match_length += LZX_MIN_MATCH; - - /* get match offset */ - switch ((match_offset = (main_element >> 3))) { - case 0: match_offset = R0; break; - case 1: match_offset = R1; R1 = R0; R0 = match_offset; break; - case 2: match_offset = R2; R2 = R0; R0 = match_offset; break; - default: - extra = lzx->extra_bits[match_offset]; - match_offset = lzx->position_base[match_offset] - 2; - if (extra > 3) { - /* verbatim and aligned bits */ - extra -= 3; - LZX_READ_BITS(verbatim_bits, extra); - match_offset += (verbatim_bits << 3); - LZX_READ_HUFFSYM(ALIGNED, aligned_bits); - match_offset += aligned_bits; - } - else if (extra == 3) { - /* aligned bits only */ - LZX_READ_HUFFSYM(ALIGNED, aligned_bits); - match_offset += aligned_bits; - } - else if (extra > 0) { /* extra==1, extra==2 */ - /* verbatim bits only */ - LZX_READ_BITS(verbatim_bits, extra); - match_offset += verbatim_bits; - } - else /* extra == 0 */ { - /* ??? not defined in LZX specification! */ - match_offset = 1; - } - /* update repeated offset LRU queue */ - R2 = R1; R1 = R0; R0 = match_offset; - } - - if ((window_posn + match_length) > lzx->window_size) { - cli_dbgmsg("lzx_decompress: match ran over window wrap\n"); - return lzx->error = CL_EFORMAT; - } - - /* copy match */ - rundest = &window[window_posn]; - i = match_length; - /* does match offset wrap the window? */ - if (match_offset > window_posn) { - /* j = length from match offset to end of window */ - j = match_offset - window_posn; - if (j > (int) lzx->window_size) { - cli_dbgmsg("lzx_decompress: match offset beyond window boundaries\n"); - return lzx->error = CL_EFORMAT; - } - runsrc = &window[lzx->window_size - j]; - if (j < i) { - /* if match goes over the window edge, do two copy runs */ - i -= j; while (j-- > 0) *rundest++ = *runsrc++; - runsrc = window; - } - while (i-- > 0) *rundest++ = *runsrc++; - } - else { - runsrc = rundest - match_offset; - while (i-- > 0) *rundest++ = *runsrc++; - } - - this_run -= match_length; - window_posn += match_length; - } - } /* while (this_run > 0) */ - break; - - case LZX_BLOCKTYPE_UNCOMPRESSED: - /* as this_run is limited not to wrap a frame, this also means it - * won't wrap the window (as the window is a multiple of 32k) */ - rundest = &window[window_posn]; - window_posn += this_run; - while (this_run > 0) { - if ((i = i_end - i_ptr)) { - if (i > this_run) i = this_run; - memcpy(rundest, i_ptr, (size_t) i); - rundest += i; - i_ptr += i; - this_run -= i; - } - else { - if (lzx_read_input(lzx)) return lzx->error; - i_ptr = lzx->i_ptr; - i_end = lzx->i_end; - } - } - break; - - default: - return lzx->error = CL_EFORMAT; /* might as well */ - } - - /* did the final match overrun our desired this_run length? */ - if (this_run < 0) { - if ((unsigned int)(-this_run) > lzx->block_remaining) { - cli_dbgmsg("lzx_decompress: overrun went past end of block by %d (%d remaining)\n", -this_run, lzx->block_remaining); - return lzx->error = CL_EFORMAT; - } - lzx->block_remaining -= -this_run; - } - } /* while (bytes_todo > 0) */ - - /* streams don't extend over frame boundaries */ - if ((window_posn - lzx->frame_posn) != frame_size) { - cli_dbgmsg("lzx_decompress: decode beyond output frame limits! %d != %d\n", window_posn - lzx->frame_posn, frame_size); - return lzx->error = CL_EFORMAT; - } - - /* re-align input bitstream */ - if (bits_left > 0) LZX_ENSURE_BITS(16); - if (bits_left & 15) LZX_REMOVE_BITS(bits_left & 15); - - /* check that we've used all of the previous frame first */ - if (lzx->o_ptr != lzx->o_end) { - cli_dbgmsg("lzx_decompress: %d avail bytes, new %d frame\n", lzx->o_end-lzx->o_ptr, frame_size); - return lzx->error = CL_EFORMAT; - } - - /* does this intel block _really_ need decoding? */ - if (lzx->intel_started && lzx->intel_filesize && - (lzx->frame <= 32768) && (frame_size > 10)) - { - unsigned char *data = &lzx->e8_buf[0]; - unsigned char *dataend = &lzx->e8_buf[frame_size - 10]; - signed int curpos = lzx->intel_curpos; - signed int filesize = lzx->intel_filesize; - signed int abs_off, rel_off; - - /* copy e8 block to the e8 buffer and tweak if needed */ - lzx->o_ptr = data; - memcpy(data, &lzx->window[lzx->frame_posn], frame_size); - - while (data < dataend) { - if (*data++ != 0xE8) { curpos++; continue; } - abs_off = data[0] | (data[1]<<8) | (data[2]<<16) | (data[3]<<24); - if ((abs_off >= -curpos) && (abs_off < filesize)) { - rel_off = (abs_off >= 0) ? abs_off - curpos : abs_off + filesize; - data[0] = (unsigned char) rel_off; - data[1] = (unsigned char) (rel_off >> 8); - data[2] = (unsigned char) (rel_off >> 16); - data[3] = (unsigned char) (rel_off >> 24); - } - data += 4; - curpos += 5; - } - lzx->intel_curpos += frame_size; - } - else { - lzx->o_ptr = &lzx->window[lzx->frame_posn]; - if (lzx->intel_filesize) lzx->intel_curpos += frame_size; - } - lzx->o_end = &lzx->o_ptr[frame_size]; - - /* write a frame */ - i = (out_bytes < (off_t)frame_size) ? (unsigned int)out_bytes : frame_size; - if (lzx->wflag && (ret = mspack_write(lzx->ofd, lzx->o_ptr, i, lzx->file)) != CL_SUCCESS) { - return lzx->error = ret; - } - lzx->o_ptr += i; - lzx->offset += i; - out_bytes -= i; - - /* advance frame start position */ - lzx->frame_posn += frame_size; - lzx->frame++; - - /* wrap window / frame position pointers */ - if (window_posn == lzx->window_size) window_posn = 0; - if (lzx->frame_posn == lzx->window_size) lzx->frame_posn = 0; - - } /* while (lzx->frame < end_frame) */ - - if (out_bytes) - cli_dbgmsg("lzx_decompress: bytes left to output\n"); - - /* store local state */ - LZX_STORE_BITS; - lzx->window_posn = window_posn; - lzx->R0 = R0; - lzx->R1 = R1; - lzx->R2 = R2; - - return CL_SUCCESS; -} - -void lzx_free(struct lzx_stream *lzx) { - if (lzx) { - free(lzx->inbuf); - free(lzx->window); - free(lzx); - } -} - -/*************************************************************************** - * Quantum decompression implementation - *************************************************************************** - * The Quantum method was created by David Stafford, adapted by Microsoft - * Corporation. - * - * This decompressor is based on an implementation by Matthew Russotto, used - * with permission. - * - * This decompressor was researched and implemented by Matthew Russotto. It - * has since been tidied up by Stuart Caie. More information can be found at - * http://www.speakeasy.org/~russotto/quantumcomp.html - */ - -/* Quantum decompressor bitstream reading macros - * - * QTM_STORE_BITS stores bitstream state in qtm_stream structure - * QTM_RESTORE_BITS restores bitstream state from qtm_stream structure - * QTM_READ_BITS(var,n) takes N bits from the buffer and puts them in var - * QTM_FILL_BUFFER if there is room for another 16 bits, reads another - * 16 bits from the input stream. - * QTM_PEEK_BITS(n) extracts without removing N bits from the bit buffer - * QTM_REMOVE_BITS(n) removes N bits from the bit buffer - * - * These bit access routines work by using the area beyond the MSB and the - * LSB as a free source of zeroes. This avoids having to mask any bits. - * So we have to know the bit width of the bitbuffer variable. - */ - -#define QTM_BITBUF_WIDTH (sizeof(unsigned int) * CHAR_BIT) - -#define QTM_STORE_BITS do { \ - qtm->i_ptr = i_ptr; \ - qtm->i_end = i_end; \ - qtm->bit_buffer = bit_buffer; \ - qtm->bits_left = bits_left; \ -} while (0) - -#define QTM_RESTORE_BITS do { \ - i_ptr = qtm->i_ptr; \ - i_end = qtm->i_end; \ - bit_buffer = qtm->bit_buffer; \ - bits_left = qtm->bits_left; \ -} while (0) - -/* adds 16 bits to bit buffer, if there's space for the new bits */ -#define QTM_FILL_BUFFER do { \ - if (bits_left <= (QTM_BITBUF_WIDTH - 16)) { \ - if (i_ptr >= i_end) { \ - if (qtm_read_input(qtm)) return qtm->error; \ - i_ptr = qtm->i_ptr; \ - i_end = qtm->i_end; \ - } \ - bit_buffer |= ((i_ptr[0] << 8) | i_ptr[1]) \ - << (QTM_BITBUF_WIDTH - 16 - bits_left); \ - bits_left += 16; \ - i_ptr += 2; \ - } \ -} while (0) - -#define QTM_PEEK_BITS(n) (bit_buffer >> (QTM_BITBUF_WIDTH - (n))) -#define QTM_REMOVE_BITS(n) ((bit_buffer <<= (n)), (bits_left -= (n))) - -#define QTM_READ_BITS(val, bits) do { \ - (val) = 0; \ - for (bits_needed = (bits); bits_needed > 0; bits_needed -= bit_run) { \ - QTM_FILL_BUFFER; \ - bit_run = (bits_left < bits_needed) ? bits_left : bits_needed; \ - (val) = ((val) << bit_run) | QTM_PEEK_BITS(bit_run); \ - QTM_REMOVE_BITS(bit_run); \ - } \ -} while (0) - -static int qtm_read_input(struct qtm_stream *qtm) { - int nread = qtm->read_cb(qtm->file, &qtm->inbuf[0], (int)qtm->inbuf_size); - if (nread < 0) { - if (qtm->file->error == CL_BREAK) - return qtm->error = CL_BREAK; - else - return qtm->error = CL_EFORMAT; - } - - if (nread == 0) { - if (qtm->input_end) { - cli_dbgmsg("qtm_read_input: out of input bytes\n"); - return qtm->error = CL_EREAD; - } - else { - nread = 2; - qtm->inbuf[0] = qtm->inbuf[1] = 0; - qtm->input_end = 1; - } - } - - qtm->i_ptr = &qtm->inbuf[0]; - qtm->i_end = &qtm->inbuf[nread]; - return CL_SUCCESS; -} - -/* Arithmetic decoder: - * - * QTM_GET_SYMBOL(model, var) fetches the next symbol from the stated model - * and puts it in var. - * - * If necessary, qtm_update_model() is called. - */ -#define QTM_GET_SYMBOL(model, var) do { \ - range = ((H - L) & 0xFFFF) + 1; \ - symf = ((((C - L + 1) * model.syms[0].cumfreq)-1) / range) & 0xFFFF; \ - \ - for (i = 1; i < model.entries; i++) { \ - if (model.syms[i].cumfreq <= symf) break; \ - } \ - (var) = model.syms[i-1].sym; \ - \ - range = (H - L) + 1; \ - symf = model.syms[0].cumfreq; \ - H = L + ((model.syms[i-1].cumfreq * range) / symf) - 1; \ - L = L + ((model.syms[i].cumfreq * range) / symf); \ - \ - do { model.syms[--i].cumfreq += 8; } while (i > 0); \ - if (model.syms[0].cumfreq > 3800) qtm_update_model(&model); \ - \ - while (1) { \ - if ((L & 0x8000) != (H & 0x8000)) { \ - if ((L & 0x4000) && !(H & 0x4000)) { \ - /* underflow case */ \ - C ^= 0x4000; L &= 0x3FFF; H |= 0x4000; \ - } \ - else break; \ - } \ - L <<= 1; H = (H << 1) | 1; \ - QTM_FILL_BUFFER; \ - C = (C << 1) | QTM_PEEK_BITS(1); \ - QTM_REMOVE_BITS(1); \ - } \ -} while (0) - -static void qtm_update_model(struct qtm_model *model) { - struct qtm_modelsym tmp; - int i, j; - - if (--model->shiftsleft) { - for (i = model->entries - 1; i >= 0; i--) { - /* -1, not -2; the 0 entry saves this */ - model->syms[i].cumfreq >>= 1; - if (model->syms[i].cumfreq <= model->syms[i+1].cumfreq) { - model->syms[i].cumfreq = model->syms[i+1].cumfreq + 1; - } - } - } - else { - model->shiftsleft = 50; - for (i = 0; i < model->entries; i++) { - /* no -1, want to include the 0 entry */ - /* this converts cumfreqs into frequencies, then shifts right */ - model->syms[i].cumfreq -= model->syms[i+1].cumfreq; - model->syms[i].cumfreq++; /* avoid losing things entirely */ - model->syms[i].cumfreq >>= 1; - } - - /* now sort by frequencies, decreasing order -- this must be an - * inplace selection sort, or a sort with the same (in)stability - * characteristics */ - for (i = 0; i < model->entries - 1; i++) { - for (j = i + 1; j < model->entries; j++) { - if (model->syms[i].cumfreq < model->syms[j].cumfreq) { - tmp = model->syms[i]; - model->syms[i] = model->syms[j]; - model->syms[j] = tmp; - } - } - } - - /* then convert frequencies back to cumfreq */ - for (i = model->entries - 1; i >= 0; i--) { - model->syms[i].cumfreq += model->syms[i+1].cumfreq; - } - } -} - -/* Initialises a model to decode symbols from [start] to [start]+[len]-1 */ -static void qtm_init_model(struct qtm_model *model, - struct qtm_modelsym *syms, int start, int len) -{ - int i; - - model->shiftsleft = 4; - model->entries = len; - model->syms = syms; - - for (i = 0; i <= len; i++) { - syms[i].sym = start + i; /* actual symbol */ - syms[i].cumfreq = len - i; /* current frequency of that symbol */ - } -} - - -/*-------- main Quantum code --------*/ - -struct qtm_stream *qtm_init(int ofd, - int window_bits, int input_buffer_size, - struct cab_file *file, - int (*read_cb)(struct cab_file *, unsigned char *, int)) -{ - unsigned int window_size = 1 << window_bits; - struct qtm_stream *qtm; - unsigned offset; - int i; - - /* Quantum supports window sizes of 2^10 (1Kb) through 2^21 (2Mb) */ - - /* tk: temporary fix: only process 32KB+ window sizes */ - if (window_bits < 15 || window_bits > 21) return NULL; - - input_buffer_size = (input_buffer_size + 1) & -2; - if (input_buffer_size < 2) return NULL; - - /* allocate decompression state */ - if (!(qtm = cli_calloc(1, sizeof(struct qtm_stream)))) { - return NULL; - } - - for (i = 0, offset = 0; i < 42; i++) { - qtm->position_base[i] = offset; - qtm->extra_bits[i] = ((i < 2) ? 0 : (i - 2)) >> 1; - offset += 1 << qtm->extra_bits[i]; - } - - for (i = 0, offset = 0; i < 26; i++) { - qtm->length_base[i] = offset; - qtm->length_extra[i] = (i < 2 ? 0 : i - 2) >> 2; - offset += 1 << qtm->length_extra[i]; - } - qtm->length_base[26] = 254; qtm->length_extra[26] = 0; - - /* allocate decompression window and input buffer */ - qtm->window = cli_calloc(1, (size_t) window_size); - if (!qtm->window) { - cli_errmsg("qtm_init: Unable to allocate decompression window\n"); - free(qtm); - return NULL; - } - - qtm->inbuf = cli_calloc(1, (size_t) input_buffer_size); - if (!qtm->inbuf) { - cli_errmsg("qtm_init: Unable to allocate input buffer\n"); - free(qtm->window); - free(qtm); - return NULL; - } - - /* initialise decompression state */ - qtm->ofd = ofd; - qtm->wflag = 1; - qtm->inbuf_size = input_buffer_size; - qtm->window_size = window_size; - qtm->window_posn = 0; - qtm->frame_start = 0; - qtm->header_read = 0; - qtm->error = CL_SUCCESS; - - qtm->i_ptr = qtm->i_end = &qtm->inbuf[0]; - qtm->o_ptr = qtm->o_end = &qtm->window[0]; - qtm->bits_left = 0; - qtm->bit_buffer = 0; - - /* initialise arithmetic coding models - * - model 4 depends on window size, ranges from 20 to 24 - * - model 5 depends on window size, ranges from 20 to 36 - * - model 6pos depends on window size, ranges from 20 to 42 - */ - i = window_bits * 2; - qtm_init_model(&qtm->model0, &qtm->m0sym[0], 0, 64); - qtm_init_model(&qtm->model1, &qtm->m1sym[0], 64, 64); - qtm_init_model(&qtm->model2, &qtm->m2sym[0], 128, 64); - qtm_init_model(&qtm->model3, &qtm->m3sym[0], 192, 64); - qtm_init_model(&qtm->model4, &qtm->m4sym[0], 0, (i > 24) ? 24 : i); - qtm_init_model(&qtm->model5, &qtm->m5sym[0], 0, (i > 36) ? 36 : i); - qtm_init_model(&qtm->model6, &qtm->m6sym[0], 0, i); - qtm_init_model(&qtm->model6len, &qtm->m6lsym[0], 0, 27); - qtm_init_model(&qtm->model7, &qtm->m7sym[0], 0, 7); - - qtm->file = file; - qtm->read_cb = read_cb; - - /* all ok */ - return qtm; -} - -int qtm_decompress(struct qtm_stream *qtm, uint32_t out_bytes) { - unsigned int frame_start, frame_end, window_posn, match_offset, range; - unsigned char *window, *i_ptr, *i_end, *runsrc, *rundest; - int i, j, selector, extra, sym, match_length, ret; - unsigned short H, L, C, symf; - - register unsigned int bit_buffer; - register unsigned char bits_left; - unsigned char bits_needed, bit_run; - - /* easy answers */ - if (!qtm) return CL_ENULLARG; - if (qtm->error) return qtm->error; - - /* flush out any stored-up bytes before we begin */ - i = qtm->o_end - qtm->o_ptr; - if (((off_t) i > out_bytes) && ((int) out_bytes >= 0)) i = (int) out_bytes; - if (i) { - if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) { - return qtm->error = ret; - } - qtm->o_ptr += i; - out_bytes -= i; - } - if (out_bytes == 0) return CL_SUCCESS; - - /* restore local state */ - QTM_RESTORE_BITS; - window = qtm->window; - window_posn = qtm->window_posn; - frame_start = qtm->frame_start; - H = qtm->H; - L = qtm->L; - C = qtm->C; - - /* while we do not have enough decoded bytes in reserve: */ - while ((qtm->o_end - qtm->o_ptr) < out_bytes) { - - /* read header if necessary. Initialises H, L and C */ - if (!qtm->header_read) { - H = 0xFFFF; L = 0; QTM_READ_BITS(C, 16); - qtm->header_read = 1; - } - - /* decode more, at most up to to frame boundary */ - frame_end = window_posn + (out_bytes - (qtm->o_end - qtm->o_ptr)); - if ((frame_start + QTM_FRAME_SIZE) < frame_end) { - frame_end = frame_start + QTM_FRAME_SIZE; - } - if (frame_end < window_posn) { - cli_dbgmsg("qtm_decompress: window position beyond end of frame\n"); - return qtm->error = CL_EFORMAT; - } - - while (window_posn < frame_end) { - QTM_GET_SYMBOL(qtm->model7, selector); - if (selector < 4) { - struct qtm_model *mdl = (selector == 0) ? &qtm->model0 : - ((selector == 1) ? &qtm->model1 : - ((selector == 2) ? &qtm->model2 : - &qtm->model3)); - QTM_GET_SYMBOL((*mdl), sym); - window[window_posn++] = sym; - } - else { - switch (selector) { - case 4: /* selector 4 = fixed length match (3 bytes) */ - QTM_GET_SYMBOL(qtm->model4, sym); - QTM_READ_BITS(extra, qtm->extra_bits[sym]); - match_offset = qtm->position_base[sym] + extra + 1; - match_length = 3; - break; - - case 5: /* selector 5 = fixed length match (4 bytes) */ - QTM_GET_SYMBOL(qtm->model5, sym); - QTM_READ_BITS(extra, qtm->extra_bits[sym]); - match_offset = qtm->position_base[sym] + extra + 1; - match_length = 4; - break; - - case 6: /* selector 6 = variable length match */ - QTM_GET_SYMBOL(qtm->model6len, sym); - QTM_READ_BITS(extra, qtm->length_extra[sym]); - match_length = qtm->length_base[sym] + extra + 5; - - QTM_GET_SYMBOL(qtm->model6, sym); - QTM_READ_BITS(extra, qtm->extra_bits[sym]); - match_offset = qtm->position_base[sym] + extra + 1; - break; - - default: - /* should be impossible, model7 can only return 0-6 */ - return qtm->error = CL_EFORMAT; - } - - if (window_posn + match_length > qtm->window_size) { - cli_dbgmsg("qtm_decompress: match ran over window wrap\n"); - return qtm->error = CL_EFORMAT; - } - - rundest = &window[window_posn]; - i = match_length; - /* does match offset wrap the window? */ - if (match_offset > window_posn) { - /* j = length from match offset to end of window */ - j = match_offset - window_posn; - if (j > (int) qtm->window_size) { - cli_dbgmsg("qtm_decompress: match offset beyond window boundaries\n"); - return qtm->error = CL_EFORMAT; - } - runsrc = &window[qtm->window_size - j]; - if (j < i) { - /* if match goes over the window edge, do two copy runs */ - i -= j; while (j-- > 0) *rundest++ = *runsrc++; - runsrc = window; - } - while (i-- > 0) *rundest++ = *runsrc++; - } - else { - runsrc = rundest - match_offset; - if(i > (int) (qtm->window_size - window_posn)) - i = qtm->window_size - window_posn; - while (i-- > 0) *rundest++ = *runsrc++; - } - window_posn += match_length; - } - } /* while (window_posn < frame_end) */ - - qtm->o_end = &window[window_posn]; - - /* another frame completed? */ - if ((window_posn - frame_start) >= QTM_FRAME_SIZE) { - if ((window_posn - frame_start) != QTM_FRAME_SIZE) { - cli_dbgmsg("qtm_decompress: overshot frame alignment\n"); - return qtm->error = CL_EFORMAT; - } - - /* re-align input */ - if (bits_left & 7) QTM_REMOVE_BITS(bits_left & 7); - do { QTM_READ_BITS(i, 8); } while (i != 0xFF); - qtm->header_read = 0; - - /* window wrap? */ - if (window_posn == qtm->window_size) { - /* flush all currently stored data */ - i = (qtm->o_end - qtm->o_ptr); - if(i <= 0) - break; - if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) { - return qtm->error = ret; - } - out_bytes -= i; - qtm->o_ptr = &window[0]; - qtm->o_end = &window[0]; - window_posn = 0; - } - - frame_start = window_posn; - } - - } /* while (more bytes needed) */ - - if (out_bytes > 0) { - i = (int) out_bytes; - if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) { - return qtm->error = ret; - } - qtm->o_ptr += i; - } - - /* store local state */ - QTM_STORE_BITS; - qtm->window_posn = window_posn; - qtm->frame_start = frame_start; - qtm->H = H; - qtm->L = L; - qtm->C = C; - - return CL_SUCCESS; -} - -void qtm_free(struct qtm_stream *qtm) { - if (qtm) { - free(qtm->window); - free(qtm->inbuf); - free(qtm); - } -} diff -Nru clamav-0.99.2+dfsg/libclamav/mspack.h clamav-0.99.3~beta1+dfsg/libclamav/mspack.h --- clamav-0.99.2+dfsg/libclamav/mspack.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/mspack.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,294 +0,0 @@ -/* - * This file includes code from libmspack adapted for libclamav by - * tkojm@clamav.net - * - * Copyright (C) 2003-2004 Stuart Caie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef __MSPACK_H -#define __MSPACK_H - -#include -#include "cab.h" - - -/*************************************************************************** - * MS-ZIP decompression definitions * - ***************************************************************************/ - -#define MSZIP_FRAME_SIZE (32768) /* size of LZ history window */ -#define MSZIP_MAX_HUFFBITS (16) /* maximum huffman code length */ -#define MSZIP_LITERAL_MAXSYMBOLS (288) /* literal/length huffman tree */ -#define MSZIP_LITERAL_TABLEBITS (9) -#define MSZIP_DISTANCE_MAXSYMBOLS (32) /* distance huffman tree */ -#define MSZIP_DISTANCE_TABLEBITS (6) - -/* if there are less direct lookup entries than symbols, the longer - * code pointers will be <= maxsymbols. This must not happen, or we - * will decode entries badly */ -#if (1 << MSZIP_LITERAL_TABLEBITS) < (MSZIP_LITERAL_MAXSYMBOLS * 2) -# define MSZIP_LITERAL_TABLESIZE (MSZIP_LITERAL_MAXSYMBOLS * 4) -#else -# define MSZIP_LITERAL_TABLESIZE ((1 << MSZIP_LITERAL_TABLEBITS) + \ - (MSZIP_LITERAL_MAXSYMBOLS * 2)) -#endif - -#if (1 << MSZIP_DISTANCE_TABLEBITS) < (MSZIP_DISTANCE_MAXSYMBOLS * 2) -# define MSZIP_DISTANCE_TABLESIZE (MSZIP_DISTANCE_MAXSYMBOLS * 4) -#else -# define MSZIP_DISTANCE_TABLESIZE ((1 << MSZIP_DISTANCE_TABLEBITS) + \ - (MSZIP_DISTANCE_MAXSYMBOLS * 2)) -#endif - -struct mszip_stream { - int ofd; /* output file descriptor */ - - /* inflate() will call this whenever the window should be emptied. */ - int (*flush_window)(struct mszip_stream *, unsigned int); - - int error, repair_mode, bytes_output, input_end; - - /* I/O buffering */ - unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end; - unsigned int bit_buffer, bits_left, inbuf_size; - - unsigned int window_posn; /* offset within window */ - - /* huffman code lengths */ - unsigned char LITERAL_len[MSZIP_LITERAL_MAXSYMBOLS]; - unsigned char DISTANCE_len[MSZIP_DISTANCE_MAXSYMBOLS]; - - /* huffman decoding tables */ - unsigned short LITERAL_table [MSZIP_LITERAL_TABLESIZE]; - unsigned short DISTANCE_table[MSZIP_DISTANCE_TABLESIZE]; - - /* 32kb history window */ - unsigned char window[MSZIP_FRAME_SIZE]; - - /* cabinet related stuff */ - struct cab_file *file; - int (*read_cb)(struct cab_file *, unsigned char *, int); - - unsigned char wflag; /* write flag */ - unsigned int last; /* prior end of content buffer */ - -}; - -struct mszip_stream *mszip_init(int ofd, - int input_buffer_size, - int repair_mode, - struct cab_file *file, - int (*read_cb)(struct cab_file *, unsigned char *, int)); - -extern int mszip_decompress(struct mszip_stream *zip, uint32_t out_bytes); - -void mszip_free(struct mszip_stream *zip); - - -/*************************************************************************** - * Quantum decompression definitions * - ***************************************************************************/ - -/* Quantum compression / decompression definitions */ - -#define QTM_FRAME_SIZE (32768) - -struct qtm_modelsym { - unsigned short sym, cumfreq; -}; - -struct qtm_model { - int shiftsleft, entries; - struct qtm_modelsym *syms; -}; - -struct qtm_stream { - int ofd; /* output file descriptor */ - - unsigned char *window; /* decoding window */ - unsigned int window_size; /* window size */ - unsigned int window_posn; /* decompression offset within window */ - unsigned int frame_start; /* start of current frame within window */ - - unsigned short H, L, C; /* high/low/current: arith coding state */ - unsigned char header_read; /* have we started decoding a new frame? */ - unsigned char wflag; /* write flag */ - - int error, input_end; - - /* data tables */ - unsigned int position_base[42]; - unsigned char extra_bits[42], length_base[27], length_extra[27]; - - /* four literal models, each representing 64 symbols - * model0 for literals from 0 to 63 (selector = 0) - * model1 for literals from 64 to 127 (selector = 1) - * model2 for literals from 128 to 191 (selector = 2) - * model3 for literals from 129 to 255 (selector = 3) */ - struct qtm_model model0, model1, model2, model3; - - /* three match models. - * model4 for match with fixed length of 3 bytes - * model5 for match with fixed length of 4 bytes - * model6 for variable length match, encoded with model6len model */ - struct qtm_model model4, model5, model6, model6len; - - /* selector model. 0-6 to say literal (0,1,2,3) or match (4,5,6) */ - struct qtm_model model7; - - /* symbol arrays for all models */ - struct qtm_modelsym m0sym[64 + 1]; - struct qtm_modelsym m1sym[64 + 1]; - struct qtm_modelsym m2sym[64 + 1]; - struct qtm_modelsym m3sym[64 + 1]; - struct qtm_modelsym m4sym[24 + 1]; - struct qtm_modelsym m5sym[36 + 1]; - struct qtm_modelsym m6sym[42 + 1], m6lsym[27 + 1]; - struct qtm_modelsym m7sym[7 + 1]; - - /* I/O buffers - 1*/ - unsigned int bit_buffer; - - /* cabinet related stuff */ - struct cab_file *file; - int (*read_cb)(struct cab_file *, unsigned char *, int); - - /* I/O buffers - 2*/ - unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end; - unsigned int inbuf_size; - unsigned char bits_left; - -}; - -extern struct qtm_stream *qtm_init(int ofd, - int window_bits, - int input_buffer_size, - struct cab_file *file, - int (*read_cb)(struct cab_file *, unsigned char *, int)); - -extern int qtm_decompress(struct qtm_stream *qtm, uint32_t out_bytes); - -void qtm_free(struct qtm_stream *qtm); - -/*************************************************************************** - * LZX decompression definitions * - ***************************************************************************/ - -/* some constants defined by the LZX specification */ -#define LZX_MIN_MATCH (2) -#define LZX_MAX_MATCH (257) -#define LZX_NUM_CHARS (256) -#define LZX_BLOCKTYPE_INVALID (0) /* also blocktypes 4-7 invalid */ -#define LZX_BLOCKTYPE_VERBATIM (1) -#define LZX_BLOCKTYPE_ALIGNED (2) -#define LZX_BLOCKTYPE_UNCOMPRESSED (3) -#define LZX_PRETREE_NUM_ELEMENTS (20) -#define LZX_ALIGNED_NUM_ELEMENTS (8) /* aligned offset tree #elements */ -#define LZX_NUM_PRIMARY_LENGTHS (7) /* this one missing from spec! */ -#define LZX_NUM_SECONDARY_LENGTHS (249) /* length tree #elements */ - -/* LZX huffman defines: tweak tablebits as desired */ -#define LZX_PRETREE_MAXSYMBOLS (LZX_PRETREE_NUM_ELEMENTS) -#define LZX_PRETREE_TABLEBITS (6) -#define LZX_MAINTREE_MAXSYMBOLS (LZX_NUM_CHARS + 50*8) -#define LZX_MAINTREE_TABLEBITS (12) -#define LZX_LENGTH_MAXSYMBOLS (LZX_NUM_SECONDARY_LENGTHS+1) -#define LZX_LENGTH_TABLEBITS (12) -#define LZX_ALIGNED_MAXSYMBOLS (LZX_ALIGNED_NUM_ELEMENTS) -#define LZX_ALIGNED_TABLEBITS (7) -#define LZX_LENTABLE_SAFETY (64) /* table decoding overruns are allowed */ - -#define LZX_FRAME_SIZE (32768) /* the size of a frame in LZX */ - -struct lzx_stream { - int ofd; /* output file descriptor */ - - off_t offset; /* number of bytes actually output */ - off_t length; /* overall decompressed length of stream */ - - unsigned char *window; /* decoding window */ - unsigned int window_size; /* window size */ - unsigned int window_posn; /* decompression offset within window */ - unsigned int frame_posn; /* current frame offset within in window */ - unsigned int frame; /* the number of 32kb frames processed */ - unsigned int reset_interval; /* which frame do we reset the compressor? */ - - unsigned int R0, R1, R2; /* for the LRU offset system */ - unsigned int block_length; /* uncompressed length of this LZX block */ - unsigned int block_remaining; /* uncompressed bytes still left to decode */ - - signed int intel_filesize; /* magic header value used for transform */ - signed int intel_curpos; /* current offset in transform space */ - - unsigned char intel_started; /* has intel E8 decoding started? */ - unsigned char block_type; /* type of the current block */ - unsigned char header_read; /* have we started decoding at all yet? */ - unsigned char posn_slots; /* how many posn slots in stream? */ - - int error; - - /* I/O buffering */ - unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end; - unsigned int bit_buffer, bits_left, inbuf_size; - - /* huffman code lengths */ - unsigned char PRETREE_len [LZX_PRETREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; - unsigned char MAINTREE_len [LZX_MAINTREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; - unsigned char LENGTH_len [LZX_LENGTH_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; - unsigned char ALIGNED_len [LZX_ALIGNED_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; - - /* huffman decoding tables */ - unsigned short PRETREE_table [(1 << LZX_PRETREE_TABLEBITS) + - (LZX_PRETREE_MAXSYMBOLS * 2)]; - unsigned short MAINTREE_table[(1 << LZX_MAINTREE_TABLEBITS) + - (LZX_MAINTREE_MAXSYMBOLS * 2)]; - unsigned short LENGTH_table [(1 << LZX_LENGTH_TABLEBITS) + - (LZX_LENGTH_MAXSYMBOLS * 2)]; - unsigned short ALIGNED_table [(1 << LZX_ALIGNED_TABLEBITS) + - (LZX_ALIGNED_MAXSYMBOLS * 2)]; - unsigned char input_end; /* have we reached the end of input? */ - unsigned char wflag; /* write flag */ - - /* this is used purely for doing the intel E8 transform */ - unsigned char e8_buf[LZX_FRAME_SIZE]; - - unsigned int position_base[51]; - - /* cabinet related stuff */ - struct cab_file *file; - int (*read_cb)(struct cab_file *, unsigned char *, int); - - unsigned char extra_bits[51]; - -}; - -struct lzx_stream *lzx_init(int ofd, - int window_bits, - int reset_interval, - int input_buffer_size, - off_t output_length, - struct cab_file *file, - int (*read_cb)(struct cab_file *, unsigned char *, int)); - -extern void lzx_set_output_length(struct lzx_stream *lzx, - off_t output_length); - -extern int lzx_decompress(struct lzx_stream *lzx, uint32_t out_bytes); - -void lzx_free(struct lzx_stream *lzx); - -#endif diff -Nru clamav-0.99.2+dfsg/libclamav/msxml_parser.c clamav-0.99.3~beta1+dfsg/libclamav/msxml_parser.c --- clamav-0.99.2+dfsg/libclamav/msxml_parser.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/msxml_parser.c 2017-02-20 18:36:39.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Extract component parts of MS XML files (e.g. MS Office 2003 XML Documents) + * Extract component parts of various MS XML files (e.g. MS Office 2003 XML Documents) * * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. * Copyright (C) 2007-2013 Sourcefire, Inc. @@ -62,10 +62,23 @@ } \ } while(0) +#define track_json(mxctx) (mxctx->ictx->flags & MSXML_FLAG_JSON) + +struct msxml_ictx { + cli_ctx *ctx; + uint32_t flags; + const struct key_entry *keys; + size_t num_keys; + +#if HAVE_JSON + json_object *root; + int toval; +#endif +}; struct key_entry blank_key = { NULL, NULL, 0 }; -static const struct key_entry *msxml_check_key(struct msxml_ctx *mxctx, const xmlChar *key, size_t keylen) +static const struct key_entry *msxml_check_key(struct msxml_ictx *ictx, const xmlChar *key, size_t keylen) { unsigned i; @@ -74,9 +87,9 @@ return &blank_key; } - for (i = 0; i < mxctx->num_keys; ++i) { - if (keylen == strlen(mxctx->keys[i].key) && !strncasecmp((char *)key, mxctx->keys[i].key, keylen)) { - return &mxctx->keys[i]; + for (i = 0; i < ictx->num_keys; ++i) { + if (keylen == strlen(ictx->keys[i].key) && !strncasecmp((char *)key, ictx->keys[i].key, keylen)) { + return &ictx->keys[i]; } } @@ -91,11 +104,11 @@ switch (severity) { case XML_PARSER_SEVERITY_WARNING: case XML_PARSER_SEVERITY_VALIDITY_WARNING: - cli_warnmsg("%s:%d: parser warning : %s", (char*)URI, line, msg); + cli_dbgmsg("%s:%d: parser warning : %s", (char*)URI, line, msg); break; case XML_PARSER_SEVERITY_ERROR: case XML_PARSER_SEVERITY_VALIDITY_ERROR: - cli_warnmsg("%s:%d: parser error : %s", (char*)URI, line, msg); + cli_dbgmsg("%s:%d: parser error : %s", (char*)URI, line, msg); break; default: cli_dbgmsg("%s:%d: unknown severity : %s", (char*)URI, line, msg); @@ -164,8 +177,9 @@ const struct key_entry *keyinfo; struct attrib_entry attribs[MAX_ATTRIBS]; int ret, virus = 0, state, node_type, endtag = 0, num_attribs = 0; - cli_ctx *ctx = mxctx->ctx; + cli_ctx *ctx = mxctx->ictx->ctx; #if HAVE_JSON + json_object *root = mxctx->ictx->root; json_object *parent = (json_object *)jptr; json_object *thisjobj = NULL; #else @@ -180,8 +194,8 @@ cli_dbgmsg("msxml_parse_element: reached msxml json recursion limit\n"); #if HAVE_JSON - if (mxctx->mode) { - int tmp = cli_json_parse_error(mxctx->root, "MSXML_RECURSIVE_LIMIT"); + if (track_json(mxctx)) { + int tmp = cli_json_parse_error(root, "MSXML_RECURSIVE_LIMIT"); if (tmp != CL_SUCCESS) return tmp; } @@ -211,8 +225,8 @@ if (!element_name) { cli_dbgmsg("msxml_parse_element: element tag node nameless\n"); #if HAVE_JSON - if (mxctx->mode) { - int tmp = cli_json_parse_error(mxctx->root, "MSXML_NAMELESS_ELEMENT"); + if (track_json(mxctx)) { + int tmp = cli_json_parse_error(root, "MSXML_NAMELESS_ELEMENT"); if (tmp != CL_SUCCESS) return tmp; } @@ -221,7 +235,7 @@ } /* determine if the element is interesting */ - keyinfo = msxml_check_key(mxctx, element_name, xmlStrlen(element_name)); + keyinfo = msxml_check_key(mxctx->ictx, element_name, xmlStrlen(element_name)); cli_msxmlmsg("key: %s\n", keyinfo->key); cli_msxmlmsg("name: %s\n", keyinfo->name); @@ -237,9 +251,9 @@ } #if HAVE_JSON - if (mxctx->mode && (keyinfo->type & MSXML_JSON_TRACK)) { + if (track_json(mxctx) && (keyinfo->type & MSXML_JSON_TRACK)) { if (keyinfo->type & MSXML_JSON_ROOT) - thisjobj = cli_jsonobj(mxctx->root, keyinfo->name); + thisjobj = cli_jsonobj(root, keyinfo->name); else if (keyinfo->type & MSXML_JSON_WRKPTR) thisjobj = cli_jsonobj(parent, keyinfo->name); @@ -353,7 +367,7 @@ while (!endtag) { #if HAVE_JSON - if (mxctx->mode && (cli_json_timeout_cycle_check(mxctx->ctx, &(mxctx->toval)) != CL_SUCCESS)) + if (track_json(mxctx) && (cli_json_timeout_cycle_check(ctx, &(mxctx->ictx->toval)) != CL_SUCCESS)) return CL_ETIMEOUT; #endif @@ -402,12 +416,16 @@ if (cli_writen(of, (char *)node_value, vlen) != vlen) { close(of); + if (!(ctx->engine->keeptmp)) + cli_unlink(tempfile); + free(tempfile); return CL_EWRITE; } cli_dbgmsg("msxml_parse_element: extracted binary data to %s\n", tempfile); - ret = mxctx->scan_cb(of, ctx, num_attribs, attribs); + ret = mxctx->scan_cb(of, ctx, num_attribs, attribs, mxctx->scan_data); + close(of); if (!(ctx->engine->keeptmp)) cli_unlink(tempfile); free(tempfile); @@ -444,6 +462,9 @@ if(cli_writen(of, decoded, decodedlen) != (int)decodedlen) { free(decoded); close(of); + if (!(ctx->engine->keeptmp)) + cli_unlink(tempfile); + free(tempfile); return CL_EWRITE; } free(decoded); @@ -467,6 +488,31 @@ check_state(state); break; + case XML_READER_TYPE_COMMENT: + node_value = xmlTextReaderConstValue(reader); + + cli_msxmlmsg("COMMENT: %s\n", node_value); + + /* callback-based scanning mechanism for comments (used by MHTML) */ + if ((keyinfo->type & MSXML_COMMENT_CB) && mxctx->comment_cb) { +#if HAVE_JSON + ret = mxctx->comment_cb((const char *)node_value, ctx, thisjobj, mxctx->comment_data); +#else + ret = mxctx->comment_cb((const char *)node_value, ctx, NULL, mxctx->comment_data); +#endif + if (ret != CL_SUCCESS && (ret != CL_VIRUS || (!SCAN_ALL && ret == CL_VIRUS))) { + return ret; + } else if (SCAN_ALL && ret == CL_VIRUS) { + virus = 1; + } + + } + + /* advance to next node */ + state = xmlTextReaderRead(reader); + check_state(state); + break; + case XML_READER_TYPE_SIGNIFICANT_WHITESPACE: /* advance to next node */ state = xmlTextReaderRead(reader); @@ -499,9 +545,8 @@ cli_dbgmsg("msxml_parse_element: unhandled xml secondary node %s [%d]: %s\n", node_name, node_type, node_value); - state = xmlTextReaderNext(reader); + state = xmlTextReaderRead(reader); check_state(state); - return (virus ? CL_VIRUS : CL_SUCCESS); } } @@ -522,43 +567,52 @@ return (virus ? CL_VIRUS : CL_SUCCESS); } -/* reader intialization and closing handled by caller */ -int cli_msxml_parse_document(cli_ctx *ctx, xmlTextReaderPtr reader, const struct key_entry *keys, const size_t num_keys, int mode, msxml_scan_cb scan_cb) +/* reader initialization and closing handled by caller */ +int cli_msxml_parse_document(cli_ctx *ctx, xmlTextReaderPtr reader, const struct key_entry *keys, const size_t num_keys, uint32_t flags, struct msxml_ctx *mxctx) { - struct msxml_ctx mxctx; + struct msxml_ctx reserve; + struct msxml_ictx ictx; int state, virus = 0, ret = CL_SUCCESS; if (!ctx) return CL_ENULLARG; - mxctx.ctx = ctx; - mxctx.scan_cb = scan_cb; - mxctx.keys = keys; - mxctx.num_keys = num_keys; -#if HAVE_JSON - mxctx.mode = mode; - if (mode) { - mxctx.root = ctx->wrkproperty; + if (!mxctx) { + memset(&reserve, 0, sizeof(reserve)); + mxctx = &reserve; + } + + ictx.ctx = ctx; + ictx.flags = flags; + ictx.keys = keys; + ictx.num_keys = num_keys; +#if HAVE_JSON + if (flags & MSXML_FLAG_JSON) { + ictx.root = ctx->wrkproperty; /* JSON Sanity Check */ - if (!mxctx.root) - mxctx.mode = 0; - mxctx.toval = 0; + if (!ictx.root) + ictx.flags &= ~MSXML_FLAG_JSON; + ictx.toval = 0; } +#else + ictx.flags &= ~MSXML_FLAG_JSON; #endif + mxctx->ictx = &ictx; - /* Error Handler */ - xmlTextReaderSetErrorHandler(reader, NULL, NULL); /* xml default handler */ - //xmlTextReaderSetErrorHandler(reader, msxml_error_handler, NULL); + /* Error Handler (setting handler on tree walker causes segfault) */ + if (!(flags & MSXML_FLAG_WALK)) + //xmlTextReaderSetErrorHandler(reader, NULL, NULL); /* xml default handler */ + xmlTextReaderSetErrorHandler(reader, msxml_error_handler, NULL); /* Main Processing Loop */ while ((state = xmlTextReaderRead(reader)) == 1) { #if HAVE_JSON - if (mxctx.mode && (cli_json_timeout_cycle_check(mxctx.ctx, &(mxctx.toval)) != CL_SUCCESS)) + if ((ictx.flags & MSXML_FLAG_JSON) && (cli_json_timeout_cycle_check(ictx.ctx, &(ictx.toval)) != CL_SUCCESS)) return CL_ETIMEOUT; - ret = msxml_parse_element(&mxctx, reader, 0, mxctx.root); + ret = msxml_parse_element(mxctx, reader, 0, ictx.root); #else - ret = msxml_parse_element(&mxctx, reader, 0, NULL); + ret = msxml_parse_element(mxctx, reader, 0, NULL); #endif if (ret == CL_SUCCESS); else if (SCAN_ALL && ret == CL_VIRUS) { @@ -578,7 +632,7 @@ #if HAVE_JSON /* Parse General Error Handler */ - if (mxctx.mode) { + if (ictx.flags & MSXML_FLAG_JSON) { int tmp = CL_SUCCESS; switch(ret) { @@ -586,22 +640,22 @@ case CL_BREAK: /* OK */ break; case CL_VIRUS: - tmp = cli_json_parse_error(mxctx.root, "MSXML_INTR_VIRUS"); + tmp = cli_json_parse_error(ictx.root, "MSXML_INTR_VIRUS"); break; case CL_ETIMEOUT: - tmp = cli_json_parse_error(mxctx.root, "MSXML_INTR_TIMEOUT"); + tmp = cli_json_parse_error(ictx.root, "MSXML_INTR_TIMEOUT"); break; case CL_EPARSE: - tmp = cli_json_parse_error(mxctx.root, "MSXML_ERROR_XMLPARSER"); + tmp = cli_json_parse_error(ictx.root, "MSXML_ERROR_XMLPARSER"); break; case CL_EMEM: - tmp = cli_json_parse_error(mxctx.root, "MSXML_ERROR_OUTOFMEM"); + tmp = cli_json_parse_error(ictx.root, "MSXML_ERROR_OUTOFMEM"); break; case CL_EFORMAT: - tmp = cli_json_parse_error(mxctx.root, "MSXML_ERROR_MALFORMED"); + tmp = cli_json_parse_error(ictx.root, "MSXML_ERROR_MALFORMED"); break; default: - tmp = cli_json_parse_error(mxctx.root, "MSXML_ERROR_OTHER"); + tmp = cli_json_parse_error(ictx.root, "MSXML_ERROR_OTHER"); break; } @@ -610,7 +664,7 @@ } #endif - /* non-critical return supression */ + /* non-critical return suppression */ if (ret == CL_ETIMEOUT || ret == CL_BREAK) ret = CL_SUCCESS; diff -Nru clamav-0.99.2+dfsg/libclamav/msxml_parser.h clamav-0.99.3~beta1+dfsg/libclamav/msxml_parser.h --- clamav-0.99.2+dfsg/libclamav/msxml_parser.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/msxml_parser.h 2016-10-13 15:45:44.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Extract component parts of MS XML files (e.g. MS Office 2003 XML Documents) + * Extract component parts of various MS XML files (e.g. MS Office 2003 XML Documents) * * Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. * Copyright (C) 2007-2013 Sourcefire, Inc. @@ -30,7 +30,6 @@ #endif #include "others.h" -#include "json_api.h" #ifdef _WIN32 #ifndef LIBXML_WRITER_ENABLED @@ -43,6 +42,12 @@ #define MSXML_RECLEVEL_MAX 20 #define MSXML_JSON_STRLEN_MAX 128 +/* reader usage flags */ +#define MSXML_FLAG_JSON 0x1 +#define MSXML_FLAG_WALK 0x2 + +struct msxml_ictx; + struct attrib_entry { const char *key; const char *value; @@ -54,37 +59,35 @@ #define MSXML_IGNORE_ELEM 0x1 #define MSXML_SCAN_CB 0x2 #define MSXML_SCAN_B64 0x4 +#define MSXML_COMMENT_CB 0x8 /* where */ -#define MSXML_JSON_ROOT 0x8 -#define MSXML_JSON_WRKPTR 0x10 -#define MSXML_JSON_MULTI 0x20 +#define MSXML_JSON_ROOT 0x10 +#define MSXML_JSON_WRKPTR 0x20 +#define MSXML_JSON_MULTI 0x40 #define MSXML_JSON_TRACK (MSXML_JSON_ROOT | MSXML_JSON_WRKPTR) /* what */ -#define MSXML_JSON_COUNT 0x40 -#define MSXML_JSON_VALUE 0x80 -#define MSXML_JSON_ATTRIB 0x100 +#define MSXML_JSON_COUNT 0x100 +#define MSXML_JSON_VALUE 0x200 +#define MSXML_JSON_ATTRIB 0x400 const char *key; const char *name; uint32_t type; }; -typedef int (*msxml_scan_cb)(int fd, cli_ctx *ctx, int num_attribs, struct attrib_entry *attribs); +typedef int (*msxml_scan_cb)(int fd, cli_ctx *ctx, int num_attribs, struct attrib_entry *attribs, void *cbdata); +typedef int (*msxml_comment_cb)(const char *comment, cli_ctx *ctx, void *wrkjobj, void *cbdata); struct msxml_ctx { - cli_ctx *ctx; msxml_scan_cb scan_cb; - const struct key_entry *keys; - size_t num_keys; - -#if HAVE_JSON - json_object *root; - int mode, toval; -#endif + void *scan_data; + msxml_comment_cb comment_cb; + void *comment_data; + struct msxml_ictx *ictx; }; -int cli_msxml_parse_document(cli_ctx *ctx, xmlTextReaderPtr reader, const struct key_entry *keys, const size_t num_keys, int mode, msxml_scan_cb scan_cb); +int cli_msxml_parse_document(cli_ctx *ctx, xmlTextReaderPtr reader, const struct key_entry *keys, const size_t num_keys, uint32_t flags, struct msxml_ctx *mxctx); #endif /* HAVE_LIBXML2 */ diff -Nru clamav-0.99.2+dfsg/libclamav/ole2_extract.c clamav-0.99.3~beta1+dfsg/libclamav/ole2_extract.c --- clamav-0.99.2+dfsg/libclamav/ole2_extract.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/ole2_extract.c 2016-10-13 15:45:44.000000000 +0000 @@ -1230,9 +1230,17 @@ current_block = prop->start_block; len = prop->size; + if (cli_debug_flag) { + if (!name) + name = get_property_name2(prop->name, prop->name_size); + cli_dbgmsg("OLE2 [handler_otf]: Dumping '%s' to '%s'\n", name, tempfile); + } + buff = (unsigned char *)cli_malloc(1 << hdr->log2_big_block_size); if (!buff) { close(ofd); + if (name) + free(name); cli_unlink(tempfile); free(tempfile); return CL_EMEM; @@ -1243,6 +1251,8 @@ cli_errmsg("OLE2: OTF handler init bitset failed\n"); free(buff); close(ofd); + if (name) + free(name); if (cli_unlink(tempfile)) { free(tempfile); return CL_EUNLINK; @@ -1274,6 +1284,8 @@ offset = (1 << hdr->log2_small_block_size) * (current_block % (1 << (hdr->log2_big_block_size - hdr->log2_small_block_size))); if (cli_writen(ofd, &buff[offset], MIN(len, 1 << hdr->log2_small_block_size)) != MIN(len, 1 << hdr->log2_small_block_size)) { close(ofd); + if (name) + free(name); free(buff); cli_bitset_free(blk_bitset); if (cli_unlink(tempfile)) { @@ -1293,6 +1305,8 @@ if (cli_writen(ofd, buff, MIN(len, (1 << hdr->log2_big_block_size))) != MIN(len, (1 << hdr->log2_big_block_size))) { close(ofd); + if (name) + free(name); free(buff); cli_bitset_free(blk_bitset); if (cli_unlink(tempfile)) { @@ -1312,6 +1326,8 @@ is_mso = likely_mso_stream(ofd); if (lseek(ofd, 0, SEEK_SET) == -1) { close(ofd); + if (name) + free(name); if (ctx && !(ctx->engine->keeptmp)) cli_unlink(tempfile); @@ -1324,7 +1340,8 @@ #if HAVE_JSON /* JSON Output Summary Information */ if (ctx->options & CL_SCAN_FILE_PROPERTIES && ctx->properties != NULL) { - name = get_property_name2(prop->name, prop->name_size); + if (!name) + name = get_property_name2(prop->name, prop->name_size); if (name) { if (!strncmp(name, "_5_summaryinformation", 21)) { cli_dbgmsg("OLE2: detected a '_5_summaryinformation' stream\n"); diff -Nru clamav-0.99.2+dfsg/libclamav/ooxml.c clamav-0.99.3~beta1+dfsg/libclamav/ooxml.c --- clamav-0.99.2+dfsg/libclamav/ooxml.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/ooxml.c 2016-10-13 15:45:44.000000000 +0000 @@ -128,7 +128,7 @@ return CL_SUCCESS; // internal error from libxml2 } - ret = cli_msxml_parse_document(ctx, reader, ooxml_keys, num_ooxml_keys, 1, NULL); + ret = cli_msxml_parse_document(ctx, reader, ooxml_keys, num_ooxml_keys, MSXML_FLAG_JSON, NULL); if (ret != CL_SUCCESS && ret != CL_ETIMEOUT && ret != CL_BREAK) cli_warnmsg("ooxml_parse_document: encountered issue in parsing properties document\n"); @@ -375,7 +375,7 @@ return CL_SUCCESS; // internal error from libxml2 } - ret = cli_msxml_parse_document(ctx, reader, ooxml_hwp_keys, num_ooxml_hwp_keys, 1, NULL); + ret = cli_msxml_parse_document(ctx, reader, ooxml_hwp_keys, num_ooxml_hwp_keys, MSXML_FLAG_JSON, NULL); if (ret != CL_SUCCESS && ret != CL_ETIMEOUT && ret != CL_BREAK) cli_warnmsg("ooxml_hwp_cb: encountered issue in parsing properties document\n"); diff -Nru clamav-0.99.2+dfsg/libclamav/others.c clamav-0.99.3~beta1+dfsg/libclamav/others.c --- clamav-0.99.2+dfsg/libclamav/others.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/others.c 2017-06-09 20:02:26.000000000 +0000 @@ -934,6 +934,16 @@ return CL_SUCCESS; } +void cli_check_blockmax(cli_ctx *ctx, int rc) +{ + if (BLOCKMAX && !ctx->limit_exceeded) { + cli_append_virus (ctx, "Heuristic.Limits.Exceeded"); + ctx->limit_exceeded = 1; + cli_dbgmsg ("Limit %s Exceeded: scanning may be incomplete and additional analysis needed for this file.\n", + cl_strerror(rc)); + } +} + int cli_checklimits(const char *who, cli_ctx *ctx, unsigned long need1, unsigned long need2, unsigned long need3) { int ret = CL_SUCCESS; unsigned long needed; @@ -963,8 +973,12 @@ if(ctx->engine->maxfiles && ctx->scannedfiles>=ctx->engine->maxfiles) { cli_dbgmsg("%s: files limit reached (max: %u)\n", who, ctx->engine->maxfiles); - return CL_EMAXFILES; + ret = CL_EMAXFILES; } + + if (ret != CL_SUCCESS) + cli_check_blockmax(ctx, ret); + return ret; } @@ -1074,14 +1088,40 @@ return 0; } -void cli_append_virus(cli_ctx * ctx, const char * virname) +void cli_virus_found_cb(cli_ctx * ctx) { - if (ctx->virname == NULL) - return; if (ctx->engine->cb_virus_found) - ctx->engine->cb_virus_found(fmap_fd(*ctx->fmap), virname, ctx->cb_ctx); - ctx->num_viruses++; - *ctx->virname = virname; + ctx->engine->cb_virus_found(fmap_fd(*ctx->fmap), (const char *)*ctx->virname, ctx->cb_ctx); +} + +int cli_append_possibly_unwanted(cli_ctx * ctx, const char * virname) +{ + if (SCAN_ALL) + return cli_append_virus(ctx, virname); + else if (ctx->options & CL_SCAN_HEURISTIC_PRECEDENCE) + return cli_append_virus(ctx, virname); + else if (ctx->num_viruses == 0 && ctx->virname != NULL && *ctx->virname == NULL) { + ctx->found_possibly_unwanted = 1; + ctx->num_viruses++; + *ctx->virname = virname; + } + return CL_CLEAN; +} + +int cli_append_virus(cli_ctx * ctx, const char * virname) +{ + if (ctx->virname == NULL) + return CL_CLEAN; + if (ctx->fmap != NULL && (*ctx->fmap) != NULL && CL_VIRUS != cli_checkfp_virus((*ctx->fmap)->maphash, (*ctx->fmap)->len, ctx, virname)) + return CL_CLEAN; + if (!SCAN_ALL && ctx->num_viruses != 0) + if (ctx->options & CL_SCAN_HEURISTIC_PRECEDENCE) + return CL_CLEAN; + if (ctx->limit_exceeded == 0 || SCAN_ALL) { + ctx->num_viruses++; + *ctx->virname = virname; + cli_virus_found_cb(ctx); + } #if HAVE_JSON if (SCAN_PROPERTIES && ctx->wrkproperty) { json_object *arrobj, *virobj; @@ -1089,18 +1129,19 @@ arrobj = json_object_new_array(); if (NULL == arrobj) { cli_errmsg("cli_append_virus: no memory for json virus array\n"); - return; + return CL_EMEM; } json_object_object_add(ctx->wrkproperty, "Viruses", arrobj); } virobj = json_object_new_string(virname); if (NULL == virobj) { cli_errmsg("cli_append_virus: no memory for json virus name object\n"); - return; + return CL_EMEM; } json_object_array_add(arrobj, virobj); } #endif + return CL_VIRUS; } const char * cli_get_last_virus(const cli_ctx * ctx) @@ -1118,6 +1159,49 @@ return ""; } +void cli_set_container(cli_ctx *ctx, cli_file_t type, size_t size) +{ + ctx->containers[ctx->recursion].type = type; + ctx->containers[ctx->recursion].size = size; + if (type >= CL_TYPE_MSEXE && type != CL_TYPE_HTML && type != CL_TYPE_OTHER && type != CL_TYPE_IGNORED) + ctx->containers[ctx->recursion].flag = CONTAINER_FLAG_VALID; + else + ctx->containers[ctx->recursion].flag = 0; +} + +cli_file_t cli_get_container(cli_ctx *ctx, int index) +{ + if (index < 0) + index = ctx->recursion + index + 1; + while (index >= 0 && index <= ctx->recursion) { + if (ctx->containers[index].flag & CONTAINER_FLAG_VALID) + return ctx->containers[index].type; + index--; + } + return CL_TYPE_ANY; +} + +cli_file_t cli_get_container_intermediate(cli_ctx *ctx, int index) +{ + if (index < 0) + index = ctx->recursion + index + 1; + if (index >= 0 && index <= ctx->recursion) + return ctx->containers[index].type; + return CL_TYPE_ANY; +} + +size_t cli_get_container_size(cli_ctx *ctx, int index) +{ + if (index < 0) + index = ctx->recursion + index + 1; + while (index >= 0 && index <= ctx->recursion) { + if (ctx->containers[index].flag & CONTAINER_FLAG_VALID) + return ctx->containers[index].size; + index--; + } + return ctx->containers[0].size; +} + #ifdef C_WINDOWS diff -Nru clamav-0.99.2+dfsg/libclamav/others_common.c clamav-0.99.3~beta1+dfsg/libclamav/others_common.c --- clamav-0.99.2+dfsg/libclamav/others_common.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/others_common.c 2017-07-31 18:34:32.000000000 +0000 @@ -117,6 +117,17 @@ { } #endif + +#if defined(C_SOLARIS) +size_t strnlen(const char *s, size_t n) __attribute__((weak)); +size_t strnlen(const char *s, size_t n) +{ + size_t i = 0; + for(; (i < n) && s[i] != '\0'; ++i); + return i; +} +#endif + uint8_t cli_debug_flag = 0; uint8_t cli_always_gen_section_hash = 0; @@ -284,6 +295,30 @@ return alloc; } +char *cli_strndup(const char *s, size_t n) +{ + char *alloc; + size_t len; + + if(s == NULL) { + cli_errmsg("cli_strndup(): s == NULL. Please report to http://bugs.clamav.net\n"); + return NULL; + } + + len = strnlen(s, n); + alloc = malloc(len+1); + + if(!alloc) { + perror("strndup_problem"); + cli_errmsg("cli_strndup(): Can't allocate memory (%u bytes).\n", (unsigned int) strlen(s)); + return NULL; + } else + memcpy(alloc, s, len); + + alloc[len] = '\0'; + return alloc; +} + /* returns converted timestamp, in case of error the returned string contains at least one character */ const char* cli_ctime(const time_t *timep, char *buf, const size_t bufsize) { diff -Nru clamav-0.99.2+dfsg/libclamav/others.h clamav-0.99.3~beta1+dfsg/libclamav/others.h --- clamav-0.99.2+dfsg/libclamav/others.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/others.h 2017-06-09 20:02:26.000000000 +0000 @@ -72,7 +72,7 @@ * in re-enabling affected modules. */ -#define CL_FLEVEL 82 +#define CL_FLEVEL 83 #define CL_FLEVEL_DCONF CL_FLEVEL #define CL_FLEVEL_SIGTOOL CL_FLEVEL @@ -126,6 +126,13 @@ unsigned long length; } bitset_t; +typedef struct cli_ctx_container_tag { + cli_file_t type; + size_t size; + unsigned char flag; +} cli_ctx_container; +#define CONTAINER_FLAG_VALID 0x01 + /* internal clamav context */ typedef struct cli_ctx_tag { const char **virname; @@ -140,8 +147,7 @@ unsigned int found_possibly_unwanted; unsigned int corrupted_input; unsigned int img_validate; - cli_file_t container_type; /* FIXME: to be made into a stack or array - see bb#1579 & bb#1293 */ - size_t container_size; + cli_ctx_container *containers; /* set container type after recurse */ unsigned char handlertype_hash[16]; struct cli_dconf *dconf; fmap_t **fmap; @@ -157,6 +163,7 @@ struct json_object *wrkproperty; #endif struct timeval time_limit; + int limit_exceeded; } cli_ctx; #define STATS_ANON_UUID "5b585e8f-3be5-11e3-bf0b-18037319526c" @@ -271,7 +278,7 @@ * within a single archive */ /* This is for structured data detection. You can set the minimum - * number of occurences of an CC# or SSN before the system will + * number of occurrences of an CC# or SSN before the system will * generate a notification. */ uint32_t min_cc_count; @@ -284,6 +291,8 @@ struct cli_matcher *hm_hdb; /* hash matcher for MD5 sigs for PE sections */ struct cli_matcher *hm_mdb; + /* hash matcher for MD5 sigs for PE import tables */ + struct cli_matcher *hm_imp; /* hash matcher for whitelist db */ struct cli_matcher *hm_fp; @@ -471,7 +480,7 @@ #define SCAN_ELF (ctx->options & CL_SCAN_ELF) #define SCAN_ALGO (ctx->options & CL_SCAN_ALGORITHMIC) #define DETECT_ENCRYPTED (ctx->options & CL_SCAN_BLOCKENCRYPTED) -/* #define BLOCKMAX (ctx->options & CL_SCAN_BLOCKMAX) */ +#define BLOCKMAX (ctx->options & CL_SCAN_BLOCKMAX) #define DETECT_BROKEN (ctx->options & CL_SCAN_BLOCKBROKEN) #define BLOCK_MACROS (ctx->options & CL_SCAN_BLOCKMACROS) #define SCAN_STRUCTURED (ctx->options & CL_SCAN_STRUCTURED) @@ -539,6 +548,7 @@ #define be16_to_host(v) cbswap16(v) #define be32_to_host(v) cbswap32(v) #define be64_to_host(v) cbswap64(v) +#define cli_readint64(buff) (((const union unaligned_64 *)(buff))->una_s64) #define cli_readint32(buff) (((const union unaligned_32 *)(buff))->una_s32) #define cli_readint16(buff) (((const union unaligned_16 *)(buff))->una_s16) #define cli_writeint32(offset, value) (((union unaligned_32 *)(offset))->una_u32=(uint32_t)(value)) @@ -551,6 +561,21 @@ #define be32_to_host(v) (v) #define be64_to_host(v) (v) +static inline int32_t cli_readint64(const void *buff) +{ + int64_t ret; + ret = ((const char *)buff)[0] & 0xff; + ret |= (((const char *)buff)[1] & 0xff) << 8; + ret |= (((const char *)buff)[2] & 0xff) << 16; + ret |= (((const char *)buff)[3] & 0xff) << 24; + + ret |= (((const char *)buff)[4] & 0xff) << 32; + ret |= (((const char *)buff)[5] & 0xff) << 40; + ret |= (((const char *)buff)[6] & 0xff) << 48; + ret |= (((const char *)buff)[7] & 0xff) << 56; + return ret; +} + static inline int32_t cli_readint32(const void *buff) { int32_t ret; @@ -578,9 +603,15 @@ } #endif -void cli_append_virus(cli_ctx *ctx, const char *virname); +int cli_append_virus(cli_ctx *ctx, const char *virname); const char *cli_get_last_virus(const cli_ctx *ctx); const char *cli_get_last_virus_str(const cli_ctx *ctx); +void cli_virus_found_cb(cli_ctx *ctx); + +void cli_set_container(cli_ctx *ctx, cli_file_t type, size_t size); +cli_file_t cli_get_container(cli_ctx *ctx, int index); +size_t cli_get_container_size(cli_ctx *ctx, int index); +cli_file_t cli_get_container_intermediate(cli_ctx *ctx, int index); /* used by: spin, yc (C) aCaB */ #define __SHIFTBITS(a) (sizeof(a)<<3) @@ -676,6 +707,7 @@ void *cli_realloc(void *ptr, size_t size); void *cli_realloc2(void *ptr, size_t size); char *cli_strdup(const char *s); +char *cli_strndup(const char *s, size_t n); int cli_rmdirs(const char *dirname); char *cli_hashstream(FILE *fs, unsigned char *digcpy, int type); char *cli_hashfile(const char *filename, int type); @@ -693,6 +725,7 @@ int cli_bitset_set(bitset_t *bs, unsigned long bit_offset); int cli_bitset_test(bitset_t *bs, unsigned long bit_offset); const char* cli_ctime(const time_t *timep, char *buf, const size_t bufsize); +void cli_check_blockmax(cli_ctx *, int); int cli_checklimits(const char *, cli_ctx *, unsigned long, unsigned long, unsigned long); int cli_updatelimits(cli_ctx *, unsigned long); unsigned long cli_getsizelimit(cli_ctx *, unsigned long); diff -Nru clamav-0.99.2+dfsg/libclamav/pdf.c clamav-0.99.3~beta1+dfsg/libclamav/pdf.c --- clamav-0.99.2+dfsg/libclamav/pdf.c 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/pdf.c 2017-06-09 20:02:26.000000000 +0000 @@ -48,9 +48,14 @@ #include #endif +#ifdef _WIN32 +#include +#endif + #include "clamav.h" #include "others.h" #include "pdf.h" +#include "pdfdecode.h" #include "scanners.h" #include "fmap.h" #include "str.h" @@ -298,7 +303,7 @@ return cli_writen(fout, buf, len); } -static void pdfobj_flag(struct pdf_struct *pdf, struct pdf_obj *obj, enum pdf_flag flag) +void pdfobj_flag(struct pdf_struct *pdf, struct pdf_obj *obj, enum pdf_flag flag) { const char *s= ""; pdf->flags |= 1 << flag; @@ -375,149 +380,6 @@ cli_dbgmsg("cli_pdf: %s flagged in object %u %u\n", s, obj->id>>8, obj->id&0xff); } -static int filter_flatedecode(struct pdf_struct *pdf, struct pdf_obj *obj, const char *buf, off_t len, int fout, off_t *sum) -{ - int skipped = 0; - int zstat; - z_stream stream; - off_t nbytes; - char output[BUFSIZ]; - - if (len == 0) - return CL_CLEAN; - - if (*buf == '\r') { - buf++; - len--; - pdfobj_flag(pdf, obj, BAD_STREAMSTART); - /* PDF spec says stream is followed by \r\n or \n, but not \r alone. - * Sample 0015315109, it has \r followed by zlib header. - * Flag pdf as suspicious, and attempt to extract by skipping the \r. - */ - if (!len) - return CL_CLEAN; - } - - memset(&stream, 0, sizeof(stream)); - stream.next_in = (Bytef *)buf; - stream.avail_in = len; - stream.next_out = (Bytef *)output; - stream.avail_out = sizeof(output); - - zstat = inflateInit(&stream); - if(zstat != Z_OK) { - cli_warnmsg("cli_pdf: inflateInit failed\n"); - return CL_EMEM; - } - - nbytes = 0; - while(stream.avail_in) { - int written; - zstat = inflate(&stream, Z_NO_FLUSH); /* zlib */ - switch(zstat) { - case Z_OK: - if(stream.avail_out == 0) { - if ((written=filter_writen(pdf, obj, fout, output, sizeof(output), sum))!=sizeof(output)) { - cli_errmsg("cli_pdf: failed to write output file\n"); - inflateEnd(&stream); - return CL_EWRITE; - } - - nbytes += written; - stream.next_out = (Bytef *)output; - stream.avail_out = sizeof(output); - } - - continue; - case Z_STREAM_END: - default: - written = sizeof(output) - stream.avail_out; - if (!written && !nbytes && !skipped) { - /* skip till EOL, and try inflating from there, sometimes - * PDFs contain extra whitespace */ - const char *q = pdf_nextlinestart(buf, len); - if (q) { - skipped = 1; - inflateEnd(&stream); - len -= q - buf; - buf = q; - - stream.next_in = (Bytef *)buf; - stream.avail_in = len; - stream.next_out = (Bytef *)output; - stream.avail_out = sizeof(output); - zstat = inflateInit(&stream); - - if(zstat != Z_OK) { - cli_warnmsg("cli_pdf: inflateInit failed\n"); - return CL_EMEM; - } - - pdfobj_flag(pdf, obj, BAD_FLATESTART); - continue; - } - } - - if (filter_writen(pdf, obj, fout, output, written, sum)!=written) { - cli_errmsg("cli_pdf: failed to write output file\n"); - inflateEnd(&stream); - return CL_EWRITE; - } - - nbytes += written; - stream.next_out = (Bytef *)output; - stream.avail_out = sizeof(output); - if (zstat == Z_STREAM_END) - break; - - if(stream.msg) - cli_dbgmsg("cli_pdf: after writing %lu bytes, got error \"%s\" inflating PDF stream in %u %u obj\n", - (unsigned long)nbytes, - stream.msg, obj->id>>8, obj->id&0xff); - else - cli_dbgmsg("cli_pdf: after writing %lu bytes, got error %d inflating PDF stream in %u %u obj\n", - (unsigned long)nbytes, zstat, obj->id>>8, obj->id&0xff); - - if(stream.msg) - noisy_warnmsg("cli_pdf: after writing %lu bytes, got error \"%s\" inflating PDF stream in %u %u obj\n", - (unsigned long)nbytes, - stream.msg, obj->id>>8, obj->id&0xff); - else - noisy_warnmsg("cli_pdf: after writing %lu bytes, got error %d inflating PDF stream in %u %u obj\n", - (unsigned long)nbytes, zstat, obj->id>>8, obj->id&0xff); - - /* mark stream as bad only if not encrypted */ - inflateEnd(&stream); - if (!nbytes) { - pdfobj_flag(pdf, obj, BAD_FLATESTART); - cli_dbgmsg("filter_flatedecode: No bytes, returning CL_EFORMAT for this stream.\n"); - - return CL_EFORMAT; - } else { - pdfobj_flag(pdf, obj, BAD_FLATE); - } - - return CL_CLEAN; - } - - break; - } - - if(stream.avail_out != sizeof(output)) { - if(filter_writen(pdf, obj, fout, output, sizeof(output) - stream.avail_out, sum) < 0) { - cli_errmsg("cli_pdf: failed to write output file\n"); - - inflateEnd(&stream); - - return CL_EWRITE; - } - } - - inflateEnd(&stream); - - return CL_CLEAN; -} - struct pdf_obj *find_obj(struct pdf_struct *pdf, struct pdf_obj *obj, uint32_t objid) { uint32_t j; @@ -652,7 +514,7 @@ if (fd != -1) { map = fmap(fd, 0, 0); if (!map) { - cli_warnmsg("can't mmap pdf extracted obj\n"); + cli_dbgmsg("can't mmap pdf extracted obj\n"); map = *ctx->fmap; fd = -1; } @@ -950,7 +812,6 @@ static const char *pdf_getdict(const char *q0, int* len, const char *key); static char *pdf_readval(const char *q, int len, const char *key); -static enum enc_method parse_enc_method(const char *dict, unsigned len, const char *key, enum enc_method def); static char *pdf_readstring(const char *q0, int len, const char *key, unsigned *slen, const char **qend, int noescape); int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj, uint32_t flags) @@ -959,8 +820,6 @@ int fout; off_t sum = 0; int rc = CL_SUCCESS; - char *ascii_decoded = NULL; - char *decrypted = NULL; int dump = 1; cli_dbgmsg("pdf_extract_obj: obj %u %u\n", obj->id>>8, obj->id&0xff); @@ -991,7 +850,6 @@ if (fout < 0) { char err[128]; cli_errmsg("cli_pdf: can't create temporary file %s: %s\n", fullname, cli_strerror(errno, err, sizeof(err))); - free(ascii_decoded); return CL_ETMPFILE; } @@ -1002,9 +860,8 @@ do { if (obj->flags & (1 << OBJ_STREAM)) { const char *start = pdf->map + obj->start; - const char *flate_orig; off_t p_stream = 0, p_endstream = 0; - off_t length, flate_orig_length; + off_t length; find_stream_bounds(start, pdf->size - obj->start, pdf->size - obj->start, @@ -1013,10 +870,12 @@ pdf->enc_method_embeddedfile <= ENC_IDENTITY); if (p_stream && p_endstream) { - const char *flate_in; - long ascii_decoded_size = 0; size_t size = p_endstream - p_stream; off_t orig_length; + int len = p_stream; + const char *pstr; + struct pdf_dict *dparams = NULL; + int xref = 0; length = find_length(pdf, obj, start, p_stream); if (length < 0) @@ -1049,18 +908,18 @@ if (length < 0) length = 0; - cli_dbgmsg("cli_pdf: calculated length %ld\n", length); + cli_dbgmsg("cli_pdf: calculated length %jd\n", (intmax_t)length); } else { if (size > (size_t)length+2) { - cli_dbgmsg("cli_pdf: calculated length %llu < %llu\n", - (long long unsigned)length, (long long unsigned)size); + cli_dbgmsg("cli_pdf: calculated length %jd < %jd\n", + (intmax_t)length, (intmax_t)size); length = size; } } if (orig_length && size > (size_t)orig_length + 20) { - cli_dbgmsg("cli_pdf: orig length: %ld, length: %ld, size: %llu\n", orig_length, length, - (long long unsigned)size); + cli_dbgmsg("cli_pdf: orig length: %jd, length: %jd, size: %jd\n", + (intmax_t)orig_length, (intmax_t)length, (intmax_t)size); pdfobj_flag(pdf, obj, BAD_STREAMLEN); } @@ -1072,97 +931,46 @@ } } - flate_orig = flate_in = start + p_stream; - flate_orig_length = length; - if (pdf->flags & (1 << DECRYPTABLE_PDF)) { - enum enc_method enc = get_enc_method(pdf, obj); - - if (obj->flags & (1 << OBJ_FILTER_CRYPT)) { - int len = p_stream; - const char *q = pdf_getdict(start, &len, "/DecodeParams"); - - enc = ENC_IDENTITY; - if (q && pdf->CF) { - char *name = pdf_readval(q, len, "/Name"); - cli_dbgmsg("cli_pdf: Crypt filter %s\n", name); + if (cli_memstr(start, p_stream, "/XRef", 5)) + xref = 1; - if (name && strcmp(name, "/Identity")) - enc = parse_enc_method(pdf->CF, pdf->CF_n, name, enc); + cli_dbgmsg("-------------EXPERIMENTAL-------------\n"); - free(name); - } + pstr = pdf_getdict(start, &len, "/DecodeParms"); + if (!pstr) + pstr = pdf_getdict(start, &len, "/DP"); + + if (pstr) { + unsigned int objsz = obj_size(pdf, obj, 1); + + /* shift pstr left to "<<" for pdf_parse_dict */ + while ((*pstr == '<') && (pstr > start)) { + pstr--; + len++; } - if (cli_memstr(start, p_stream, "/XRef", 5)) { - cli_dbgmsg("cli_pdf: cross reference stream, skipping\n"); - } else { - decrypted = decrypt_any(pdf, obj->id, flate_in, &length, - enc); - - if (decrypted) - flate_in = decrypted; + /* shift pstr right to "<<" for pdf_parse_dict */ + while ((*pstr != '<') && (len > 0)) { + pstr++; + len--; } - } - if (obj->flags & (1 << OBJ_FILTER_AH)) { - ascii_decoded = cli_malloc(length/2 + 1); - if (!ascii_decoded) { - cli_errmsg("Cannot allocate memory for ascii_decoded\n"); - rc = CL_EMEM; - break; - } - ascii_decoded_size = asciihexdecode(flate_in, - length, - ascii_decoded); - } else if (obj->flags & (1 << OBJ_FILTER_A85)) { - ascii_decoded = cli_malloc(length*5); - if (!ascii_decoded) { - cli_errmsg("Cannot allocate memory for ascii_decoded\n"); - rc = CL_EMEM; - break; - } - - ascii_decoded_size = ascii85decode(flate_in, length, (unsigned char*)ascii_decoded); + if (len > 4) + dparams = pdf_parse_dict(pdf, obj, objsz, (char *)pstr, NULL); + else + cli_dbgmsg("cli_pdf: failed to locate DecodeParms dictionary start\n"); } - if (ascii_decoded_size < 0) { - /* don't flag for images or truncated objs*/ - if (!(obj->flags & ((1 << OBJ_IMAGE) | (1 << OBJ_TRUNCATED)))) - pdfobj_flag(pdf, obj, BAD_ASCIIDECODE); - - cli_dbgmsg("cli_pdf: failed to asciidecode in %u %u obj\n", obj->id>>8,obj->id&0xff); - free(ascii_decoded); - ascii_decoded = NULL; - /* attempt to directly flatedecode it */ - } - - /* either direct or ascii-decoded input */ - if (!ascii_decoded) - ascii_decoded_size = length; - else - flate_in = ascii_decoded; + sum = pdf_decodestream(pdf, obj, dparams, start + p_stream, length, xref, fout, &rc); + if (dparams) + pdf_free_dict(dparams); - if (obj->flags & (1 << OBJ_FILTER_FLATE)) { - cli_dbgmsg("cli_pdf: deflate len %ld (orig %ld)\n", ascii_decoded_size, (long)orig_length); - rc = filter_flatedecode(pdf, obj, flate_in, ascii_decoded_size, fout, &sum); - if (rc == CL_EFORMAT) { - if (decrypted) { - flate_in = flate_orig; - ascii_decoded_size = flate_orig_length; - } - - cli_dbgmsg("cli_pdf: dumping raw stream (probably encrypted)\n"); - noisy_warnmsg("cli_pdf: dumping raw stream, probably encrypted and we failed to decrypt'n"); - - if (filter_writen(pdf, obj, fout, flate_in, ascii_decoded_size, &sum) != ascii_decoded_size) { - cli_errmsg("cli_pdf: failed to write output file\n"); - return CL_EWRITE; - } - } - } else { - if (filter_writen(pdf, obj, fout, flate_in, ascii_decoded_size, &sum) != ascii_decoded_size) - rc = CL_EWRITE; + if (sum < 0 || (rc == CL_VIRUS && !(pdf->ctx->options & CL_SCAN_ALLMATCHES))) { + sum = 0; /* prevents post-filter scan */ + break; } + + cli_dbgmsg("-------------EXPERIMENTAL-------------\n"); } else { noisy_warnmsg("cannot find stream bounds for obj %u %u\n", obj->id>>8, obj->id&0xff); } @@ -1192,6 +1000,7 @@ q = q2; if (js) { + char *decrypted = NULL; const char *out = js; js_len = strlen(js); if (pdf->flags & (1 << DECRYPTABLE_PDF)) { @@ -1211,6 +1020,7 @@ break; } + free(decrypted); free(js); cli_dbgmsg("bytesleft: %d\n", (int)bytesleft); @@ -1246,7 +1056,7 @@ } } while (0); - cli_dbgmsg("cli_pdf: extracted %ld bytes %u %u obj\n", sum, obj->id>>8, obj->id&0xff); + cli_dbgmsg("cli_pdf: extracted %jd bytes %u %u obj\n", (intmax_t)sum, obj->id>>8, obj->id&0xff); cli_dbgmsg(" ... to %s\n", fullname); if (flags & PDF_EXTRACT_OBJ_SCAN && sum) { @@ -1279,8 +1089,6 @@ } close(fout); - free(ascii_decoded); - free(decrypted); if (flags & PDF_EXTRACT_OBJ_SCAN && !pdf->ctx->engine->keeptmp) if (cli_unlink(fullname) && rc != CL_VIRUS) @@ -1429,6 +1237,10 @@ return; } + /* record filter order */ + if ((*state == STATE_FILTER) && ((1 << act->set_objflag) & KNOWN_FILTERS)) + obj->filterlist[obj->numfilters++] = act->set_objflag; + if ((act->nameflags & NAMEFLAG_HEURISTIC) && escapes) { /* if a commonly used PDF name is escaped that is certainly suspicious. */ @@ -1662,7 +1474,9 @@ char * dictionary = malloc(dict_length + 1); if (dictionary) { for (i = 0; i < dict_length; i++) { - if (isprint(dict[i]) || isspace(dict[i])) + if (dict[i] == '\r') + dictionary[i] = '\n'; + else if (isprint(dict[i]) || isspace(dict[i])) dictionary[i] = dict[i]; else dictionary[i] = '*'; @@ -1993,6 +1807,7 @@ { const char *end; char *s; + int origlen = len; q = pdf_getdict(q, &len, key); if (!q || len <= 0) @@ -2015,6 +1830,12 @@ len--; } + /* end-of-buffer whitespace trimming */ + while (len < origlen && isspace(*(end-1))) { + end--; + len++; + } + s = cli_malloc(end - q + 1); if (!s) return NULL; @@ -2216,7 +2037,7 @@ } } -static enum enc_method parse_enc_method(const char *dict, unsigned len, const char *key, enum enc_method def) +enum enc_method parse_enc_method(const char *dict, unsigned len, const char *key, enum enc_method def) { const char *q; char *CFM = NULL; @@ -2500,7 +2321,7 @@ if (pdfver != start || offset) { pdf.flags |= 1 << BAD_PDF_HEADERPOS; - cli_dbgmsg("cli_pdf: PDF header is not at position 0: %ld\n",pdfver-start+offset); + cli_dbgmsg("cli_pdf: PDF header is not at position 0: %jd\n",(intmax_t)(pdfver-start+offset)); #if HAVE_JSON if (pdfobj) cli_jsonbool(pdfobj, "BadVersionLocation", 1); @@ -2609,7 +2430,7 @@ while ((rc = pdf_findobj(&pdf)) > 0) { struct pdf_obj *obj = &pdf.objs[pdf.nobjs-1]; - cli_dbgmsg("cli_pdf: found %d %d obj @%ld\n", obj->id >> 8, obj->id&0xff, obj->start + offset); + cli_dbgmsg("cli_pdf: found %d %d obj @%jd\n", obj->id >> 8, obj->id&0xff, (intmax_t)(obj->start + offset)); } if (pdf.nobjs) @@ -2636,6 +2457,12 @@ } pdf_parseobj(&pdf, obj); + if (SCAN_ALGO && obj->numfilters > PDF_FILTER_DTRIGGER) { + rc = cli_append_virus(ctx, "Heuristic.PDF.TooManyFilters"); + alerts++; + if (SCAN_ALL && rc == CL_VIRUS) + rc = CL_CLEAN; + } } pdf_handle_enc(&pdf); @@ -2652,8 +2479,8 @@ * a password to decrypt */ cli_append_virus(ctx, "Heuristics.Encrypted.PDF"); alerts++; - if (!SCAN_ALL) - rc = CL_VIRUS; + if (SCAN_ALL && rc == CL_VIRUS) + rc = CL_CLEAN; } if (!rc) { @@ -2720,8 +2547,7 @@ if (!rc && SCAN_ALGO && (ctx->dconf->other & OTHER_CONF_PDFNAMEOBJ)) { if (pdf.flags & (1 << ESCAPED_COMMON_PDFNAME)) { /* for example /Fl#61te#44#65#63#6f#64#65 instead of /FlateDecode */ - cli_append_virus(ctx, "Heuristics.PDF.ObfuscatedNameObject"); - rc = cli_found_possibly_unwanted(ctx); + cli_append_possibly_unwanted(ctx, "Heuristics.PDF.ObfuscatedNameObject"); } } #if 0 @@ -2760,109 +2586,6 @@ return rc == CL_BREAK ? CL_CLEAN : rc; } -static int asciihexdecode(const char *buf, off_t len, char *output) -{ - unsigned i,j; - for (i=0,j=0;i+1') - break; - - if (cli_hex2str_to(buf+i, output+j, 2) == -1) { - if (len - i < 4) - continue; - - return -1; - } - - j++; - i++; - } - - return j; -} - -/* - * ascii85 inflation, returns number of bytes in output, -1 for error - * - * See http://www.piclist.com/techref/method/encode.htm (look for base85) - */ -static int -ascii85decode(const char *buf, off_t len, unsigned char *output) -{ - const char *ptr; - uint32_t sum = 0; - int quintet = 0; - int ret = 0; - - if(cli_memstr(buf, len, "~>", 2) == NULL) - cli_dbgmsg("cli_pdf: ascii85decode: no EOF marker found\n"); - - ptr = buf; - - cli_dbgmsg("cli_pdf: ascii85decode %lu bytes\n", (unsigned long)len); - - while(len > 0) { - int byte = (len--) ? (int)*ptr++ : EOF; - - if((byte == '~') && (len > 0) && (*ptr == '>')) - byte = EOF; - - if(byte >= '!' && byte <= 'u') { - sum = (sum * 85) + ((uint32_t)byte - '!'); - if(++quintet == 5) { - *output++ = (unsigned char)(sum >> 24); - *output++ = (unsigned char)((sum >> 16) & 0xFF); - *output++ = (unsigned char)((sum >> 8) & 0xFF); - *output++ = (unsigned char)(sum & 0xFF); - ret += 4; - quintet = 0; - sum = 0; - } - } else if(byte == 'z') { - if(quintet) { - cli_dbgmsg("cli_pdf: ascii85decode: unexpected 'z'\n"); - return -1; - } - - *output++ = '\0'; - *output++ = '\0'; - *output++ = '\0'; - *output++ = '\0'; - ret += 4; - } else if(byte == EOF) { - cli_dbgmsg("cli_pdf: ascii85decode: quintet %d\n", quintet); - if(quintet) { - int i; - - if(quintet == 1) { - cli_dbgmsg("cli_pdf: ascii85Decode: only 1 byte in last quintet\n"); - return -1; - } - - for(i = quintet; i < 5; i++) - sum *= 85; - - if(quintet > 1) - sum += (0xFFFFFF >> ((quintet - 2) * 8)); - - ret += quintet-1; - for(i = 0; i < quintet - 1; i++) - *output++ = (unsigned char)((sum >> (24 - 8 * i)) & 0xFF); - } - - break; - } else if(!isspace(byte)) { - cli_dbgmsg("cli_pdf: ascii85Decode: invalid character 0x%x, len %lu\n", byte & 0xFF, (unsigned long)len); - - return -1; - } - } - return ret; -} - /* * Find the start of the next line */ diff -Nru clamav-0.99.2+dfsg/libclamav/pdfdecode.c clamav-0.99.3~beta1+dfsg/libclamav/pdfdecode.c --- clamav-0.99.2+dfsg/libclamav/pdfdecode.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/pdfdecode.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,948 @@ +/* + * Copyright (C) 2016 Cisco and/or its affiliates. All rights reserved. + * + * Author: Kevin Lin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations + * including the two. + * + * You must obey the GNU General Public License in all respects + * for all of the code used other than OpenSSL. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you + * do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source + * files in the program, then also delete it here. + */ + +#if HAVE_CONFIG_H +#include "clamav-config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_LIMITS_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#include + +#if HAVE_ICONV +#include +#endif + +#include "clamav.h" +#include "others.h" +#include "pdf.h" +#include "pdfdecode.h" +#include "str.h" +#include "bytecode.h" +#include "bytecode_api.h" +#include "lzw/lzwdec.h" + +#define PDFTOKEN_FLAG_XREF 0x1 + +struct pdf_token { + uint32_t flags; /* tracking flags */ + uint32_t success; /* successfully decoded filters */ + + uint32_t length; /* length of current content */ + uint8_t *content; /* content stream */ +}; + +static int pdf_decodestream_internal(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_dict *params, struct pdf_token *token); +static int pdf_decode_dump(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_token *token, int lvl); + +static int filter_ascii85decode(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_token *token); +static int filter_rldecode(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_token *token); +static int filter_flatedecode(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_dict *params, struct pdf_token *token); +static int filter_asciihexdecode(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_token *token); +static int filter_decrypt(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_dict *params, struct pdf_token *token, int mode); +static int filter_lzwdecode(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_dict *params, struct pdf_token *token); + +off_t pdf_decodestream(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_dict *params, const char *stream, uint32_t streamlen, int xref, int fout, int *rc) +{ + struct pdf_token *token; + off_t rv; + + if (!stream || !streamlen || fout < 0) { + cli_dbgmsg("cli_pdf: no filters or stream on obj %u %u\n", obj->id>>8, obj->id&0xff); + if (rc) + *rc = CL_ENULLARG; + return -1; + } + +#if 0 + if (params) + pdf_print_dict(params, 0); +#endif + + token = cli_malloc(sizeof(struct pdf_token)); + if (!token) { + if (rc) + *rc = CL_EMEM; + return -1; + } + + token->flags = 0; + if (xref) + token->flags |= PDFTOKEN_FLAG_XREF; + + token->success = 0; + + token->content = cli_malloc(streamlen); + if (!token->content) { + free(token); + if (rc) + *rc = CL_EMEM; + return -1; + } + memcpy(token->content, stream, streamlen); + token->length = streamlen; + + cli_dbgmsg("cli_pdf: detected %lu applied filters\n", (long unsigned)(obj->numfilters)); + + rv = pdf_decodestream_internal(pdf, obj, params, token); + /* return is generally ignored */ + if (rc) { + if (rv == CL_VIRUS) + *rc = CL_VIRUS; + else + *rc = CL_SUCCESS; + } + + if (token->success) { + if (!cli_checklimits("pdf", pdf->ctx, token->length, 0, 0)) { + if (cli_writen(fout, token->content, token->length) != token->length) { + cli_errmsg("cli_pdf: failed to write output file\n"); + if (rc) + *rc = CL_EWRITE; + return -1; + } + rv = token->length; + } + } else { /* if no non-forced filter are decoded, return the raw stream */ + if (!cli_checklimits("pdf", pdf->ctx, streamlen, 0, 0)) { + cli_dbgmsg("cli_pdf: no non-forced filters decoded, returning raw stream\n"); + + if (cli_writen(fout, stream, streamlen) != streamlen) { + cli_errmsg("cli_pdf: failed to write output file\n"); + if (rc) + *rc = CL_EWRITE; + return -1; + } + rv = streamlen; + } + } + + free(token->content); + free(token); + return rv; +} + +static int pdf_decodestream_internal(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_dict *params, struct pdf_token *token) +{ + const char *filter = NULL; + int i, vir = 0, rc = CL_SUCCESS; + + /* + * if pdf is decryptable, scan for CRYPT filter + * if none, force a DECRYPT filter application + */ + if ((pdf->flags & (1 << DECRYPTABLE_PDF)) && !(obj->flags & (1 << OBJ_FILTER_CRYPT))) { + if (token->flags & PDFTOKEN_FLAG_XREF) /* TODO: is this on all crypt filters or only the assumed one? */ + cli_dbgmsg("cli_pdf: skipping decoding => non-filter CRYPT (reason: xref)\n"); + else { + cli_dbgmsg("cli_pdf: decoding => non-filter CRYPT\n"); + if ((rc = filter_decrypt(pdf, obj, params, token, 1)) != CL_SUCCESS) { + return rc; + } + } + } + + for (i = 0; i < obj->numfilters; i++) { + switch(obj->filterlist[i]) { + case OBJ_FILTER_A85: + cli_dbgmsg("cli_pdf: decoding [%d] => ASCII85DECODE\n", obj->filterlist[i]); + rc = filter_ascii85decode(pdf, obj, token); + break; + + case OBJ_FILTER_RL: + cli_dbgmsg("cli_pdf: decoding [%d] => RLDECODE\n", obj->filterlist[i]); + rc = filter_rldecode(pdf, obj, token); + break; + + case OBJ_FILTER_FLATE: + cli_dbgmsg("cli_pdf: decoding [%d] => FLATEDECODE\n", obj->filterlist[i]); + rc = filter_flatedecode(pdf, obj, params, token); + break; + + case OBJ_FILTER_AH: + cli_dbgmsg("cli_pdf: decoding [%d] => ASCIIHEXDECODE\n", obj->filterlist[i]); + rc = filter_asciihexdecode(pdf, obj, token); + break; + + case OBJ_FILTER_CRYPT: + cli_dbgmsg("cli_pdf: decoding [%d] => CRYPT\n", obj->filterlist[i]); + rc = filter_decrypt(pdf, obj, params, token, 0); + break; + + case OBJ_FILTER_LZW: + cli_dbgmsg("cli_pdf: decoding [%d] => LZWDECODE\n", obj->filterlist[i]); + rc = filter_lzwdecode(pdf, obj, params, token); + break; + + case OBJ_FILTER_JPX: + if (!filter) filter = "JPXDECODE"; + case OBJ_FILTER_DCT: + if (!filter) filter = "DCTDECODE"; + case OBJ_FILTER_FAX: + if (!filter) filter = "FAXDECODE"; + case OBJ_FILTER_JBIG2: + if (!filter) filter = "JBIG2DECODE"; + + cli_dbgmsg("cli_pdf: unimplemented filter type [%d] => %s\n", obj->filterlist[i], filter); + filter = NULL; + rc = CL_BREAK; + break; + + default: + cli_dbgmsg("cli_pdf: unknown filter type [%d]\n", obj->filterlist[i]); + rc = CL_BREAK; + break; + } + + if (!(token->content) || !(token->length)) { + cli_dbgmsg("cli_pdf: empty content, breaking after %d (of %lu) filters\n", + i, (long unsigned)(obj->numfilters)); + break; + } + + if (rc != CL_SUCCESS) { + if (rc == CL_VIRUS && pdf->ctx->options & CL_SCAN_ALLMATCHES) + vir = 1; + else { + const char *reason; + switch (rc) { + case CL_VIRUS: + reason = "detection"; + break; + case CL_BREAK: + reason = "decoding break"; + break; + default: + reason = "decoding error"; + break; + } + + cli_dbgmsg("cli_pdf: stopping after %d (of %lu) filters (reason: %s)\n", + i, (long unsigned)(obj->numfilters), reason); + break; + } + } + token->success++; + + if (pdf->ctx->engine->keeptmp) { + + if ((rc = pdf_decode_dump(pdf, obj, token, i+1)) != CL_SUCCESS) + return rc; + } + } + + if (vir) + return CL_VIRUS; + if (rc == CL_BREAK) + return CL_SUCCESS; + return rc; +} + +/* used only for intermediate dumping */ +static int pdf_decode_dump(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_token *token, int lvl) +{ + char fname[1024]; + int ifd; + + snprintf(fname, sizeof(fname), "%s"PATHSEP"pdf%02u_%02ui", pdf->dir, (pdf->files-1), lvl); + ifd = open(fname, O_RDWR|O_CREAT|O_EXCL|O_TRUNC|O_BINARY, 0600); + if (ifd < 0) { + char err[128]; + + cli_errmsg("cli_pdf: can't create intermediate temporary file %s: %s\n", fname, cli_strerror(errno, err, sizeof(err))); + return CL_ETMPFILE; + } + + cli_dbgmsg("cli_pdf: decoded filter %d obj %u %u\n", lvl, obj->id>>8, obj->id&0xff); + cli_dbgmsg(" ... to %s\n", fname); + + if (cli_writen(ifd, token->content, token->length) != token->length) { + cli_errmsg("cli_pdf: failed to write output file\n"); + close(ifd); + return CL_EWRITE; + } + + close(ifd); + return CL_SUCCESS; +} + +/* + * ascii85 inflation + * See http://www.piclist.com/techref/method/encode.htm (look for base85) + */ +static int filter_ascii85decode(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_token *token) +{ + uint8_t *decoded, *dptr; + uint32_t declen = 0; + + const uint8_t *ptr = (uint8_t *)token->content; + uint32_t remaining = token->length; + int quintet = 0, rc = CL_SUCCESS; + uint64_t sum = 0; + + /* 5:4 decoding ratio, with 1:4 expansion sequences => (4*length)+1 */ + if (!(dptr = decoded = (uint8_t *)cli_malloc((4*remaining)+1))) { + cli_errmsg("cli_pdf: cannot allocate memory for decoded output\n"); + return CL_EMEM; + } + + if(cli_memstr((const char *)ptr, remaining, "~>", 2) == NULL) + cli_dbgmsg("cli_pdf: no EOF marker found\n"); + + while (remaining > 0) { + int byte = (remaining--) ? (int)*ptr++ : EOF; + + if((byte == '~') && (remaining > 0) && (*ptr == '>')) + byte = EOF; + + if(byte >= '!' && byte <= 'u') { + sum = (sum * 85) + ((uint32_t)byte - '!'); + if(++quintet == 5) { + *dptr++ = (unsigned char)(sum >> 24); + *dptr++ = (unsigned char)((sum >> 16) & 0xFF); + *dptr++ = (unsigned char)((sum >> 8) & 0xFF); + *dptr++ = (unsigned char)(sum & 0xFF); + + declen += 4; + quintet = 0; + sum = 0; + } + } else if(byte == 'z') { + if(quintet) { + cli_dbgmsg("cli_pdf: unexpected 'z'\n"); + rc = CL_EFORMAT; + break; + } + + *dptr++ = '\0'; + *dptr++ = '\0'; + *dptr++ = '\0'; + *dptr++ = '\0'; + + declen += 4; + } else if(byte == EOF) { + cli_dbgmsg("cli_pdf: last quintet contains %d bytes\n", quintet); + if(quintet) { + int i; + + if(quintet == 1) { + cli_dbgmsg("cli_pdf: invalid last quintet (only 1 byte)\n"); + rc = CL_EFORMAT; + break; + } + + for(i = quintet; i < 5; i++) + sum *= 85; + + if(quintet > 1) + sum += (0xFFFFFF >> ((quintet - 2) * 8)); + + for(i = 0; i < quintet - 1; i++) + *dptr++ = (uint8_t)((sum >> (24 - 8 * i)) & 0xFF); + declen += quintet-1; + } + + break; + } else if(!isspace(byte)) { + cli_dbgmsg("cli_pdf: invalid character 0x%x @ %lu\n", + byte & 0xFF, (unsigned long)(token->length-remaining)); + + rc = CL_EFORMAT; + break; + } + } + + if (rc == CL_SUCCESS) { + free(token->content); + + cli_dbgmsg("cli_pdf: deflated %lu bytes from %lu total bytes\n", + (unsigned long)declen, (unsigned long)(token->length)); + + token->content = decoded; + token->length = declen; + } else { + if (!(obj->flags & ((1 << OBJ_IMAGE) | (1 << OBJ_TRUNCATED)))) + pdfobj_flag(pdf, obj, BAD_ASCIIDECODE); + + cli_dbgmsg("cli_pdf: error occurred parsing byte %lu of %lu\n", + (unsigned long)(token->length-remaining), (unsigned long)(token->length)); + free(decoded); + } + return rc; +} + +/* imported from razorback */ +static int filter_rldecode(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_token *token) +{ + uint8_t *decoded, *temp; + uint32_t declen = 0, capacity = 0; + + uint8_t *content = (uint8_t *)token->content; + uint32_t length = token->length; + uint32_t offset = 0; + int rc = CL_SUCCESS; + + UNUSEDPARAM(obj); + + if (!(decoded = cli_calloc(BUFSIZ, sizeof(uint8_t)))) { + cli_errmsg("cli_pdf: cannot allocate memory for decoded output\n"); + return CL_EMEM; + } + capacity = BUFSIZ; + + while (offset < length) { + uint8_t srclen = content[offset++]; + if (srclen < 128) { + /* direct copy of (srclen + 1) bytes */ + if (offset + srclen + 1 > length) { + cli_dbgmsg("cli_pdf: required source length (%lu) exceeds remaining length (%lu)\n", + (long unsigned)(offset+srclen+1), (long unsigned)(length-offset)); + rc = CL_EFORMAT; + break; + } + if (declen + srclen + 1 > capacity) { + if ((rc = cli_checklimits("pdf", pdf->ctx, capacity+BUFSIZ, 0, 0)) != CL_SUCCESS) + break; + + if (!(temp = cli_realloc(decoded, capacity + BUFSIZ))) { + cli_errmsg("cli_pdf: cannot reallocate memory for decoded output\n"); + rc = CL_EMEM; + break; + } + decoded = temp; + capacity += BUFSIZ; + } + + memcpy(decoded+declen, content+offset, srclen+1); + offset += srclen + 1; + declen += srclen + 1; + } else if (srclen > 128) { + /* copy the next byte (257 - srclen) times */ + if (offset + 1 > length) { + cli_dbgmsg("cli_pdf: required source length (%lu) exceeds remaining length (%lu)\n", + (long unsigned)(offset+srclen+1), (long unsigned)(length-offset)); + rc = CL_EFORMAT; + break; + } + if (declen + (257 - srclen) + 1 > capacity) { + if ((rc = cli_checklimits("pdf", pdf->ctx, capacity+BUFSIZ, 0, 0)) != CL_SUCCESS) + break; + + if (!(temp = cli_realloc(decoded, capacity + BUFSIZ))) { + cli_errmsg("cli_pdf: cannot reallocate memory for decoded output\n"); + rc = CL_EMEM; + break; + } + decoded = temp; + capacity += BUFSIZ; + } + + memset(decoded+declen, content[offset], 257-srclen); + offset++; + declen += 257 - srclen; + } else { /* srclen == 128 */ + /* end of data */ + cli_dbgmsg("cli_pdf: end-of-stream marker @ offset %lu (%lu bytes remaining)\n", + (unsigned long)offset, (long unsigned)(token->length-offset)); + break; + } + } + + if (rc == CL_SUCCESS) { + free(token->content); + + cli_dbgmsg("cli_pdf: decoded %lu bytes from %lu total bytes\n", + (unsigned long)declen, (unsigned long)(token->length)); + + token->content = decoded; + token->length = declen; + } else { + cli_dbgmsg("cli_pdf: error occurred parsing byte %lu of %lu\n", + (unsigned long)offset, (unsigned long)(token->length)); + free(decoded); + } + return rc; +} + +static uint8_t *decode_nextlinestart(uint8_t *content, uint32_t length) +{ + uint8_t *pt = content; + uint32_t r; + int toggle = 0; + + for (r = 0; r < length; r++, pt++) { + if (*pt == '\n' || *pt == '\r') + toggle = 1; + else if (toggle) + break; + } + + return pt; +} + +static int filter_flatedecode(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_dict *params, struct pdf_token *token) +{ + uint8_t *decoded, *temp; + uint32_t declen = 0, capacity = 0; + + uint8_t *content = (uint8_t *)token->content; + uint32_t length = token->length; + z_stream stream; + int zstat, skip = 0, rc = CL_SUCCESS; + + UNUSEDPARAM(params); + + if (*content == '\r') { + content++; + length--; + pdfobj_flag(pdf, obj, BAD_STREAMSTART); + /* PDF spec says stream is followed by \r\n or \n, but not \r alone. + * Sample 0015315109, it has \r followed by zlib header. + * Flag pdf as suspicious, and attempt to extract by skipping the \r. + */ + if (!length) + return CL_SUCCESS; + } + + if (!(decoded = (uint8_t *)cli_calloc(BUFSIZ, sizeof(uint8_t)))) { + cli_errmsg("cli_pdf: cannot allocate memory for decoded output\n"); + return CL_EMEM; + } + capacity = BUFSIZ; + + memset(&stream, 0, sizeof(stream)); + stream.next_in = (Bytef *)content; + stream.avail_in = length; + stream.next_out = (Bytef *)decoded; + stream.avail_out = BUFSIZ; + + zstat = inflateInit(&stream); + if(zstat != Z_OK) { + cli_warnmsg("cli_pdf: inflateInit failed\n"); + free(decoded); + return CL_EMEM; + } + + /* initial inflate */ + zstat = inflate(&stream, Z_NO_FLUSH); + /* check if nothing written whatsoever */ + if ((zstat != Z_OK) && (stream.avail_out == BUFSIZ)) { + /* skip till EOL, and try inflating from there, sometimes + * PDFs contain extra whitespace */ + uint8_t *q = decode_nextlinestart(content, length); + if (q) { + (void)inflateEnd(&stream); + length -= q - content; + content = q; + + stream.next_in = (Bytef *)content; + stream.avail_in = length; + stream.next_out = (Bytef *)decoded; + stream.avail_out = capacity; + + zstat = inflateInit(&stream); + if(zstat != Z_OK) { + cli_warnmsg("cli_pdf: inflateInit failed\n"); + free(decoded); + return CL_EMEM; + } + + pdfobj_flag(pdf, obj, BAD_FLATESTART); + } + + zstat = inflate(&stream, Z_NO_FLUSH); + } + + while (zstat == Z_OK && stream.avail_in) { + /* extend output capacity if needed,*/ + if(stream.avail_out == 0) { + if ((rc = cli_checklimits("pdf", pdf->ctx, capacity+BUFSIZ, 0, 0)) != CL_SUCCESS) + break; + + if (!(temp = cli_realloc(decoded, capacity + BUFSIZ))) { + cli_errmsg("cli_pdf: cannot reallocate memory for decoded output\n"); + rc = CL_EMEM; + break; + } + decoded = temp; + stream.next_out = decoded + capacity; + stream.avail_out = BUFSIZ; + declen += BUFSIZ; + capacity += BUFSIZ; + } + + /* continue inflation */ + zstat = inflate(&stream, Z_NO_FLUSH); + } + + /* add stream end fragment to decoded length */ + declen += (BUFSIZ - stream.avail_out); + + /* error handling */ + switch(zstat) { + case Z_OK: + cli_dbgmsg("cli_pdf: Z_OK on stream inflation completion\n"); + /* intentional fall-through */ + case Z_STREAM_END: + cli_dbgmsg("cli_pdf: inflated %lu bytes from %lu total bytes (%lu bytes remaining)\n", + (unsigned long)declen, (unsigned long)(token->length), (unsigned long)(stream.avail_in)); + break; + + /* potentially fatal - *mostly* ignored as per older version */ + case Z_STREAM_ERROR: + case Z_NEED_DICT: + case Z_DATA_ERROR: + case Z_MEM_ERROR: + default: + if(stream.msg) + cli_dbgmsg("cli_pdf: after writing %lu bytes, got error \"%s\" inflating PDF stream in %u %u obj\n", + (unsigned long)declen, stream.msg, obj->id>>8, obj->id&0xff); + else + cli_dbgmsg("cli_pdf: after writing %lu bytes, got error %d inflating PDF stream in %u %u obj\n", + (unsigned long)declen, zstat, obj->id>>8, obj->id&0xff); + + if (declen == 0) { + pdfobj_flag(pdf, obj, BAD_FLATESTART); + cli_dbgmsg("cli_pdf: no bytes were inflated.\n"); + + rc = CL_EFORMAT; + } else { + pdfobj_flag(pdf, obj, BAD_FLATE); + } + break; + } + + (void)inflateEnd(&stream); + + if (rc == CL_SUCCESS) { + free(token->content); + + token->content = decoded; + token->length = declen; + } else { + cli_dbgmsg("cli_pdf: error occurred parsing byte %lu of %lu\n", + (unsigned long)(length-stream.avail_in), (unsigned long)(token->length)); + free(decoded); + } + + return rc; +} + +static int filter_asciihexdecode(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_token *token) +{ + uint8_t *decoded; + + const uint8_t *content = (uint8_t *)token->content; + uint32_t length = token->length; + uint32_t i, j; + int rc = CL_SUCCESS; + + if (!(decoded = (uint8_t *)cli_calloc(length/2 + 1, sizeof(uint8_t)))) { + cli_errmsg("cli_pdf: cannot allocate memory for decoded output\n"); + return CL_EMEM; + } + + for (i = 0, j = 0; i+1 < length; i++) { + if (content[i] == ' ') + continue; + + if (content[i] == '>') + break; + + if (cli_hex2str_to((const char *)content+i, (char *)decoded+j, 2) == -1) { + if (length - i < 4) + continue; + + rc = CL_EFORMAT; + break; + } + + i++; + j++; + } + + if (rc == CL_SUCCESS) { + free(token->content); + + cli_dbgmsg("cli_pdf: deflated %lu bytes from %lu total bytes\n", + (unsigned long)j, (unsigned long)(token->length)); + + token->content = decoded; + token->length = j; + } else { + if (!(obj->flags & ((1 << OBJ_IMAGE) | (1 << OBJ_TRUNCATED)))) + pdfobj_flag(pdf, obj, BAD_ASCIIDECODE); + + cli_dbgmsg("cli_pdf: error occurred parsing byte %lu of %lu\n", + (unsigned long)i, (unsigned long)(token->length)); + free(decoded); + } + return rc; +} + +/* modes: 0 = use default/DecodeParms, 1 = use document setting */ +static int filter_decrypt(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_dict *params, struct pdf_token *token, int mode) +{ + char *decrypted; + off_t length = token->length; + enum enc_method enc = ENC_IDENTITY; + + if (mode) + enc = get_enc_method(pdf, obj); + else if (params) { + struct pdf_dict_node *node = params->nodes; + + while (node) { + if (node->type == PDF_DICT_STRING) { + if (!strncmp(node->key, "/Type", 6)) { /* optional field - Type */ + /* MUST be "CryptFilterDecodeParms" */ + if (node->value) + cli_dbgmsg("cli_pdf: Type: %s\n", (char *)(node->value)); + } else if (!strncmp(node->key, "/Name", 6)) { /* optional field - Name */ + /* overrides document and default encryption method */ + if (node->value) + cli_dbgmsg("cli_pdf: Name: %s\n", (char *)(node->value)); + enc = parse_enc_method(pdf->CF, pdf->CF_n, (char *)(node->value), enc); + } + } + node = node->next; + } + } + + decrypted = decrypt_any(pdf, obj->id, (const char *)token->content, &length, enc); + if (!decrypted) { + cli_dbgmsg("cli_pdf: failed to decrypt stream\n"); + return CL_EPARSE; /* TODO: what should this value be? CL_SUCCESS would mirror previous behavior */ + } + + cli_dbgmsg("cli_pdf: decrypted %lld bytes from %lu total bytes\n", + (long long int)length, (long unsigned)token->length); + + + free(token->content); + token->content = (uint8_t *)decrypted; + token->length = (uint32_t)length; /* this may truncate unfortunately, TODO: use 64-bit values internally? */ + return CL_SUCCESS; +} + +static int filter_lzwdecode(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_dict *params, struct pdf_token *token) +{ + uint8_t *decoded, *temp; + uint32_t declen = 0, capacity = 0; + + uint8_t *content = (uint8_t *)token->content; + uint32_t length = token->length; + lzw_stream stream; + int echg = 1, lzwstat, skip = 0, rc = CL_SUCCESS; + + if (pdf->ctx && !(pdf->ctx->dconf->other & OTHER_CONF_LZW)) + return CL_BREAK; + + if (params) { + struct pdf_dict_node *node = params->nodes; + + while (node) { + if (node->type == PDF_DICT_STRING) { + if (!strncmp(node->key, "/EarlyChange", 13)) { /* optional field - lzw flag */ + char *end, *value = (char *)node->value; + long set; + + if (value) { + cli_dbgmsg("cli_pdf: EarlyChange: %s\n", value); + set = strtol(value, &end, 10); + if (end != value) + echg = (int)set; + } + } + } + node = node->next; + } + } + + if (*content == '\r') { + content++; + length--; + pdfobj_flag(pdf, obj, BAD_STREAMSTART); + /* PDF spec says stream is followed by \r\n or \n, but not \r alone. + * Sample 0015315109, it has \r followed by zlib header. + * Flag pdf as suspicious, and attempt to extract by skipping the \r. + */ + if (!length) + return CL_SUCCESS; + } + + if (!(decoded = (uint8_t *)cli_calloc(BUFSIZ, sizeof(uint8_t)))) { + cli_errmsg("cli_pdf: cannot allocate memory for decoded output\n"); + return CL_EMEM; + } + capacity = BUFSIZ; + + memset(&stream, 0, sizeof(stream)); + stream.next_in = content; + stream.avail_in = length; + stream.next_out = decoded; + stream.avail_out = BUFSIZ; + if (echg) + stream.flags |= LZW_FLAG_EARLYCHG; + + lzwstat = lzwInit(&stream); + if(lzwstat != Z_OK) { + cli_warnmsg("cli_pdf: lzwInit failed\n"); + free(decoded); + return CL_EMEM; + } + + /* initial inflate */ + lzwstat = lzwInflate(&stream); + /* check if nothing written whatsoever */ + if ((lzwstat != Z_OK) && (stream.avail_out == BUFSIZ)) { + /* skip till EOL, and try inflating from there, sometimes + * PDFs contain extra whitespace */ + uint8_t *q = decode_nextlinestart(content, length); + if (q) { + (void)lzwInflateEnd(&stream); + length -= q - content; + content = q; + + stream.next_in = (Bytef *)content; + stream.avail_in = length; + stream.next_out = (Bytef *)decoded; + stream.avail_out = capacity; + + lzwstat = lzwInit(&stream); + if(lzwstat != Z_OK) { + cli_warnmsg("cli_pdf: lzwInit failed\n"); + free(decoded); + return CL_EMEM; + } + + pdfobj_flag(pdf, obj, BAD_FLATESTART); + } + + lzwstat = lzwInflate(&stream); + } + + while (lzwstat == Z_OK && stream.avail_in) { + /* extend output capacity if needed,*/ + if(stream.avail_out == 0) { + if ((rc = cli_checklimits("pdf", pdf->ctx, capacity+BUFSIZ, 0, 0)) != CL_SUCCESS) + break; + + if (!(temp = cli_realloc(decoded, capacity + BUFSIZ))) { + cli_errmsg("cli_pdf: cannot reallocate memory for decoded output\n"); + rc = CL_EMEM; + break; + } + decoded = temp; + stream.next_out = decoded + capacity; + stream.avail_out = BUFSIZ; + declen += BUFSIZ; + capacity += BUFSIZ; + } + + /* continue inflation */ + lzwstat = lzwInflate(&stream); + } + + /* add stream end fragment to decoded length */ + declen += (BUFSIZ - stream.avail_out); + + /* error handling */ + switch(lzwstat) { + case LZW_OK: + cli_dbgmsg("cli_pdf: LZW_OK on stream inflation completion\n"); + /* intentional fall-through */ + case LZW_STREAM_END: + cli_dbgmsg("cli_pdf: inflated %lu bytes from %lu total bytes (%lu bytes remaining)\n", + (unsigned long)declen, (unsigned long)(token->length), (unsigned long)(stream.avail_in)); + break; + + /* potentially fatal - *mostly* ignored as per older version */ + case LZW_STREAM_ERROR: + case LZW_DATA_ERROR: + case LZW_MEM_ERROR: + case LZW_BUF_ERROR: + case LZW_DICT_ERROR: + default: + if(stream.msg) + cli_dbgmsg("cli_pdf: after writing %lu bytes, got error \"%s\" inflating PDF stream in %u %u obj\n", + (unsigned long)declen, stream.msg, obj->id>>8, obj->id&0xff); + else + cli_dbgmsg("cli_pdf: after writing %lu bytes, got error %d inflating PDF stream in %u %u obj\n", + (unsigned long)declen, lzwstat, obj->id>>8, obj->id&0xff); + + if (declen == 0) { + pdfobj_flag(pdf, obj, BAD_FLATESTART); + cli_dbgmsg("cli_pdf: no bytes were inflated.\n"); + + rc = CL_EFORMAT; + } else { + pdfobj_flag(pdf, obj, BAD_FLATE); + } + break; + } + + (void)lzwInflateEnd(&stream); + + if (rc == CL_SUCCESS) { + free(token->content); + + token->content = decoded; + token->length = declen; + } else { + cli_dbgmsg("cli_pdf: error occurred parsing byte %lu of %lu\n", + (unsigned long)(length-stream.avail_in), (unsigned long)(token->length)); + free(decoded); + } + + /* + heuristic checks: + - full dictionary heuristics? + - invalid code points? + */ + + return rc; +} diff -Nru clamav-0.99.2+dfsg/libclamav/pdfdecode.h clamav-0.99.3~beta1+dfsg/libclamav/pdfdecode.h --- clamav-0.99.2+dfsg/libclamav/pdfdecode.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/pdfdecode.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2016 Cisco and/or its affiliates. All rights reserved. + * + * Author: Kevin Lin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations + * including the two. + * + * You must obey the GNU General Public License in all respects + * for all of the code used other than OpenSSL. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you + * do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source + * files in the program, then also delete it here. + */ +#ifndef __PDFDECODE_H__ +#define __PDFDECODE_H__ + +#include "pdf.h" + +off_t pdf_decodestream(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_dict *params, const char *stream, uint32_t streamlen, int xref, int fout, int *rc); + +#endif /* __PDFDECODE_H__ */ diff -Nru clamav-0.99.2+dfsg/libclamav/pdf.h clamav-0.99.3~beta1+dfsg/libclamav/pdf.h --- clamav-0.99.2+dfsg/libclamav/pdf.h 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/pdf.h 2016-10-13 15:45:44.000000000 +0000 @@ -22,11 +22,15 @@ #define __PDF_H #include "others.h" +#define PDF_FILTERLIST_MAX 64 +#define PDF_FILTER_DTRIGGER 8 struct pdf_obj { uint32_t start; uint32_t id; uint32_t flags; uint32_t statsflags; + uint32_t numfilters; + uint32_t filterlist[PDF_FILTERLIST_MAX]; char *path; }; @@ -158,7 +162,9 @@ void pdf_handle_enc(struct pdf_struct *pdf); char *decrypt_any(struct pdf_struct *pdf, uint32_t id, const char *in, off_t *length, enum enc_method enc_method); enum enc_method get_enc_method(struct pdf_struct *pdf, struct pdf_obj *obj); +enum enc_method parse_enc_method(const char *dict, unsigned len, const char *key, enum enc_method def); +void pdfobj_flag(struct pdf_struct *pdf, struct pdf_obj *obj, enum pdf_flag flag); char *pdf_finalize_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char *in, size_t len); char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char *objstart, size_t objsize, const char *str, char **endchar, struct pdf_stats_metadata *stats); struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, size_t objsz, char *begin, char **endchar); diff -Nru clamav-0.99.2+dfsg/libclamav/pdfng.c clamav-0.99.3~beta1+dfsg/libclamav/pdfng.c --- clamav-0.99.2+dfsg/libclamav/pdfng.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/pdfng.c 2017-03-17 16:59:03.000000000 +0000 @@ -377,7 +377,7 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char *objstart, size_t objsize, const char *str, char **endchar, struct pdf_stats_metadata *meta) { - const char *q = objstart; + const char *q = objstart, *oobj=obj->start+pdf->map; char *p1, *p2; size_t len, checklen; char *res = NULL; @@ -551,10 +551,10 @@ /* Hex string */ p2 = p1+1; - while ((size_t)(p2 - q) < objsize && *p2 != '>') + while ((size_t)(p2 - oobj) < objsize && *p2 != '>') p2++; - if ((size_t)(p2 - q) == objsize) { + if ((size_t)(p2 - oobj) == objsize) { return NULL; } @@ -990,7 +990,7 @@ break; } - /* Not a dictionary. Intentially fall through. */ + /* Not a dictionary. Intentionally fall through. */ case '(': val = pdf_parse_string(pdf, obj, begin, objsz, NULL, &begin, NULL); begin += 2; diff -Nru clamav-0.99.2+dfsg/libclamav/pe.c clamav-0.99.3~beta1+dfsg/libclamav/pe.c --- clamav-0.99.2+dfsg/libclamav/pe.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/pe.c 2017-04-27 21:41:26.000000000 +0000 @@ -18,6 +18,21 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ +/* + Portions of Code (i.e. pe_ordinal) Copyright (c) 2014. The YARA Authors. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ #if HAVE_CONFIG_H #include "clamav-config.h" @@ -86,7 +101,11 @@ #define UPX_LZMA1 "\x56\x83\xc3\x04\x53\x50\xc7\x03\x03\x00\x02\x00\x90\x90\x90\x55\x57\x56\x53\x83" #define UPX_LZMA2 "\x56\x83\xc3\x04\x53\x50\xc7\x03\x03\x00\x02\x00\x90\x90\x90\x90\x90\x55\x57\x56" -#define EC32(x) ((uint32_t)cli_readint32(&(x))) /* Convert little endian to host */ +#define PE_MAXNAMESIZE 256 +#define PE_MAXIMPORTS 1024 + +#define EC64(x) ((uint64_t)cli_readint64(&(x))) /* Convert little endian to host */ +#define EC32(x) ((uint32_t)cli_readint32(&(x))) #define EC16(x) ((uint16_t)cli_readint16(&(x))) /* lower and upper bondary alignment (size vs offset) */ #define PEALIGN(o,a) (((a))?(((o)/(a))*(a)):(o)) @@ -208,6 +227,43 @@ struct offset_list *next; }; +struct pe_image_import_descriptor { + union { + uint32_t Characteristics; + uint32_t OriginalFirstThunk; + } u; + uint32_t TimeDateStamp; + uint32_t ForwarderChain; + uint32_t Name; + uint32_t FirstThunk; +}; + +#define PE_IMAGEDIR_ORDINAL_FLAG32 0x80000000 +#define PE_IMAGEDIR_ORDINAL_FLAG64 0x8000000000000000L + +struct pe_image_thunk32 { + union { + uint32_t ForwarderString; + uint32_t Function; + uint32_t Ordinal; + uint32_t AddressOfData; + } u; +}; + +struct pe_image_thunk64 { + union { + uint64_t ForwarderString; + uint64_t Function; + uint64_t Ordinal; + uint64_t AddressOfData; + } u; +}; + +struct pe_image_import_by_name { + uint16_t Hint; + uint8_t Name[1]; +}; + static void cli_multifree(void *f, ...) { void *ff; va_list ap; @@ -499,7 +555,7 @@ if (cli_debug_flag) { md5 = hashset[CLI_HASH_MD5]; if (md5) { - cli_dbgmsg("MDB: %u:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", + cli_dbgmsg("MDB hashset: %u:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", exe_section->rsz, md5[0], md5[1], md5[2], md5[3], md5[4], md5[5], md5[6], md5[7], md5[8], md5[9], md5[10], md5[11], md5[12], md5[13], md5[14], md5[15]); } else if (cli_always_gen_section_hash) { @@ -525,32 +581,2007 @@ free(md5); - } else { - cli_dbgmsg("MDB: %u:notgenerated\n", exe_section->rsz); + } else { + cli_dbgmsg("MDB: %u:notgenerated\n", exe_section->rsz); + } + } + + /* Do scans */ + for(type = CLI_HASH_MD5; type < CLI_HASH_AVAIL_TYPES; type++) { + if(foundsize[type] && cli_hm_scan(hashset[type], exe_section->rsz, &virname, mdb_sect, type) == CL_VIRUS) { + ret = cli_append_virus(ctx, virname); + if (ret != CL_CLEAN) { + if (ret != CL_VIRUS) + break; + else if (!SCAN_ALL) + break; + } + } + if(foundwild[type] && cli_hm_scan_wild(hashset[type], &virname, mdb_sect, type) == CL_VIRUS) { + ret = cli_append_virus(ctx, virname); + if (ret != CL_CLEAN) { + if (ret != CL_VIRUS) + break; + else if (!SCAN_ALL) + break; + } + } + } + +end: + for(type = CLI_HASH_AVAIL_TYPES; type > 0;) + free(hashset[--type]); + return ret; +} + +/* imptbl scanning */ +static char *pe_ordinal(const char *dll, uint16_t ord) +{ + char name[64]; + name[0] = '\0'; + + if (strncasecmp(dll, "WS2_32.dll", 10) == 0 || + strncasecmp(dll, "wsock32.dll", 11) == 0) + { + switch(ord) { + case 1: + sprintf(name, "accept"); + break; + case 2: + sprintf(name, "bind"); + break; + case 3: + sprintf(name, "closesocket"); + break; + case 4: + sprintf(name, "connect"); + break; + case 5: + sprintf(name, "getpeername"); + break; + case 6: + sprintf(name, "getsockname"); + break; + case 7: + sprintf(name, "getsockopt"); + break; + case 8: + sprintf(name, "htonl"); + break; + case 9: + sprintf(name, "htons"); + break; + case 10: + sprintf(name, "ioctlsocket"); + break; + case 11: + sprintf(name, "inet_addr"); + break; + case 12: + sprintf(name, "inet_ntoa"); + break; + case 13: + sprintf(name, "listen"); + break; + case 14: + sprintf(name, "ntohl"); + break; + case 15: + sprintf(name, "ntohs"); + break; + case 16: + sprintf(name, "recv"); + break; + case 17: + sprintf(name, "recvfrom"); + break; + case 18: + sprintf(name, "select"); + break; + case 19: + sprintf(name, "send"); + break; + case 20: + sprintf(name, "sendto"); + break; + case 21: + sprintf(name, "setsockopt"); + break; + case 22: + sprintf(name, "shutdown"); + break; + case 23: + sprintf(name, "socket"); + break; + case 24: + sprintf(name, "GetAddrInfoW"); + break; + case 25: + sprintf(name, "GetNameInfoW"); + break; + case 26: + sprintf(name, "WSApSetPostRoutine"); + break; + case 27: + sprintf(name, "FreeAddrInfoW"); + break; + case 28: + sprintf(name, "WPUCompleteOverlappedRequest"); + break; + case 29: + sprintf(name, "WSAAccept"); + break; + case 30: + sprintf(name, "WSAAddressToStringA"); + break; + case 31: + sprintf(name, "WSAAddressToStringW"); + break; + case 32: + sprintf(name, "WSACloseEvent"); + break; + case 33: + sprintf(name, "WSAConnect"); + break; + case 34: + sprintf(name, "WSACreateEvent"); + break; + case 35: + sprintf(name, "WSADuplicateSocketA"); + break; + case 36: + sprintf(name, "WSADuplicateSocketW"); + break; + case 37: + sprintf(name, "WSAEnumNameSpaceProvidersA"); + break; + case 38: + sprintf(name, "WSAEnumNameSpaceProvidersW"); + break; + case 39: + sprintf(name, "WSAEnumNetworkEvents"); + break; + case 40: + sprintf(name, "WSAEnumProtocolsA"); + break; + case 41: + sprintf(name, "WSAEnumProtocolsW"); + break; + case 42: + sprintf(name, "WSAEventSelect"); + break; + case 43: + sprintf(name, "WSAGetOverlappedResult"); + break; + case 44: + sprintf(name, "WSAGetQOSByName"); + break; + case 45: + sprintf(name, "WSAGetServiceClassInfoA"); + break; + case 46: + sprintf(name, "WSAGetServiceClassInfoW"); + break; + case 47: + sprintf(name, "WSAGetServiceClassNameByClassIdA"); + break; + case 48: + sprintf(name, "WSAGetServiceClassNameByClassIdW"); + break; + case 49: + sprintf(name, "WSAHtonl"); + break; + case 50: + sprintf(name, "WSAHtons"); + break; + case 51: + sprintf(name, "gethostbyaddr"); + break; + case 52: + sprintf(name, "gethostbyname"); + break; + case 53: + sprintf(name, "getprotobyname"); + break; + case 54: + sprintf(name, "getprotobynumber"); + break; + case 55: + sprintf(name, "getservbyname"); + break; + case 56: + sprintf(name, "getservbyport"); + break; + case 57: + sprintf(name, "gethostname"); + break; + case 58: + sprintf(name, "WSAInstallServiceClassA"); + break; + case 59: + sprintf(name, "WSAInstallServiceClassW"); + break; + case 60: + sprintf(name, "WSAIoctl"); + break; + case 61: + sprintf(name, "WSAJoinLeaf"); + break; + case 62: + sprintf(name, "WSALookupServiceBeginA"); + break; + case 63: + sprintf(name, "WSALookupServiceBeginW"); + break; + case 64: + sprintf(name, "WSALookupServiceEnd"); + break; + case 65: + sprintf(name, "WSALookupServiceNextA"); + break; + case 66: + sprintf(name, "WSALookupServiceNextW"); + break; + case 67: + sprintf(name, "WSANSPIoctl"); + break; + case 68: + sprintf(name, "WSANtohl"); + break; + case 69: + sprintf(name, "WSANtohs"); + break; + case 70: + sprintf(name, "WSAProviderConfigChange"); + break; + case 71: + sprintf(name, "WSARecv"); + break; + case 72: + sprintf(name, "WSARecvDisconnect"); + break; + case 73: + sprintf(name, "WSARecvFrom"); + break; + case 74: + sprintf(name, "WSARemoveServiceClass"); + break; + case 75: + sprintf(name, "WSAResetEvent"); + break; + case 76: + sprintf(name, "WSASend"); + break; + case 77: + sprintf(name, "WSASendDisconnect"); + break; + case 78: + sprintf(name, "WSASendTo"); + break; + case 79: + sprintf(name, "WSASetEvent"); + break; + case 80: + sprintf(name, "WSASetServiceA"); + break; + case 81: + sprintf(name, "WSASetServiceW"); + break; + case 82: + sprintf(name, "WSASocketA"); + break; + case 83: + sprintf(name, "WSASocketW"); + break; + case 84: + sprintf(name, "WSAStringToAddressA"); + break; + case 85: + sprintf(name, "WSAStringToAddressW"); + break; + case 86: + sprintf(name, "WSAWaitForMultipleEvents"); + break; + case 87: + sprintf(name, "WSCDeinstallProvider"); + break; + case 88: + sprintf(name, "WSCEnableNSProvider"); + break; + case 89: + sprintf(name, "WSCEnumProtocols"); + break; + case 90: + sprintf(name, "WSCGetProviderPath"); + break; + case 91: + sprintf(name, "WSCInstallNameSpace"); + break; + case 92: + sprintf(name, "WSCInstallProvider"); + break; + case 93: + sprintf(name, "WSCUnInstallNameSpace"); + break; + case 94: + sprintf(name, "WSCUpdateProvider"); + break; + case 95: + sprintf(name, "WSCWriteNameSpaceOrder"); + break; + case 96: + sprintf(name, "WSCWriteProviderOrder"); + break; + case 97: + sprintf(name, "freeaddrinfo"); + break; + case 98: + sprintf(name, "getaddrinfo"); + break; + case 99: + sprintf(name, "getnameinfo"); + break; + case 101: + sprintf(name, "WSAAsyncSelect"); + break; + case 102: + sprintf(name, "WSAAsyncGetHostByAddr"); + break; + case 103: + sprintf(name, "WSAAsyncGetHostByName"); + break; + case 104: + sprintf(name, "WSAAsyncGetProtoByNumber"); + break; + case 105: + sprintf(name, "WSAAsyncGetProtoByName"); + break; + case 106: + sprintf(name, "WSAAsyncGetServByPort"); + break; + case 107: + sprintf(name, "WSAAsyncGetServByName"); + break; + case 108: + sprintf(name, "WSACancelAsyncRequest"); + break; + case 109: + sprintf(name, "WSASetBlockingHook"); + break; + case 110: + sprintf(name, "WSAUnhookBlockingHook"); + break; + case 111: + sprintf(name, "WSAGetLastError"); + break; + case 112: + sprintf(name, "WSASetLastError"); + break; + case 113: + sprintf(name, "WSACancelBlockingCall"); + break; + case 114: + sprintf(name, "WSAIsBlocking"); + break; + case 115: + sprintf(name, "WSAStartup"); + break; + case 116: + sprintf(name, "WSACleanup"); + break; + case 151: + sprintf(name, "__WSAFDIsSet"); + break; + case 500: + sprintf(name, "WEP"); + break; + default: + break; + } + } + else if (strncasecmp(dll, "oleaut32.dll", 12) == 0) + { + switch (ord) { + case 2: + sprintf(name, "SysAllocString"); + break; + case 3: + sprintf(name, "SysReAllocString"); + break; + case 4: + sprintf(name, "SysAllocStringLen"); + break; + case 5: + sprintf(name, "SysReAllocStringLen"); + break; + case 6: + sprintf(name, "SysFreeString"); + break; + case 7: + sprintf(name, "SysStringLen"); + break; + case 8: + sprintf(name, "VariantInit"); + break; + case 9: + sprintf(name, "VariantClear"); + break; + case 10: + sprintf(name, "VariantCopy"); + break; + case 11: + sprintf(name, "VariantCopyInd"); + break; + case 12: + sprintf(name, "VariantChangeType"); + break; + case 13: + sprintf(name, "VariantTimeToDosDateTime"); + break; + case 14: + sprintf(name, "DosDateTimeToVariantTime"); + break; + case 15: + sprintf(name, "SafeArrayCreate"); + break; + case 16: + sprintf(name, "SafeArrayDestroy"); + break; + case 17: + sprintf(name, "SafeArrayGetDim"); + break; + case 18: + sprintf(name, "SafeArrayGetElemsize"); + break; + case 19: + sprintf(name, "SafeArrayGetUBound"); + break; + case 20: + sprintf(name, "SafeArrayGetLBound"); + break; + case 21: + sprintf(name, "SafeArrayLock"); + break; + case 22: + sprintf(name, "SafeArrayUnlock"); + break; + case 23: + sprintf(name, "SafeArrayAccessData"); + break; + case 24: + sprintf(name, "SafeArrayUnaccessData"); + break; + case 25: + sprintf(name, "SafeArrayGetElement"); + break; + case 26: + sprintf(name, "SafeArrayPutElement"); + break; + case 27: + sprintf(name, "SafeArrayCopy"); + break; + case 28: + sprintf(name, "DispGetParam"); + break; + case 29: + sprintf(name, "DispGetIDsOfNames"); + break; + case 30: + sprintf(name, "DispInvoke"); + break; + case 31: + sprintf(name, "CreateDispTypeInfo"); + break; + case 32: + sprintf(name, "CreateStdDispatch"); + break; + case 33: + sprintf(name, "RegisterActiveObject"); + break; + case 34: + sprintf(name, "RevokeActiveObject"); + break; + case 35: + sprintf(name, "GetActiveObject"); + break; + case 36: + sprintf(name, "SafeArrayAllocDescriptor"); + break; + case 37: + sprintf(name, "SafeArrayAllocData"); + break; + case 38: + sprintf(name, "SafeArrayDestroyDescriptor"); + break; + case 39: + sprintf(name, "SafeArrayDestroyData"); + break; + case 40: + sprintf(name, "SafeArrayRedim"); + break; + case 41: + sprintf(name, "SafeArrayAllocDescriptorEx"); + break; + case 42: + sprintf(name, "SafeArrayCreateEx"); + break; + case 43: + sprintf(name, "SafeArrayCreateVectorEx"); + break; + case 44: + sprintf(name, "SafeArraySetRecordInfo"); + break; + case 45: + sprintf(name, "SafeArrayGetRecordInfo"); + break; + case 46: + sprintf(name, "VarParseNumFromStr"); + break; + case 47: + sprintf(name, "VarNumFromParseNum"); + break; + case 48: + sprintf(name, "VarI2FromUI1"); + break; + case 49: + sprintf(name, "VarI2FromI4"); + break; + case 50: + sprintf(name, "VarI2FromR4"); + break; + case 51: + sprintf(name, "VarI2FromR8"); + break; + case 52: + sprintf(name, "VarI2FromCy"); + break; + case 53: + sprintf(name, "VarI2FromDate"); + break; + case 54: + sprintf(name, "VarI2FromStr"); + break; + case 55: + sprintf(name, "VarI2FromDisp"); + break; + case 56: + sprintf(name, "VarI2FromBool"); + break; + case 57: + sprintf(name, "SafeArraySetIID"); + break; + case 58: + sprintf(name, "VarI4FromUI1"); + break; + case 59: + sprintf(name, "VarI4FromI2"); + break; + case 60: + sprintf(name, "VarI4FromR4"); + break; + case 61: + sprintf(name, "VarI4FromR8"); + break; + case 62: + sprintf(name, "VarI4FromCy"); + break; + case 63: + sprintf(name, "VarI4FromDate"); + break; + case 64: + sprintf(name, "VarI4FromStr"); + break; + case 65: + sprintf(name, "VarI4FromDisp"); + break; + case 66: + sprintf(name, "VarI4FromBool"); + break; + case 67: + sprintf(name, "SafeArrayGetIID"); + break; + case 68: + sprintf(name, "VarR4FromUI1"); + break; + case 69: + sprintf(name, "VarR4FromI2"); + break; + case 70: + sprintf(name, "VarR4FromI4"); + break; + case 71: + sprintf(name, "VarR4FromR8"); + break; + case 72: + sprintf(name, "VarR4FromCy"); + break; + case 73: + sprintf(name, "VarR4FromDate"); + break; + case 74: + sprintf(name, "VarR4FromStr"); + break; + case 75: + sprintf(name, "VarR4FromDisp"); + break; + case 76: + sprintf(name, "VarR4FromBool"); + break; + case 77: + sprintf(name, "SafeArrayGetVartype"); + break; + case 78: + sprintf(name, "VarR8FromUI1"); + break; + case 79: + sprintf(name, "VarR8FromI2"); + break; + case 80: + sprintf(name, "VarR8FromI4"); + break; + case 81: + sprintf(name, "VarR8FromR4"); + break; + case 82: + sprintf(name, "VarR8FromCy"); + break; + case 83: + sprintf(name, "VarR8FromDate"); + break; + case 84: + sprintf(name, "VarR8FromStr"); + break; + case 85: + sprintf(name, "VarR8FromDisp"); + break; + case 86: + sprintf(name, "VarR8FromBool"); + break; + case 87: + sprintf(name, "VarFormat"); + break; + case 88: + sprintf(name, "VarDateFromUI1"); + break; + case 89: + sprintf(name, "VarDateFromI2"); + break; + case 90: + sprintf(name, "VarDateFromI4"); + break; + case 91: + sprintf(name, "VarDateFromR4"); + break; + case 92: + sprintf(name, "VarDateFromR8"); + break; + case 93: + sprintf(name, "VarDateFromCy"); + break; + case 94: + sprintf(name, "VarDateFromStr"); + break; + case 95: + sprintf(name, "VarDateFromDisp"); + break; + case 96: + sprintf(name, "VarDateFromBool"); + break; + case 97: + sprintf(name, "VarFormatDateTime"); + break; + case 98: + sprintf(name, "VarCyFromUI1"); + break; + case 99: + sprintf(name, "VarCyFromI2"); + break; + case 100: + sprintf(name, "VarCyFromI4"); + break; + case 101: + sprintf(name, "VarCyFromR4"); + break; + case 102: + sprintf(name, "VarCyFromR8"); + break; + case 103: + sprintf(name, "VarCyFromDate"); + break; + case 104: + sprintf(name, "VarCyFromStr"); + break; + case 105: + sprintf(name, "VarCyFromDisp"); + break; + case 106: + sprintf(name, "VarCyFromBool"); + break; + case 107: + sprintf(name, "VarFormatNumber"); + break; + case 108: + sprintf(name, "VarBstrFromUI1"); + break; + case 109: + sprintf(name, "VarBstrFromI2"); + break; + case 110: + sprintf(name, "VarBstrFromI4"); + break; + case 111: + sprintf(name, "VarBstrFromR4"); + break; + case 112: + sprintf(name, "VarBstrFromR8"); + break; + case 113: + sprintf(name, "VarBstrFromCy"); + break; + case 114: + sprintf(name, "VarBstrFromDate"); + break; + case 115: + sprintf(name, "VarBstrFromDisp"); + break; + case 116: + sprintf(name, "VarBstrFromBool"); + break; + case 117: + sprintf(name, "VarFormatPercent"); + break; + case 118: + sprintf(name, "VarBoolFromUI1"); + break; + case 119: + sprintf(name, "VarBoolFromI2"); + break; + case 120: + sprintf(name, "VarBoolFromI4"); + break; + case 121: + sprintf(name, "VarBoolFromR4"); + break; + case 122: + sprintf(name, "VarBoolFromR8"); + break; + case 123: + sprintf(name, "VarBoolFromDate"); + break; + case 124: + sprintf(name, "VarBoolFromCy"); + break; + case 125: + sprintf(name, "VarBoolFromStr"); + break; + case 126: + sprintf(name, "VarBoolFromDisp"); + break; + case 127: + sprintf(name, "VarFormatCurrency"); + break; + case 128: + sprintf(name, "VarWeekdayName"); + break; + case 129: + sprintf(name, "VarMonthName"); + break; + case 130: + sprintf(name, "VarUI1FromI2"); + break; + case 131: + sprintf(name, "VarUI1FromI4"); + break; + case 132: + sprintf(name, "VarUI1FromR4"); + break; + case 133: + sprintf(name, "VarUI1FromR8"); + break; + case 134: + sprintf(name, "VarUI1FromCy"); + break; + case 135: + sprintf(name, "VarUI1FromDate"); + break; + case 136: + sprintf(name, "VarUI1FromStr"); + break; + case 137: + sprintf(name, "VarUI1FromDisp"); + break; + case 138: + sprintf(name, "VarUI1FromBool"); + break; + case 139: + sprintf(name, "VarFormatFromTokens"); + break; + case 140: + sprintf(name, "VarTokenizeFormatString"); + break; + case 141: + sprintf(name, "VarAdd"); + break; + case 142: + sprintf(name, "VarAnd"); + break; + case 143: + sprintf(name, "VarDiv"); + break; + case 144: + sprintf(name, "DllCanUnloadNow"); + break; + case 145: + sprintf(name, "DllGetClassObject"); + break; + case 146: + sprintf(name, "DispCallFunc"); + break; + case 147: + sprintf(name, "VariantChangeTypeEx"); + break; + case 148: + sprintf(name, "SafeArrayPtrOfIndex"); + break; + case 149: + sprintf(name, "SysStringByteLen"); + break; + case 150: + sprintf(name, "SysAllocStringByteLen"); + break; + case 151: + sprintf(name, "DllRegisterServer"); + break; + case 152: + sprintf(name, "VarEqv"); + break; + case 153: + sprintf(name, "VarIdiv"); + break; + case 154: + sprintf(name, "VarImp"); + break; + case 155: + sprintf(name, "VarMod"); + break; + case 156: + sprintf(name, "VarMul"); + break; + case 157: + sprintf(name, "VarOr"); + break; + case 158: + sprintf(name, "VarPow"); + break; + case 159: + sprintf(name, "VarSub"); + break; + case 160: + sprintf(name, "CreateTypeLib"); + break; + case 161: + sprintf(name, "LoadTypeLib"); + break; + case 162: + sprintf(name, "LoadRegTypeLib"); + break; + case 163: + sprintf(name, "RegisterTypeLib"); + break; + case 164: + sprintf(name, "QueryPathOfRegTypeLib"); + break; + case 165: + sprintf(name, "LHashValOfNameSys"); + break; + case 166: + sprintf(name, "LHashValOfNameSysA"); + break; + case 167: + sprintf(name, "VarXor"); + break; + case 168: + sprintf(name, "VarAbs"); + break; + case 169: + sprintf(name, "VarFix"); + break; + case 170: + sprintf(name, "OaBuildVersion"); + break; + case 171: + sprintf(name, "ClearCustData"); + break; + case 172: + sprintf(name, "VarInt"); + break; + case 173: + sprintf(name, "VarNeg"); + break; + case 174: + sprintf(name, "VarNot"); + break; + case 175: + sprintf(name, "VarRound"); + break; + case 176: + sprintf(name, "VarCmp"); + break; + case 177: + sprintf(name, "VarDecAdd"); + break; + case 178: + sprintf(name, "VarDecDiv"); + break; + case 179: + sprintf(name, "VarDecMul"); + break; + case 180: + sprintf(name, "CreateTypeLib2"); + break; + case 181: + sprintf(name, "VarDecSub"); + break; + case 182: + sprintf(name, "VarDecAbs"); + break; + case 183: + sprintf(name, "LoadTypeLibEx"); + break; + case 184: + sprintf(name, "SystemTimeToVariantTime"); + break; + case 185: + sprintf(name, "VariantTimeToSystemTime"); + break; + case 186: + sprintf(name, "UnRegisterTypeLib"); + break; + case 187: + sprintf(name, "VarDecFix"); + break; + case 188: + sprintf(name, "VarDecInt"); + break; + case 189: + sprintf(name, "VarDecNeg"); + break; + case 190: + sprintf(name, "VarDecFromUI1"); + break; + case 191: + sprintf(name, "VarDecFromI2"); + break; + case 192: + sprintf(name, "VarDecFromI4"); + break; + case 193: + sprintf(name, "VarDecFromR4"); + break; + case 194: + sprintf(name, "VarDecFromR8"); + break; + case 195: + sprintf(name, "VarDecFromDate"); + break; + case 196: + sprintf(name, "VarDecFromCy"); + break; + case 197: + sprintf(name, "VarDecFromStr"); + break; + case 198: + sprintf(name, "VarDecFromDisp"); + break; + case 199: + sprintf(name, "VarDecFromBool"); + break; + case 200: + sprintf(name, "GetErrorInfo"); + break; + case 201: + sprintf(name, "SetErrorInfo"); + break; + case 202: + sprintf(name, "CreateErrorInfo"); + break; + case 203: + sprintf(name, "VarDecRound"); + break; + case 204: + sprintf(name, "VarDecCmp"); + break; + case 205: + sprintf(name, "VarI2FromI1"); + break; + case 206: + sprintf(name, "VarI2FromUI2"); + break; + case 207: + sprintf(name, "VarI2FromUI4"); + break; + case 208: + sprintf(name, "VarI2FromDec"); + break; + case 209: + sprintf(name, "VarI4FromI1"); + break; + case 210: + sprintf(name, "VarI4FromUI2"); + break; + case 211: + sprintf(name, "VarI4FromUI4"); + break; + case 212: + sprintf(name, "VarI4FromDec"); + break; + case 213: + sprintf(name, "VarR4FromI1"); + break; + case 214: + sprintf(name, "VarR4FromUI2"); + break; + case 215: + sprintf(name, "VarR4FromUI4"); + break; + case 216: + sprintf(name, "VarR4FromDec"); + break; + case 217: + sprintf(name, "VarR8FromI1"); + break; + case 218: + sprintf(name, "VarR8FromUI2"); + break; + case 219: + sprintf(name, "VarR8FromUI4"); + break; + case 220: + sprintf(name, "VarR8FromDec"); + break; + case 221: + sprintf(name, "VarDateFromI1"); + break; + case 222: + sprintf(name, "VarDateFromUI2"); + break; + case 223: + sprintf(name, "VarDateFromUI4"); + break; + case 224: + sprintf(name, "VarDateFromDec"); + break; + case 225: + sprintf(name, "VarCyFromI1"); + break; + case 226: + sprintf(name, "VarCyFromUI2"); + break; + case 227: + sprintf(name, "VarCyFromUI4"); + break; + case 228: + sprintf(name, "VarCyFromDec"); + break; + case 229: + sprintf(name, "VarBstrFromI1"); + break; + case 230: + sprintf(name, "VarBstrFromUI2"); + break; + case 231: + sprintf(name, "VarBstrFromUI4"); + break; + case 232: + sprintf(name, "VarBstrFromDec"); + break; + case 233: + sprintf(name, "VarBoolFromI1"); + break; + case 234: + sprintf(name, "VarBoolFromUI2"); + break; + case 235: + sprintf(name, "VarBoolFromUI4"); + break; + case 236: + sprintf(name, "VarBoolFromDec"); + break; + case 237: + sprintf(name, "VarUI1FromI1"); + break; + case 238: + sprintf(name, "VarUI1FromUI2"); + break; + case 239: + sprintf(name, "VarUI1FromUI4"); + break; + case 240: + sprintf(name, "VarUI1FromDec"); + break; + case 241: + sprintf(name, "VarDecFromI1"); + break; + case 242: + sprintf(name, "VarDecFromUI2"); + break; + case 243: + sprintf(name, "VarDecFromUI4"); + break; + case 244: + sprintf(name, "VarI1FromUI1"); + break; + case 245: + sprintf(name, "VarI1FromI2"); + break; + case 246: + sprintf(name, "VarI1FromI4"); + break; + case 247: + sprintf(name, "VarI1FromR4"); + break; + case 248: + sprintf(name, "VarI1FromR8"); + break; + case 249: + sprintf(name, "VarI1FromDate"); + break; + case 250: + sprintf(name, "VarI1FromCy"); + break; + case 251: + sprintf(name, "VarI1FromStr"); + break; + case 252: + sprintf(name, "VarI1FromDisp"); + break; + case 253: + sprintf(name, "VarI1FromBool"); + break; + case 254: + sprintf(name, "VarI1FromUI2"); + break; + case 255: + sprintf(name, "VarI1FromUI4"); + break; + case 256: + sprintf(name, "VarI1FromDec"); + break; + case 257: + sprintf(name, "VarUI2FromUI1"); + break; + case 258: + sprintf(name, "VarUI2FromI2"); + break; + case 259: + sprintf(name, "VarUI2FromI4"); + break; + case 260: + sprintf(name, "VarUI2FromR4"); + break; + case 261: + sprintf(name, "VarUI2FromR8"); + break; + case 262: + sprintf(name, "VarUI2FromDate"); + break; + case 263: + sprintf(name, "VarUI2FromCy"); + break; + case 264: + sprintf(name, "VarUI2FromStr"); + break; + case 265: + sprintf(name, "VarUI2FromDisp"); + break; + case 266: + sprintf(name, "VarUI2FromBool"); + break; + case 267: + sprintf(name, "VarUI2FromI1"); + break; + case 268: + sprintf(name, "VarUI2FromUI4"); + break; + case 269: + sprintf(name, "VarUI2FromDec"); + break; + case 270: + sprintf(name, "VarUI4FromUI1"); + break; + case 271: + sprintf(name, "VarUI4FromI2"); + break; + case 272: + sprintf(name, "VarUI4FromI4"); + break; + case 273: + sprintf(name, "VarUI4FromR4"); + break; + case 274: + sprintf(name, "VarUI4FromR8"); + break; + case 275: + sprintf(name, "VarUI4FromDate"); + break; + case 276: + sprintf(name, "VarUI4FromCy"); + break; + case 277: + sprintf(name, "VarUI4FromStr"); + break; + case 278: + sprintf(name, "VarUI4FromDisp"); + break; + case 279: + sprintf(name, "VarUI4FromBool"); + break; + case 280: + sprintf(name, "VarUI4FromI1"); + break; + case 281: + sprintf(name, "VarUI4FromUI2"); + break; + case 282: + sprintf(name, "VarUI4FromDec"); + break; + case 283: + sprintf(name, "BSTR_UserSize"); + break; + case 284: + sprintf(name, "BSTR_UserMarshal"); + break; + case 285: + sprintf(name, "BSTR_UserUnmarshal"); + break; + case 286: + sprintf(name, "BSTR_UserFree"); + break; + case 287: + sprintf(name, "VARIANT_UserSize"); + break; + case 288: + sprintf(name, "VARIANT_UserMarshal"); + break; + case 289: + sprintf(name, "VARIANT_UserUnmarshal"); + break; + case 290: + sprintf(name, "VARIANT_UserFree"); + break; + case 291: + sprintf(name, "LPSAFEARRAY_UserSize"); + break; + case 292: + sprintf(name, "LPSAFEARRAY_UserMarshal"); + break; + case 293: + sprintf(name, "LPSAFEARRAY_UserUnmarshal"); + break; + case 294: + sprintf(name, "LPSAFEARRAY_UserFree"); + break; + case 295: + sprintf(name, "LPSAFEARRAY_Size"); + break; + case 296: + sprintf(name, "LPSAFEARRAY_Marshal"); + break; + case 297: + sprintf(name, "LPSAFEARRAY_Unmarshal"); + break; + case 298: + sprintf(name, "VarDecCmpR8"); + break; + case 299: + sprintf(name, "VarCyAdd"); + break; + case 300: + sprintf(name, "DllUnregisterServer"); + break; + case 301: + sprintf(name, "OACreateTypeLib2"); + break; + case 303: + sprintf(name, "VarCyMul"); + break; + case 304: + sprintf(name, "VarCyMulI4"); + break; + case 305: + sprintf(name, "VarCySub"); + break; + case 306: + sprintf(name, "VarCyAbs"); + break; + case 307: + sprintf(name, "VarCyFix"); + break; + case 308: + sprintf(name, "VarCyInt"); + break; + case 309: + sprintf(name, "VarCyNeg"); + break; + case 310: + sprintf(name, "VarCyRound"); + break; + case 311: + sprintf(name, "VarCyCmp"); + break; + case 312: + sprintf(name, "VarCyCmpR8"); + break; + case 313: + sprintf(name, "VarBstrCat"); + break; + case 314: + sprintf(name, "VarBstrCmp"); + break; + case 315: + sprintf(name, "VarR8Pow"); + break; + case 316: + sprintf(name, "VarR4CmpR8"); + break; + case 317: + sprintf(name, "VarR8Round"); + break; + case 318: + sprintf(name, "VarCat"); + break; + case 319: + sprintf(name, "VarDateFromUdateEx"); + break; + case 322: + sprintf(name, "GetRecordInfoFromGuids"); + break; + case 323: + sprintf(name, "GetRecordInfoFromTypeInfo"); + break; + case 325: + sprintf(name, "SetVarConversionLocaleSetting"); + break; + case 326: + sprintf(name, "GetVarConversionLocaleSetting"); + break; + case 327: + sprintf(name, "SetOaNoCache"); + break; + case 329: + sprintf(name, "VarCyMulI8"); + break; + case 330: + sprintf(name, "VarDateFromUdate"); + break; + case 331: + sprintf(name, "VarUdateFromDate"); + break; + case 332: + sprintf(name, "GetAltMonthNames"); + break; + case 333: + sprintf(name, "VarI8FromUI1"); + break; + case 334: + sprintf(name, "VarI8FromI2"); + break; + case 335: + sprintf(name, "VarI8FromR4"); + break; + case 336: + sprintf(name, "VarI8FromR8"); + break; + case 337: + sprintf(name, "VarI8FromCy"); + break; + case 338: + sprintf(name, "VarI8FromDate"); + break; + case 339: + sprintf(name, "VarI8FromStr"); + break; + case 340: + sprintf(name, "VarI8FromDisp"); + break; + case 341: + sprintf(name, "VarI8FromBool"); + break; + case 342: + sprintf(name, "VarI8FromI1"); + break; + case 343: + sprintf(name, "VarI8FromUI2"); + break; + case 344: + sprintf(name, "VarI8FromUI4"); + break; + case 345: + sprintf(name, "VarI8FromDec"); + break; + case 346: + sprintf(name, "VarI2FromI8"); + break; + case 347: + sprintf(name, "VarI2FromUI8"); + break; + case 348: + sprintf(name, "VarI4FromI8"); + break; + case 349: + sprintf(name, "VarI4FromUI8"); + break; + case 360: + sprintf(name, "VarR4FromI8"); + break; + case 361: + sprintf(name, "VarR4FromUI8"); + break; + case 362: + sprintf(name, "VarR8FromI8"); + break; + case 363: + sprintf(name, "VarR8FromUI8"); + break; + case 364: + sprintf(name, "VarDateFromI8"); + break; + case 365: + sprintf(name, "VarDateFromUI8"); + break; + case 366: + sprintf(name, "VarCyFromI8"); + break; + case 367: + sprintf(name, "VarCyFromUI8"); + break; + case 368: + sprintf(name, "VarBstrFromI8"); + break; + case 369: + sprintf(name, "VarBstrFromUI8"); + break; + case 370: + sprintf(name, "VarBoolFromI8"); + break; + case 371: + sprintf(name, "VarBoolFromUI8"); + break; + case 372: + sprintf(name, "VarUI1FromI8"); + break; + case 373: + sprintf(name, "VarUI1FromUI8"); + break; + case 374: + sprintf(name, "VarDecFromI8"); + break; + case 375: + sprintf(name, "VarDecFromUI8"); + break; + case 376: + sprintf(name, "VarI1FromI8"); + break; + case 377: + sprintf(name, "VarI1FromUI8"); + break; + case 378: + sprintf(name, "VarUI2FromI8"); + break; + case 379: + sprintf(name, "VarUI2FromUI8"); + break; + case 401: + sprintf(name, "OleLoadPictureEx"); + break; + case 402: + sprintf(name, "OleLoadPictureFileEx"); + break; + case 411: + sprintf(name, "SafeArrayCreateVector"); + break; + case 412: + sprintf(name, "SafeArrayCopyData"); + break; + case 413: + sprintf(name, "VectorFromBstr"); + break; + case 414: + sprintf(name, "BstrFromVector"); + break; + case 415: + sprintf(name, "OleIconToCursor"); + break; + case 416: + sprintf(name, "OleCreatePropertyFrameIndirect"); + break; + case 417: + sprintf(name, "OleCreatePropertyFrame"); + break; + case 418: + sprintf(name, "OleLoadPicture"); + break; + case 419: + sprintf(name, "OleCreatePictureIndirect"); + break; + case 420: + sprintf(name, "OleCreateFontIndirect"); + break; + case 421: + sprintf(name, "OleTranslateColor"); + break; + case 422: + sprintf(name, "OleLoadPictureFile"); + break; + case 423: + sprintf(name, "OleSavePictureFile"); + break; + case 424: + sprintf(name, "OleLoadPicturePath"); + break; + case 425: + sprintf(name, "VarUI4FromI8"); + break; + case 426: + sprintf(name, "VarUI4FromUI8"); + break; + case 427: + sprintf(name, "VarI8FromUI8"); + break; + case 428: + sprintf(name, "VarUI8FromI8"); + break; + case 429: + sprintf(name, "VarUI8FromUI1"); + break; + case 430: + sprintf(name, "VarUI8FromI2"); + break; + case 431: + sprintf(name, "VarUI8FromR4"); + break; + case 432: + sprintf(name, "VarUI8FromR8"); + break; + case 433: + sprintf(name, "VarUI8FromCy"); + break; + case 434: + sprintf(name, "VarUI8FromDate"); + break; + case 435: + sprintf(name, "VarUI8FromStr"); + break; + case 436: + sprintf(name, "VarUI8FromDisp"); + break; + case 437: + sprintf(name, "VarUI8FromBool"); + break; + case 438: + sprintf(name, "VarUI8FromI1"); + break; + case 439: + sprintf(name, "VarUI8FromUI2"); + break; + case 440: + sprintf(name, "VarUI8FromUI4"); + break; + case 441: + sprintf(name, "VarUI8FromDec"); + break; + case 442: + sprintf(name, "RegisterTypeLibForUser"); + break; + case 443: + sprintf(name, "UnRegisterTypeLibForUser"); + break; + default: + break; + } + } + + if (name[0] == '\0') + sprintf(name, "ord%u", ord); + + return cli_strdup(name); +} + +static int validate_impname(const char *name, uint32_t length, int dll) +{ + uint32_t i = 0; + const char *c = name; + + if (!name || length == 0) + return 1; + + while (i < length && *c != '\0') { + if ((*c >= '0' && *c <= '9') || + (*c >= 'a' && *c <= 'z') || + (*c >= 'A' && *c <= 'Z') || + (*c == '_') || + (dll && *c == '.')) { + + c++; + i++; + } else + return 0; + } + + return 1; +} + +static inline int hash_impfns(cli_ctx *ctx, void **hashctx, uint32_t *impsz, struct pe_image_import_descriptor *image, const char *dllname, struct cli_exe_section *exe_sections, uint16_t nsections, uint32_t hdr_size, int pe_plus, int *first) +{ + uint32_t thuoff = 0, offset; + fmap_t *map = *ctx->fmap; + size_t dlllen = 0, fsize = map->len; + int i, j, err = 0, num_fns = 0, ret = CL_SUCCESS; + const char *buffer; + enum CLI_HASH_TYPE type; +#if HAVE_JSON + json_object *imptbl = NULL; +#else + void *imptbl = NULL; +#endif + + if (image->u.OriginalFirstThunk) + thuoff = cli_rawaddr(image->u.OriginalFirstThunk, exe_sections, nsections, &err, fsize, hdr_size); + if (err || thuoff == 0) + thuoff = cli_rawaddr(image->FirstThunk, exe_sections, nsections, &err, fsize, hdr_size); + if (err) { + cli_dbgmsg("scan_pe: invalid rva for image first thunk\n"); + return CL_EFORMAT; + } + +#if HAVE_JSON + if (ctx->wrkproperty) { + imptbl = cli_jsonarray(ctx->wrkproperty, "ImportTable"); + if (!imptbl) { + cli_dbgmsg("scan_pe: cannot allocate import table json object\n"); + return CL_EMEM; + } + } +#endif + +#define update_imphash() \ + do { \ + if (funcname) { \ + char *fname; \ + size_t funclen; \ + \ + if (dlllen == 0) { \ + char* ext = strstr(dllname, "."); \ + \ + if (ext && (strncasecmp(ext, ".ocx", 4) == 0 || \ + strncasecmp(ext, ".sys", 4) == 0 || \ + strncasecmp(ext, ".dll", 4) == 0)) \ + dlllen = ext - dllname; \ + else \ + dlllen = strlen(dllname); \ + } \ + \ + funclen = strlen(funcname); \ + if (validate_impname(funcname, funclen, 1) == 0) { \ + cli_dbgmsg("scan_pe: invalid name for imported function\n"); \ + ret = CL_EFORMAT; \ + break; \ + } \ + \ + fname = cli_calloc(funclen + dlllen + 3, sizeof(char)); \ + if (fname == NULL) { \ + cli_dbgmsg("scan_pe: cannot allocate memory for imphash string\n"); \ + ret = CL_EMEM; \ + break; \ + } \ + j = 0; \ + if (!*first) \ + fname[j++] = ','; \ + for (i = 0; i < dlllen; i++, j++) \ + fname[j] = tolower(dllname[i]); \ + fname[j++] = '.'; \ + for (i = 0; i < funclen; i++, j++) \ + fname[j] = tolower(funcname[i]); \ + \ + if (imptbl) { \ + char *jname = *first ? fname : fname+1; \ + cli_jsonstr(imptbl, NULL, jname); \ + } \ + \ + for(type = CLI_HASH_MD5; type < CLI_HASH_AVAIL_TYPES; type++) \ + cl_update_hash(hashctx[type], fname, strlen(fname)); \ + *impsz += strlen(fname); \ + \ + *first = 0; \ + free(fname); \ + } \ + } while(0) + + if (!pe_plus) { + struct pe_image_thunk32 thunk32; + + while ((num_fns < PE_MAXIMPORTS) && (fmap_readn(map, &thunk32, thuoff, sizeof(struct pe_image_thunk32)) == sizeof(struct pe_image_thunk32)) && (thunk32.u.Ordinal != 0)) { + char *funcname = NULL; + thuoff += sizeof(struct pe_image_thunk32); + + thunk32.u.Ordinal = EC32(thunk32.u.Ordinal); + + if (!(thunk32.u.Ordinal & PE_IMAGEDIR_ORDINAL_FLAG32)) { + offset = cli_rawaddr(thunk32.u.Function, exe_sections, nsections, &err, fsize, hdr_size); + + if (offset >= 0) { + /* Hint field is a uint16_t and precedes the Name field */ + if ((buffer = fmap_need_off_once(map, offset+sizeof(uint16_t), MIN(PE_MAXNAMESIZE, fsize-offset))) != NULL) { + funcname = cli_strndup(buffer, MIN(PE_MAXNAMESIZE, fsize-offset)); + if (funcname == NULL) { + cli_dbgmsg("scan_pe: cannot duplicate function name\n"); + return CL_EMEM; + } + } + } + } else { + /* ordinal lookup */ + funcname = pe_ordinal(dllname, thunk32.u.Ordinal & 0xFFFF); + if (funcname == NULL) { + cli_dbgmsg("scan_pe: cannot duplicate function name\n"); + return CL_EMEM; + } + } + + update_imphash(); + free(funcname); + if (ret != CL_SUCCESS) + return ret; + } + } else { + struct pe_image_thunk64 thunk64; + + while ((num_fns < PE_MAXIMPORTS) && (fmap_readn(map, &thunk64, thuoff, sizeof(struct pe_image_thunk64)) == sizeof(struct pe_image_thunk64)) && (thunk64.u.Ordinal != 0)) { + char *funcname = NULL; + thuoff += sizeof(struct pe_image_thunk64); + + thunk64.u.Ordinal = EC64(thunk64.u.Ordinal); + + if (!(thunk64.u.Ordinal & PE_IMAGEDIR_ORDINAL_FLAG64)) { + offset = cli_rawaddr(thunk64.u.Function, exe_sections, nsections, &err, fsize, hdr_size); + + if (offset >= 0) { + /* Hint field is a uint16_t and precedes the Name field */ + if ((buffer = fmap_need_off_once(map, offset+sizeof(uint16_t), MIN(PE_MAXNAMESIZE, fsize-offset))) != NULL) { + funcname = cli_strndup(buffer, MIN(PE_MAXNAMESIZE, fsize-offset)); + if (funcname == NULL) { + cli_dbgmsg("scan_pe: cannot duplicate function name\n"); + return CL_EMEM; + } + } + } + } else { + /* ordinal lookup */ + funcname = pe_ordinal(dllname, thunk64.u.Ordinal & 0xFFFF); + if (funcname == NULL) { + cli_dbgmsg("scan_pe: cannot duplicate function name\n"); + return CL_EMEM; + } + } + + update_imphash(); + free(funcname); + if (ret != CL_SUCCESS) + return ret; + } + } + + return CL_SUCCESS; +} + +static unsigned int hash_imptbl(cli_ctx *ctx, unsigned char **digest, uint32_t *impsz, int *genhash, struct pe_image_data_dir *datadir, struct cli_exe_section *exe_sections, uint16_t nsections, uint32_t hdr_size, int pe_plus) +{ + struct pe_image_import_descriptor *image; + fmap_t *map = *ctx->fmap; + size_t left, fsize = map->len; + uint32_t impoff, offset; + const char *impdes, *buffer; + void *hashctx[CLI_HASH_AVAIL_TYPES]; + enum CLI_HASH_TYPE type; + int err, nimps = 0, ret = CL_SUCCESS; + int first = 1; + + if(datadir->VirtualAddress == 0 || datadir->Size == 0) { + cli_errmsg("scan_pe: import table data directory does not exist\n"); + return CL_SUCCESS; + } + + impoff = cli_rawaddr(datadir->VirtualAddress, exe_sections, nsections, &err, fsize, hdr_size); + if(err || impoff + datadir->Size > fsize) { + cli_dbgmsg("scan_pe: invalid rva for import table data\n"); + return CL_SUCCESS; + } + + impdes = fmap_need_off(map, impoff, datadir->Size); + if(impdes == NULL) { + cli_dbgmsg("scan_pe: failed to acquire fmap buffer\n"); + return CL_EREAD; + } + left = datadir->Size; + + memset(hashctx, 0, sizeof(hashctx)); + if(genhash[CLI_HASH_MD5]) { + hashctx[CLI_HASH_MD5] = cl_hash_init("md5"); + if (hashctx[CLI_HASH_MD5] == NULL) { + fmap_unneed_off(map, impoff, datadir->Size); + return CL_EMEM; + } + } + if(genhash[CLI_HASH_SHA1]) { + hashctx[CLI_HASH_SHA1] = cl_hash_init("sha1"); + if (hashctx[CLI_HASH_SHA1] == NULL) { + fmap_unneed_off(map, impoff, datadir->Size); + return CL_EMEM; + } + } + if(genhash[CLI_HASH_SHA256]) { + hashctx[CLI_HASH_SHA256] = cl_hash_init("sha256"); + if (hashctx[CLI_HASH_SHA256] == NULL) { + fmap_unneed_off(map, impoff, datadir->Size); + return CL_EMEM; + } + } + + image = (struct pe_image_import_descriptor *)impdes; + while(left > sizeof(struct pe_image_import_descriptor) && image->Name != 0 && nimps < PE_MAXIMPORTS) { + char *dllname = NULL; + + left -= sizeof(struct pe_image_import_descriptor); + nimps++; + + /* Endian Conversion */ + image->u.OriginalFirstThunk = EC32(image->u.OriginalFirstThunk); + image->TimeDateStamp = EC32(image->TimeDateStamp); + image->ForwarderChain = EC32(image->ForwarderChain); + image->Name = EC32(image->Name); + image->FirstThunk = EC32(image->FirstThunk); + + /* DLL name aquisition */ + offset = cli_rawaddr(image->Name, exe_sections, nsections, &err, fsize, hdr_size); + if(err || offset > fsize) { + cli_dbgmsg("scan_pe: invalid rva for dll name\n"); + /* TODO: ignore or return? */ + /* + image++; + continue; + */ + ret = CL_EFORMAT; + goto hash_imptbl_end; + } + + buffer = fmap_need_off_once(map, offset, MIN(PE_MAXNAMESIZE, fsize-offset)); + if (buffer == NULL) { + cli_dbgmsg("scan_pe: failed to read name for dll\n"); + ret = CL_EREAD; + goto hash_imptbl_end; + } + + if (validate_impname(dllname, MIN(PE_MAXNAMESIZE, fsize-offset), 1) == 0) { + cli_dbgmsg("scan_pe: invalid name for imported dll\n"); + ret = CL_EFORMAT; + goto hash_imptbl_end; + } + + dllname = cli_strndup(buffer, MIN(PE_MAXNAMESIZE, fsize-offset)); + if (dllname == NULL) { + cli_dbgmsg("scan_pe: cannot duplicate dll name\n"); + ret = CL_EMEM; + goto hash_imptbl_end; + } + + /* DLL function handling - inline function */ + ret = hash_impfns(ctx, hashctx, impsz, image, dllname, exe_sections, nsections, hdr_size, pe_plus, &first); + free(dllname); + dllname = NULL; + if (ret != CL_SUCCESS) + goto hash_imptbl_end; + + image++; + } + + hash_imptbl_end: + fmap_unneed_off(map, impoff, datadir->Size); + for(type = CLI_HASH_MD5; type < CLI_HASH_AVAIL_TYPES; type++) + cl_finish_hash(hashctx[type], digest[type]); + return ret; +} + +static int scan_pe_imp(cli_ctx *ctx, struct pe_image_data_dir *dirs, struct cli_exe_section *exe_sections, uint16_t nsections, uint32_t hdr_size, int pe_plus) +{ + struct cli_matcher *imp = ctx->engine->hm_imp; + unsigned char *hashset[CLI_HASH_AVAIL_TYPES]; + const char *virname = NULL; + int genhash[CLI_HASH_AVAIL_TYPES]; + uint32_t impsz = 0; + enum CLI_HASH_TYPE type; + int ret = CL_CLEAN; + + /* pick hashtypes to generate */ + for(type = CLI_HASH_MD5; type < CLI_HASH_AVAIL_TYPES; type++) { + genhash[type] = cli_hm_have_any(imp, type); + if(genhash[type]) { + hashset[type] = cli_malloc(hashlen[type]); + if(!hashset[type]) { + cli_errmsg("scan_pe: cli_malloc failed!\n"); + for(; type > 0;) + free(hashset[--type]); + return CL_EMEM; + } + } + else { + hashset[type] = NULL; + } + } + + /* Force md5 hash generation for debug and preclass */ +#if HAVE_JSON + if ((cli_debug_flag || ctx->wrkproperty) && !genhash[CLI_HASH_MD5]) { +#else + if (cli_debug_flag && !genhash[CLI_HASH_MD5]) { +#endif + genhash[CLI_HASH_MD5] = 1; + hashset[CLI_HASH_MD5] = cli_malloc(hashlen[CLI_HASH_MD5]); + if(!hashset[CLI_HASH_MD5]) { + cli_errmsg("scan_pe: cli_malloc failed!\n"); + for(type = CLI_HASH_MD5; type < CLI_HASH_AVAIL_TYPES; type++) + free(hashset[type]); + return CL_EMEM; } } + /* Generate hashes */ + ret = hash_imptbl(ctx, hashset, &impsz, genhash, &dirs[1], exe_sections, nsections, hdr_size, pe_plus); + if (ret != CL_SUCCESS) { + for(type = CLI_HASH_MD5; type < CLI_HASH_AVAIL_TYPES; type++) + free(hashset[type]); + return ret; + } + + /* Print hash */ +#if HAVE_JSON + if (cli_debug_flag || ctx->wrkproperty) { +#else + if (cli_debug_flag) { +#endif + char *dstr = cli_str2hex(hashset[CLI_HASH_MD5], hashlen[CLI_HASH_MD5]); + cli_dbgmsg("IMP: %s:%u\n", dstr ? (char *)dstr : "(NULL)", impsz); +#if HAVE_JSON + if (ctx->wrkproperty) + cli_jsonstr(ctx->wrkproperty, "Imphash", dstr ? dstr : "(NULL)"); +#endif + if (dstr) + free(dstr); + } + /* Do scans */ for(type = CLI_HASH_MD5; type < CLI_HASH_AVAIL_TYPES; type++) { - if(foundsize[type] && cli_hm_scan(hashset[type], exe_section->rsz, &virname, mdb_sect, type) == CL_VIRUS) { - cli_append_virus(ctx, virname); - ret = CL_VIRUS; - if (!SCAN_ALL) { - break; + if(cli_hm_scan(hashset[type], impsz, &virname, imp, type) == CL_VIRUS) { + ret = cli_append_virus(ctx, virname); + if (ret != CL_CLEAN) { + if (ret != CL_VIRUS) + break; + else if (!SCAN_ALL) + break; } - } - if(foundwild[type] && cli_hm_scan_wild(hashset[type], &virname, mdb_sect, type) == CL_VIRUS) { + } + if(cli_hm_scan_wild(hashset[type], &virname, imp, type) == CL_VIRUS) { cli_append_virus(ctx, virname); - ret = CL_VIRUS; - if (!SCAN_ALL) { - break; + if (ret != CL_CLEAN) { + if (ret != CL_VIRUS) + break; + else if (!SCAN_ALL) + break; } } } -end: - for(type = CLI_HASH_AVAIL_TYPES; type > 0;) - free(hashset[--type]); + for(type = CLI_HASH_MD5; type < CLI_HASH_AVAIL_TYPES; type++) + free(hashset[type]); return ret; } @@ -738,8 +2769,8 @@ cli_dbgmsg("Can't read new header address\n"); /* truncated header? */ if(DETECT_BROKEN_PE) { - cli_append_virus(ctx,"Heuristics.Broken.Executable"); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.Broken.Executable"); + return ret; } return CL_CLEAN; @@ -754,7 +2785,7 @@ if(fmap_readn(map, &file_hdr, e_lfanew, sizeof(struct pe_image_file_hdr)) != sizeof(struct pe_image_file_hdr)) { /* bad information in e_lfanew - probably not a PE file */ - cli_dbgmsg("Can't read file header\n"); + cli_dbgmsg("cli_scanpe: Can't read file header\n"); return CL_CLEAN; } @@ -887,8 +2918,8 @@ pe_add_heuristic_property(ctx, "BadNumberOfSections"); #endif if(DETECT_BROKEN_PE) { - cli_append_virus(ctx,"Heuristics.Broken.Executable"); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.Broken.Executable"); + return ret; } if(!ctx->corrupted_input) { @@ -924,8 +2955,8 @@ #endif cli_dbgmsg("SizeOfOptionalHeader too small\n"); if(DETECT_BROKEN_PE) { - cli_append_virus(ctx,"Heuristics.Broken.Executable"); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.Broken.Executable"); + return ret; } return CL_CLEAN; @@ -935,8 +2966,8 @@ if(fmap_readn(map, &optional_hdr32, at, sizeof(struct pe_image_optional_hdr32)) != sizeof(struct pe_image_optional_hdr32)) { cli_dbgmsg("Can't read optional file header\n"); if(DETECT_BROKEN_PE) { - cli_append_virus(ctx,"Heuristics.Broken.Executable"); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.Broken.Executable"); + return ret; } return CL_CLEAN; @@ -953,8 +2984,8 @@ cli_dbgmsg("Incorrect SizeOfOptionalHeader for PE32+\n"); if(DETECT_BROKEN_PE) { - cli_append_virus(ctx,"Heuristics.Broken.Executable"); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.Broken.Executable"); + return ret; } return CL_CLEAN; @@ -1023,8 +3054,8 @@ if(fmap_readn(map, &optional_hdr32 + 1, at, sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32)) != sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32)) { cli_dbgmsg("Can't read optional file header\n"); if(DETECT_BROKEN_PE) { - cli_append_virus(ctx,"Heuristics.Broken.Executable"); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.Broken.Executable"); + return ret; } return CL_CLEAN; @@ -1146,15 +3177,15 @@ cli_dbgmsg("------------------------------------\n"); if (DETECT_BROKEN_PE && !native && (!(pe_plus?EC32(optional_hdr64.SectionAlignment):EC32(optional_hdr32.SectionAlignment)) || (pe_plus?EC32(optional_hdr64.SectionAlignment):EC32(optional_hdr32.SectionAlignment))%0x1000)) { - cli_dbgmsg("Bad virtual alignemnt\n"); - cli_append_virus(ctx,"Heuristics.Broken.Executable"); - return CL_VIRUS; + cli_dbgmsg("Bad virtual alignment\n"); + ret = cli_append_virus(ctx,"Heuristics.Broken.Executable"); + return ret; } if (DETECT_BROKEN_PE && !native && (!(pe_plus?EC32(optional_hdr64.FileAlignment):EC32(optional_hdr32.FileAlignment)) || (pe_plus?EC32(optional_hdr64.FileAlignment):EC32(optional_hdr32.FileAlignment))%0x200)) { - cli_dbgmsg("Bad file alignemnt\n"); - cli_append_virus(ctx, "Heuristics.Broken.Executable"); - return CL_VIRUS; + cli_dbgmsg("Bad file alignment\n"); + ret = cli_append_virus(ctx, "Heuristics.Broken.Executable"); + return ret; } fsize = map->len; @@ -1185,8 +3216,8 @@ free(exe_sections); if(DETECT_BROKEN_PE) { - cli_append_virus(ctx,"Heuristics.Broken.Executable"); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.Broken.Executable"); + return ret; } return CL_CLEAN; @@ -1230,8 +3261,8 @@ free(exe_sections); if(DETECT_BROKEN_PE) { - cli_append_virus(ctx, "Heuristics.Broken.Executable"); - return CL_VIRUS; + ret = cli_append_virus(ctx, "Heuristics.Broken.Executable"); + return ret; } return CL_CLEAN; /* no ninjas to see here! move along! */ @@ -1303,10 +3334,10 @@ if (DETECT_BROKEN_PE && (!valign || (exe_sections[i].urva % valign))) { /* Bad virtual alignment */ cli_dbgmsg("VirtualAddress is misaligned\n"); cli_dbgmsg("------------------------------------\n"); - cli_append_virus(ctx, "Heuristics.Broken.Executable"); + ret = cli_append_virus(ctx, "Heuristics.Broken.Executable"); free(section_hdr); free(exe_sections); - return CL_VIRUS; + return ret; } if (exe_sections[i].rsz) { /* Don't bother with virtual only sections */ @@ -1334,8 +3365,8 @@ free(section_hdr); free(exe_sections); if(DETECT_BROKEN_PE) { - cli_append_virus(ctx, "Heuristics.Broken.Executable"); - return CL_VIRUS; + ret = cli_append_virus(ctx, "Heuristics.Broken.Executable"); + return ret; } return CL_CLEAN; @@ -1344,10 +3375,10 @@ if(!i) { if (DETECT_BROKEN_PE && exe_sections[i].urva!=hdr_size) { /* Bad first section RVA */ cli_dbgmsg("First section is in the wrong place\n"); - cli_append_virus(ctx, "Heuristics.Broken.Executable"); + ret = cli_append_virus(ctx, "Heuristics.Broken.Executable"); free(section_hdr); free(exe_sections); - return CL_VIRUS; + return ret; } min = exe_sections[i].rva; @@ -1355,10 +3386,10 @@ } else { if (DETECT_BROKEN_PE && exe_sections[i].urva - exe_sections[i-1].urva != exe_sections[i-1].vsz) { /* No holes, no overlapping, no virtual disorder */ cli_dbgmsg("Virtually misplaced section (wrong order, overlapping, non contiguous)\n"); - cli_append_virus(ctx, "Heuristics.Broken.Executable"); + ret = cli_append_virus(ctx, "Heuristics.Broken.Executable"); free(section_hdr); free(exe_sections); - return CL_VIRUS; + return ret; } if(exe_sections[i].rva < min) @@ -1377,8 +3408,8 @@ cli_dbgmsg("EntryPoint out of file\n"); free(exe_sections); if(DETECT_BROKEN_PE) { - cli_append_virus(ctx,"Heuristics.Broken.Executable"); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.Broken.Executable"); + return ret; } return CL_CLEAN; @@ -1461,6 +3492,33 @@ return ret == CL_VIRUS ? CL_VIRUS : CL_CLEAN; } cli_bytecode_context_destroy(bc_ctx); + + /* Attempt to run scans on import table */ + /* Run if there are existing signatures and/or preclassing */ +#if HAVE_JSON + if (DCONF & PE_CONF_IMPTBL && (ctx->engine->hm_imp || ctx->wrkproperty)) { +#else + if (DCONF & PE_CONF_IMPTBL && ctx->engine->hm_imp) { +#endif + ret = scan_pe_imp(ctx, dirs, exe_sections, nsections, hdr_size, pe_plus); + switch (ret) { + case CL_SUCCESS: + break; + case CL_ENULLARG: + cli_warnmsg("cli_scanpe: NULL argument supplied\n"); + break; + case CL_VIRUS: + if (SCAN_ALL) + break; + /* intentional fall-through */ + case CL_BREAK: + free(exe_sections); + return ret == CL_VIRUS ? CL_VIRUS : CL_CLEAN; + default: + free(exe_sections); + return ret; + } + } /* Attempt to detect some popular polymorphic viruses */ /* W32.Parite.B */ @@ -1469,13 +3527,20 @@ if(pt) { pt += 15; if((((uint32_t)cli_readint32(pt) ^ (uint32_t)cli_readint32(pt + 4)) == 0x505a4f) && (((uint32_t)cli_readint32(pt + 8) ^ (uint32_t)cli_readint32(pt + 12)) == 0xffffb) && (((uint32_t)cli_readint32(pt + 16) ^ (uint32_t)cli_readint32(pt + 20)) == 0xb8)) { - cli_append_virus(ctx,"Heuristics.W32.Parite.B"); - if (!SCAN_ALL) { - free(exe_sections); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.W32.Parite.B"); + if (ret != CL_CLEAN) { + if (ret == CL_VIRUS) { + if (!SCAN_ALL) { + free(exe_sections); + return ret; + } + else + viruses_found++; + } else { + free(exe_sections); + return ret; + } } - - viruses_found++; } } } @@ -1587,15 +3652,21 @@ break; case KZSLOOP: if (op==kzdsize+0x48 && *kzcode==0x75 && kzlen-(int8_t)kzcode[1]-3<=kzinitlen && kzlen-(int8_t)kzcode[1]>=kzxorlen) { - cli_append_virus(ctx,"Heuristics.W32.Kriz"); - if (!SCAN_ALL) { - free(exe_sections); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.W32.Kriz"); + if (ret != CL_CLEAN) { + if (ret == CL_VIRUS) { + if (!SCAN_ALL) { + free(exe_sections); + return ret; + } + else + viruses_found++; + } else { + free(exe_sections); + return ret; + } } - - viruses_found++; } - cli_dbgmsg("kriz: loop out of bounds, corrupted sample?\n"); kzstate++; } @@ -1619,13 +3690,20 @@ if((tbuff = fmap_need_off_once(map, exe_sections[nsections - 1].raw + rsize - bw, 4096))) { if(cli_memstr(tbuff, 4091, "\xe8\x2c\x61\x00\x00", 5)) { - cli_append_virus(ctx, dam ? "Heuristics.W32.Magistr.A.dam" : "Heuristics.W32.Magistr.A"); - if (!SCAN_ALL) { - free(exe_sections); - return CL_VIRUS; + ret = cli_append_virus(ctx, dam ? "Heuristics.W32.Magistr.A.dam" : "Heuristics.W32.Magistr.A"); + if (ret != CL_CLEAN) { + if (ret == CL_VIRUS) { + if (!SCAN_ALL) { + free(exe_sections); + return ret; + } + else + viruses_found++; + } else { + free(exe_sections); + return ret; + } } - - viruses_found++; } } } else if(rsize >= 0x7000 && vsize >= 0x7000 && ((vsize & 0xff) == 0xed)) { @@ -1634,13 +3712,20 @@ if((tbuff = fmap_need_off_once(map, exe_sections[nsections - 1].raw + rsize - bw, 4096))) { if(cli_memstr(tbuff, 4091, "\xe8\x04\x72\x00\x00", 5)) { - cli_append_virus(ctx,dam ? "Heuristics.W32.Magistr.B.dam" : "Heuristics.W32.Magistr.B"); - if (!SCAN_ALL) { - free(exe_sections); - return CL_VIRUS; + ret = cli_append_virus(ctx,dam ? "Heuristics.W32.Magistr.B.dam" : "Heuristics.W32.Magistr.B"); + if (ret != CL_CLEAN) { + if (ret == CL_VIRUS) { + if (!SCAN_ALL) { + free(exe_sections); + return ret; + } + else + viruses_found++; + } else { + free(exe_sections); + return ret; + } } - - viruses_found++; } } } @@ -1704,14 +3789,22 @@ continue; if((jump=cli_readint32(code))==0x60ec8b55 || (code[4]==0x0ec && ((jump==0x83ec8b55 && code[6]==0x60) || (jump==0x81ec8b55 && !code[7] && !code[8])))) { - cli_append_virus(ctx,"Heuristics.W32.Polipos.A"); - if (!SCAN_ALL) { - free(jumps); - free(exe_sections); - return CL_VIRUS; + ret = cli_append_virus(ctx,"Heuristics.W32.Polipos.A"); + if (ret != CL_CLEAN) { + if (ret == CL_VIRUS) { + if (!SCAN_ALL) { + free(jumps); + free(exe_sections); + return ret; + } + else + viruses_found++; + } else { + free(jumps); + free(exe_sections); + return ret; + } } - - viruses_found++; } } @@ -1727,21 +3820,28 @@ ret = CL_CLEAN; if (!stats) { - ret = CL_EMEM; + free(exe_sections); + return CL_EMEM; } else { cli_parseres_special(EC32(dirs[2].VirtualAddress), EC32(dirs[2].VirtualAddress), map, exe_sections, nsections, fsize, hdr_size, 0, 0, &m, stats); - if ((ret = cli_detect_swizz(stats)) == CL_VIRUS) - cli_append_virus(ctx,"Heuristics.Trojan.Swizzor.Gen"); - - free(stats); - } - if (ret != CL_CLEAN) { - if (!(ret == CL_VIRUS && SCAN_ALL)) { - free(exe_sections); - return ret; + if ((ret = cli_detect_swizz(stats)) == CL_VIRUS) { + ret = cli_append_virus(ctx,"Heuristics.Trojan.Swizzor.Gen"); + if (ret != CL_CLEAN) { + if (ret == CL_VIRUS) { + if (!SCAN_ALL) { + free(stats); + free(exe_sections); + return ret; + } + else + viruses_found++; + } else { + free(stats); + free(exe_sections); + return ret; + } + } } - - viruses_found++; } } } @@ -2934,7 +5034,7 @@ if(fmap_readn(map, &file_hdr, peinfo->offset + e_lfanew, sizeof(struct pe_image_file_hdr)) != sizeof(struct pe_image_file_hdr)) { /* bad information in e_lfanew - probably not a PE file */ - cli_dbgmsg("Can't read file header\n"); + cli_dbgmsg("cli_peheader: Can't read file header\n"); return -1; } @@ -3526,3 +5626,206 @@ return CL_VIRUS; } } + +int cli_genhash_pe(cli_ctx *ctx, unsigned int class, int type) +{ + uint16_t e_magic; /* DOS signature ("MZ") */ + uint16_t nsections; + uint32_t e_lfanew; /* address of new exe header */ + union { + struct pe_image_optional_hdr64 opt64; + struct pe_image_optional_hdr32 opt32; + } pe_opt; + const struct pe_image_section_hdr *section_hdr; + ssize_t at; + unsigned int i, j, pe_plus = 0; + size_t fsize; + uint32_t valign, falign, hdr_size; + struct pe_image_file_hdr file_hdr; + struct cli_exe_section *exe_sections; + struct pe_image_data_dir *dirs; + fmap_t *map = *ctx->fmap; + + unsigned char *hash, *hashset[CLI_HASH_AVAIL_TYPES]; + int genhash[CLI_HASH_AVAIL_TYPES]; + int hlen = 0; + + if (class >= CL_GENHASH_PE_CLASS_LAST) + return CL_EARG; + + if(fmap_readn(map, &e_magic, 0, sizeof(e_magic)) != sizeof(e_magic)) + return CL_EFORMAT; + + if(EC16(e_magic) != PE_IMAGE_DOS_SIGNATURE && EC16(e_magic) != PE_IMAGE_DOS_SIGNATURE_OLD) + return CL_EFORMAT; + + if(fmap_readn(map, &e_lfanew, 58 + sizeof(e_magic), sizeof(e_lfanew)) != sizeof(e_lfanew)) + return CL_EFORMAT; + + e_lfanew = EC32(e_lfanew); + if(!e_lfanew) + return CL_EFORMAT; + + if(fmap_readn(map, &file_hdr, e_lfanew, sizeof(struct pe_image_file_hdr)) != sizeof(struct pe_image_file_hdr)) + return CL_EFORMAT; + + if(EC32(file_hdr.Magic) != PE_IMAGE_NT_SIGNATURE) + return CL_EFORMAT; + + nsections = EC16(file_hdr.NumberOfSections); + if(nsections < 1 || nsections > 96) + return CL_EFORMAT; + + if(EC16(file_hdr.SizeOfOptionalHeader) < sizeof(struct pe_image_optional_hdr32)) + return CL_EFORMAT; + + at = e_lfanew + sizeof(struct pe_image_file_hdr); + if(fmap_readn(map, &optional_hdr32, at, sizeof(struct pe_image_optional_hdr32)) != sizeof(struct pe_image_optional_hdr32)) + return CL_EFORMAT; + + at += sizeof(struct pe_image_optional_hdr32); + + /* This will be a chicken and egg problem until we drop 9x */ + if(EC16(optional_hdr64.Magic)==PE32P_SIGNATURE) { + if(EC16(file_hdr.SizeOfOptionalHeader)!=sizeof(struct pe_image_optional_hdr64)) + return CL_EFORMAT; + + pe_plus = 1; + } + + if(!pe_plus) { /* PE */ + if (EC16(file_hdr.SizeOfOptionalHeader)!=sizeof(struct pe_image_optional_hdr32)) { + /* Seek to the end of the long header */ + at += EC16(file_hdr.SizeOfOptionalHeader)-sizeof(struct pe_image_optional_hdr32); + } + + hdr_size = EC32(optional_hdr32.SizeOfHeaders); + dirs = optional_hdr32.DataDirectory; + } else { /* PE+ */ + size_t readlen = sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32); + /* read the remaining part of the header */ + if((size_t)fmap_readn(map, &optional_hdr32 + 1, at, readlen) != readlen) + return CL_EFORMAT; + + at += sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32); + hdr_size = EC32(optional_hdr64.SizeOfHeaders); + dirs = optional_hdr64.DataDirectory; + } + + fsize = map->len; + + valign = (pe_plus)?EC32(optional_hdr64.SectionAlignment):EC32(optional_hdr32.SectionAlignment); + falign = (pe_plus)?EC32(optional_hdr64.FileAlignment):EC32(optional_hdr32.FileAlignment); + + section_hdr = fmap_need_off_once(map, at, sizeof(*section_hdr) * nsections); + if(!section_hdr) + return CL_EFORMAT; + + at += sizeof(*section_hdr) * nsections; + + exe_sections = (struct cli_exe_section *) cli_calloc(nsections, sizeof(struct cli_exe_section)); + if(!exe_sections) + return CL_EMEM; + + for(i = 0; falign!=0x200 && iexe_sections[i].raw && !CLI_ISCONTAINED(0, (uint32_t) fsize, exe_sections[i].raw, exe_sections[i].rsz)) + exe_sections[i].rsz = fsize - exe_sections[i].raw; + + if (exe_sections[i].rsz && exe_sections[i].raw >= fsize) { + free(exe_sections); + return CL_EFORMAT; + } + + if (exe_sections[i].urva>>31 || exe_sections[i].uvsz>>31 || (exe_sections[i].rsz && exe_sections[i].uraw>>31) || exe_sections[i].ursz>>31) { + free(exe_sections); + return CL_EFORMAT; + } + } + + cli_qsort(exe_sections, nsections, sizeof(*exe_sections), sort_sects); + + /* pick hashtypes to generate */ + memset(genhash, 0, sizeof(genhash)); + memset(hashset, 0, sizeof(hashset)); + switch(type) { + case 1: + genhash[CLI_HASH_MD5] = 1; + hlen = hashlen[CLI_HASH_MD5]; + hash = hashset[CLI_HASH_MD5] = cli_calloc(hlen, sizeof(char)); + break; + case 2: + genhash[CLI_HASH_SHA1] = 1; + hlen = hashlen[CLI_HASH_SHA1]; + hash = hashset[CLI_HASH_SHA1] = cli_calloc(hlen, sizeof(char)); + break; + default: + genhash[CLI_HASH_SHA256] = 1; + hlen = hashlen[CLI_HASH_SHA256]; + hash = hashset[CLI_HASH_SHA256] = cli_calloc(hlen, sizeof(char)); + break; + } + + if(!hash) { + cli_errmsg("cli_genhash_pe: cli_malloc failed!\n"); + free(exe_sections); + return CL_EMEM; + } + + if (class == CL_GENHASH_PE_CLASS_SECTION) { + char *dstr = NULL; + + for (i = 0; i < nsections; i++) { + /* Generate hashes */ + if (cli_hashsect(*ctx->fmap, &exe_sections[i], hashset, genhash, genhash) == 1) { + dstr = cli_str2hex(hash, hlen); + cli_dbgmsg("Section{%u}: %u:%s\n", i, exe_sections[i].rsz, dstr ? (char *)dstr : "(NULL)"); + if (dstr != NULL) { + free(dstr); + dstr = NULL; + } + } else { + cli_dbgmsg("Section{%u}: failed to generate hash for section\n", i); + } + } + } else if (class == CL_GENHASH_PE_CLASS_IMPTBL) { + char *dstr = NULL; + uint32_t impsz = 0; + int ret; + + /* Generate hash */ + ret = hash_imptbl(ctx, hashset, &impsz, genhash, &dirs[1], exe_sections, nsections, hdr_size, pe_plus); + if (ret == CL_SUCCESS) { + dstr = cli_str2hex(hash, hlen); + cli_dbgmsg("Imphash: %s:%u\n", dstr ? (char *)dstr : "(NULL)", impsz); + if (dstr != NULL) { + free(dstr); + dstr = NULL; + } + } else { + cli_dbgmsg("Imphash: failed to generate hash for import table (%d)\n", ret); + } + } else { + cli_dbgmsg("cli_genhash_pe: unknown pe genhash class: %u\n", class); + } + + if (hash) + free(hash); + free(exe_sections); + return CL_SUCCESS; +} diff -Nru clamav-0.99.2+dfsg/libclamav/pe.h clamav-0.99.3~beta1+dfsg/libclamav/pe.h --- clamav-0.99.2+dfsg/libclamav/pe.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/pe.h 2016-10-13 15:45:44.000000000 +0000 @@ -165,8 +165,16 @@ #define CL_CHECKFP_PE_FLAG_STATS 0x00000001 #define CL_CHECKFP_PE_FLAG_AUTHENTICODE 0x00000002 +enum { + CL_GENHASH_PE_CLASS_SECTION, + CL_GENHASH_PE_CLASS_IMPTBL, + /* place new class types above this line */ + CL_GENHASH_PE_CLASS_LAST +}; + int cli_peheader(fmap_t *map, struct cli_exe_info *peinfo); int cli_checkfp_pe(cli_ctx *ctx, uint8_t *authsha1, stats_section_t *hashes, uint32_t flags); +int cli_genhash_pe(cli_ctx *ctx, unsigned int class, int type); uint32_t cli_rawaddr(uint32_t, const struct cli_exe_section *, uint16_t, unsigned int *, size_t, uint32_t); void findres(uint32_t, uint32_t, uint32_t, fmap_t *map, struct cli_exe_section *, uint16_t, uint32_t, int (*)(void *, uint32_t, uint32_t, uint32_t, uint32_t), void *); diff -Nru clamav-0.99.2+dfsg/libclamav/phishcheck.c clamav-0.99.3~beta1+dfsg/libclamav/phishcheck.c --- clamav-0.99.2+dfsg/libclamav/phishcheck.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/phishcheck.c 2017-04-20 22:19:13.000000000 +0000 @@ -814,32 +814,31 @@ case CL_PHISH_CLEAN: continue; case CL_PHISH_NUMERIC_IP: - cli_append_virus(ctx, "Heuristics.Phishing.Email.Cloaked.NumericIP"); + cli_append_possibly_unwanted(ctx, "Heuristics.Phishing.Email.Cloaked.NumericIP"); break; case CL_PHISH_CLOAKED_NULL: - cli_append_virus(ctx, "Heuristics.Phishing.Email.Cloaked.Null");/*fakesite%01%00@fake.example.com*/ + cli_append_possibly_unwanted(ctx, "Heuristics.Phishing.Email.Cloaked.Null");/*fakesite%01%00@fake.example.com*/ break; case CL_PHISH_SSL_SPOOF: - cli_append_virus(ctx, "Heuristics.Phishing.Email.SSL-Spoof"); + cli_append_possibly_unwanted(ctx, "Heuristics.Phishing.Email.SSL-Spoof"); break; case CL_PHISH_CLOAKED_UIU: - cli_append_virus(ctx, "Heuristics.Phishing.Email.Cloaked.Username");/*http://banksite@fake.example.com*/ + cli_append_possibly_unwanted(ctx, "Heuristics.Phishing.Email.Cloaked.Username");/*http://banksite@fake.example.com*/ break; case CL_PHISH_HASH0: - cli_append_virus(ctx, "Heuristics.Safebrowsing.Suspected-malware_safebrowsing.clamav.net"); + cli_append_possibly_unwanted(ctx, "Heuristics.Safebrowsing.Suspected-malware_safebrowsing.clamav.net"); break; case CL_PHISH_HASH1: - cli_append_virus(ctx, "Heuristics.Phishing.URL.Blacklisted"); + cli_append_possibly_unwanted(ctx, "Heuristics.Phishing.URL.Blacklisted"); break; case CL_PHISH_HASH2: - cli_append_virus(ctx, "Heuristics.Safebrowsing.Suspected-phishing_safebrowsing.clamav.net"); + cli_append_possibly_unwanted(ctx, "Heuristics.Safebrowsing.Suspected-phishing_safebrowsing.clamav.net"); break; case CL_PHISH_NOMATCH: default: - cli_append_virus(ctx, "Heuristics.Phishing.Email.SpoofedDomain"); + cli_append_possibly_unwanted(ctx, "Heuristics.Phishing.Email.SpoofedDomain"); break; } - return cli_found_possibly_unwanted(ctx); } return CL_CLEAN; } @@ -1265,7 +1264,9 @@ ++host_begin; /* ignore username in URL */ - p = strchr(host_begin, '@'); + while((host_begin < urlend) && *host_begin == '/') ++host_begin; + host_len = strcspn(host_begin, ":/?"); + p = memchr(host_begin, '@', host_len); if (p) host_begin = p+1; url = host_begin; @@ -1399,7 +1400,7 @@ while(k < COMPONENTS+2) { p = strchr(path_begin + pp[k-1] + 1, '/'); if(p && p > path_begin) { - pp[k++] = p - path_begin; + pp[k++] = p - path_begin + 1; } else break; } diff -Nru clamav-0.99.2+dfsg/libclamav/png.c clamav-0.99.3~beta1+dfsg/libclamav/png.c --- clamav-0.99.2+dfsg/libclamav/png.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/png.c 2017-02-20 18:36:39.000000000 +0000 @@ -710,7 +710,7 @@ } else if (cur_y >= h) { inflateEnd(&zstrm); if(eod - p > 0) { - cli_dbgmsg("PNG: %d bytes remaining in buffer before inflateEnd()", eod-p); + cli_dbgmsg("PNG: %ld bytes remaining in buffer before inflateEnd()", eod-p); return CL_EPARSE; } err = Z_STREAM_END; diff -Nru clamav-0.99.2+dfsg/libclamav/readdb.c clamav-0.99.3~beta1+dfsg/libclamav/readdb.c --- clamav-0.99.2+dfsg/libclamav/readdb.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/readdb.c 2017-02-20 18:36:39.000000000 +0000 @@ -1353,7 +1353,8 @@ static int lsigattribs(char *attribs, struct cli_lsig_tdb *tdb) { struct lsig_attrib attrtab[] = { -#define ATTRIB_TOKENS 9 +#define ATTRIB_TOKENS 10 +#define EXPR_TOKEN_MAX 16 { "Target", CLI_TDB_UINT, (void **) &tdb->target }, { "Engine", CLI_TDB_RANGE, (void **) &tdb->engine }, @@ -1366,6 +1367,7 @@ { "Container", CLI_TDB_FTYPE, (void **) &tdb->container }, { "HandlerType", CLI_TDB_FTYPE, (void **) &tdb->handlertype }, + { "Intermediates", CLI_TDB_FTYPE_EXPR, (void **) &tdb->intermediates }, /* { "SectOff", CLI_TDB_RANGE2, (void **) &tdb->sectoff }, { "SectRVA", CLI_TDB_RANGE2, (void **) &tdb->sectrva }, @@ -1435,7 +1437,7 @@ case CLI_TDB_FTYPE: if((v1 = cli_ftcode(pt)) == CL_TYPE_ERROR) { - cli_dbgmsg("lsigattribs: Unknown file type in %s\n", tokens[i]); + cli_dbgmsg("lsigattribs: Unknown file type '%s' in %s\n", pt, tokens[i]); return 1; /* skip */ } @@ -1449,6 +1451,35 @@ tdb->val[cnt] = v1; break; + case CLI_TDB_FTYPE_EXPR: + { + char *ftypes[EXPR_TOKEN_MAX]; + unsigned int ftypes_count; + + off[i] = cnt = tdb->cnt[CLI_TDB_UINT]; + ftypes_count = cli_strtokenize(pt, '>', EXPR_TOKEN_MAX, (const char **) ftypes); + if(!ftypes_count) { + cli_dbgmsg("lsigattribs: No intermediate container tokens found."); + return 1; + } + tdb->cnt[CLI_TDB_UINT] += (ftypes_count + 1); + tdb->val = (uint32_t *) mpool_realloc2(tdb->mempool, tdb->val, tdb->cnt[CLI_TDB_UINT] * sizeof(uint32_t)); + if(!tdb->val) { + tdb->cnt[CLI_TDB_UINT] = 0; + return -1; + } + + tdb->val[cnt++] = ftypes_count; + for(j = 0; j < ftypes_count; j++) { + if((v1 = cli_ftcode(ftypes[j])) == CL_TYPE_ERROR) { + cli_dbgmsg("lsigattribs: Unknown file type '%s' in %s\n", ftypes[j], tokens[i]); + return 1; /* skip */ + } + tdb->val[cnt++] = v1; + } + } + break; + case CLI_TDB_RANGE: if(!(pt2 = strchr(pt, '-'))) { cli_errmsg("lsigattribs: Incorrect parameters in '%s'\n", tokens[i]); @@ -1535,6 +1566,7 @@ switch(apt->type) { case CLI_TDB_UINT: case CLI_TDB_FTYPE: + case CLI_TDB_FTYPE_EXPR: *apt->pt = (uint32_t *) &tdb->val[off[i]]; break; @@ -1744,9 +1776,13 @@ lsigid[0] = lsig->id = root->ac_lsigs; + if (bc_idx) + root->linked_bcs++; root->ac_lsigs++; newtable = (struct cli_ac_lsig **) mpool_realloc(engine->mempool, root->ac_lsigtable, root->ac_lsigs * sizeof(struct cli_ac_lsig *)); if(!newtable) { + if (bc_idx) + root->linked_bcs--; root->ac_lsigs--; cli_errmsg("cli_loadldb: Can't realloc root->ac_lsigtable\n"); FREE_TDB(tdb); @@ -2376,6 +2412,7 @@ #define MD5_HDB 0 #define MD5_MDB 1 #define MD5_FP 2 +#define MD5_IMP 3 #define MD5_TOKENS 5 static int cli_loadhash(FILE *fs, struct cl_engine *engine, unsigned int *signo, unsigned int mode, unsigned int options, struct cli_dbio *dbio, const char *dbname) @@ -2396,6 +2433,8 @@ db = engine->hm_mdb; } else if(mode == MD5_HDB) db = engine->hm_hdb; + else if(mode == MD5_IMP) + db = engine->hm_imp; else db = engine->hm_fp; @@ -2409,6 +2448,8 @@ engine->hm_hdb = db; else if(mode == MD5_MDB) engine->hm_mdb = db; + else if(mode == MD5_IMP) + engine->hm_imp = db; else engine->hm_fp = db; } @@ -2755,10 +2796,11 @@ if(!strcmp(tokens[1], "*")) { new->ctype = CL_TYPE_ANY; } else if((new->ctype = cli_ftcode(tokens[1])) == CL_TYPE_ERROR) { - cli_dbgmsg("cli_loadcdb: Unknown container type %s in signature for %s, skipping\n", tokens[1], tokens[0]); + cli_errmsg("cli_loadcdb: Unknown container type %s in signature for %s, skipping\n", tokens[1], tokens[0]); + ret = CL_EMALFDB; mpool_free(engine->mempool, new->virname); mpool_free(engine->mempool, new); - continue; + break; } if(strcmp(tokens[3], "*") && cli_regcomp(&new->name, tokens[3], REG_EXTENDED | REG_NOSUB)) { @@ -4275,6 +4317,8 @@ ret = cli_loadhash(fs, engine, signo, MD5_FP, options, dbio, dbname); } else if(cli_strbcasestr(dbname, ".mdb") || cli_strbcasestr(dbname, ".msb")) { ret = cli_loadhash(fs, engine, signo, MD5_MDB, options, dbio, dbname); + } else if(cli_strbcasestr(dbname, ".imp")) { + ret = cli_loadhash(fs, engine, signo, MD5_IMP, options, dbio, dbname); } else if(cli_strbcasestr(dbname, ".mdu") || cli_strbcasestr(dbname, ".msu")) { if(options & CL_DB_PUA) diff -Nru clamav-0.99.2+dfsg/libclamav/regex_list.c clamav-0.99.3~beta1+dfsg/libclamav/regex_list.c --- clamav-0.99.2+dfsg/libclamav/regex_list.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/regex_list.c 2016-11-03 16:01:29.000000000 +0000 @@ -68,7 +68,7 @@ #define MATCH_FAILED -1 /* - * Call this function when an unrecoverable error has occured, (instead of exit). + * Call this function when an unrecoverable error has occurred, (instead of exit). */ static void fatal_error(struct regex_matcher* matcher) { @@ -252,7 +252,7 @@ /* Initialization & loading */ -/* Initializes @matcher, allocating necesarry substructures */ +/* Initializes @matcher, allocating necessary substructures */ int init_regex_list(struct regex_matcher* matcher, uint8_t dconf_prefiltering) { #ifdef USE_MPOOL diff -Nru clamav-0.99.2+dfsg/libclamav/regex_pcre.c clamav-0.99.3~beta1+dfsg/libclamav/regex_pcre.c --- clamav-0.99.2+dfsg/libclamav/regex_pcre.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/regex_pcre.c 2017-02-20 18:36:39.000000000 +0000 @@ -264,7 +264,7 @@ results->match[0] = results->match[1] = 0; } #else - rc = pcre_exec(pd->re, pd->ex, buffer, buflen, startoffset, options, results->ovector, OVECCOUNT); + rc = pcre_exec(pd->re, pd->ex, (const char *)buffer, buflen, startoffset, options, results->ovector, OVECCOUNT); if (rc < 0 && rc != PCRE_ERROR_NOMATCH) { switch (rc) { case PCRE_ERROR_CALLOUT: @@ -332,7 +332,7 @@ for (i = 0; i < namecount; i++) { int n = (tabptr[0] << 8) | tabptr[1]; - start = buffer + ovector[2*n]; + start = (const char *)buffer + ovector[2*n]; length = ovector[2*n+1] - ovector[2*n]; trunc = 0; @@ -380,7 +380,7 @@ if (rc > 0) { /* print out full-match and capture groups */ for (i = 0; i < rc; ++i) { - start = buffer + ovector[2*i]; + start = (const char *)buffer + ovector[2*i]; length = ovector[2*i+1] - ovector[2*i]; if (ovector[2*i+1] > buflen) { diff -Nru clamav-0.99.2+dfsg/libclamav/scanners.c clamav-0.99.3~beta1+dfsg/libclamav/scanners.c --- clamav-0.99.2+dfsg/libclamav/scanners.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/scanners.c 2017-06-23 21:16:39.000000000 +0000 @@ -60,7 +60,7 @@ #include "vba_extract.h" #include "msexpand.h" #include "mbox.h" -#include "chmunpack.h" +#include "libmspack.h" #include "pe.h" #include "elf.h" #include "filetypes.h" @@ -73,8 +73,6 @@ #include "sis.h" #include "pdf.h" #include "str.h" -#include "mspack.h" -#include "cab.h" #include "rtf.h" #include "unarj.h" #include "nsis/nulsft.h" @@ -205,6 +203,7 @@ static int cli_unrar_scanmetadata(int desc, unrar_metadata_t *metadata, cli_ctx *ctx, unsigned int files, uint32_t* sfx_check) { int ret = CL_SUCCESS; + int virus_found = 0; if(files == 1 && sfx_check) { if(*sfx_check == metadata->crc) @@ -218,18 +217,23 @@ (unsigned int) metadata->unpack_size, metadata->method, metadata->pack_size ? (unsigned int) (metadata->unpack_size / metadata->pack_size) : 0); - if(cli_matchmeta(ctx, metadata->filename, metadata->pack_size, metadata->unpack_size, metadata->encrypted, files, metadata->crc, NULL) == CL_VIRUS) - return CL_VIRUS; + if(cli_matchmeta(ctx, metadata->filename, metadata->pack_size, metadata->unpack_size, metadata->encrypted, files, metadata->crc, NULL) == CL_VIRUS) { + if (!SCAN_ALL) + return CL_VIRUS; + virus_found = 1; + } if(DETECT_ENCRYPTED && metadata->encrypted) { cli_dbgmsg("RAR: Encrypted files found in archive.\n"); ret = cli_scandesc(desc, ctx, 0, 0, NULL, AC_SCAN_VIR, NULL); if(ret != CL_VIRUS) { - cli_append_virus(ctx, "Heuristics.Encrypted.RAR"); - return CL_VIRUS; - } + if (CL_VIRUS == cli_append_virus(ctx, "Heuristics.Encrypted.RAR")) + return CL_VIRUS; + } } + if (virus_found != 0) + return CL_VIRUS; return ret; } @@ -265,13 +269,13 @@ cli_dbgmsg("RAR: Encrypted main header\n"); if(DETECT_ENCRYPTED) { if (lseek(desc, 0, SEEK_SET) == -1) { - cli_dbgmsg("RAR: call to lseek() failed\n"); - return CL_ESEEK; - } + cli_dbgmsg("RAR: call to lseek() failed\n"); + return CL_ESEEK; + } ret = cli_scandesc(desc, ctx, 0, 0, NULL, AC_SCAN_VIR, NULL); if(ret != CL_VIRUS) - cli_append_virus(ctx, "Heuristics.Encrypted.RAR"); - return CL_VIRUS; + if (CL_VIRUS == cli_append_virus(ctx, "Heuristics.Encrypted.RAR")) + return CL_VIRUS; } return CL_CLEAN; } if(ret == UNRAR_EMEM) { @@ -375,6 +379,7 @@ int ret = CL_CLEAN, rc, file = 0; arj_metadata_t metadata; char *dir; + int virus_found = 0; UNUSEDPARAM(sfx_check); @@ -410,10 +415,14 @@ } file++; if(cli_matchmeta(ctx, metadata.filename, metadata.comp_size, metadata.orig_size, metadata.encrypted, file, 0, NULL) == CL_VIRUS) { - cli_rmdirs(dir); - free(dir); - return CL_VIRUS; - } + if (!SCAN_ALL) { + cli_rmdirs(dir); + free(dir); + return CL_VIRUS; + } + virus_found = 1; + ret = CL_SUCCESS; + } if ((ret = cli_checklimits("ARJ", ctx, metadata.orig_size, metadata.comp_size, 0))!=CL_CLEAN) { ret = CL_SUCCESS; @@ -433,12 +442,16 @@ close(metadata.ofd); if (rc == CL_VIRUS) { cli_dbgmsg("ARJ: infected with %s\n", cli_get_last_virus(ctx)); - ret = CL_VIRUS; - if (metadata.filename) { - free(metadata.filename); - metadata.filename = NULL; - } - break; + if (!SCAN_ALL) { + ret = CL_VIRUS; + if (metadata.filename) { + free(metadata.filename); + metadata.filename = NULL; + } + break; + } + virus_found = 1; + ret = CL_SUCCESS; } } if (metadata.filename) { @@ -456,6 +469,8 @@ free(metadata.filename); } + if (virus_found != 0) + ret = CL_VIRUS; cli_dbgmsg("ARJ: Exit code: %d\n", ret); if (ret == CL_BREAK) ret = CL_CLEAN; @@ -783,6 +798,10 @@ /* xz decompress a chunk */ rc = cli_XzDecode(&strm); if (XZ_RESULT_OK != rc && XZ_STREAM_END != rc) { + if (rc == XZ_DIC_HEURISTIC) { + ret = cli_append_virus(ctx, "Heuristic.XZ.DicSizeLimit"); + goto xz_exit; + } cli_errmsg("cli_scanxz: decompress error: %d\n", rc); ret = CL_EFORMAT; goto xz_exit; @@ -862,82 +881,6 @@ return ret; } -static int cli_scanmscab(cli_ctx *ctx, off_t sfx_offset) -{ - char *tempname; - int ret; - unsigned int files = 0; - struct cab_archive cab; - struct cab_file *file; - unsigned int corrupted_input; - unsigned int viruses_found = 0; - - cli_dbgmsg("in cli_scanmscab()\n"); - - if((ret = cab_open(*ctx->fmap, sfx_offset, &cab))) - return ret; - - for(file = cab.files; file; file = file->next) { - files++; - - if(cli_matchmeta(ctx, file->name, 0, file->length, 0, files, 0, NULL) == CL_VIRUS) { - if (!SCAN_ALL) { - ret = CL_VIRUS; - break; - } - viruses_found++; - } - - if(ctx->engine->maxscansize && ctx->scansize >= ctx->engine->maxscansize) { - ret = CL_CLEAN; - break; - } - - if(!(tempname = cli_gentemp(ctx->engine->tmpdir))) { - ret = CL_EMEM; - break; - } - - if(ctx->engine->maxscansize && ctx->scansize + ctx->engine->maxfilesize >= ctx->engine->maxscansize) - file->max_size = ctx->engine->maxscansize - ctx->scansize; - else - file->max_size = ctx->engine->maxfilesize ? ctx->engine->maxfilesize : 0xffffffff; - - cli_dbgmsg("CAB: Extracting file %s to %s, size %u, max_size: %u\n", file->name, tempname, file->length, (unsigned int) file->max_size); - file->written_size = 0; - if((ret = cab_extract(file, tempname))) { - cli_dbgmsg("CAB: Failed to extract file: %s\n", cl_strerror(ret)); - } else { - corrupted_input = ctx->corrupted_input; - if(file->length != file->written_size) { - cli_dbgmsg("CAB: Length from header %u but wrote %u bytes\n", (unsigned int) file->length, (unsigned int) file->written_size); - ctx->corrupted_input = 1; - } - ret = cli_scanfile(tempname, ctx); - ctx->corrupted_input = corrupted_input; - } - if(!ctx->engine->keeptmp) { - if (!access(tempname, R_OK) && cli_unlink(tempname)) { - free(tempname); - ret = CL_EUNLINK; - break; - } - } - free(tempname); - if(ret == CL_VIRUS) { - if (SCAN_ALL) - viruses_found++; - else - break; - } - } - - cab_free(&cab); - if (viruses_found) - return CL_VIRUS; - return ret; -} - static int vba_scandata(const unsigned char *data, unsigned int len, cli_ctx *ctx) { struct cli_matcher *groot = ctx->engine->root[0]; @@ -962,12 +905,18 @@ viruses_found++; if (ret == CL_CLEAN || (ret == CL_VIRUS && SCAN_ALL)) { + fmap_t *map = *ctx->fmap; + *ctx->fmap = cl_fmap_open_memory(data, len); + if (*ctx->fmap == NULL) + return CL_EMEM; ret = cli_exp_eval(ctx, troot, &tmdata, NULL, NULL); if (ret == CL_VIRUS) viruses_found++; if (ret == CL_CLEAN || (ret == CL_VIRUS && SCAN_ALL)) ret = cli_exp_eval(ctx, groot, &gmdata, NULL, NULL); + funmap(*ctx->fmap); + *ctx->fmap = map; } cli_ac_freedata(&tmdata); cli_ac_freedata(&gmdata); @@ -1016,6 +965,25 @@ /* cli_dbgmsg("Project content:\n%s", data); */ if(ctx->scanned) *ctx->scanned += data_len / CL_COUNT_PRECISION; + if (ctx->engine->keeptmp) { + char *tempfile; + int of; + + if ((ret = cli_gentempfd(ctx->engine->tmpdir, &tempfile, &of)) != CL_SUCCESS) { + cli_warnmsg("VBADir: WARNING: VBA project '%s_%u' cannot be dumped to file\n", vba_project->name[i], j); + return ret; + } + if (cli_writen(of, data, data_len) != data_len) { + cli_warnmsg("VBADir: WARNING: VBA project '%s_%u' failed to write to file\n", vba_project->name[i], j); + close(of); + free(tempfile); + return CL_EWRITE; + } + + cli_dbgmsg("VBADir: VBA project '%s_%u' dumped to %s\n", vba_project->name[i], j, tempfile); + free(tempfile); + } + if(vba_scandata(data, data_len, ctx) == CL_VIRUS) { if (SCAN_ALL) viruses_found++; @@ -1215,9 +1183,9 @@ cli_jsonbool(ctx->wrkproperty, "HasMacros", 1); #endif if(BLOCK_MACROS && hasmacros) { - cli_append_virus(ctx, "Heuristics.OLE2.ContainsMacros"); - ret = CL_VIRUS; - viruses_found++; + ret = cli_append_virus(ctx, "Heuristics.OLE2.ContainsMacros"); + if (ret == CL_VIRUS) + viruses_found++; } if (SCAN_ALL && viruses_found) return CL_VIRUS; @@ -1342,44 +1310,40 @@ return CL_CLEAN; } - /* dump to disk only if explicitly asked to - * or if necessary to check relative offsets, - * otherwise we can process just in-memory */ - if(ctx->engine->keeptmp || (troot && troot->ac_reloff_num > 0)) { - if((ret = cli_gentempfd(ctx->engine->tmpdir, &tmpname, &ofd))) { - cli_dbgmsg("cli_scanscript: Can't generate temporary file/descriptor\n"); - return ret; - } - if (ctx->engine->keeptmp) - cli_dbgmsg("cli_scanscript: saving normalized file to %s\n", tmpname); - } - if(!(normalized = cli_malloc(SCANBUFF + maxpatlen))) { cli_dbgmsg("cli_scanscript: Unable to malloc %u bytes\n", SCANBUFF); - free(tmpname); return CL_EMEM; } - text_normalize_init(&state, normalized, SCANBUFF + maxpatlen); - ret = CL_CLEAN; - if ((ret = cli_ac_initdata(&tmdata, troot?troot->ac_partsigs:0, troot?troot->ac_lsigs:0, troot?troot->ac_reloff_num:0, CLI_DEFAULT_AC_TRACKLEN))) { - free(tmpname); - return ret; + free(normalized); + return ret; } if ((ret = cli_ac_initdata(&gmdata, groot->ac_partsigs, groot->ac_lsigs, groot->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN))) { - cli_ac_freedata(&tmdata); - free(tmpname); - return ret; + cli_ac_freedata(&tmdata); + free(normalized); + return ret; + } + + /* dump to disk only if explicitly asked to + * or if necessary to check relative offsets, + * otherwise we can process just in-memory */ + if(ctx->engine->keeptmp || (troot && (troot->ac_reloff_num > 0 || troot->linked_bcs))) { + if((ret = cli_gentempfd(ctx->engine->tmpdir, &tmpname, &ofd))) { + cli_dbgmsg("cli_scanscript: Can't generate temporary file/descriptor\n"); + goto done; + } + if (ctx->engine->keeptmp) + cli_dbgmsg("cli_scanscript: saving normalized file to %s\n", tmpname); } mdata[0] = &tmdata; mdata[1] = &gmdata; - /* If there's a relative offset in troot, normalize the file.*/ - if (troot && troot->ac_reloff_num > 0) { + /* If there's a relative offset in troot or triggered bytecodes, normalize to file.*/ + if (troot && (troot->ac_reloff_num > 0 || troot->linked_bcs)) { size_t map_off = 0; while(map_off < map->len) { size_t written; @@ -1387,10 +1351,9 @@ map_off += written; if (write(ofd, state.out, state.out_pos) == -1) { - cli_errmsg("cli_scanscript: can't write to file %s\n",tmpname); - close(ofd); - free(tmpname); - return CL_EWRITE; + cli_errmsg("cli_scanscript: can't write to file %s\n",tmpname); + ret = CL_EWRITE; + goto done; } text_normalize_reset(&state); } @@ -1398,7 +1361,7 @@ /* Temporarily store the normalized file map in the context. */ *ctx->fmap = fmap(ofd, 0, 0); if (!(*ctx->fmap)) { - cli_errmsg("cli_scanscript: could not map file %s\n",tmpname); + cli_dbgmsg("cli_scanscript: could not map file %s\n",tmpname); } else { /* scan map */ @@ -1409,11 +1372,6 @@ funmap(*ctx->fmap); } *ctx->fmap = map; - - /* If we aren't keeping temps, delete the normalized file after scan. */ - if(!(ctx->engine->keeptmp)) - if (cli_unlink(tmpname)) ret = CL_EUNLINK; - } else { /* Since the above is moderately costly all in all, * do the old stuff if there's no relative offsets. */ @@ -1421,11 +1379,8 @@ if (troot) { cli_targetinfo(&info, 7, map); ret = cli_ac_caloff(troot, &tmdata, &info); - if (ret) { - cli_ac_freedata(&tmdata); - free(tmpname); - return ret; - } + if (ret) + goto done; } while(1) { @@ -1466,13 +1421,6 @@ } - if(ctx->engine->keeptmp) { - free(tmpname); - if (ofd >= 0) - close(ofd); - } - free(normalized); - if(ret != CL_VIRUS || SCAN_ALL) { if ((ret = cli_exp_eval(ctx, troot, &tmdata, NULL, NULL)) == CL_VIRUS) viruses_found++; @@ -1481,11 +1429,21 @@ viruses_found++; } + done: + free(normalized); cli_ac_freedata(&tmdata); cli_ac_freedata(&gmdata); - if (SCAN_ALL && viruses_found) - return CL_VIRUS; + if (ofd != -1) + close(ofd); + if (tmpname != NULL) { + if (!ctx->engine->keeptmp) + cli_unlink(tmpname); + free(tmpname); + } + + if (viruses_found) + return CL_VIRUS; return ret; } @@ -1627,72 +1585,6 @@ return ret; } -static int cli_scanmschm(cli_ctx *ctx) -{ - int ret = CL_CLEAN, rc; - chm_metadata_t metadata; - char *dir; - unsigned int viruses_found = 0; - - cli_dbgmsg("in cli_scanmschm()\n"); - - /* generate the temporary directory */ - if(!(dir = cli_gentemp(ctx->engine->tmpdir))) - return CL_EMEM; - - if(mkdir(dir, 0700)) { - cli_dbgmsg("CHM: Can't create temporary directory %s\n", dir); - free(dir); - return CL_ETMPDIR; - } - - ret = cli_chm_open(dir, &metadata, ctx); - if (ret != CL_SUCCESS) { - if(!ctx->engine->keeptmp) - cli_rmdirs(dir); - free(dir); - cli_dbgmsg("CHM: Error: %s\n", cl_strerror(ret)); - return ret; - } - - do { - ret = cli_chm_prepare_file(&metadata); - if (ret != CL_SUCCESS) { - break; - } - ret = cli_chm_extract_file(dir, &metadata, ctx); - if (ret == CL_SUCCESS) { - rc = cli_magic_scandesc(metadata.ofd, ctx); - close(metadata.ofd); - if (rc == CL_VIRUS) { - cli_dbgmsg("CHM: infected with %s\n", cli_get_last_virus(ctx)); - if (SCAN_ALL) - viruses_found++; - else { - ret = CL_VIRUS; - break; - } - } - } - - } while(ret == CL_SUCCESS); - - cli_chm_close(&metadata); - - if(!ctx->engine->keeptmp) - cli_rmdirs(dir); - - free(dir); - - cli_dbgmsg("CHM: Exit code: %d\n", ret); - if (ret == CL_BREAK) - ret = CL_CLEAN; - - if (SCAN_ALL && viruses_found) - return CL_VIRUS; - return ret; -} - static int cli_scanscrenc(cli_ctx *ctx) { char *tempname; @@ -1721,24 +1613,20 @@ static int cli_scanriff(cli_ctx *ctx) { - int ret = CL_CLEAN; + int ret = CL_CLEAN; - if(cli_check_riff_exploit(ctx) == 2) { - ret = CL_VIRUS; - cli_append_virus(ctx, "Heuristics.Exploit.W32.MS05-002"); - } + if (cli_check_riff_exploit(ctx) == 2) + ret = cli_append_virus(ctx, "Heuristics.Exploit.W32.MS05-002"); return ret; } static int cli_scanjpeg(cli_ctx *ctx) { - int ret = CL_CLEAN; + int ret = CL_CLEAN; - if(cli_check_jpeg_exploit(ctx, 0) == 1) { - ret = CL_VIRUS; - cli_append_virus(ctx, "Heuristics.Exploit.W32.MS04-028"); - } + if(cli_check_jpeg_exploit(ctx, 0) == 1) + ret = cli_append_virus(ctx, "Heuristics.Exploit.W32.MS04-028"); return ret; } @@ -1918,7 +1806,7 @@ cli_rmdirs(dir); free(dir); - if (SCAN_ALL && viruses_found) + if (viruses_found) return CL_VIRUS; return ret; } @@ -1984,23 +1872,23 @@ if(cc_count != 0 && cc_count >= ctx->engine->min_cc_count) { cli_dbgmsg("cli_scan_structured: %u credit card numbers detected\n", cc_count); - cli_append_virus(ctx,"Heuristics.Structured.CreditCardNumber"); - if (SCAN_ALL) - viruses_found++; - else - return CL_VIRUS; + if (CL_VIRUS == cli_append_virus(ctx,"Heuristics.Structured.CreditCardNumber")) + if (SCAN_ALL) + viruses_found++; + else + return CL_VIRUS; } if(ssn_count != 0 && ssn_count >= ctx->engine->min_ssn_count) { cli_dbgmsg("cli_scan_structured: %u social security numbers detected\n", ssn_count); - cli_append_virus(ctx,"Heuristics.Structured.SSN"); - if (SCAN_ALL) - viruses_found++; - else - return CL_VIRUS; + if (CL_VIRUS == cli_append_virus(ctx,"Heuristics.Structured.SSN")) + if (SCAN_ALL) + viruses_found++; + else + return CL_VIRUS; } - if (SCAN_ALL && viruses_found) + if (viruses_found) return CL_VIRUS; return CL_CLEAN; } @@ -2246,12 +2134,12 @@ struct cli_exe_info peinfo; unsigned int acmode = AC_SCAN_VIR, break_loop = 0; fmap_t *map = *ctx->fmap; - cli_file_t current_container_type = ctx->container_type; - size_t current_container_size = ctx->container_size; - if(ctx->engine->maxreclevel && ctx->recursion >= ctx->engine->maxreclevel) + if(ctx->engine->maxreclevel && ctx->recursion >= ctx->engine->maxreclevel) { + cli_check_blockmax(ctx, CL_EMAXREC); return CL_EMAXREC; + } perf_start(ctx, PERFT_RAW); if(typercg) @@ -2267,37 +2155,46 @@ fpt = ftoffset; while(fpt) { + /* set current level as container AFTER recursing */ + cli_set_container(ctx, fpt->type, map->len); if(fpt->offset) switch(fpt->type) { + case CL_TYPE_MHTML: + if(SCAN_MAIL && (DCONF_MAIL & MAIL_CONF_MBOX)) { + cli_dbgmsg("MHTML signature found at %u\n", (unsigned int) fpt->offset); + nret = ret = cli_scanmail(ctx); + } + break; + case CL_TYPE_XDP: if(SCAN_PDF && (DCONF_DOC & DOC_CONF_PDF)) { cli_dbgmsg("XDP signature found at %u\n", (unsigned int) fpt->offset); - ret = cli_scanxdp(ctx); + nret = ret = cli_scanxdp(ctx); } break; case CL_TYPE_XML_WORD: if(SCAN_XMLDOCS && (DCONF_DOC & DOC_CONF_MSXML)) { cli_dbgmsg("XML-WORD signature found at %u\n", (unsigned int) fpt->offset); - ret = cli_scanmsxml(ctx); + nret = ret = cli_scanmsxml(ctx); } break; case CL_TYPE_XML_XL: if(SCAN_XMLDOCS && (DCONF_DOC & DOC_CONF_MSXML)) { cli_dbgmsg("XML-XL signature found at %u\n", (unsigned int) fpt->offset); - ret = cli_scanmsxml(ctx); + nret = ret = cli_scanmsxml(ctx); } break; case CL_TYPE_XML_HWP: if(SCAN_XMLDOCS && (DCONF_DOC & DOC_CONF_HWP)) { cli_dbgmsg("XML-HWP signature found at %u\n", (unsigned int) fpt->offset); - ret = cli_scanhwpml(ctx); + nret = ret = cli_scanhwpml(ctx); } break; case CL_TYPE_RARSFX: if(type != CL_TYPE_RAR && have_rar && SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_RAR)) { char *tmpname = NULL; int tmpfd = fmap_fd(map); - ctx->container_type = CL_TYPE_RAR; - ctx->container_size = map->len - fpt->offset; /* not precise */ + size_t csize = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_RAR, csize); cli_dbgmsg("RAR/RAR-SFX signature found at %u\n", (unsigned int) fpt->offset); /* if map is not file-backed, have to dump to file for scanrar */ if(tmpfd == -1) { @@ -2327,8 +2224,8 @@ case CL_TYPE_ZIPSFX: if(type != CL_TYPE_ZIP && SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_ZIP)) { - ctx->container_type = CL_TYPE_ZIP; - ctx->container_size = map->len - fpt->offset; /* not precise */ + size_t csize = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_ZIP, csize); cli_dbgmsg("ZIP/ZIP-SFX signature found at %u\n", (unsigned int) fpt->offset); nret = cli_unzip_single(ctx, fpt->offset); } @@ -2336,8 +2233,8 @@ case CL_TYPE_CABSFX: if(type != CL_TYPE_MSCAB && SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_CAB)) { - ctx->container_type = CL_TYPE_MSCAB; - ctx->container_size = map->len - fpt->offset; /* not precise */ + size_t csize = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_MSCAB, csize); cli_dbgmsg("CAB/CAB-SFX signature found at %u\n", (unsigned int) fpt->offset); nret = cli_scanmscab(ctx, fpt->offset); } @@ -2345,8 +2242,8 @@ case CL_TYPE_ARJSFX: if(type != CL_TYPE_ARJ && SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_ARJ)) { - ctx->container_type = CL_TYPE_ARJ; - ctx->container_size = map->len - fpt->offset; /* not precise */ + size_t csize = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_ARJ, csize); cli_dbgmsg("ARJ-SFX signature found at %u\n", (unsigned int) fpt->offset); nret = cli_scanarj(ctx, fpt->offset, &lastrar); } @@ -2354,8 +2251,8 @@ case CL_TYPE_7ZSFX: if(type != CL_TYPE_7Z && SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_7Z)) { - ctx->container_type = CL_TYPE_7Z; - ctx->container_size = map->len - fpt->offset; /* not precise */ + size_t csize = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_7Z, csize); cli_dbgmsg("7Zip-SFX signature found at %u\n", (unsigned int) fpt->offset); nret = cli_7unz(ctx, fpt->offset); } @@ -2363,8 +2260,8 @@ case CL_TYPE_ISO9660: if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_ISO9660)) { - ctx->container_type = CL_TYPE_ISO9660; - ctx->container_size = map->len - fpt->offset; /* not precise */ + size_t csize = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_ISO9660, csize); cli_dbgmsg("ISO9660 signature found at %u\n", (unsigned int) fpt->offset); nret = cli_scaniso(ctx, fpt->offset); } @@ -2373,8 +2270,8 @@ case CL_TYPE_NULSFT: if(SCAN_ARCHIVE && type == CL_TYPE_MSEXE && (DCONF_ARCH & ARCH_CONF_NSIS) && fpt->offset > 4) { - ctx->container_type = CL_TYPE_NULSFT; - ctx->container_size = map->len - fpt->offset; /* not precise */ + size_t csize = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_NULSFT, csize); cli_dbgmsg("NSIS signature found at %u\n", (unsigned int) fpt->offset-4); nret = cli_scannulsft(ctx, fpt->offset - 4); } @@ -2382,8 +2279,8 @@ case CL_TYPE_AUTOIT: if(SCAN_ARCHIVE && type == CL_TYPE_MSEXE && (DCONF_ARCH & ARCH_CONF_AUTOIT)) { - ctx->container_type = CL_TYPE_AUTOIT; - ctx->container_size = map->len - fpt->offset; /* not precise */ + size_t csize = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_AUTOIT, csize); cli_dbgmsg("AUTOIT signature found at %u\n", (unsigned int) fpt->offset); nret = cli_scanautoit(ctx, fpt->offset + 23); } @@ -2391,8 +2288,8 @@ case CL_TYPE_ISHIELD_MSI: if(SCAN_ARCHIVE && type == CL_TYPE_MSEXE && (DCONF_ARCH & ARCH_CONF_ISHIELD)) { - ctx->container_type = CL_TYPE_AUTOIT; - ctx->container_size = map->len - fpt->offset; /* not precise */ + size_t csize = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_AUTOIT, csize); cli_dbgmsg("ISHIELD-MSI signature found at %u\n", (unsigned int) fpt->offset); nret = cli_scanishield_msi(ctx, fpt->offset + 14); } @@ -2400,7 +2297,6 @@ case CL_TYPE_DMG: if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_DMG)) { - ctx->container_type = CL_TYPE_DMG; cli_dbgmsg("DMG signature found at %u\n", (unsigned int) fpt->offset); nret = cli_scandmg(ctx); } @@ -2411,12 +2307,11 @@ int iret = cli_mbr_check2(ctx, 0); if ((iret == CL_TYPE_GPT) && (DCONF_ARCH & ARCH_CONF_GPT)) { cli_dbgmsg("Recognized GUID Partition Table file\n"); - ctx->container_type = CL_TYPE_GPT; + cli_set_container(ctx, CL_TYPE_GPT, map->len); cli_dbgmsg("GPT signature found at %u\n", (unsigned int) fpt->offset); nret = cli_scangpt(ctx, 0); } else if ((iret == CL_CLEAN) && (DCONF_ARCH & ARCH_CONF_MBR)) { - ctx->container_type = CL_TYPE_MBR; cli_dbgmsg("MBR signature found at %u\n", (unsigned int) fpt->offset); nret = cli_scanmbr(ctx, 0); } @@ -2425,8 +2320,8 @@ case CL_TYPE_PDF: if(type != CL_TYPE_PDF && SCAN_PDF && (DCONF_DOC & DOC_CONF_PDF)) { - ctx->container_type = CL_TYPE_PDF; - ctx->container_size = map->len - fpt->offset; /* not precise */ + size_t csize = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_PDF, csize); cli_dbgmsg("PDF signature found at %u\n", (unsigned int) fpt->offset); nret = cli_scanpdf(ctx, fpt->offset); } @@ -2436,13 +2331,13 @@ if(SCAN_PE && (type == CL_TYPE_MSEXE || type == CL_TYPE_ZIP || type == CL_TYPE_MSOLE2) && ctx->dconf->pe) { uint64_t curr_len = map->len; + size_t csize = map->len - fpt->offset; /* not precise */ /* CL_ENGINE_MAX_EMBEDDED_PE */ if(curr_len > ctx->engine->maxembeddedpe) { cli_dbgmsg("cli_scanraw: MaxEmbeddedPE exceeded\n"); break; } - ctx->container_type = CL_TYPE_MSEXE; /* PE is a container for another executable here */ - ctx->container_size = map->len - fpt->offset; /* not precise */ + cli_set_container(ctx, CL_TYPE_MSEXE, csize); memset(&peinfo, 0, sizeof(struct cli_exe_info)); peinfo.offset = fpt->offset; if(cli_peheader(map, &peinfo) == 0) { @@ -2471,13 +2366,11 @@ fpt = fpt->next; } - ctx->container_type = current_container_type; - ctx->container_size = current_container_size; if(nret != CL_VIRUS) switch(ret) { case CL_TYPE_HTML: /* bb#11196 - autoit script file misclassified as HTML */ - if (ctx->container_type == CL_TYPE_AUTOIT) { + if (cli_get_container_intermediate(ctx, -2) == CL_TYPE_AUTOIT) { ret = CL_TYPE_TEXT_ASCII; } else if (SCAN_HTML && (type == CL_TYPE_TEXT_ASCII || type == CL_TYPE_GRAPHICS) && (DCONF_DOC & DOC_CONF_HTML)) { @@ -2487,14 +2380,11 @@ break; case CL_TYPE_MAIL: - ctx->container_type = CL_TYPE_MAIL; - ctx->container_size = map->len; + cli_set_container(ctx, CL_TYPE_MAIL, map->len); if(SCAN_MAIL && type == CL_TYPE_TEXT_ASCII && (DCONF_MAIL & MAIL_CONF_MBOX)) { *dettype = CL_TYPE_MAIL; nret = cli_scanmail(ctx); } - ctx->container_type = current_container_type; - ctx->container_size = current_container_size; break; default: @@ -2551,10 +2441,16 @@ UNUSEDPARAM(type); - if (retcode == CL_CLEAN && (ctx->found_possibly_unwanted || ctx->num_viruses != 0)) + if (retcode == CL_CLEAN && ctx->found_possibly_unwanted) { + cli_virus_found_cb(ctx); cb_retcode = CL_VIRUS; - else - cb_retcode = retcode; + } + else { + if (retcode == CL_CLEAN && ctx->num_viruses != 0) + cb_retcode = CL_VIRUS; + else + cb_retcode = retcode; + } cli_dbgmsg("cli_magic_scandesc: returning %d %s\n", retcode, __AT__); if(ctx->engine->cb_post_scan) { @@ -2587,6 +2483,8 @@ cache_add(hash, hashed_size, ctx); perf_stop(ctx, PERFT_CACHE); } + if (retcode == CL_VIRUS && SCAN_ALL) + return CL_CLEAN; return retcode; } @@ -2635,17 +2533,16 @@ int ret = CL_CLEAN; cli_file_t dettype = 0; uint8_t typercg = 1; - cli_file_t current_container_type = ctx->container_type; - size_t current_container_size = ctx->container_size, hashed_size; + size_t hashed_size; unsigned char hash[16] = {'\0'}; bitset_t *old_hook_lsig_matches; const char *filetype; int cache_clean = 0, res; - int run_cleanup = 0; + int run_cleanup = 0; #if HAVE_JSON struct json_object *parent_property = NULL; #else - void *parent_property = NULL; + void *parent_property = NULL; #endif if(!ctx->engine) { @@ -2661,6 +2558,7 @@ if(ctx->engine->maxreclevel && ctx->recursion > ctx->engine->maxreclevel) { cli_dbgmsg("cli_magic_scandesc: Archive recursion limit exceeded (%u, max: %u)\n", ctx->recursion, ctx->engine->maxreclevel); emax_reached(ctx); + cli_check_blockmax(ctx, CL_EMAXREC); early_ret_from_magicscan(CL_CLEAN); } @@ -2701,7 +2599,8 @@ type == CL_TYPE_HWP3 || type == CL_TYPE_XML_HWP || type == CL_TYPE_HWPOLE2 || - type == CL_TYPE_OOXML_HWP) { + type == CL_TYPE_OOXML_HWP || + type == CL_TYPE_MHTML) { ctx->properties = json_object_new_object(); if (NULL == ctx->properties) { cli_errmsg("magic_scandesc: no memory for json properties object\n"); @@ -2763,6 +2662,8 @@ perf_start(ctx, PERFT_CACHE); if (!(SCAN_PROPERTIES)) res = cache_check(hash, ctx); + else + res = CL_VIRUS; #if HAVE_JSON if (SCAN_PROPERTIES /* ctx.options & CL_SCAN_FILE_PROPERTIES && ctx->wrkproperty != NULL */) { @@ -2781,7 +2682,6 @@ if (ret != CL_SUCCESS) { early_ret_from_magicscan(ret); } - res = CL_VIRUS; } #endif @@ -2795,11 +2695,14 @@ perf_stop(ctx, PERFT_CACHE); hashed_size = (*ctx->fmap)->len; + memcpy((*ctx->fmap)->maphash, hash, 16); ctx->hook_lsig_matches = NULL; if(!(ctx->options&~CL_SCAN_ALLMATCHES) || (ctx->recursion == ctx->engine->maxreclevel)) { /* raw mode (stdin, etc.) or last level of recursion */ - if(ctx->recursion == ctx->engine->maxreclevel) + if(ctx->recursion == ctx->engine->maxreclevel) { + cli_check_blockmax(ctx, CL_EMAXREC); cli_dbgmsg("cli_magic_scandesc: Hit recursion limit, only scanning raw file\n"); + } else cli_dbgmsg("Raw mode: No support for special files\n"); @@ -2854,7 +2757,8 @@ ctx->recursion++; perf_nested_start(ctx, PERFT_CONTAINER, PERFT_SCAN); - ctx->container_size = (*ctx->fmap)->len; + /* set current level as container AFTER recursing */ + cli_set_container(ctx, type, (*ctx->fmap)->len); switch(type) { case CL_TYPE_IGNORED: break; @@ -2890,7 +2794,6 @@ break; case CL_TYPE_RAR: - ctx->container_type = CL_TYPE_RAR; if(have_rar && SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_RAR)) { char *tmpname = NULL; int desc = fmap_fd(*ctx->fmap); @@ -2936,7 +2839,6 @@ } #endif case CL_TYPE_ZIP: - ctx->container_type = CL_TYPE_ZIP; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_ZIP)) ret = cli_unzip(ctx); break; @@ -2967,19 +2869,16 @@ break; case CL_TYPE_ARJ: - ctx->container_type = CL_TYPE_ARJ; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_ARJ)) ret = cli_scanarj(ctx, 0, NULL); break; case CL_TYPE_NULSFT: - ctx->container_type = CL_TYPE_NULSFT; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_NSIS)) ret = cli_scannulsft(ctx, 0); break; case CL_TYPE_AUTOIT: - ctx->container_type = CL_TYPE_AUTOIT; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_AUTOIT)) ret = cli_scanautoit(ctx, 23); break; @@ -2990,7 +2889,6 @@ break; case CL_TYPE_MSCAB: - ctx->container_type = CL_TYPE_MSCAB; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_CAB)) ret = cli_scanmscab(ctx, 0); break; @@ -3016,13 +2914,16 @@ break; case CL_TYPE_RTF: - ctx->container_type = CL_TYPE_RTF; if(SCAN_ARCHIVE && (DCONF_DOC & DOC_CONF_RTF)) ret = cli_scanrtf(ctx); break; case CL_TYPE_MAIL: - ctx->container_type = CL_TYPE_MAIL; + if(SCAN_MAIL && (DCONF_MAIL & MAIL_CONF_MBOX)) + ret = cli_scanmail(ctx); + break; + + case CL_TYPE_MHTML: if(SCAN_MAIL && (DCONF_MAIL & MAIL_CONF_MBOX)) ret = cli_scanmail(ctx); break; @@ -3038,55 +2939,46 @@ break; case CL_TYPE_MSCHM: - ctx->container_type = CL_TYPE_MSCHM; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_CHM)) ret = cli_scanmschm(ctx); break; case CL_TYPE_MSOLE2: - ctx->container_type = CL_TYPE_MSOLE2; if(SCAN_OLE2 && (DCONF_ARCH & ARCH_CONF_OLE2)) ret = cli_scanole2(ctx); break; case CL_TYPE_7Z: - ctx->container_type = CL_TYPE_7Z; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_7Z)) ret = cli_7unz(ctx, 0); break; case CL_TYPE_POSIX_TAR: - ctx->container_type = CL_TYPE_POSIX_TAR; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_TAR)) ret = cli_scantar(ctx, 1); break; case CL_TYPE_OLD_TAR: - ctx->container_type = CL_TYPE_OLD_TAR; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_TAR)) ret = cli_scantar(ctx, 0); break; case CL_TYPE_CPIO_OLD: - ctx->container_type = CL_TYPE_CPIO_OLD; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_CPIO)) ret = cli_scancpio_old(ctx); break; case CL_TYPE_CPIO_ODC: - ctx->container_type = CL_TYPE_CPIO_ODC; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_CPIO)) ret = cli_scancpio_odc(ctx); break; case CL_TYPE_CPIO_NEWC: - ctx->container_type = CL_TYPE_CPIO_NEWC; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_CPIO)) ret = cli_scancpio_newc(ctx, 0); break; case CL_TYPE_CPIO_CRC: - ctx->container_type = CL_TYPE_CPIO_CRC; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_CPIO)) ret = cli_scancpio_newc(ctx, 1); break; @@ -3125,7 +3017,6 @@ break; case CL_TYPE_PDF: /* FIXMELIMITS: pdf should be an archive! */ - ctx->container_type = CL_TYPE_PDF; if(SCAN_PDF && (DCONF_DOC & DOC_CONF_PDF)) ret = cli_scanpdf(ctx, 0); break; @@ -3151,19 +3042,16 @@ break; case CL_TYPE_SIS: - ctx->container_type = CL_TYPE_SIS; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_SIS)) ret = cli_scansis(ctx); break; case CL_TYPE_XAR: - ctx->container_type = CL_TYPE_XAR; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_XAR)) ret = cli_scanxar(ctx); break; case CL_TYPE_PART_HFSPLUS: - ctx->container_type = CL_TYPE_PART_HFSPLUS; if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_HFSPLUS)) ret = cli_scanhfsplus(ctx); break; @@ -3188,11 +3076,8 @@ } perf_nested_stop(ctx, PERFT_CONTAINER, PERFT_SCAN); ctx->recursion--; - ctx->container_type = current_container_type; - ctx->container_size = current_container_size; - if(ret == CL_VIRUS) { - ret = cli_checkfp(hash, hashed_size, ctx); + if(ret == CL_VIRUS && !SCAN_ALL) { cli_bitset_free(ctx->hook_lsig_matches); ctx->hook_lsig_matches = old_hook_lsig_matches; return magic_scandesc_cleanup(ctx, type, hash, hashed_size, cache_clean, ret, parent_property); @@ -3228,7 +3113,7 @@ return magic_scandesc_cleanup(ctx, type, hash, hashed_size, cache_clean, res, parent_property); /* CL_VIRUS = malware found, check FP and report */ case CL_VIRUS: - ret = cli_checkfp(hash, hashed_size, ctx); + ret = res; if (SCAN_ALL) break; cli_bitset_free(ctx->hook_lsig_matches); @@ -3263,9 +3148,9 @@ case CL_TYPE_TEXT_UTF16LE: case CL_TYPE_TEXT_UTF8: perf_nested_start(ctx, PERFT_SCRIPT, PERFT_SCAN); - if((DCONF_DOC & DOC_CONF_SCRIPT) && dettype != CL_TYPE_HTML && ret != CL_VIRUS) + if((DCONF_DOC & DOC_CONF_SCRIPT) && dettype != CL_TYPE_HTML && (ret != CL_VIRUS || SCAN_ALL) && SCAN_HTML) ret = cli_scanscript(ctx); - if(SCAN_MAIL && (DCONF_MAIL & MAIL_CONF_MBOX) && ret != CL_VIRUS && (ctx->container_type == CL_TYPE_MAIL || dettype == CL_TYPE_MAIL)) { + if(SCAN_MAIL && (DCONF_MAIL & MAIL_CONF_MBOX) && ret != CL_VIRUS && (cli_get_container(ctx, -1) == CL_TYPE_MAIL || dettype == CL_TYPE_MAIL)) { ret = cli_fmap_scandesc(ctx, CL_TYPE_MAIL, 0, NULL, AC_SCAN_VIR, NULL, NULL); } perf_nested_stop(ctx, PERFT_SCRIPT, PERFT_SCAN); @@ -3289,8 +3174,6 @@ break; } - if(ret == CL_VIRUS) - ret = cli_checkfp(hash, hashed_size, ctx); ctx->recursion--; cli_bitset_free(ctx->hook_lsig_matches); ctx->hook_lsig_matches = old_hook_lsig_matches; @@ -3541,8 +3424,10 @@ ctx.scanned = scanned; ctx.options = scanoptions; ctx.found_possibly_unwanted = 0; - ctx.container_type = CL_TYPE_ANY; - ctx.container_size = 0; + ctx.containers = cli_calloc(sizeof(cli_ctx_container), ctx.engine->maxreclevel + 2); + if(!ctx.containers) + return CL_EMEM; + cli_set_container(&ctx, CL_TYPE_ANY, 0); ctx.dconf = (struct cli_dconf *) engine->dconf; ctx.cb_ctx = context; ctx.fmap = cli_calloc(sizeof(fmap_t *), ctx.engine->maxreclevel + 2); @@ -3614,6 +3499,7 @@ } else { int ret = CL_SUCCESS; + struct cli_matcher *iroot = ctx.engine->root[13]; cli_dbgmsg("%s\n", jstring); if (rc != CL_VIRUS) { @@ -3646,7 +3532,7 @@ } /* backwards compatibility: scan the json string unless a virus was detected */ - if (rc != CL_VIRUS && ctx.engine->root[13]->ac_lsigs) { + if (rc != CL_VIRUS && (iroot->ac_lsigs || iroot->ac_patterns || iroot->pcre_metas)) { cli_dbgmsg("scan_common: running deprecated preclass bytecodes for target type 13\n"); ctx.options &= ~CL_SCAN_FILE_PROPERTIES; rc = cli_mem_scandesc(jstring, strlen(jstring), &ctx); @@ -3678,7 +3564,7 @@ free(tmpname); } } - json_object_put(ctx.properties); /* frees all json memory */ + cli_json_delobj(ctx.properties); /* frees all json memory */ #if 0 // test code - to be deleted if (cli_checktimelimit(&ctx) != CL_SUCCESS) { @@ -3689,10 +3575,11 @@ } #endif + free(ctx.containers); cli_bitset_free(ctx.hook_lsig_matches); free(ctx.fmap); if (rc == CL_CLEAN) { - if ((ctx.num_viruses != 0 && ctx.options & CL_SCAN_ALLMATCHES) || + if ((ctx.num_viruses != 0 && (ctx.options & (CL_SCAN_ALLMATCHES | CL_SCAN_BLOCKMAX))) || ctx.found_possibly_unwanted) rc = CL_VIRUS; } diff -Nru clamav-0.99.2+dfsg/libclamav/special.c clamav-0.99.3~beta1+dfsg/libclamav/special.c --- clamav-0.99.2+dfsg/libclamav/special.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/special.c 2017-04-20 22:19:13.000000000 +0000 @@ -90,8 +90,7 @@ if ((~check) != key) return CL_CLEAN; - cli_append_virus(ctx, "Heuristics.Worm.Mydoom.M.log"); - return CL_VIRUS; + return cli_append_virus(ctx, "Heuristics.Worm.Mydoom.M.log"); } static int jpeg_check_photoshop_8bim(cli_ctx *ctx, off_t *off) @@ -268,7 +267,7 @@ return 0; cur_offset += 4*2; - buffer = buf; + buffer = (char *)buf; memcpy (&cache_buf, buffer + sizeof (cache_buf), sizeof (cache_buf)); chunk_size = riff_endian_convert_32(cache_buf, big_endian); diff -Nru clamav-0.99.2+dfsg/libclamav/spin.c clamav-0.99.3~beta1+dfsg/libclamav/spin.c --- clamav-0.99.2+dfsg/libclamav/spin.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/spin.c 2017-02-20 18:36:39.000000000 +0000 @@ -395,7 +395,7 @@ cli_dbgmsg("spin: Compression bitmap is %x\n", bitmap); if ( (sects= (char **) cli_malloc(sectcnt*sizeof(char *))) == NULL ) { - cli_dbgmsg("spin: malloc(%d) failed\n", sectcnt*sizeof(char *)); + cli_dbgmsg("spin: malloc(%lu) failed\n", sectcnt*sizeof(char *)); return 1; } diff -Nru clamav-0.99.2+dfsg/libclamav/tiff.c clamav-0.99.3~beta1+dfsg/libclamav/tiff.c --- clamav-0.99.2+dfsg/libclamav/tiff.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/tiff.c 2017-04-20 22:19:13.000000000 +0000 @@ -146,8 +146,7 @@ if(entry.value + value_size > map->len) { cli_warnmsg("cli_parsetiff: TFD entry field %u exceeds bounds of TIFF file [%llu > %llu]\n", i, (long long unsigned)(entry.value + value_size), (long long unsigned)map->len); - cli_append_virus(ctx, "Heuristic.TIFF.OutOfBoundsAccess"); - return CL_VIRUS; + return cli_append_virus(ctx, "Heuristic.TIFF.OutOfBoundsAccess"); } } } diff -Nru clamav-0.99.2+dfsg/libclamav/unzip.c clamav-0.99.3~beta1+dfsg/libclamav/unzip.c --- clamav-0.99.2+dfsg/libclamav/unzip.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/unzip.c 2017-04-20 22:19:13.000000000 +0000 @@ -80,7 +80,7 @@ if((of = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRUSR|S_IWUSR))==-1) { cli_warnmsg("cli_unzip: failed to create temporary file %s\n", tempfile); if(!tmpd) free(tempfile); - return CL_ECREAT; + return CL_ETMPFILE; } switch (method) { case ALG_STORED: @@ -432,7 +432,7 @@ if((of = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRUSR|S_IWUSR))==-1) { cli_warnmsg("cli_unzip: decrypt - failed to create temporary file %s\n", tempfile); if(!tmpd) free(tempfile); - return CL_ECREAT; + return CL_ETMPFILE; } for (i = 12; i < csize; i++) { @@ -504,6 +504,7 @@ const uint8_t *lh, *zip; char name[256]; uint32_t csize, usize; + int virus_found = 0; if(!(lh = fmap_need_off(map, loff, SIZEOF_LH))) { cli_dbgmsg("cli_unzip: lh - out of file\n"); @@ -540,8 +541,10 @@ /* ZMDfmt virname:encrypted(0-1):filename(exact|*):usize(exact|*):csize(exact|*):crc32(exact|*):method(exact|*):fileno(exact|*):maxdepth(exact|*) */ if(cli_matchmeta(ctx, name, LH_csize, LH_usize, (LH_flags & F_ENCR)!=0, fc, LH_crc32, NULL) == CL_VIRUS) { - *ret = CL_VIRUS; - return 0; + *ret = CL_VIRUS; + if (!SCAN_ALL) + return 0; + virus_found = 1; } if(LH_flags & F_MSKED) { @@ -553,10 +556,12 @@ if(detect_encrypted && (LH_flags & F_ENCR) && DETECT_ENCRYPTED) { cli_dbgmsg("cli_unzip: Encrypted files found in archive.\n"); - cli_append_virus(ctx, "Heuristics.Encrypted.Zip"); - *ret = CL_VIRUS; - fmap_unneed_off(map, loff, SIZEOF_LH); - return 0; + *ret = cli_append_virus(ctx, "Heuristics.Encrypted.Zip"); + if ((*ret == CL_VIRUS && !SCAN_ALL) || *ret != CL_CLEAN) { + fmap_unneed_off(map, loff, SIZEOF_LH); + return 0; + } + virus_found = 1; } if(LH_flags & F_USEDD) { @@ -595,6 +600,9 @@ zsize-=csize; } + if (virus_found != 0) + *ret = CL_VIRUS; + fmap_unneed_off(map, loff, SIZEOF_LH); /* unneed now. block is guaranteed to exists till the next need */ if(LH_flags & F_USEDD) { if(zsize<12) { @@ -620,6 +628,7 @@ char name[256]; int last = 0; const uint8_t *ch; + int virus_found = 0; if(!(ch = fmap_need_off(map, coff, SIZEOF_CH)) || CH_magic != 0x02014b50) { if(ch) fmap_unneed_ptr(map, ch, SIZEOF_CH); @@ -636,7 +645,7 @@ } name[0]='\0'; - if((cli_debug_flag && !last) || requests) { + if(!last) { unsigned int size = (CH_flen>=sizeof(name))?sizeof(name)-1:CH_flen; const char *src = fmap_need_off_once(map, coff, size); if(src) { @@ -647,6 +656,10 @@ } coff+=CH_flen; + /* requests do not supply a ctx; also prevent multiple scans */ + if(ctx && cli_matchmeta(ctx, name, CH_csize, CH_usize, (CH_flags & F_ENCR)!=0, fc, CH_crc32, NULL) == CL_VIRUS) + virus_found = 1; + if(zsize-coff<=CH_elen && !last) { cli_dbgmsg("cli_unzip: ch - extra out of file\n"); last=1; @@ -682,6 +695,8 @@ } } + if (virus_found == 1) + *ret = CL_VIRUS; fmap_unneed_ptr(map, ch, SIZEOF_CH); return (last?0:coff); } diff -Nru clamav-0.99.2+dfsg/libclamav/version.h clamav-0.99.3~beta1+dfsg/libclamav/version.h --- clamav-0.99.2+dfsg/libclamav/version.h 2016-04-22 16:24:45.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/version.h 2017-07-31 20:11:49.000000000 +0000 @@ -1 +1 @@ -#define REPO_VERSION "devel-clamav-0.99.2" +#define REPO_VERSION "devel-clamav-0.99-beta1-694-g56cf29f" diff -Nru clamav-0.99.2+dfsg/libclamav/wwunpack.c clamav-0.99.3~beta1+dfsg/libclamav/wwunpack.c --- clamav-0.99.2+dfsg/libclamav/wwunpack.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/wwunpack.c 2017-03-08 14:06:34.000000000 +0000 @@ -226,7 +226,10 @@ return CL_EFORMAT; exe[pe+6]=(uint8_t)scount; exe[pe+7]=(uint8_t)(scount>>8); - cli_writeint32(&exe[pe+0x28], cli_readint32(wwsect+0x295)+sects[scount].rva+0x299); + if (!CLI_ISCONTAINED(wwsect, sects[scount].rsz, wwsect+0x295, 4)) + cli_dbgmsg("WWPack: unpack memory address out of bounds.\n"); + else + cli_writeint32(&exe[pe+0x28], cli_readint32(wwsect+0x295)+sects[scount].rva+0x299); cli_writeint32(&exe[pe+0x50], cli_readint32(&exe[pe+0x50])-sects[scount].vsz); structs = &exe[(0xffff&cli_readint32(&exe[pe+0x14]))+pe+0x18]; diff -Nru clamav-0.99.2+dfsg/libclamav/xar.c clamav-0.99.3~beta1+dfsg/libclamav/xar.c --- clamav-0.99.2+dfsg/libclamav/xar.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/xar.c 2016-10-13 15:45:44.000000000 +0000 @@ -71,17 +71,20 @@ value - pointer to long to contain the returned value returns - CL_SUCCESS or CL_EFORMAT */ -static int xar_get_numeric_from_xml_element(xmlTextReaderPtr reader, long * value) +static int xar_get_numeric_from_xml_element(xmlTextReaderPtr reader, size_t * value) { const xmlChar * numstr; + ssize_t numval; + if (xmlTextReaderRead(reader) == 1 && xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT) { numstr = xmlTextReaderConstValue(reader); if (numstr) { - *value = atol((const char *)numstr); - if (*value < 0) { + numval = atol((const char *)numstr); + if (numval < 0) { cli_dbgmsg("cli_scanxar: XML element value %li\n", *value); return CL_EFORMAT; } + *value = numval; return CL_SUCCESS; } } @@ -123,8 +126,18 @@ if (xmlTextReaderRead(reader) == 1 && xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT) { xmlval = xmlTextReaderConstValue(reader); if (xmlval) { - *cksum = xmlStrdup(xmlval); - cli_dbgmsg("cli_scanxar: checksum value is %s.\n", *cksum); + cli_dbgmsg("cli_scanxar: checksum value is %s.\n", xmlval); + if (*hash == XAR_CKSUM_SHA1 && xmlStrlen(xmlval) == 2 * CLI_HASHLEN_SHA1 || + *hash == XAR_CKSUM_MD5 && xmlStrlen(xmlval) == 2 * CLI_HASHLEN_MD5) + { + *cksum = xmlStrdup(xmlval); + } + else + { + cli_dbgmsg("cli_scanxar: checksum type is unknown or length is invalid.\n"); + *hash = XAR_CKSUM_OTHER; + *cksum = NULL; + } } else { *cksum = NULL; cli_dbgmsg("cli_scanxar: xmlTextReaderConstValue() returns NULL for checksum value.\n"); @@ -149,7 +162,7 @@ e_hash - pointer to int for returning extracted checksum algorithm. returns - CL_FORMAT, CL_SUCCESS, CL_BREAK. CL_BREAK indicates no more / element. */ -static int xar_get_toc_data_values(xmlTextReaderPtr reader, long *length, long *offset, long *size, int *encoding, +static int xar_get_toc_data_values(xmlTextReaderPtr reader, size_t *length, size_t *offset, size_t *size, int *encoding, unsigned char ** a_cksum, int * a_hash, unsigned char ** e_cksum, int * e_hash) { const xmlChar *name; @@ -386,10 +399,10 @@ return 1; switch (hash) { case XAR_CKSUM_SHA1: - len = SHA1_HASH_SIZE; + len = CLI_HASHLEN_SHA1; break; case XAR_CKSUM_MD5: - len = CLI_HASH_MD5; + len = CLI_HASHLEN_MD5; break; case XAR_CKSUM_OTHER: case XAR_CKSUM_NONE: @@ -417,7 +430,7 @@ int fd = -1; struct xar_header hdr; fmap_t *map = *ctx->fmap; - long length, offset, size, at; + size_t length, offset, size, at; int encoding; z_stream strm; char *toc, *tmpname; @@ -490,6 +503,13 @@ goto exit_toc; } + if (hdr.toc_length_decompressed != strm.total_out) { + cli_dbgmsg("TOC decompress length %" PRIu64 " does not match amount decompressed %lu\n", + hdr.toc_length_decompressed, strm.total_out); + toc[strm.total_out] = '\0'; + hdr.toc_length_decompressed = strm.total_out; + } + /* cli_dbgmsg("cli_scanxar: TOC xml:\n%s\n", toc); */ /* printf("cli_scanxar: TOC xml:\n%s\n", toc); */ /* cli_dbgmsg("cli_scanxar: TOC end:\n"); */ @@ -557,8 +577,8 @@ goto exit_reader; } - cli_dbgmsg("cli_scanxar: decompress into temp file:\n%s, size %li,\n" - "from xar heap offset %li length %li\n", + cli_dbgmsg("cli_scanxar: decompress into temp file:\n%s, size %zu,\n" + "from xar heap offset %zu length %zu\n", tmpname, size, offset, length); @@ -638,11 +658,14 @@ #define CLI_LZMA_IBUF_SIZE CLI_LZMA_OBUF_SIZE>>2 /* estimated compression ratio 25% */ { struct CLI_LZMA lz; - unsigned long in_remaining = length; + unsigned long in_remaining = MIN(length, map->len - at); unsigned long out_size = 0; unsigned char * buff = __lzma_wrap_alloc(NULL, CLI_LZMA_OBUF_SIZE); int lret; - + + if (length > in_remaining) + length = in_remaining; + memset(&lz, 0, sizeof(lz)); if (buff == NULL) { cli_dbgmsg("cli_scanxar: memory request for lzma decompression buffer fails.\n"); @@ -655,8 +678,8 @@ if (blockp == NULL) { char errbuff[128]; cli_strerror(errno, errbuff, sizeof(errbuff)); - cli_dbgmsg("cli_scanxar: Can't read %li bytes @ %li, errno:%s.\n", - length, at, errbuff); + cli_dbgmsg("cli_scanxar: Can't read %i bytes @ %li, errno:%s.\n", + CLI_LZMA_HDR_SIZE, at, errbuff); rc = CL_EREAD; __lzma_wrap_free(NULL, buff); goto exit_tmpfile; @@ -693,7 +716,7 @@ char errbuff[128]; cli_strerror(errno, errbuff, sizeof(errbuff)); cli_dbgmsg("cli_scanxar: Can't read %li bytes @ %li, errno: %s.\n", - length, at, errbuff); + lz.avail_in, at, errbuff); rc = CL_EREAD; __lzma_wrap_free(NULL, buff); cli_LzmaShutdown(&lz); @@ -758,33 +781,31 @@ /* for uncompressed, bzip2, xz, and unknown, just pull the file, cli_magic_scandesc does the rest */ do_extract_cksum = 0; { - unsigned long write_len; - + size_t writelen = MIN(map->len - at, length); + if (ctx->engine->maxfilesize) - write_len = MIN((size_t)(ctx->engine->maxfilesize), (size_t)length); - else - write_len = length; + writelen = MIN((size_t)(ctx->engine->maxfilesize), writelen); - if (!(blockp = (void*)fmap_need_off_once(map, at, length))) { + if (!(blockp = (void*)fmap_need_off_once(map, at, writelen))) { char errbuff[128]; cli_strerror(errno, errbuff, sizeof(errbuff)); - cli_dbgmsg("cli_scanxar: Can't read %li bytes @ %li, errno:%s.\n", - length, at, errbuff); + cli_dbgmsg("cli_scanxar: Can't read %zu bytes @ %zu, errno:%s.\n", + writelen, at, errbuff); rc = CL_EREAD; goto exit_tmpfile; } if (a_hash_ctx != NULL) - xar_hash_update(a_hash_ctx, blockp, length, a_hash); + xar_hash_update(a_hash_ctx, blockp, writelen, a_hash); - if (cli_writen(fd, blockp, write_len) < 0) { - cli_dbgmsg("cli_scanxar: cli_writen error %li bytes @ %li.\n", length, at); + if (cli_writen(fd, blockp, writelen) < 0) { + cli_dbgmsg("cli_scanxar: cli_writen error %zu bytes @ %li.\n", writelen, at); rc = CL_EWRITE; goto exit_tmpfile; } /*break;*/ } - } + } /* end of switch */ if (rc == CL_SUCCESS) { if (a_hash_ctx != NULL) { @@ -871,7 +892,7 @@ cli_dbgmsg("cli_scanxar: can't scan xar files, need libxml2.\n"); #endif if (cksum_fails + extract_errors != 0) { - cli_warnmsg("cli_scanxar: %u checksum errors and %u extraction errors, use --debug for more info.\n", + cli_dbgmsg("cli_scanxar: %u checksum errors and %u extraction errors.\n", cksum_fails, extract_errors); } diff -Nru clamav-0.99.2+dfsg/libclamav/xz_iface.c clamav-0.99.3~beta1+dfsg/libclamav/xz_iface.c --- clamav-0.99.2+dfsg/libclamav/xz_iface.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/xz_iface.c 2017-06-23 21:16:39.000000000 +0000 @@ -76,7 +76,11 @@ return XZ_STREAM_END; if (XZ->status == CODER_STATUS_NOT_FINISHED && XZ->avail_out == 0) return XZ_RESULT_OK; - if (((inbytes == 0) && (outbytes == 0)) || res != SZ_OK) + if (((inbytes == 0) && (outbytes == 0)) || res != SZ_OK) { + if (res == SZ_ERROR_MEM) { + return XZ_DIC_HEURISTIC; + } return XZ_RESULT_DATA_ERROR; + } return XZ_RESULT_OK; } diff -Nru clamav-0.99.2+dfsg/libclamav/xz_iface.h clamav-0.99.3~beta1+dfsg/libclamav/xz_iface.h --- clamav-0.99.2+dfsg/libclamav/xz_iface.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/xz_iface.h 2017-06-23 21:16:39.000000000 +0000 @@ -43,6 +43,8 @@ #define XZ_RESULT_DATA_ERROR 1 #define XZ_STREAM_END 2 +#define XZ_DIC_HEURISTIC 3 + #define CLI_XZ_OBUF_SIZE 1024*1024 #define CLI_XZ_IBUF_SIZE CLI_XZ_OBUF_SIZE>>2 /* compression ratio 25% */ diff -Nru clamav-0.99.2+dfsg/libclamav/yara_grammar.c clamav-0.99.3~beta1+dfsg/libclamav/yara_grammar.c --- clamav-0.99.2+dfsg/libclamav/yara_grammar.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/yara_grammar.c 2016-12-05 20:15:48.000000000 +0000 @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.5. */ /* Bison implementation for Yacc-like parsers in C diff -Nru clamav-0.99.2+dfsg/libclamav/yara_grammar.h clamav-0.99.3~beta1+dfsg/libclamav/yara_grammar.h --- clamav-0.99.2+dfsg/libclamav/yara_grammar.h 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/yara_grammar.h 2016-12-05 20:15:48.000000000 +0000 @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.5. */ /* Bison interface for Yacc-like parsers in C diff -Nru clamav-0.99.2+dfsg/libclamav/yara_grammar.y clamav-0.99.3~beta1+dfsg/libclamav/yara_grammar.y --- clamav-0.99.2+dfsg/libclamav/yara_grammar.y 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libclamav/yara_grammar.y 2016-11-03 16:01:29.000000000 +0000 @@ -1166,7 +1166,7 @@ yyscanner, OP_INCR_M, mem_offset + 2, NULL); // If next string is not undefined, go back to the - // begining of the loop. + // beginning of the loop. yr_parser_emit_with_arg_reloc( yyscanner, OP_JNUNDEF, diff -Nru clamav-0.99.2+dfsg/libfreshclam/Makefile.in clamav-0.99.3~beta1+dfsg/libfreshclam/Makefile.in --- clamav-0.99.2+dfsg/libfreshclam/Makefile.in 2016-04-22 16:19:53.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libfreshclam/Makefile.in 2017-06-23 21:20:58.000000000 +0000 @@ -105,10 +105,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -163,12 +164,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -336,6 +342,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -363,7 +371,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -457,6 +474,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/libltdl/Makefile.in clamav-0.99.3~beta1+dfsg/libltdl/Makefile.in --- clamav-0.99.2+dfsg/libltdl/Makefile.in 2016-04-22 16:19:53.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/libltdl/Makefile.in 2017-06-23 21:20:58.000000000 +0000 @@ -94,10 +94,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -152,12 +153,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -388,6 +394,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -415,7 +423,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -509,6 +526,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/m4/lib-prelude.m4 clamav-0.99.3~beta1+dfsg/m4/lib-prelude.m4 --- clamav-0.99.2+dfsg/m4/lib-prelude.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/lib-prelude.m4 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,189 @@ +dnl Autoconf macros for libprelude +dnl $id$ + +# Modified for LIBPRELUDE -- Yoann Vandoorselaere +# Modified for LIBGNUTLS -- nmav +# Configure paths for LIBGCRYPT +# Shamelessly stolen from the one of XDELTA by Owen Taylor +# Werner Koch 99-12-09 + +dnl AM_PATH_LIBPRELUDE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]], THREAD_SUPPORT) +dnl Test for libprelude, and define LIBPRELUDE_PREFIX, LIBPRELUDE_CFLAGS, LIBPRELUDE_PTHREAD_CFLAGS, +dnl LIBPRELUDE_LDFLAGS, and LIBPRELUDE_LIBS +dnl +AC_DEFUN([AM_PATH_LIBPRELUDE], +[dnl +dnl Get the cflags and libraries from the libprelude-config script +dnl +AC_ARG_WITH(libprelude-prefix, AC_HELP_STRING(--with-libprelude-prefix=PFX, + Prefix where libprelude is installed (optional)), + libprelude_config_prefix="$withval", libprelude_config_prefix="") + + if test x$libprelude_config_prefix != x ; then + if test x${LIBPRELUDE_CONFIG+set} != xset ; then + LIBPRELUDE_CONFIG=$libprelude_config_prefix/bin/libprelude-config + fi + fi + + AC_PATH_PROG(LIBPRELUDE_CONFIG, libprelude-config, no) + if test "$LIBPRELUDE_CONFIG" != "no"; then + if $($LIBPRELUDE_CONFIG --thread > /dev/null 2>&1); then + LIBPRELUDE_PTHREAD_CFLAGS=`$LIBPRELUDE_CONFIG --thread --cflags` + + if test x$4 = xtrue || test x$4 = xyes; then + libprelude_config_args="--thread" + else + libprelude_config_args="--no-thread" + fi + else + LIBPRELUDE_PTHREAD_CFLAGS=`$LIBPRELUDE_CONFIG --pthread-cflags` + fi + fi + + min_libprelude_version=ifelse([$1], ,0.1.0,$1) + AC_MSG_CHECKING(for libprelude - version >= $min_libprelude_version) + no_libprelude="" + if test "$LIBPRELUDE_CONFIG" = "no" ; then + no_libprelude=yes + else + LIBPRELUDE_CFLAGS=`$LIBPRELUDE_CONFIG $libprelude_config_args --cflags` + LIBPRELUDE_LDFLAGS=`$LIBPRELUDE_CONFIG $libprelude_config_args --ldflags` + LIBPRELUDE_LIBS=`$LIBPRELUDE_CONFIG $libprelude_config_args --libs` + LIBPRELUDE_PREFIX=`$LIBPRELUDE_CONFIG $libprelude_config_args --prefix` + LIBPRELUDE_CONFIG_PREFIX=`$LIBPRELUDE_CONFIG $libprelude_config_args --config-prefix` + libprelude_config_version=`$LIBPRELUDE_CONFIG $libprelude_config_args --version` + + + ac_save_CFLAGS="$CFLAGS" + ac_save_LDFLAGS="$LDFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $LIBPRELUDE_CFLAGS" + LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS" + LIBS="$LIBS $LIBPRELUDE_LIBS" +dnl +dnl Now check if the installed libprelude is sufficiently new. Also sanity +dnl checks the results of libprelude-config to some extent +dnl + rm -f conf.libpreludetest + AC_TRY_RUN([ +#include +#include +#include +#include + +int +main () +{ + system ("touch conf.libpreludetest"); + + if( strcmp( prelude_check_version(NULL), "$libprelude_config_version" ) ) + { + printf("\n*** 'libprelude-config --version' returned %s, but LIBPRELUDE (%s)\n", + "$libprelude_config_version", prelude_check_version(NULL) ); + printf("*** was found! If libprelude-config was correct, then it is best\n"); + printf("*** to remove the old version of LIBPRELUDE. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If libprelude-config was wrong, set the environment variable LIBPRELUDE_CONFIG\n"); + printf("*** to point to the correct copy of libprelude-config, and remove the file config.cache\n"); + printf("*** before re-running configure\n"); + } + else if ( strcmp(prelude_check_version(NULL), LIBPRELUDE_VERSION ) ) { + printf("\n*** LIBPRELUDE header file (version %s) does not match\n", LIBPRELUDE_VERSION); + printf("*** library (version %s)\n", prelude_check_version(NULL) ); + } + else { + if ( prelude_check_version( "$min_libprelude_version" ) ) + return 0; + else { + printf("no\n*** An old version of LIBPRELUDE (%s) was found.\n", + prelude_check_version(NULL) ); + printf("*** You need a version of LIBPRELUDE newer than %s. The latest version of\n", + "$min_libprelude_version" ); + printf("*** LIBPRELUDE is always available from http://www.prelude-ids.com/development/download/\n"); + printf("*** \n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the libprelude-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of LIBPRELUDE, but you can also set the LIBPRELUDE_CONFIG environment to point to the\n"); + printf("*** correct copy of libprelude-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_libprelude=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + LDFLAGS="$ac_save_LDFLAGS" + fi + + if test "x$no_libprelude" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + if test -f conf.libpreludetest ; then + : + else + AC_MSG_RESULT(no) + fi + if test "$LIBPRELUDE_CONFIG" = "no" ; then + echo "*** The libprelude-config script installed by LIBPRELUDE could not be found" + echo "*** If LIBPRELUDE was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the LIBPRELUDE_CONFIG environment variable to the" + echo "*** full path to libprelude-config." + else + if test -f conf.libpreludetest ; then + : + else + echo "*** Could not run libprelude test program, checking why..." + CFLAGS="$CFLAGS $LIBPRELUDE_CFLAGS" + LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS" + LIBS="$LIBS $LIBPRELUDE_LIBS" + AC_TRY_LINK([ +#include +#include +#include +#include +], [ return !!prelude_check_version(NULL); ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding LIBPRELUDE or finding the wrong" + echo "*** version of LIBPRELUDE. If it is not finding LIBPRELUDE, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" + echo "***" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means LIBPRELUDE was incorrectly installed" + echo "*** or that you have moved LIBPRELUDE since it was installed. In the latter case, you" + echo "*** may want to edit the libprelude-config script: $LIBPRELUDE_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LDFLAGS="$ac_save_LDFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + LIBPRELUDE_CFLAGS="" + LIBPRELUDE_LDFLAGS="" + LIBPRELUDE_LIBS="" + ifelse([$3], , :, [$3]) + fi + rm -f conf.libpreludetest + AC_SUBST(LIBPRELUDE_CFLAGS) + AC_SUBST(LIBPRELUDE_PTHREAD_CFLAGS) + AC_SUBST(LIBPRELUDE_LDFLAGS) + AC_SUBST(LIBPRELUDE_LIBS) + AC_SUBST(LIBPRELUDE_PREFIX) + AC_SUBST(LIBPRELUDE_CONFIG_PREFIX) + + m4_ifdef([LT_INIT], + [AC_DEFINE([PRELUDE_APPLICATION_USE_LIBTOOL2], [], [Define whether application use libtool >= 2.0])], + []) + +]) + +dnl *-*wedit:notab*-* Please keep this as the last line. diff -Nru clamav-0.99.2+dfsg/m4/reorganization/code_checks/fts.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/code_checks/fts.m4 --- clamav-0.99.2+dfsg/m4/reorganization/code_checks/fts.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/code_checks/fts.m4 2017-07-13 16:18:13.000000000 +0000 @@ -0,0 +1,23 @@ +AC_MSG_CHECKING([LFS safe fts implementation]) +AC_COMPILE_IFELSE( [ +#include + +int main(void) { + fts_open((void *)0, FTS_PHYSICAL, (void *)0); + + return 0; +} +], +[have_LFS_fts=yes], +[have_LFS_fts=no], +[have_LFS_fts=no] +) +AC_MSG_RESULT([$have_LFS_fts]) +AM_CONDITIONAL([SYSTEM_LFS_FTS], [test "x$have_LFS_fts" = "xyes"]) +if test "x$have_LFS_fts" = "xyes"; then + AC_DEFINE([HAVE_SYSTEM_LFS_FTS], [1], [Use libc's fts() implementation]) + lfs_fts_msg="libc" +else + AC_DEFINE([HAVE_SYSTEM_LFS_FTS], [0], [Use private fts() implementation which is LFS safe]) + lfs_fts_msg="internal, libc's is not LFS compatible" +fi diff -Nru clamav-0.99.2+dfsg/m4/reorganization/code_checks/iconv.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/code_checks/iconv.m4 --- clamav-0.99.2+dfsg/m4/reorganization/code_checks/iconv.m4 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/code_checks/iconv.m4 2017-03-08 14:06:34.000000000 +0000 @@ -9,24 +9,44 @@ esac], [ wiconv=auto ]) if test "X$wiconv" != "Xno"; then - AC_CHECK_LIB([iconv], [libiconv_open], LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -liconv") - AC_MSG_CHECKING([for iconv]) - save_LIBS="$LIBS" - LIBS="$LIBCLAMAV_LIBS" - AC_TRY_LINK([ + save_LDFLAGS="$LDFLAGS" + LDFLAGS="-L/usr/local/lib -liconv" + ICONV_HOME="" + AC_CHECK_LIB([iconv], [libiconv_open], [ICONV_HOME="/usr/local"], + [ + LDFLAGS="-L/usr/lib -liconv" + AC_CHECK_LIB([iconv], [libiconv_open], [ICONV_HOME="/usr"], [LDFLAGS="$save_LDFLAGS"]) + ]) + AC_MSG_CHECKING([for iconv]) + save_LIBS="$LIBS" + save_CPPFLAGS="$CPPFLAGS" + LIBS="$LIBCLAMAV_LIBS" + if test "X$ICONV_HOME" != "X"; then + ICONV_LDFLAGS="$LDFLAGS" + ICONV_CPPFLAGS="-I$ICONV_HOME/include" + else + ICONV_LDFLAGS="" + ICONV_CPPFLAGS="" + fi + CPPFLAGS="$ICONV_CPPFLAGS $LIBCLAMAV_CPPFLAGS" + AC_TRY_LINK([ #include - ],[ - char** xin,**xout; - unsigned long il,ol; - int rc; - iconv_t iconv_struct = iconv_open("UTF-16BE","UTF-8"); - rc = iconv(iconv_struct,xin,&il,xout,&ol); - iconv_close(iconv_struct); -],[ - AC_MSG_RESULT(yes) - AC_DEFINE([HAVE_ICONV], 1, [iconv() available]) -],[ - AC_MSG_RESULT(no) -]) - LIBS="$save_LIBS" + ],[ + char** xin,**xout; + unsigned long il,ol; + int rc; + iconv_t iconv_struct = iconv_open("UTF-16BE","UTF-8"); + rc = iconv(iconv_struct,xin,&il,xout,&ol); + iconv_close(iconv_struct); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_ICONV], 1, [iconv() available]) + AC_SUBST(ICONV_LDFLAGS) + AC_SUBST(ICONV_CPPFLAGS) + ],[ + AC_MSG_RESULT(no) + ]) + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + CPPFLAGS="$save_CPPFLAGS" fi diff -Nru clamav-0.99.2+dfsg/m4/reorganization/code_checks/stat64.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/code_checks/stat64.m4 --- clamav-0.99.2+dfsg/m4/reorganization/code_checks/stat64.m4 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/code_checks/stat64.m4 2017-04-20 22:19:13.000000000 +0000 @@ -24,6 +24,6 @@ if test "$enable_stat64" != "no"; then AC_DEFINE([HAVE_STAT64],1,[enable stat64]) -CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE" +CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" fi AC_MSG_RESULT([$enable_stat64]) diff -Nru clamav-0.99.2+dfsg/m4/reorganization/libfreshclam.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/libfreshclam.m4 --- clamav-0.99.2+dfsg/m4/reorganization/libfreshclam.m4 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/libfreshclam.m4 2016-10-13 15:46:46.000000000 +0000 @@ -1,3 +1,5 @@ +AM_CONDITIONAL([ENABLE_CLAMSUBMIT], [test "$have_curl" = "yes"]) + AC_ARG_ENABLE([libfreshclam], [AS_HELP_STRING([--enable-libfreshclam], [enable building of libfreshclam])], enable_libfreshclam=$enableval, enable_libfreshclam="no") diff -Nru clamav-0.99.2+dfsg/m4/reorganization/libmspack.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/libmspack.m4 --- clamav-0.99.2+dfsg/m4/reorganization/libmspack.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/libmspack.m4 2017-04-20 22:19:13.000000000 +0000 @@ -0,0 +1,11 @@ +m4_include([libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4]) + +if test "x$system_libmspack" = "xno"; then + use_internal_mspack=yes + AM_CONDITIONAL([USE_INTERNAL_MSPACK], test TRUE) + CLFAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" +else + PKG_CHECK_MODULES([LIBMSPACK], [libmspack], + use_internal_mspack=no, use_internal_mspack=yes) + AM_CONDITIONAL([USE_INTERNAL_MSPACK], test "x$use_internal_mspack" = "xyes") +fi diff -Nru clamav-0.99.2+dfsg/m4/reorganization/libs/libz.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/libs/libz.m4 --- clamav-0.99.2+dfsg/m4/reorganization/libs/libz.m4 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/libs/libz.m4 2017-01-13 18:12:34.000000000 +0000 @@ -29,9 +29,9 @@ AC_MSG_ERROR([Please install zlib and zlib-devel packages]) else - vuln=`grep "ZLIB_VERSION \"1.2.0" $ZLIB_HOME/include/zlib.h` + vuln=`grep "ZLIB_VERSION \"1.2.0\"" $ZLIB_HOME/include/zlib.h` if test -z "$vuln"; then - vuln=`grep "ZLIB_VERSION \"1.2.1" $ZLIB_HOME/include/zlib.h` + vuln=`grep "ZLIB_VERSION \"1.2.1\"" $ZLIB_HOME/include/zlib.h` fi if test -n "$vuln"; then diff -Nru clamav-0.99.2+dfsg/m4/reorganization/libs/openssl.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/libs/openssl.m4 --- clamav-0.99.2+dfsg/m4/reorganization/libs/openssl.m4 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/libs/openssl.m4 2016-10-13 15:45:44.000000000 +0000 @@ -26,12 +26,13 @@ save_CFLAGS="$CFLAGS" save_LIBS="$LIBS" -SSL_LIBS="-lssl -lcrypto -lz" +SSL_LIBS="$LIBS -lssl -lcrypto -lz" +LIBS="$LIBS $SSL_LIBS" if test "$LIBSSL_HOME" != "/usr"; then SSL_LDFLAGS="-L$LIBSSL_HOME/lib" SSL_CPPFLAGS="-I$LIBSSL_HOME/include" - LDFLAGS="-L$LIBSSL_HOME/lib $SSL_LIBS" + LDFLAGS="-L$LIBSSL_HOME/lib" CFLAGS="$SSL_CPPFLAGS" else SSL_LDFLAGS="" @@ -41,7 +42,12 @@ have_ssl="no" have_crypto="no" -AC_CHECK_LIB([ssl], [SSL_library_init], [have_ssl="yes"], [AC_MSG_ERROR([Your OpenSSL installation is misconfigured or missing])], [-lcrypto -lz]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[SSL_library_init();]])], + [have_ssl="yes";], + [AC_MSG_ERROR([Your OpenSSL installation is misconfigured or missing])]) + AC_CHECK_LIB([crypto], [EVP_EncryptInit], [have_crypto="yes"], [AC_MSG_ERROR([Your OpenSSL installation is misconfigured or missing])], [-lcrypto -lz]) diff -Nru clamav-0.99.2+dfsg/m4/reorganization/libs/pcre.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/libs/pcre.m4 --- clamav-0.99.2+dfsg/m4/reorganization/libs/pcre.m4 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/libs/pcre.m4 2016-10-13 15:45:44.000000000 +0000 @@ -54,17 +54,13 @@ fi AC_MSG_RESULT([$pcre_version]) - AC_CANONICAL_HOST - case $host_os in - darwin* ) - pcrever_major=`echo "$pcre_version" | sed -Ee 's/([[0-9]]+).*/\1/'` - pcrever_minor=`echo "$pcre_version" | sed -Ee 's/[[0-9]]+\.([[0-9]]+).*/\1/'` - ;; - *) - pcrever_major=`echo "$pcre_version" | sed -re 's/([[0-9]]+).*/\1/'` - pcrever_minor=`echo "$pcre_version" | sed -re 's/[[0-9]]+\.([[0-9]]+).*/\1/'` - ;; - esac + + pcrever_prefix=`expr "$pcre_version" : '\([[^0-9]]*\)'` + pcrever_frag=${pcre_version#$pcrever_prefix} + + pcrever_major=`expr "$pcrever_frag" : '\([[0-9]]*\)'` + pcrever_frag=${pcrever_frag#*\.} + pcrever_minor=`expr "$pcrever_frag" : '\([[0-9]]*\)'` dnl check for match_limit_recursion support if test "$pcrelib" = "pcre"; then diff -Nru clamav-0.99.2+dfsg/m4/reorganization/llvm.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/llvm.m4 --- clamav-0.99.2+dfsg/m4/reorganization/llvm.m4 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/llvm.m4 2016-10-13 15:45:44.000000000 +0000 @@ -1,53 +1,13 @@ -AC_ARG_WITH([system-llvm], [AC_HELP_STRING([--with-system-llvm], -[use system llvm instead of built-in, uses full path to llvm-config -@<:@default=/usr/local or /usr if not found in /usr/local@:>@])], -[case "$withval" in - yes) - system_llvm="default" - ;; - no) - system_llvm="built-in" - ;; - *) - system_llvm=$withval - esac -], [system_llvm="built-in"]) +m4_include([libclamav/c++/m4/llvm-opts.m4]) -AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking], -[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])], -[ -if test "x$system_llvm" = "xbuilt-in"; then - AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without specifying system-llvm]) -else -case "$withval" in - static) - llvm_linking="static" - ;; - dynamic) - llvm_linking="dynamic" - ;; - *) - AC_MSG_ERROR([Invalid argument to --with-llvm-linking]) -esac +if test "x$llvmoptserrmsg" != "x"; then + if test "$enable_llvm" = "auto"; then + enable_llvm="no" + else + AC_MSG_ERROR([Failed to configure LLVM, and LLVM was explicitly requested]) + dnl AC_MSG_ERROR([$llvmoptserrmsg]) + fi fi -], [ -if test "x$system_llvm" = "xbuilt-in"; then - llvm_linking="" -else - llvm_linking="auto" -fi -]) - -AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm], -[enable 'llvm' JIT/verifier support @<:@default=auto@:>@]), -[enable_llvm=$enableval], -[ -if test "x$system_llvm" != "xbuilt-in"; then - enable_llvm="yes" -else - enable_llvm="auto" -fi -]) if test "$enable_llvm" != "no"; then dnl Try to configure subdir, optionally diff -Nru clamav-0.99.2+dfsg/m4/reorganization/prelude.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/prelude.m4 --- clamav-0.99.2+dfsg/m4/reorganization/prelude.m4 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/prelude.m4 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,13 @@ +# PRELUDE +AC_ARG_ENABLE(prelude, + AS_HELP_STRING([--enable-prelude], + [Enable Prelude support for alerts.]), +[ + if test "$enableval" != "no"; then + AM_PATH_LIBPRELUDE(0.9.9, , AC_MSG_ERROR(Cannot find libprelude: Is libprelude-config in the path?), no) + CPPFLAGS="${CPPFLAGS} ${LIBPRELUDE_CFLAGS}" + LDFLAGS="${LDFLAGS} ${LIBPRELUDE_LDFLAGS}" + LDFLAGS="${LDFLAGS} ${LIBPRELUDE_LIBS}" + AC_DEFINE([PRELUDE], [1], [Libprelude support enabled]) + fi +],) diff -Nru clamav-0.99.2+dfsg/m4/reorganization/version.m4 clamav-0.99.3~beta1+dfsg/m4/reorganization/version.m4 --- clamav-0.99.2+dfsg/m4/reorganization/version.m4 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/m4/reorganization/version.m4 2017-07-19 19:56:35.000000000 +0000 @@ -1,6 +1,6 @@ dnl change this on a release dnl VERSION="devel-`date +%Y%m%d`" -VERSION="0.99.2" +VERSION="0.99.3-beta1" LC_CURRENT=8 LC_REVISION=1 diff -Nru clamav-0.99.2+dfsg/Makefile.am clamav-0.99.3~beta1+dfsg/Makefile.am --- clamav-0.99.2+dfsg/Makefile.am 2016-05-03 21:11:17.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/Makefile.am 2017-08-06 19:54:50.000000000 +0000 @@ -37,7 +37,7 @@ # don't complain that configuration files and databases are not removed, this is intended distuninstallcheck_listfiles = find . -type f ! -name clamd.conf ! -name freshclam.conf ! -name daily.cvd ! -name main.cvd -print DISTCLEANFILES = target.h -DISTCHECK_CONFIGURE_FLAGS=--enable-milter --disable-clamav --enable-all-jit-targets --enable-llvm=yes --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) +DISTCHECK_CONFIGURE_FLAGS=--enable-milter --disable-clamav --enable-all-jit-targets --enable-llvm=yes --with-system-llvm=no --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) lcov: ($(MAKE); cd unit_tests; $(MAKE) lcov) quick-check: diff -Nru clamav-0.99.2+dfsg/Makefile.in clamav-0.99.3~beta1+dfsg/Makefile.in --- clamav-0.99.2+dfsg/Makefile.in 2016-05-03 21:11:17.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/Makefile.in 2017-08-06 19:54:50.000000000 +0000 @@ -132,10 +132,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -190,12 +191,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -401,6 +407,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -428,7 +436,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -522,6 +539,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ @@ -561,7 +579,7 @@ # don't complain that configuration files and databases are not removed, this is intended distuninstallcheck_listfiles = find . -type f ! -name clamd.conf ! -name freshclam.conf ! -name daily.cvd ! -name main.cvd -print DISTCLEANFILES = target.h -DISTCHECK_CONFIGURE_FLAGS = --enable-milter --disable-clamav --enable-all-jit-targets --enable-llvm=yes --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) +DISTCHECK_CONFIGURE_FLAGS = --enable-milter --disable-clamav --enable-all-jit-targets --enable-llvm=yes --with-system-llvm=no --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) all: clamav-config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive diff -Nru clamav-0.99.2+dfsg/NEWS clamav-0.99.3~beta1+dfsg/NEWS --- clamav-0.99.2+dfsg/NEWS 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/NEWS 2017-07-20 21:05:27.000000000 +0000 @@ -1,17 +1,49 @@ -0.99.1 +0.99.3 ------ -ClamAV 0.99.1 contains a new feature for parsing Hancom Office files -including extracting and scanning embedded objects. ClamAV 0.99.1 -also contains important bug fixes. Please see ChangeLog for details. +Welcome to ClamAV 0.99.3. In this release, we have included many code +submissions from the ClamAV community: + - Interfaces to the Prelude SIEM open source package for collecting + ClamAV virus events. + - Visual Studio 2015 for building Microsoft Windows binaries. + - Support libmspack internal code or as a shared object library. + The internal library is the default and contains additional + integrity checks. + - Linking with openssl 1.1.0. + - Numerous code patches, typos, and compiler warning fixes. -Thanks to the following community members for code submissions used in -ClamAV 0.99.1: +Additionally, we have introduced important changes and new features in +ClamAV 0.99.3, including: + - Deprecating internal LLVM code support. The configure script has changed + to search the system for an installed instance of the LLVM development + libraries, and to otherwise use the bytecode interpreter for ClamAV + bytecode signatures. To use the LLVM Just-In-Time compiler for + executing bytecode signatures, please ensure that the LLVM development + package at version 3.6 or lower is installed. Using the deprecated LLVM + code is possible with the command: './configure --with-system-llvm=no', + but it no longer compiles on all platforms. + - Compute and check PE import table hash (a.k.a. "imphash") signatures. + - Support file property collection and analysis for MHTML files. + - Raw scanning of PostScript files. + - Fix clamsubmit to use the new virus and false positive submission web + interface. + - Optionally, flag files with the virus "Heuristic.Limits.Exceeded" when + size limitations are exceeded. + - Improve decoders for PDF files. -Jim Morris -Andreas Cadhalpun -Mark Allan -Sebastian Siewior +The ClamAV community thanks the following individuals for their ClamAV 0.99.3 +code submissions: + +Sebastian Andrzej Siewior +Keith Jones +Bill Parker +Chris Miserva +Daniel J. Luke +Matthew Boedicker +Ningirsu +Michael Pelletier +Anthony Chan +Stephen Welker -- The ClamAV team (http://www.clamav.net/about.html#credits) diff -Nru clamav-0.99.2+dfsg/README clamav-0.99.3~beta1+dfsg/README --- clamav-0.99.2+dfsg/README 2016-04-22 15:02:18.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/README 2017-07-20 21:05:27.000000000 +0000 @@ -2,6 +2,53 @@ here may not be available in binary packages. -- +0.99.3 +------ + +Welcome to ClamAV 0.99.3. In this release, we have included many code +submissions from the ClamAV community: + - Interfaces to the Prelude SIEM open source package for collecting + ClamAV virus events. + - Visual Studio 2015 for building Microsoft Windows binaries. + - Support libmspack internal code or as a shared object library. + The internal library is the default and contains additional + integrity checks. + - Linking with openssl 1.1.0. + - Numerous code patches, typos, and compiler warning fixes. + +Additionally, we have introduced important changes and new features in +ClamAV 0.99.3, including: + - Deprecating internal LLVM code support. The configure script has changed + to search the system for an installed instance of the LLVM development + libraries, and to otherwise use the bytecode interpreter for ClamAV + bytecode signatures. To use the LLVM Just-In-Time compiler for + executing bytecode signatures, please ensure that the LLVM development + package at version 3.6 or lower is installed. Using the deprecated LLVM + code is possible with the command: './configure --with-system-llvm=no', + but it no longer compiles on all platforms. + - Compute and check PE import table hash (a.k.a. "imphash") signatures. + - Support file property collection and analysis for MHTML files. + - Raw scanning of PostScript files. + - Fix clamsubmit to use the new virus and false positive submission web + interface. + - Optionally, flag files with the virus "Heuristic.Limits.Exceeded" when + size limitations are exceeded. + - Improve decoders for PDF files. + +The ClamAV community thanks the following individuals for their ClamAV 0.99.3 +code submissions: + +Sebastian Andrzej Siewior +Keith Jones +Bill Parker +Chris Miserva +Daniel J. Luke +Matthew Boedicker +Ningirsu +Michael Pelletier +Anthony Chan +Stephen Welker + 0.99.2 ------ @@ -738,7 +785,7 @@ (clamd: ExcludePUA, IncludePUA; clamscan: --exclude-pua, --include-pua) - Data Loss Prevention (DLP): This version includes a new module that, when - enabled, scans data for the inclusion of US formated Social Security + enabled, scans data for the inclusion of US formatted Social Security Numbers and credit card numbers (clamd: StructuredDataDetection, clamscan: --detect-structured; additional fine-tuning options are available) @@ -1408,7 +1455,7 @@ + a lot of minor improvements, including support for new platforms -) clamd: - + new directive ExitOnOOM (stop the deamon when libclamav reports an out of + + new directive ExitOnOOM (stop the daemon when libclamav reports an out of memory condition) + new directives StreamMinPort and StreamMaxPort (port range specification for a stream mode) @@ -2224,7 +2271,7 @@ Tru64 support (thanks to Christophe Varoqui ) -) documentation: - + included how-to in Portugese by Alexandre de Jesus Marcolino + + included how-to in Portuguese by Alexandre de Jesus Marcolino + clamdoc.pdf and system manual updates Many thanks to Luca 'NERvOus' Gibelli from ElektraPro for his support, @@ -2286,7 +2333,7 @@ viruses (eg. W32/Yaha.E) are using very long file names, and they were ignored in mbox mode. Users of AMaViS-ng and other wrappers were not vulnerable to this problem, because that programs don't use original -attachement file names. +attachment file names. -) clamscan: + removed limit for a file name length (thanks to Odhiambo Washington @@ -2444,9 +2491,9 @@ update viruses.db2 and supports OpenAntiVirus.org site only (the last update of the OAV database was 1 July !). Nicholas Chua has generated over 200 new signatures, ClamAV's database is also frequently -updated (expecially when new wild virus/worm appears, eg. W32/BugBear.A). +updated (especially when new wild virus/worm appears, eg. W32/BugBear.A). - This software is still in developement (new software == new bugs), however + This software is still in development (new software == new bugs), however clamscan should be very stable. You shouldn't use clamd/clamuko (well, clamd is stable, clamuko isn't) on production systems, yet. Please wait for 0.51 at least ;). ClamAV 0.50 was tested on Linux and Solaris and should work fine. @@ -2520,7 +2567,7 @@ ---- This release fixes bug with scanning archives in unaccessible directories with -*superuser* priviledges (after dropping priviledges scanner wasn't able to +*superuser* privileges (after dropping privileges scanner wasn't able to access the archive, although the same archive was accessible), thanks for Sergei Pronin for the problem description. Now all archives unaccessible directly by the clamav user are copied (with a respect to @@ -2558,7 +2605,7 @@ ------------ The most important change in this release is a new, linear pattern matching -algorithm. You will find more informations about it in clamscan/matcher.c - +algorithm. You will find more information about it in clamscan/matcher.c - in the sources and in clamdoc. Summary (since 0.15): New features: diff -Nru clamav-0.99.2+dfsg/shared/clamdcom.c clamav-0.99.3~beta1+dfsg/shared/clamdcom.c --- clamav-0.99.2+dfsg/shared/clamdcom.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/shared/clamdcom.c 2016-11-03 16:01:29.000000000 +0000 @@ -66,9 +66,9 @@ /* Receives a full (terminated with \0) line from a socket * Sets rbol to the begin of the received line, and optionally * reol to the end of line. - * Should be called repeatedly untill all input is consumed + * Should be called repeatedly until all input is consumed * Returns: - * - the lenght of the line (a positive number) on success + * - the length of the line (a positive number) on success * - 0 if the connection is closed * - -1 on error */ diff -Nru clamav-0.99.2+dfsg/shared/idmef_logging.c clamav-0.99.3~beta1+dfsg/shared/idmef_logging.c --- clamav-0.99.2+dfsg/shared/idmef_logging.c 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/shared/idmef_logging.c 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,250 @@ +/* + * Copyright (C) 2007-2009 Sourcefire, Inc. + * + * Authors: Selim Menouar, Verene Houdebine + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + + +#include "shared/misc.h" +#include "shared/output.h" +#include +#include +#include +#include + +#ifndef PRELUDE +void prelude_logging(const char *filename, const char *virname, const char *virhash, int virsize){ + logg("You have to compile with libprelude using ./configure --enable-prelude\n"); +} +#else + +#include + +#define ANALYZER_MODEL "ClamAV" +#define ANALYZER_CLASS "AntiVirus" +#define ANALYZER_MANUFACTURER "http://www.sourcefire.com" + + +static prelude_client_t *prelude_client; + +int idmef_analyzer_setup(idmef_analyzer_t *analyzer, const char *analyzer_name){ + int ret; + prelude_string_t *str; + + /* alert->analyzer->name */ + ret = idmef_analyzer_new_name(analyzer, &str); + if ( ret < 0 ) + return ret; + + prelude_string_set_constant(str, analyzer_name); + + /* alert->analyzer->model */ + ret = idmef_analyzer_new_model(analyzer, &str); + if ( ret < 0 ) + return ret; + + prelude_string_set_constant(str, ANALYZER_MODEL ); + + /* alert->analyzer->class */ + ret = idmef_analyzer_new_class(analyzer, &str); + if ( ret < 0 ) + return ret; + + prelude_string_set_constant(str, ANALYZER_CLASS); + + /* alert->analyzer->manufacturer */ + ret = idmef_analyzer_new_manufacturer(analyzer, &str); + if ( ret < 0 ) + return ret; + + prelude_string_set_constant(str, ANALYZER_MANUFACTURER); + + /* alert->analyzer->version */ + ret = idmef_analyzer_new_version(analyzer, &str); + if ( ret < 0 ) + return ret; + + prelude_string_set_constant(str, get_version()); + + return 0; +} + +int prelude_initialize_client(const char *analyzer_name){ + int ret; + + prelude_client = NULL; + + ret = prelude_init(0, NULL); + if ( ret < 0 ) { + logg("Unable to initialize the prelude library : %s", prelude_strerror(ret)); + return -1; + } + + + ret = prelude_client_new(&prelude_client, analyzer_name); + if ( ret < 0 ) { + logg("Unable to create a prelude client object : %s", prelude_strerror(ret)); + return -1; + } + + ret = idmef_analyzer_setup(prelude_client_get_analyzer(prelude_client), analyzer_name); + if ( ret < 0 ) { + logg("%s", prelude_strerror(ret)); + return -1; + } + + ret = prelude_client_start(prelude_client); + if ( ret < 0 || ! prelude_client ) { + logg("Unable to start prelude client : %s", prelude_strerror(ret)); + prelude_client_destroy(prelude_client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS); + return -1; + } + + ret = prelude_client_set_flags(prelude_client, PRELUDE_CLIENT_FLAGS_ASYNC_SEND|PRELUDE_CLIENT_FLAGS_ASYNC_TIMER); + if ( ret < 0) { + logg("Unable to send asynchrnous send and timer : %s", prelude_strerror(ret)); + prelude_client_destroy(prelude_client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS); + return -1; + } + + return 0; +} + +int add_string_additional_data(idmef_alert_t *alert, const char *meaning, const char *ptr){ + int ret; + prelude_string_t *str; + idmef_additional_data_t *ad; + idmef_data_t *data; + + ret = idmef_alert_new_additional_data(alert, &ad, IDMEF_LIST_APPEND); + if ( ret < 0 ) + return ret; + + idmef_additional_data_set_type(ad, IDMEF_ADDITIONAL_DATA_TYPE_STRING); + + idmef_additional_data_new_data(ad, &data); + + ret = idmef_data_set_char_string_ref(data, ptr); + if ( ret < 0) + return ret; + + + ret = idmef_additional_data_new_meaning(ad, &str); + if ( ret < 0) + return ret; + + ret = prelude_string_set_ref(str, meaning); + if ( ret < 0 ) + return ret; + + return 0; +} + +int add_int_additional_data(idmef_alert_t *alert, const char *meaning, int data){ + int ret; + prelude_string_t *str; + idmef_additional_data_t *ad; + + ret = idmef_alert_new_additional_data(alert, &ad, IDMEF_LIST_APPEND); + if ( ret < 0 ) + return ret; + + idmef_additional_data_set_integer(ad, data); + + ret = idmef_additional_data_new_meaning(ad, &str); + if ( ret < 0) + return ret; + + ret = prelude_string_set_ref(str, meaning); + if ( ret < 0 ) + return ret; + + return 0; +} + + +void prelude_logging(const char *filename, const char *virname, const char *virhash, int virsize){ + int ret; + idmef_message_t *idmef = NULL; + idmef_alert_t *alert; + idmef_classification_t *class; + prelude_string_t *str; + idmef_target_t *target; + idmef_file_t *file; + + ret = idmef_message_new(&idmef); + if ( ret < 0 ) + goto err; + + ret = idmef_message_new_alert(idmef, &alert); + if ( ret < 0 ) + goto err; + + ret = idmef_alert_new_classification(alert, &class); + if ( ret < 0 ) + goto err; + + ret = idmef_classification_new_text(class, &str); + if ( ret < 0 ) + goto err; + + prelude_string_set_constant(str, "Virus Found"); + + ret = idmef_alert_new_target(alert, &target, 0); + if ( ret < 0 ) + goto err; + + ret = idmef_target_new_file(target, &file, 0); + if ( ret < 0 ) + goto err; + + ret = idmef_file_new_path(file, &str); + if ( ret < 0 ) + goto err; + + prelude_string_set_ref(str, filename); + + if ( virname != NULL ) { + ret = add_string_additional_data(alert, "virname", virname); + if ( ret < 0 ) + goto err; + } + + if ( virhash != NULL){ + ret = add_string_additional_data(alert, "virhash", virhash); + if ( ret < 0 ) + goto err; + } + + ret = add_int_additional_data(alert, "virsize", virsize); + if ( ret < 0 ) + goto err; + + logg("le client : %s", prelude_client_get_config_filename(prelude_client)); + prelude_client_send_idmef(prelude_client, idmef); + idmef_message_destroy(idmef); + + return; + +err: + if (idmef != NULL) + idmef_message_destroy(idmef); + + logg("%s error: %s", prelude_strsource(ret), prelude_strerror(ret)); + return; +} +#endif diff -Nru clamav-0.99.2+dfsg/shared/idmef_logging.h clamav-0.99.3~beta1+dfsg/shared/idmef_logging.h --- clamav-0.99.2+dfsg/shared/idmef_logging.h 1970-01-01 00:00:00.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/shared/idmef_logging.h 2016-10-13 15:45:44.000000000 +0000 @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2007-2009 Sourcefire, Inc. + * + * Authors: Selim Menouar, Verene Houdebine + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef __IDMEF_LOGGING_H_ +#define __IDMEF_LOGGING_H_ +#endif + +#ifdef PRELUDE +int prelude_initialize_client(const char *analyzer_name); +#endif + +void prelude_logging(const char *filename, const char *virname, const char *virhash, int virsize); + diff -Nru clamav-0.99.2+dfsg/shared/Makefile.am clamav-0.99.3~beta1+dfsg/shared/Makefile.am --- clamav-0.99.2+dfsg/shared/Makefile.am 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/shared/Makefile.am 2016-10-13 15:45:44.000000000 +0000 @@ -4,6 +4,7 @@ cdiff.c\ clamdcom.c\ getopt.c\ + idmef_logging.c\ misc.c\ optparser.c\ tar.c diff -Nru clamav-0.99.2+dfsg/shared/optparser.c clamav-0.99.3~beta1+dfsg/shared/optparser.c --- clamav-0.99.2+dfsg/shared/optparser.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/shared/optparser.c 2017-03-08 14:06:34.000000000 +0000 @@ -87,6 +87,7 @@ { NULL, "fdpass", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMDSCAN, "", "" }, { NULL, "stream", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMDSCAN, "", "" }, { NULL, "allmatch", 'z', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" }, + { NULL, "normalize", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 1, NULL, 0, OPT_CLAMSCAN, "Perform HTML, script, and text normalization", "" }, { NULL, "database", 'd', CLOPT_TYPE_STRING, NULL, -1, DATADIR, FLAG_REQUIRED | FLAG_MULTIPLE, OPT_CLAMSCAN, "", "" }, /* merge it with DatabaseDirectory (and fix conflict with --datadir */ { NULL, "recursive", 'r', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", "" }, { NULL, "gen-mdb", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "Always generate MDB entries for PE sections", "" }, @@ -110,6 +111,7 @@ { NULL, "sha1", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_SIGTOOL, "", "" }, { NULL, "sha256", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_SIGTOOL, "", "" }, { NULL, "mdb", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_SIGTOOL, "", "" }, + { NULL, "imp", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_SIGTOOL, "", "" }, { NULL, "print-certs", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" }, { NULL, "html-normalise", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" }, { NULL, "ascii-normalise", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" }, @@ -134,6 +136,7 @@ { NULL, "compare", 'c', CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" }, { NULL, "run-cdiff", 'r', CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" }, { NULL, "verify-cdiff", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_SIGTOOL, "", "" }, + { NULL, "hybrid", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_SIGTOOL, "Create a hybrid (standard and bytecode) database file", ""}, { NULL, "defaultcolors", 'd', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMDTOP, "", "" }, { NULL, "config-dir", 'c', CLOPT_TYPE_STRING, NULL, 0, CONFDIR, FLAG_REQUIRED, OPT_CLAMCONF, "", "" }, @@ -172,7 +175,7 @@ { NULL, "no-phishing-restrictedscan", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, { NULL, "max-ratio", 0, CLOPT_TYPE_NUMBER, MATCH_NUMBER, 0, NULL, 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, { NULL, "max-space", 0, CLOPT_TYPE_SIZE, MATCH_SIZE, 0, NULL, 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, - { NULL, "block-max", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, + { NULL, "block-max", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", "" }, { NULL, "unzip", 0, CLOPT_TYPE_STRING, NULL, -1, "foo", 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, { NULL, "unrar", 0, CLOPT_TYPE_STRING, NULL, -1, "foo", 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, { NULL, "arj", 0, CLOPT_TYPE_STRING, NULL, -1, "foo", 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, @@ -184,6 +187,10 @@ { NULL, "deb", 0, CLOPT_TYPE_STRING, NULL, -1, "foo", 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, /* config file/cmdline options */ + { "PreludeEnable", "prelude-enable", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD, "Enable prelude"}, + + { "PreludeAnalyzerName", "prelude-analyzer-name", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMD, "Name of the analyzer as seen in prewikka"}, + { "LogFile", "log", 'l', CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMD | OPT_MILTER | OPT_CLAMSCAN | OPT_CLAMDSCAN, "Save all reports to a log file.", "/tmp/clamav.log" }, { "StatsHostID", "stats-host-id", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM | OPT_CLAMD | OPT_CLAMSCAN, "HostID in the form of an UUID to use when submitting statistical information. See the clamscan manpage for more information.", "default" }, @@ -285,8 +292,6 @@ { "User", NULL, 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMD | OPT_MILTER, "Run the daemon as a specified user (the process must be started by root).", "clamav" }, - { "AllowSupplementaryGroups", NULL, 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_MILTER, "Initialize a supplementary group access (the process must be started by root).", "no" }, - /* Scan options */ { "Bytecode", "bytecode", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 1, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "With this option enabled ClamAV will load bytecode from the database. It is highly recommended you keep this option on, otherwise you'll miss detections for many new viruses.", "yes" }, @@ -391,11 +396,11 @@ { "TimeLimit", "timelimit", 0, CLOPT_TYPE_NUMBER, MATCH_NUMBER, 0, NULL, 0, OPT_CLAMSCAN, "This clamscan option is currently for testing only. It sets the engine parameter CL_ENGINE_TIME_LIMIT. The value is in milliseconds.", "0" }, - { "PCREMatchLimit", "pcre-match-limit", 0, CLOPT_TYPE_NUMBER, MATCH_NUMBER, CLI_DEFAULT_PCRE_MATCH_LIMIT, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option sets the maximum calls to the PCRE match function during an instance of regex matching.\nInstances using more than this limit will be terminated and alert the user but the scan will continue.\nFor more information on match_limit, see the PCRE documentation.\nNegative values are not allowed.\nWARNING: setting this limit too high may severely impact performance.", "10000" }, + { "PCREMatchLimit", "pcre-match-limit", 0, CLOPT_TYPE_NUMBER, MATCH_NUMBER, CLI_DEFAULT_PCRE_MATCH_LIMIT, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option sets the maximum calls to the PCRE match function during an instance of regex matching.\nInstances using more than this limit will be terminated and alert the user but the scan will continue.\nFor more information on match_limit, see the PCRE documentation.\nNegative values are not allowed.\nWARNING: setting this limit too high may severely impact performance.", "100000" }, { "PCRERecMatchLimit", "pcre-recmatch-limit", 0, CLOPT_TYPE_NUMBER, MATCH_NUMBER, CLI_DEFAULT_PCRE_RECMATCH_LIMIT, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option sets the maximum recursive calls to the PCRE match function during an instance of regex matching.\nInstances using more than this limit will be terminated and alert the user but the scan will continue.\nFor more information on match_limit_recursion, see the PCRE documentation.\nNegative values are not allowed and values > PCREMatchLimit are superfluous.\nWARNING: setting this limit too high may severely impact performance.", "5000" }, - { "PCREMaxFileSize", "pcre-max-filesize", 0, CLOPT_TYPE_NUMBER, MATCH_SIZE, CLI_DEFAULT_PCRE_MAX_FILESIZE, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option sets the maximum filesize for which PCRE subsigs will be executed.\nFiles exceeding this limit will not have PCRE subsigs executed unless a subsig is encompassed to a smaller buffer.\nNegative values are not allowed.\nSetting this value to zero disables the limit.\nWARNING: setting this limit too high or disabling it may severely impact performance.", "25M" }, + { "PCREMaxFileSize", "pcre-max-filesize", 0, CLOPT_TYPE_SIZE, MATCH_SIZE, CLI_DEFAULT_PCRE_MAX_FILESIZE, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option sets the maximum filesize for which PCRE subsigs will be executed.\nFiles exceeding this limit will not have PCRE subsigs executed unless a subsig is encompassed to a smaller buffer.\nNegative values are not allowed.\nSetting this value to zero disables the limit.\nWARNING: setting this limit too high or disabling it may severely impact performance.", "25M" }, /* OnAccess settings */ { "ScanOnAccess", NULL, 0, CLOPT_TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_CLAMD, "This option enables on-access scanning (Linux only)", "no" }, diff -Nru clamav-0.99.2+dfsg/sigtool/Makefile.in clamav-0.99.3~beta1+dfsg/sigtool/Makefile.in --- clamav-0.99.2+dfsg/sigtool/Makefile.in 2016-04-22 16:19:53.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/sigtool/Makefile.in 2017-06-23 21:20:59.000000000 +0000 @@ -106,10 +106,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -164,12 +165,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -310,6 +316,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -337,7 +345,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @SSL_LDFLAGS@ @SSL_LIBS@ $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @THREAD_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -431,6 +448,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/sigtool/sigtool.c clamav-0.99.3~beta1+dfsg/sigtool/sigtool.c --- clamav-0.99.2+dfsg/sigtool/sigtool.c 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/sigtool/sigtool.c 2017-07-19 19:03:40.000000000 +0000 @@ -111,13 +111,14 @@ { "zmd", 1 }, { "rmd", 1 }, { "idb", 0 }, - { "fp", 0 }, + { "fp", 1 }, { "sfp", 0 }, { "gdb", 1 }, { "pdb", 1 }, { "wdb", 0 }, { "crb", 1 }, { "cdb", 1 }, + { "imp", 1 }, { NULL, 0 } }; @@ -164,7 +165,129 @@ return 0; } -static int hashsig(const struct optstruct *opts, unsigned int mdb, int type) +static int hashpe(const char *filename, unsigned int class, int type) +{ + STATBUF sb; + const char *fmptr; + struct cl_engine *engine; + cli_ctx ctx; + int fd, ret; + + /* build engine */ + if(!(engine = cl_engine_new())) { + mprintf("!hashpe: Can't create new engine\n"); + return -1; + } + cl_engine_set_num(engine, CL_ENGINE_AC_ONLY, 1); + + if(cli_initroots(engine, 0) != CL_SUCCESS) { + mprintf("!hashpe: cli_initroots() failed\n"); + cl_engine_free(engine); + return -1; + } + + if(cli_parse_add(engine->root[0], "test", "deadbeef", 0, 0, 0, "*", 0, NULL, 0) != CL_SUCCESS) { + mprintf("!hashpe: Can't parse signature\n"); + cl_engine_free(engine); + return -1; + } + + if(cl_engine_compile(engine) != CL_SUCCESS) { + mprintf("!hashpe: Can't compile engine\n"); + cl_engine_free(engine); + return -1; + } + + /* prepare context */ + memset(&ctx, '\0', sizeof(cli_ctx)); + ctx.engine = engine; + ctx.options = CL_SCAN_STDOPT; + ctx.containers = cli_calloc(sizeof(cli_ctx_container), engine->maxreclevel + 2); + if(!ctx.containers) { + cl_engine_free(engine); + return -1; + } + ctx.containers[0].type = CL_TYPE_ANY; + ctx.dconf = (struct cli_dconf *) engine->dconf; + ctx.fmap = calloc(sizeof(fmap_t *), 1); + if(!ctx.fmap) { + free(ctx.containers); + cl_engine_free(engine); + return -1; + } + + /* Prepare file */ + fd = open(filename, O_RDONLY); + if(fd < 0) { + mprintf("!hashpe: Can't open file %s!\n", filename); + free(ctx.containers); + cl_engine_free(engine); + return -1; + } + + lseek(fd, 0, SEEK_SET); + FSTAT(fd, &sb); + if(!(*ctx.fmap = fmap(fd, 0, sb.st_size))) { + free(ctx.containers); + free(ctx.fmap); + close(fd); + cl_engine_free(engine); + return -1; + } + + fmptr = fmap_need_off_once(*ctx.fmap, 0, sb.st_size); + if(!fmptr) { + mprintf("!hashpe: fmap_need_off_once failed!\n"); + free(ctx.containers); + free(ctx.fmap); + close(fd); + cl_engine_free(engine); + return -1; + } + + cl_debug(); + + /* Send to PE-specific hasher */ + switch(class) { + case 1: + ret = cli_genhash_pe(&ctx, CL_GENHASH_PE_CLASS_SECTION, type); + break; + case 2: + ret = cli_genhash_pe(&ctx, CL_GENHASH_PE_CLASS_IMPTBL, type); + break; + default: + mprintf("!hashpe: unknown classification(%u) for pe hash!\n", class); + cl_engine_free(engine); + return -1; + } + + /* THIS MAY BE UNNECESSARY */ + switch(ret) { + case CL_CLEAN: + break; + case CL_VIRUS: + mprintf("*hashpe: CL_VIRUS after cli_genhash_pe()!\n"); + break; + case CL_BREAK: + mprintf("*hashpe: CL_BREAK after cli_genhash_pe()!\n"); + break; + case CL_EFORMAT: + mprintf("!hashpe: Not a valid PE file!\n"); + break; + default: + mprintf("!hashpe: Other error %d inside cli_genhash_pe.\n", ret); + break; + } + + /* Cleanup */ + free(ctx.containers); + free(ctx.fmap); + close(fd); + cl_engine_free(engine); + return 0; +} + +static int hashsig(const struct optstruct *opts, unsigned int class, int type) { char *hash; unsigned int i; @@ -179,12 +302,11 @@ return -1; } else { if((sb.st_mode & S_IFMT) == S_IFREG) { - if((hash = cli_hashfile(opts->filename[i], type))) { - if(mdb) - mprintf("%u:%s:%s\n", (unsigned int) sb.st_size, hash, basename(opts->filename[i])); - else - mprintf("%s:%u:%s\n", hash, (unsigned int) sb.st_size, basename(opts->filename[i])); + if((class == 0) && (hash = cli_hashfile(opts->filename[i], type))) { + mprintf("%s:%u:%s\n", hash, (unsigned int) sb.st_size, basename(opts->filename[i])); free(hash); + } else if((class > 0) && (hashpe(opts->filename[i], class, type) == 0)) { + /* intentionally empty - printed in cli_genhash_pe() */ } else { mprintf("!hashsig: Can't generate hash for %s\n", opts->filename[i]); return -1; @@ -194,6 +316,10 @@ } } else { /* stream */ + if (class > 0) { + mprintf("!hashsig: Can't generate requested hash for input stream\n"); + return -1; + } hash = cli_hashstream(stdin, NULL, type); if(!hash) { mprintf("!hashsig: Can't generate hash for input stream\n"); @@ -545,7 +671,8 @@ } free(pt); } - } else { + } + if(!dblist2cnt || optget(opts, "hybrid")->enabled) { for(i = 0; dblist[i].ext; i++) { snprintf(dbfile, sizeof(dbfile), "%s.%s", dbname, dblist[i].ext); if(strcmp(dblist[i].ext, "info") && !access(dbfile, R_OK)) { @@ -726,7 +853,7 @@ static int build(const struct optstruct *opts) { - int ret, bc = 0; + int ret, bc = 0, hy = 0; size_t bytes; unsigned int i, sigs = 0, oldsigs = 0, entries = 0, version, real_header, fl, maxentries; STATBUF foo; @@ -767,6 +894,9 @@ if(!strcmp(dbname, "bytecode")) bc = 1; + if(optget(opts, "hybrid")->enabled) + hy = 1; + if(!(engine = cl_engine_new())) { mprintf("!build: Can't initialize antivirus engine\n"); return 50; @@ -782,7 +912,7 @@ if(!sigs) { mprintf("!build: There are no signatures in database files\n"); } else { - if(bc) { + if(bc || hy) { if((dd = opendir(".")) == NULL) { mprintf("!build: Can't open current directory\n"); return -1; @@ -831,7 +961,8 @@ dblist2cnt++; entries += countlines("last.hdb"); } - } else { + } + if(!bc || hy) { for(i = 0; dblist[i].ext; i++) { snprintf(dbfile, sizeof(dbfile), "%s.%s", dbname, dblist[i].ext); if(dblist[i].count && !access(dbfile, R_OK)) @@ -842,15 +973,15 @@ if(entries != sigs) mprintf("^build: Signatures in %s db files: %u, loaded by libclamav: %u\n", dbname, entries, sigs); - maxentries = optget(opts, "max-bad-sigs")->numarg; + maxentries = optget(opts, "max-bad-sigs")->numarg; - if (maxentries) { - if(!entries || (sigs > entries && sigs - entries >= maxentries)) { - mprintf("!Bad number of signatures in database files\n"); - FREE_LS(dblist2); - return -1; - } - } + if (maxentries) { + if(!entries || (sigs > entries && sigs - entries >= maxentries)) { + mprintf("!Bad number of signatures in database files\n"); + FREE_LS(dblist2); + return -1; + } + } } /* try to read cvd header of current database */ @@ -970,8 +1101,8 @@ return -1; } - if(bc) { - if(tar_addfile(-1, tar, "bytecode.info") == -1) { + if(bc || hy) { + if(!hy && tar_addfile(-1, tar, "bytecode.info") == -1) { gzclose(tar); unlink(tarfile); free(tarfile); @@ -987,7 +1118,8 @@ return -1; } } - } else { + } + if(!bc || hy) { for(i = 0; dblist[i].ext; i++) { snprintf(dbfile, sizeof(dbfile), "%s.%s", dbname, dblist[i].ext); if(!access(dbfile, R_OK)) { @@ -1299,7 +1431,8 @@ cli_strbcasestr(dent->d_name, ".cbc") || cli_strbcasestr(dent->d_name, ".cld") || cli_strbcasestr(dent->d_name, ".cvd") || - cli_strbcasestr(dent->d_name, ".crb"))) { + cli_strbcasestr(dent->d_name, ".crb") || + cli_strbcasestr(dent->d_name, ".imp"))) { dbfile = (char *) malloc(strlen(dent->d_name) + strlen(dirname) + 2); if(!dbfile) { @@ -1443,7 +1576,7 @@ line++; mprintf("%s\n", buffer); } - } else if(cli_strbcasestr(filename, ".hdb") || cli_strbcasestr(filename, ".hdu") || cli_strbcasestr(filename, ".mdb") || cli_strbcasestr(filename, ".mdu") || cli_strbcasestr(filename, ".hsb") || cli_strbcasestr(filename, ".hsu") || cli_strbcasestr(filename, ".msb") || cli_strbcasestr(filename, ".msu")) { /* hash database */ + } else if(cli_strbcasestr(filename, ".hdb") || cli_strbcasestr(filename, ".hdu") || cli_strbcasestr(filename, ".mdb") || cli_strbcasestr(filename, ".mdu") || cli_strbcasestr(filename, ".hsb") || cli_strbcasestr(filename, ".hsu") || cli_strbcasestr(filename, ".msb") || cli_strbcasestr(filename, ".msu") || cli_strbcasestr(filename, ".imp")) { /* hash database */ while(fgets(buffer, FILEBUFF, fh)) { cli_chomp(buffer); @@ -2104,16 +2237,23 @@ memset(&ctx, '\0', sizeof(cli_ctx)); ctx.engine = engine; ctx.options = CL_SCAN_STDOPT; - ctx.container_type = CL_TYPE_ANY; + ctx.containers = cli_calloc(sizeof(cli_ctx_container), engine->maxreclevel + 2); + if(!ctx.containers) { + cl_engine_free(engine); + return; + } + ctx.containers[0].type = CL_TYPE_ANY; ctx.dconf = (struct cli_dconf *) engine->dconf; ctx.fmap = calloc(sizeof(fmap_t *), 1); if(!ctx.fmap) { + free(ctx.containers); cl_engine_free(engine); return; } lseek(fd, 0, SEEK_SET); FSTAT(fd, &sb); if(!(*ctx.fmap = fmap(fd, 0, sb.st_size))) { + free(ctx.containers); free(ctx.fmap); cl_engine_free(engine); return; @@ -2141,6 +2281,7 @@ acres = acres->next; free(res); } + free(ctx.containers); free(ctx.fmap); cl_engine_free(engine); } @@ -2817,6 +2958,23 @@ return 0; } +static int decodeftm(char **tokens, int tokens_count) +{ + mprintf("FILE TYPE NAME: %s\n", tokens[3]); + mprintf("FILE SIGNATURE TYPE: %s\n", tokens[0]); + mprintf("FILE MAGIC OFFSET: %s\n", tokens[1]); + mprintf("FILE MAGIC HEX: %s\n", tokens[2]); + mprintf("FILE MAGIC DECODED:\n"); + decodehex(tokens[2]); + mprintf("FILE TYPE REQUIRED: %s\n", tokens[4]); + mprintf("FILE TYPE DETECTED: %s\n", tokens[5]); + if(tokens_count == 7) + mprintf("FTM FLEVEL: >=%s\n", tokens[6]); + else if(tokens_count == 8) + mprintf("FTM FLEVEL: %s..%s\n", tokens[6], tokens[7]); + return 0; +} + static int decodesig(char *sig, int fd) { char *pt; @@ -2891,13 +3049,21 @@ matchsig(subhex, subhex, fd); } } - } else if(strchr(sig, ':')) { /* ndb */ + } else if(strchr(sig, ':')) { /* ndb or cdb or ftm*/ tokens_count = cli_strtokenize(sig, ':', 12 + 1, (const char **) tokens); if (tokens_count > 9 && tokens_count < 13) { /* cdb*/ return decodecdb(tokens); } + if (tokens_count > 5 && tokens_count < 9) { /* ftm */ + long ftmsigtype; + char * end; + ftmsigtype = strtol(tokens[0], &end, 10); + if (end == tokens[0]+1 && (ftmsigtype == 0||ftmsigtype == 1||ftmsigtype == 4)) + return decodeftm(tokens, tokens_count); + } + if(tokens_count < 4 || tokens_count > 6) { mprintf("!decodesig: Invalid or not supported signature format\n"); mprintf("TOKENS COUNT: %u\n", tokens_count); @@ -3265,10 +3431,16 @@ memset(&ctx, '\0', sizeof(cli_ctx)); ctx.engine = engine; ctx.options = CL_SCAN_STDOPT; - ctx.container_type = CL_TYPE_ANY; + ctx.containers = cli_calloc(sizeof(cli_ctx_container), engine->maxreclevel + 2); + if(!ctx.containers) { + cl_engine_free(engine); + return -1; + } + ctx.containers[0].type = CL_TYPE_ANY; ctx.dconf = (struct cli_dconf *) engine->dconf; ctx.fmap = calloc(sizeof(fmap_t *), 1); if(!ctx.fmap) { + free(ctx.containers); cl_engine_free(engine); return -1; } @@ -3277,6 +3449,7 @@ fd = open(filename, O_RDONLY); if(fd < 0) { mprintf("!dumpcerts: Can't open file %s!\n", filename); + free(ctx.containers); cl_engine_free(engine); return -1; } @@ -3284,6 +3457,7 @@ lseek(fd, 0, SEEK_SET); FSTAT(fd, &sb); if(!(*ctx.fmap = fmap(fd, 0, sb.st_size))) { + free(ctx.containers); free(ctx.fmap); close(fd); cl_engine_free(engine); @@ -3293,6 +3467,7 @@ fmptr = fmap_need_off_once(*ctx.fmap, 0, sb.st_size); if(!fmptr) { mprintf("!dumpcerts: fmap_need_off_once failed!\n"); + free(ctx.containers); free(ctx.fmap); close(fd); cl_engine_free(engine); @@ -3323,6 +3498,7 @@ } /* Cleanup */ + free(ctx.containers); free(ctx.fmap); close(fd); cl_engine_free(engine); @@ -3334,7 +3510,7 @@ mprintf("\n"); mprintf("Clam AntiVirus: Signature Tool (sigtool) %s\n", get_version()); mprintf(" By The ClamAV Team: http://www.clamav.net/team\n"); - mprintf(" (C) 2007-2015 Cisco Systems, Inc.\n\n"); + mprintf(" (C) 2007-2017 Cisco Systems, Inc.\n\n"); mprintf(" --help -h show help\n"); mprintf(" --version -V print version number and exit\n"); @@ -3349,7 +3525,8 @@ mprintf(" or SHA1 sigs for FILES\n"); mprintf(" --sha256 [FILES] generate SHA256 checksum from stdin\n"); mprintf(" or SHA256 sigs for FILES\n"); - mprintf(" --mdb [FILES] generate .mdb sigs\n"); + mprintf(" --mdb [FILES] generate .mdb (section hash) sigs\n"); + mprintf(" --imp [FILES] generate .imp (import table hash) sigs\n"); mprintf(" --html-normalise=FILE create normalised parts of HTML file\n"); mprintf(" --ascii-normalise=FILE create normalised text file from ascii source\n"); mprintf(" --utf16-decode=FILE decode UTF16 encoded files\n"); @@ -3370,6 +3547,7 @@ mprintf(" this value is ignored.\n"); mprintf(" --no-cdiff Don't generate .cdiff file\n"); mprintf(" --unsigned Create unsigned database file (.cud)\n"); + mprintf(" --hybrid Create a hybrid (standard and bytecode) database file\n"); mprintf(" --print-certs=FILE Print Authenticode details from a PE\n"); mprintf(" --server=ADDR ClamAV Signing Service address\n"); mprintf(" --datadir=DIR Use DIR as default database directory\n"); @@ -3444,6 +3622,8 @@ ret = hashsig(opts, 0, 3); else if(optget(opts, "mdb")->enabled) ret = hashsig(opts, 1, 1); + else if(optget(opts, "imp")->enabled) + ret = hashsig(opts, 2, 1); else if(optget(opts, "html-normalise")->enabled) ret = htmlnorm(opts); else if(optget(opts, "ascii-normalise")->enabled) diff -Nru clamav-0.99.2+dfsg/test/Makefile.am clamav-0.99.3~beta1+dfsg/test/Makefile.am --- clamav-0.99.2+dfsg/test/Makefile.am 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/test/Makefile.am 2017-05-19 17:47:01.000000000 +0000 @@ -26,7 +26,7 @@ all: $(FILES) $(FILES) : - cat $(SPLIT_DIR)/split.$@aa $(SPLIT_DIR)/split.$@ab > $@ + cat $(SPLIT_DIR)/split.$@a* > $@ clean-local: rm -f clam* diff -Nru clamav-0.99.2+dfsg/test/Makefile.in clamav-0.99.3~beta1+dfsg/test/Makefile.in --- clamav-0.99.2+dfsg/test/Makefile.in 2016-04-22 16:19:54.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/test/Makefile.in 2017-06-23 21:20:59.000000000 +0000 @@ -87,10 +87,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -145,12 +146,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -240,6 +246,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -267,7 +275,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -361,6 +378,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ @@ -598,7 +616,7 @@ all: $(FILES) $(FILES) : - cat $(SPLIT_DIR)/split.$@aa $(SPLIT_DIR)/split.$@ab > $@ + cat $(SPLIT_DIR)/split.$@a* > $@ clean-local: rm -f clam* Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeaa and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeaa differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeab and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeab differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeac and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeac differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exead and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exead differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeae and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeae differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeaf and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeaf differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeag and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeag differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeah and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeah differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeai and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeai differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeaj and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeaj differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeak and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeak differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeal and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeal differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeam and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeam differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exean and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exean differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeao and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeao differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_ext.exeap and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_ext.exeap differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_int.exeaa and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_int.exeaa differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_int.exeab and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_int.exeab differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_int.exeac and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_int.exeac differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam_IScab_int.exead and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam_IScab_int.exead differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam.isoaa and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam.isoaa differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam.isoab and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam.isoab differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam.isoac and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam.isoac differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam.isoad and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam.isoad differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam.isoae and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam.isoae differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam.isoaf and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam.isoaf differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clam.isoag and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clam.isoag differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clamjol.isoaa and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clamjol.isoaa differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clamjol.isoab and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clamjol.isoab differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clamjol.isoac and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clamjol.isoac differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clamjol.isoad and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clamjol.isoad differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clamjol.isoae and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clamjol.isoae differ Binary files /tmp/tmpDFPV1u/Bn37grBwgO/clamav-0.99.2+dfsg/test/.split/split.clamjol.isoaf and /tmp/tmpDFPV1u/C3wPGn26RJ/clamav-0.99.3~beta1+dfsg/test/.split/split.clamjol.isoaf differ diff -Nru clamav-0.99.2+dfsg/unit_tests/check_clamd.c clamav-0.99.3~beta1+dfsg/unit_tests/check_clamd.c --- clamav-0.99.2+dfsg/unit_tests/check_clamd.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/unit_tests/check_clamd.c 2016-10-13 15:45:44.000000000 +0000 @@ -42,7 +42,9 @@ #include #include +#ifdef HAVE_SYS_SELECT_H #include +#endif #include #include #include diff -Nru clamav-0.99.2+dfsg/unit_tests/check_jsnorm.c clamav-0.99.3~beta1+dfsg/unit_tests/check_jsnorm.c --- clamav-0.99.2+dfsg/unit_tests/check_jsnorm.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/unit_tests/check_jsnorm.c 2017-03-08 14:06:34.000000000 +0000 @@ -145,7 +145,7 @@ START_TEST (test_token_dval) { - int val = 0.12345; + double val = 0.12345; yystype tok; memset(&tok, 0, sizeof(tok)); diff -Nru clamav-0.99.2+dfsg/unit_tests/check_regex.c clamav-0.99.3~beta1+dfsg/unit_tests/check_regex.c --- clamav-0.99.2+dfsg/unit_tests/check_regex.c 2016-04-22 15:02:19.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/unit_tests/check_regex.c 2017-04-20 22:19:13.000000000 +0000 @@ -461,27 +461,27 @@ fail_unless(rc == CL_CLEAN,"phishingScan"); switch(rtest->result) { case 0: - fail_unless_fmt(ctx.found_possibly_unwanted, + fail_unless_fmt(ctx.num_viruses, "this should be phishing, realURL: %s, displayURL: %s", rtest->realurl, rtest->displayurl); break; case 1: - fail_unless_fmt(!ctx.found_possibly_unwanted, + fail_unless_fmt(!ctx.num_viruses, "this should be whitelisted, realURL: %s, displayURL: %s", rtest->realurl, rtest->displayurl); break; case 2: - fail_unless_fmt(!ctx.found_possibly_unwanted, + fail_unless_fmt(!ctx.num_viruses, "this should be clean, realURL: %s, displayURL: %s", rtest->realurl, rtest->displayurl); break; case 3: if(!loaded_2) - fail_unless_fmt(!ctx.found_possibly_unwanted, + fail_unless_fmt(!ctx.num_viruses, "this should be clean, realURL: %s, displayURL: %s", rtest->realurl, rtest->displayurl); else { - fail_unless_fmt(ctx.found_possibly_unwanted, + fail_unless_fmt(ctx.num_viruses, "this should be blacklisted, realURL: %s, displayURL: %s", rtest->realurl, rtest->displayurl); if (*ctx.virname) diff -Nru clamav-0.99.2+dfsg/unit_tests/Makefile.in clamav-0.99.3~beta1+dfsg/unit_tests/Makefile.in --- clamav-0.99.2+dfsg/unit_tests/Makefile.in 2016-04-22 16:19:54.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/unit_tests/Makefile.in 2017-06-23 21:20:59.000000000 +0000 @@ -89,10 +89,11 @@ $(top_srcdir)/m4/ax_check_uname_syscall.m4 \ $(top_srcdir)/m4/fdpassing.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/llvm.m4 \ - $(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.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/lib-prelude.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/llvm.m4 $(top_srcdir)/m4/ltargz.m4 \ + $(top_srcdir)/m4/ltdl.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/mmap_private.m4 $(top_srcdir)/m4/resolv.m4 \ $(top_srcdir)/m4/reorganization/version.m4 \ $(top_srcdir)/m4/reorganization/build_tools.m4 \ @@ -147,12 +148,17 @@ $(top_srcdir)/m4/reorganization/clamdtop.m4 \ $(top_srcdir)/m4/reorganization/distcheck.m4 \ $(top_srcdir)/m4/reorganization/llvm.m4 \ + $(top_srcdir)/libclamav/c++/m4/llvm-opts.m4 \ $(top_srcdir)/m4/reorganization/sha_collect.m4 \ $(top_srcdir)/m4/reorganization/yara.m4 \ + $(top_srcdir)/m4/reorganization/code_checks/fts.m4 \ $(top_srcdir)/m4/reorganization/libfreshclam.m4 \ + $(top_srcdir)/m4/reorganization/prelude.m4 \ $(top_srcdir)/m4/reorganization/bsd.m4 \ $(top_srcdir)/m4/reorganization/libs/curl.m4 \ $(top_srcdir)/m4/reorganization/substitutions.m4 \ + $(top_srcdir)/m4/reorganization/libmspack.m4 \ + $(top_srcdir)/libclamav/libmspack-0.5alpha/m4/libmspack-opts.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -530,6 +536,8 @@ GPERF = @GPERF@ GREP = @GREP@ HAVE_YARA = @HAVE_YARA@ +ICONV_CPPFLAGS = @ICONV_CPPFLAGS@ +ICONV_LDFLAGS = @ICONV_LDFLAGS@ INCLTDL = @INCLTDL@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -557,7 +565,16 @@ LIBCLAMSHARED_CPPFLAGS = @LIBCLAMSHARED_CPPFLAGS@ LIBLTDL = @LIBLTDL@ LIBM = @LIBM@ +LIBMSPACK_CFLAGS = @LIBMSPACK_CFLAGS@ +LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ +LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@ +LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@ +LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@ +LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@ +LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@ +LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@ +LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ @@ -651,6 +668,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +llvmconfig = @llvmconfig@ localedir = @localedir@ localstatedir = @localstatedir@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ diff -Nru clamav-0.99.2+dfsg/unit_tests/valgrind.supp clamav-0.99.3~beta1+dfsg/unit_tests/valgrind.supp --- clamav-0.99.2+dfsg/unit_tests/valgrind.supp 2016-04-22 16:19:09.000000000 +0000 +++ clamav-0.99.3~beta1+dfsg/unit_tests/valgrind.supp 2016-10-13 15:45:44.000000000 +0000 @@ -99,3 +99,21 @@ fun:scanmanager fun:main } +{ + dlopen-libcheck-overread + Memcheck:Addr8 + ... + fun:vm_open + fun:tryall_dlopen + fun:find_handle_callback + fun:foreach_dirinpath + ... +} +{ + lib-ltdl + Memcheck:Addr8 + obj:/libexec/ld-elf* + ... + obj:/usr/*lib*/libltdl* + fun:lt_dlopen +}