cabextract-1.4/0000755000175000017500000000000011562533600010500 500000000000000cabextract-1.4/doc/0000755000175000017500000000000011562533600011245 500000000000000cabextract-1.4/doc/ja/0000755000175000017500000000000011562533600011637 500000000000000cabextract-1.4/doc/ja/cabextract.10000644000175000017500000000450107730101333013755 00000000000000.TH CABEXTRACT 1 "2003ǯ 4·î20Æü" .SH ̾Á° cabextract \- Microsoft cabinet (.cab) archives ¤«¤é¥Õ¥¡¥¤¥ë¤ò²òÅह¤ë¥×¥í¥°¥é¥à .SH ½ñ¼° .B cabextract .RB [ -d \fIdir\fP ] .RB [ -f ] .RB [ -F \fIpattern\fP ] .RB [ -h ] .RB [ -l ] .RB [ -L ] .RB [ -p ] .RB [ -q ] .RB [ -s ] .RB [ -v ] .I " ¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë" ... .SH ¾ÜºÙ .B cabextract ¤Ï¡¢Microsoft ¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë·Á¼° (.cab) ¤Þ¤¿¤Ï¡¢ ¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë¤¬Ëä¤á¹þ¤Þ¤ì¤¿ ¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë (¤è¤¯ .exe ¥Õ¥¡¥¤¥ë¤Ç¸«¤Ä¤«¤ë) ¤«¤é²òÅह¤ë¥×¥í¥°¥é¥à¤Ç¤¹¡£ .PP .B cabextract ¤Ï¡¢¥³¥Þ¥ó¥É¥é¥¤¥ó¾å¤Ç»ØÄꤵ¤ì¤¿Á´¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë¤«¤é ¥Õ¥¡¥¤¥ë¤òÃê½Ð¤¹¤ë¤Ç¤·¤ç¤¦¡£ .PP ´ö¤Ä¤«¤Î¥Õ¥¡¥¤¥ë¤Ëʬ³ä¤µ¤ì¤¿¥Þ¥ë¥Á¥Ñ¡¼¥È¤Î¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë ¤Î¾ì¹ç¤Ï¡¢ .I ºÇ½é¤Î ¥Õ¥¡¥¤¥ë¤Î¤ß¤ò .B cabextract ¤Î°ú¿ô¤ËÍ¿¤¨¤ì¤Ð¡¢»Ä¤ê¤Î¥Õ¥¡¥¤¥ë¤ò¼«Æ°Åª¤Ë¸¡½Ð¤·¤Þ¤¹¡£ »ØÄꤷ¤Ê¤¤¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë¤ò .B cabextract ¤¬¥ê¥¹¥È¤Þ¤¿¤Ï²òÅष¤Æ¤·¤Þ¤¦¤Î¤ò Í޻ߤ¹¤ë¤Ë¤Ï¡¢-s ¥ª¥×¥·¥ç¥ó¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£ .SH ¥ª¥×¥·¥ç¥ó ¥ª¥×¥·¥ç¥ó¤ÎÍ×Ìó¤Ï¡¢°Ê²¼¤ò»²¾È²¼¤µ¤¤¡£ .TP .B \-d \fIdir\fP ¥Ç¥£¥ì¥¯¥È¥ê \fIdir\fP ¤ËÁ´¤Æ¤Î¥Õ¥¡¥¤¥ë¤ò²òÅष¤Þ¤¹¡£ .TP .B \-f ¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë¤òÃê½Ð¤¹¤ë¾ì¹ç¡¢ ÌäÂ꤬¤¢¤Ã¤¿ MSZIP ¥Ö¥í¥Ã¥¯¤ò̵»ë¤·¤Þ¤¹¡£ ÌäÂ꤬¤¢¤Ã¤¿ MSZIP ¥Ö¥í¥Ã¥¯¤¬¤¢¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢ ·Ù¹ð¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤·¤Þ¤¹¡£ .TP .B \-F \fIpattern\fP ¥·¥§¥ë¡¦¥Ñ¥¿¡¼¥ó \fIpattern\fP ¤È°ìÃפ¹¤ë̾Á°¤Î¥Õ¥¡¥¤¥ë¤Î¤ß¤¬²òÅव¤ì¤Þ¤¹¡£ ÈóGNU ¥·¥¹¥Æ¥à¤Ë¤ª¤¤¤Æ¤Ï¡¢¤³¤Î°ìÃפϡ¢¥±¡¼¥¹¥»¥ó¥·¥Æ¥£¥Ö¤Ç¤¹¡£ .TP .B \-h ¥Ø¥ë¥×¤Î¥Ú¡¼¥¸¤òɽ¼¨¤·½ªÎ»¤·¤Þ¤¹¡£ .TP .B \-l ¤½¤ì¤é¤òÃê½Ð¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢ »ØÄꤵ¤ì¤¿¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë¤ÎÆâÍÆ¤ò°ìÍ÷ɽ¼¨¤·¤Þ¤¹¡£ .TP .B \-L ¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë¤òÃê½Ð¤¹¤ë¾ì¹ç¡¢ ³Æ²òÅव¤ì¤¿¥Õ¥¡¥¤¥ë̾¤ò¾®Ê¸»ú¤È¤·¤ÆºîÀ®¤¹¤ë¡£ .TP .B \-p ¥Õ¥¡¥¤¥ë¤Ï¡¢É¸½à½ÐÎϤ˲òÅव¤ì¤Þ¤¹¡£ .TP .B \-q ¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë¤òÃê½Ð¤¹¤ë¾ì¹ç¡¢ ¥¨¥é¡¼¤È·Ù¹ð¥á¥Ã¥»¡¼¥¸¤ò½ü¤­¡¢Á´¤Æ¤Î¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤·¤Þ¤»¤ó¡£ .TP .B \-s Ê£¿ô¤Î¥Õ¥¡¥¤¥ë¤Ë¤Þ¤¿¤¬¤ë¥­¥ã¥Ó¥Í¥Ã¥È¤ò¥ê¥¹¥È¤¹¤ë¤«²òÅह¤ë¾ì¹ç¡¢ ¥³¥Þ¥ó¥É¥é¥¤¥ó¾å¤Ç»ØÄꤷ¤¿¥­¥ã¥Ó¥Í¥Ã¥È¡¦¥Õ¥¡¥¤¥ë¤Î¤ß¤ò»ÈÍѤ·¤Þ¤¹¡£ .TP .B \-v ¥³¥Þ¥ó¥É¥é¥¤¥ó¤«¤é¡¢Ã±ÆÈ¤Ç»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢ .B cabextract ¤Î¥Ð¡¼¥¸¥ç¥óÈÖ¹æ¤òɽ¼¨¤·¤Æ½ªÎ»¤·¤Þ¤¹¡£ ¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë¤Î¥ê¥¹¥È¤òÍ¿¤¨¤¿¾ì¹ç¤Ï¡¢ ¥­¥ã¥Ó¥Í¥Ã¥È¥Õ¥¡¥¤¥ë¤ÎÆâÍÆ¤ò°ìÍ÷ɽ¼¨¤·¤Þ¤¹¡£ .SH Ãø¼Ô ¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ï¡¢ Stuart Caie ¤Ë¤è¤Ã¤Æ½ñ¤«¤ì¡¢ Debian GNU/Linux ¥·¥¹¥Æ¥à¤Î¤¿¤á¤Ë¡¢ Eric Sharkey ¤Î¤ß¤Ë¤è¤Ã¤Æ¥Ù¡¼¥¹¤¬½ñ¤«¤ì¤Þ¤·¤¿¡£ .SH Ìõ¼Ô ÆüËܸìÌõ¤Ï¡¢Katsumi Saito ¤¬ ¹Ô¤¤¤Þ¤·¤¿¡£ cabextract-1.4/doc/cabextract.10000644000175000017500000000460110401407360013362 00000000000000.TH CABEXTRACT 1 "October 30, 2005" .SH NAME cabextract \- program to extract files from Microsoft cabinet (.cab) archives .SH SYNOPSIS .B cabextract .RB [ -d \fIdir\fP ] .RB [ -f ] .RB [ -F \fIpattern\fP ] .RB [ -h ] .RB [ -l ] .RB [ -L ] .RB [ -p ] .RB [ -q ] .RB [ -s ] .RB [ -t ] .RB [ -v ] .I " cabinet files" ... .SH DESCRIPTION .B cabextract is a program that un-archives files in the Microsoft cabinet file format (.cab) or any binary file which contains an embedded cabinet file (frequently found in .exe files). .PP .B cabextract will extract all files from all cabinet files specified on the command line. .PP To extract a multi\-part cabinet consisting of several files, only the .I first cabinet file needs to be given as an argument to .B cabextract as it will automatically look for the remaining files. To prevent .B cabextract from extracting cabinet files you did not specify, use the .B -s option. .SH OPTIONS A summary of options is included below. .TP .B \-d \fIdir\fP Extracts all files into the directory \fIdir\fP. .TP .B \-f When testing or extracting cabinet files, corrupted MSZIP blocks will be ignored. A warning will be printed if a corrupted MSZIP block is encountered. .TP .B \-F \fIpattern\fP Only files with names that match the shell pattern \fIpattern\fP shall be listed, tested or extracted. On non-GNU systems, this match may be case-sensitive. .TP .B \-h Prints a page of help and exits. .TP .B \-l Lists the contents of the given cabinet files, rather than extracting them. .TP .B \-L When extracting cabinet files, makes each extracted file's name lowercase. .TP .B \-p Files shall be extracted to standard output. .TP .B \-q When extracting cabinet files, suppresses all messages except errors and warnings. .TP .B \-s When testing, listing or extracting cabinets which span multiple files, only cabinet files given on the command line shall be used. .TP .B \-t Tests the integrity of the cabinet. Files are decompressed, but not written to disk or standard output. If the file successfully decompresses, the MD5 checksum of the file is printed. .TP .B \-v If given alone on the command line, prints the version of .B cabextract and exits. Given with a list of cabinet files, it will list the contents of the cabinet files. .SH AUTHOR This manual page was written by Stuart Caie , based on the one written by Eric Sharkey , for the Debian GNU/Linux system. cabextract-1.4/doc/magic0000644000175000017500000000235507730101333012171 00000000000000#------------------------------------------------------------------------------ # Microsoft Cabinet files # # From (part of cabextract package) 0 string MSCF\0\0\0\0 Microsoft Cabinet file >8 lelong x \b, %u bytes >28 leshort 1 \b, 1 file >28 leshort >1 \b, %u files #------------------------------------------------------------------------------ # InstallShield Cabinet files # # From (part of cabextract package) 0 string ISc( InstallShield Cabinet file >5 byte&0xf0 =0x60 version 6, >5 byte&0xf0 !0x60 version 4/5, >(12.l+40) lelong x %u files #------------------------------------------------------------------------------ # Windows CE package files # # From (part of cabextract package) 0 string MSCE\0\0\0\0 Microsoft WinCE install header >20 lelong 0 \b, architecture-independent >20 lelong 103 \b, Hitachi SH3 >20 lelong 104 \b, Hitachi SH4 >20 lelong 0xA11 \b, StrongARM >20 lelong 4000 \b, MIPS R4000 >20 lelong 10003 \b, Hitachi SH3 >20 lelong 10004 \b, Hitachi SH3E >20 lelong 10005 \b, Hitachi SH4 >20 lelong 70001 \b, ARM 7TDMI >52 leshort 1 \b, 1 file >52 leshort >1 \b, %u files >56 leshort 1 \b, 1 registry entry >56 leshort >1 \b, %u registry entries cabextract-1.4/doc/wince_cab_format.html0000644000175000017500000005630011515537077015353 00000000000000 Windows CE installation cabinet (.CAB) file format

Windows CE installation cabinet (.CAB) file format

Table of Contents

About the format

The Windows CE installation cabinet format was designed by Microsoft make it easy to create packaged software for the Windows CE platform. After generating all his executable programs, data files, help files and so on, a developer can then write an "installation script" which lists the name of the software package, where each file should be installed on the target device's filesystem, registry entries to make on the target system's Windows Registry, and so on. A tool called "CabWiz" takes the installation script and produces a single CAB file with a special control file stored in it. On the target Windows CE device, a program called WCELOAD.EXE will read cabinet files, install them, register them as installed packages, set their registry entries, and so on.

The Cabinet format was previously developed by Microsoft for creating a simple archive format for packaged software, from entire operating systems down to ActiveX Web plugins. They also intended to displace Sun's JAR format for packaging Java software, but this did not succeed.

Overall cabinet file format

Firstly, the overall file format of a Windows CE installation cabinet is the standard Microsoft Cabinet file format. This was originally documented in the Microsoft document CABFMT.DOC as part of the Microsoft Cabinet SDK (CAB-SDK.EXE), it is now documented in the Windows Installer documentation. The format can also be gleaned from open source tools and libraries such as cabextract and libmspack. Windows CE installation cabinets typically use no compression (the NONE compression method in the cabinet specification), sometimes MSZIP compression.

Cabinet file contents

The filenames of the files in the cabinet use the MS-DOS "8.3" convention, where the first eight characters in the filename come from the "true filename", and are followed by a period and three numeric digits. The digits form a decimal number from 000 to 999. The name part before the period is currently always 8 characters (shorter names are padded on the left with "0"), but this shouldn't be relied upon. Only the numeric extension should be used to identify the file. There should not be more than one file in the cabinet with the same numeric extension. As an example:

Name in cab fileOriginal filename
BLKJAC~4.000--- (installation data)
BLACKJ~1.999Blackjack Setup.dll
SELFRE~1.006SelfRegister.dll
0Blkjack.005Blkjack.exe
00Sample.004Sample.BJL
WINGAM~1.003Win Game.wav
LOSEGA~1.002Lose Game.wav
BLACKJ~1.001Blackjack Help.htp

The order of these files within the cab file is important. The first file in the cabinet should be the ".000" file. It should then be followed by all other files in descending numerical order of their extensions.

These original filenames are not recoverable, they are not stored anywhere. The only names available are the target filenames given in the FILES section of the .000 file.

All installation data is contained in the .000 file. If a .999 file exists, it is an "application specific Setup.DLL"; a Microsoft standard Dynamic Link Library that will be loaded and executed after installation by the installation program. All other files are files for installation on the Windows CE device, and the three digits should be resolved into an integer "file number".

Format of the .000 file

All multi-byte integers are little-endian. Values given in this document are in decimal, unless otherwise specified. The overall file format of the .000 file is as follows:

Only the fixed size header has a fixed file offset, all other strings and sections may be at any file offset, in any order. They are typically in the order given above. Each file offset is given in the fixed size header.

The fixed size header

The .000 file begins at file offset 0 with a fixed size header of exactly 100 bytes. The format of this header is as follows:

OffsetSize in bytesDescription
04An ASCII signature, "MSCE". This is 0x4543534D as a little-endian integer.
44Unknown purpose, usually 0.
84The overall length of this .000 header file, in bytes.
124Unknown purpose, usually 0.
164Unknown purpose, usually 1.
204Target architecture for this cabinet: see Appendix A.
244Minimal version of WinCE (major version number) required to install this cabinet, or 0 to indicate no restriction.
284Minimal version of WinCE (minor version number) required to install this cabinet, or 0 to indicate no restriction.
324Maximal version of WinCE (major version number) required to install this cabinet, or 0 to indicate no restriction.
364Maximal version of WinCE (minor version number) required to install this cabinet, or 0 to indicate no restriction.
404Minmal version of WinCE (build number) required to install this cabinet, or 0 to indicate no restriction.
444Maximal version of WinCE (build number) required to install this cabinet, or 0 to indicate no restriction.
482The number of entries in the STRINGS section.
502The number of entries in the DIRS section.
522The number of entries in the FILES section.
542The number of entries in the REGHIVES section.
562The number of entries in the REGKEYS section.
582The number of entries in the LINKS section.
604The file offset of the STRINGS section in bytes.
644The file offset of the DIRS section in bytes.
684The file offset of the FILES section in bytes.
724The file offset of the REGHIVES section in bytes.
764The file offset of the REGKEYS section in bytes.
804The file offset of the LINKS section, in bytes.
842The file offset of the APPNAME string in bytes.
862The length of the APPNAME string in bytes, including null terminating byte.
882The file offset of the PROVIDER string in bytes.
902The length of the PROVIDER string in bytes, including null terminating byte.
922The file offset of the UNSUPPORTED multi string in bytes.
942The length of the UNSUPPORTED multi string in bytes, including null terminating byte.
962Unknown purpose, usually 0.
982Unknown purpose, usually 0.

The APPNAME string

This is a null-terminated ASCII string that gives the name of the packaged application.

The PROVIDER string

This is a null-terminated ASCII string that gives the name of the author or publisher of the packaged application.

The UNSUPPORTED multi string

If this string has more than zero bytes length according to the fixed size header, then this is a sequence of consecutive null terminated ASCII strings. The sequence always terminates with an empty string. Each string is the ASCII name of a Windows CE platform where this software is not supported and will not run. Platforms seen in this sequence include "PALM PC", "HPC", "JORDAN", "PALM PC2" and "POCKETPC".

The STRINGS section

The STRINGS section is a number of common ASCII strings that may be used in the installation data. In other sections, strings from the STRINGS section are referred to by their string ID. The total number of entries in this section is given in the fixed size header. There is no padding between string entries. The format of each STRING entry is as follows:

  • 2 bytes: An integer string ID.
  • 2 bytes: The length of the string, including the null terminator byte.
  • X bytes: the string itself, for the length given above.

As an example, the hexadecimal byte stream 04 00 09 00 53 6F 66 74 77 61 72 65 00 decodes to "ID=4 (04 00), length=9 (09 00), string=Software". The hexadecimal byte stream 05 00 0A 00 4D 69 63 72 6F 73 6F 66 74 00 decodes to "ID=5 (05 00), length=10 (0A 00), string=Microsoft".

The DIRS section

The DIRS section is a list of directory paths used in the installation. In other sections, paths from the DIRS section are referred to by their directory ID. The total number of entries in this section is given in the fixed size header. There is no padding between directory entries. The format of each directory entry is as follows:

  • 2 bytes: An integer directory ID.
  • 2 bytes: The length of the following directory specification, in bytes.
  • X bytes: A directory specification. This is simply an array of 16-bit (2 byte) numbers, where each number is a string ID. The final number is always 0, which terminates the list.

For example, the hexidecimal byte stream 01 00 0A 00 01 00 02 00 03 00 04 00 00 translates "dir ID=1 (01 00), length=10 (0A 00), specification={1, 2, 3, 4}". Assuming string ID 1 is "foo", string ID 2 is "bar", string ID 3 is "baz" and string ID 4 is "quux", the specification translates from {1, 2, 3, 4} to "foo\bar\baz\quux".

The directory specification may begin with a path member of the form "%CEn%", where n is a decimal integer from 1 to 17. This is an abbreviation for one of the CE standard directories, as listed in Appendix B.

The FILES section

The FILES section is a list of files to be installed on the target device. All files in the list should be installed. In other sections, files from the FILES section are referred to by their file ID. The total number of entries in this section is given in the fixed size header. There is no padding between file entries. The format of each file entry is as follows:

  • 2 bytes: An integer file ID. The file for installation is the file in the cabinet which has this integer as a three digit file extension.
  • 2 bytes: The directory ID for where this file should be installed.
  • 2 bytes: Unknown purpose, usually the same as the file ID.
  • 4 bytes: File flags. A 32-bit integer. The following bits are known:
    FlagDescription
    Bit 31 (0x80000000) If bit is set, this file is a reference-counting shared file. It is not deleted at uninstall time unless its reference count is 0.
    Bit 30 (0x40000000)If bit is set, ignore file date (stored in the cabinet file) and always overwrite target (on CE device). Mutually exclusive with bit 29.
    Bit 29 (0x20000000)If bit is set, do not overwrite target if target is newer. Mutually exclusive with bit 30.
    Bit 28 (0x10000000)If bit is set, self-register this DLL.
    Bit 10 (0x00000400)If bit is set, do not copy this file to the target unless the target already exists. Mutually exclusive with bit 4.
    Bit 4 (0x00000010)If bit is set, do not overwrite target if it already exists. Mutually exclusive with bit 10.
    Bit 1 (0x00000002)If bit is set, do not skip this file.
    Bit 0 (0x00000001)If bit is set, warn the user if this file is skipped.
    All other bits are unknown.
  • 2 bytes: the length of the installed file's filename, including the null terminator.
  • X bytes: the installed file's filename, with the length given above. A null terminated ASCII string.

The REGHIVES section

The REGHIVES section is a list of hives in the Windows Registry. These hives are then used in the REGKEYS section for actual registry entries. In other sections, hives from the REGHIVES section are referred to by their hive ID. The total number of entries in this section is given in the fixed size header. There is no padding between hive entries. The format of each hive entry is as follows:

  • 2 bytes: An integer hive ID.
  • 2 bytes: The hive root, an integer from 1 to 4:
    1. HKCR: HKEY_CLASSES_ROOT
    2. HKCU: HKEY_CURRENT_USER
    3. HKLM: HKEY_LOCAL_MACHINE
    4. HKU: HKEY_USERS
  • 2 bytes: Unknown purpose, usually 0.
  • 2 bytes: Length of the registry hive specification to follow, in bytes.
  • X bytes: A registry hive specification. This is simply an array of 16-bit (2 byte) numbers, where each number is a string ID. The final number is always 0, which terminates the list.

The REGKEYS section

The REGKEYS is a list of registry entries -- key / data pairs -- to be added to the Windows Registry upon installation. All entries in the list should be added. The total number of entries in this section is given in the fixed size header. There is no padding between entries. The format of each entry is as follows:

  • 2 bytes: An integer key ID.
  • 2 bytes: The hive ID of the hive to store this entry in.
  • 2 bytes: A Boolean value, either 1 if variable substitution should be performed or 0 if not. The entry data should have substrings such as %InstallDir% or one the %CEn% values.
  • 4 bytes: The type of entry data, and flags.
    FlagDescription
    Bit 16 set, bit 0 set (0x00010001)This key is of type TYPE_DWORD, a 32-bit integer.
    Bit 16 clear, bit 0 clear (0x00000000)This key is of type TYPE_SZ, a null terminated ASCII string.
    Bit 16 set, bit 0 clear (0x00010000)This key is of type TYPE_MULTI_SZ, a list of null terminated ASCII strings.
    Bit 16 clear, bit 0 set (0x00000001)This key is of type TYPE_BINARY, raw binary data in no particular format.
    Bit 1 (0x00000002)This is the only known flag, NOCLOBBER. If this bit is set, the registry entry should not be overwritten if it already exists in the registry.
    All other bits are undefined.
  • 2 bytes: The length of entry data to follow, in bytes.
  • X bytes: Registry entry data. This begins with a null terminated ASCII string, giving the name of the registry key. If the empty string is used here, this is the default key for the given hive. Immediately following the null byte of the string is the data for the registry entry, whose format depends on the entry type given in the flags:
    • TYPE_DWORD: four bytes, giving a single 32-bit integer.
    • TYPE_SZ: a single null terminated ASCII string.
    • TYPE_MULTI_SZ: a sequence of consecutive null terminated ASCII strings. The sequence always terminates with an empty string.
    • TYPE_BINARY: no specific format, just raw data.

The LINKS section

The LINKS section is a list of symbolic links to be made in the standard installation directories, to link to installed directories or files. The total number of links in this section is given in the fixed size header. There is no padding between links. Each link has the following format:

  • 2 bytes: An integer link ID.
  • 2 bytes: Unknown purpose.
  • 2 bytes: The base directory where the link will be stored, either 0 to indicate "%InstallDir%", the default directory where the application is installed, or a number from 1 to 17 to indicate "%CEn%", one of the standard installation directories as defined in Appendix B. The link specification, given below, should be added to this base directory, to get the full name of the link.
  • 2 bytes: Integer ID of the file or directory that the link should point to. It is either a file ID, or a directory ID, depending on the link type. If it is a directory ID, the ID 0 can be used to refer to %InstallDir%.
  • 2 bytes: The link type. This is 0 if the link target is a directory, or 1 if the link target is a file.
  • 2 bytes: The length of the link specification in bytes.
  • X bytes: The link specification. This is simply an array of 16-bit (2 byte) numbers, where each number is a string ID. The final number is always 0, which terminates the list.

Appendix A: a list of processor architectures

ValueDescription
0No specific architecture
103SHx SH3
104SHx SH4
386Intel 386
486Intel 486
586Intel Pentium
601PowerPC 601
603PowerPC 603
604PowerPC 604
620PowerPC 620
821Motorola 821
1824ARM 720
2080ARM 820
2336ARM 920
2577StrongARM
4000MIPS R4000
10003Hitachi SH3
10004Hitachi SH3E
10005Hitachi SH4
21064Alpha 21064
70001ARM 7TDMI

Appendix B: a list of %CEn% shortcuts

First, for a Handheld PC:

ValueStandard directory
%CE1%\Program Files
%CE2%\Windows
%CE3%\Windows\Desktop
%CE4%\Windows\StartUp
%CE5%\My Documents
%CE6%\Program Files\Accessories
%CE7%\Program Files\Communications
%CE8%\Program Files\Games
%CE9%\Program Files\Pocket Outlook
%CE10%\Program Files\Office
%CE11%\Windows\Programs
%CE12%\Windows\Programs\Accessories
%CE13%\Windows\Programs\Communications
%CE14%\Windows\Programs\Games
%CE15%\Windows\Fonts
%CE16%\Windows\Recent
%CE17%\Windows\Favorites

For a Pocket PC version 1.0 or 2.0, as per Handheld PCs, except

ValueStandard directory
%CE3%undefined
%CE9%undefined
%CE10%undefined
%CE11%\Windows\Start Menu\Programs
%CE12%\Windows\Start Menu\Accessories
%CE13%\Windows\Start Menu\Communications
%CE14%\Windows\Start Menu\Games
%CE16%undefined
%CE17%\Windows\Start Menu

For a Pocket PC version 3.0, as for 1.0 or 2.0, except

ValueStandard directory
%CE6%undefined
%CE7%undefined
%CE8%undefined
%CE12%undefined
%CE13%undefined
%CE16%undefined
cabextract-1.4/mspack/0000755000175000017500000000000011562533600011756 500000000000000cabextract-1.4/mspack/mspack.h0000755000175000017500000024203711562533506013345 00000000000000/* libmspack -- a library for working with Microsoft compression formats. * (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 * * This program is distributed in the hope that 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 * * 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 * * 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 * * 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() * * 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 * * 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) /* --- 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); /* --- 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 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); }; #ifdef __cplusplus } #endif #endif cabextract-1.4/mspack/system.h0000644000175000017500000000671711555576651013425 00000000000000/* 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 /* 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 # define D(x) do { printf("%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 cabextract-1.4/mspack/system.c0000644000175000017500000001406311562206503013371 00000000000000/* 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: 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: 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 cabextract-1.4/mspack/cab.h0000644000175000017500000001150011555335536012603 00000000000000/* 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) /* 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 cabextract-1.4/mspack/cabd.c0000644000175000017500000013260411562533506012746 00000000000000/* 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, struct mscabd_cabinet_p *cab, 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; cabd_free_decomp(self); if (self->d) { if (self->d->infh) sys->close(self->d->infh); 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, cab, &x); if (x) return x; cab->base.previnfo = cabd_read_string(sys, fh, cab, &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, cab, &x); if (x) return x; cab->base.nextinfo = cabd_read_string(sys, fh, cab, &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, cab, &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, struct mscabd_cabinet_p *cab, int *error) { off_t base = sys->tell(fh); char buf[256], *str; unsigned int len, i, ok; /* read up to 256 bytes */ len = sys->read(fh, &buf[0], 256); /* search for a null terminator in the buffer */ for (i = 0, 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; } 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; /* 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)) { /* 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); /* free any existing decompressor */ cabd_free_decomp(self); 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); 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->folder || !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)", 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; } cabextract-1.4/mspack/lzx.h0000644000175000017500000002123411447100513012661 00000000000000/* 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 */ #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 + 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 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 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? */ unsigned char input_end; /* have we reached the end of input? */ 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. * @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 bistream 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. * @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); /* see description of output_length in lzxd_init() */ extern void lzxd_set_output_length(struct lzxd_stream *lzx, off_t output_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 cabextract-1.4/mspack/lzxd.c0000644000175000017500000006030011562206503013021 00000000000000/* 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 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. * * 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. * * 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 generated like so: * for (i = 0; i < 4; i++) extra_bits[i] = 0; * for (i = 4, j = 0; i < 36; i+=2) extra_bits[i] = extra_bits[i+1] = j++; * for (i = 36; i < 51; i++) extra_bits[i] = 17; * for (i = 0, j = 0; i < 51; j += 1 << extra_bits[i++]) position_base[i] = j; */ static const unsigned int position_base[51] = { 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 }; static const unsigned char extra_bits[51] = { 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, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 }; 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) { unsigned int window_size = 1 << window_bits; struct lzxd_stream *lzx; if (!system) return NULL; /* 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 = (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->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; /* 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->o_ptr = lzx->o_end = &lzx->e8_buf[0]; lzxd_reset_state(lzx); INIT_BITS; return lzx; } 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; } /* 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->posn_slots << 3)); 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 */ 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++) { 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 = 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; } 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) { /* 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 = 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; } 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) { /* 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) */ 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", 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; sys->free(lzx->inbuf); sys->free(lzx->window); sys->free(lzx); } } cabextract-1.4/mspack/mszip.h0000644000175000017500000001026711444146601013217 00000000000000/* 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); /* 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 cabextract-1.4/mspack/mszipd.c0000644000175000017500000003522011555777756013402 00000000000000/* 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; } void mszipd_free(struct mszipd_stream *zip) { struct mspack_system *sys; if (zip) { sys = zip->sys; sys->free(zip->inbuf); sys->free(zip); } } cabextract-1.4/mspack/qtm.h0000644000175000017500000001044311444146615012657 00000000000000/* 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 cabextract-1.4/mspack/qtmd.c0000644000175000017500000004067411444147754013034 00000000000000/* 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); } } cabextract-1.4/mspack/readbits.h0000644000175000017500000001675311446704401013660 00000000000000/* 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 cabextract-1.4/mspack/readhuff.h0000644000175000017500000001300711447130225013632 00000000000000/* 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_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; #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; if ((pos += bit_mask) > table_mask) return 1; /* table overflow */ } bit_mask >>= 1; } /* full table? */ return (pos == table_mask) ? 0 : 1; } #endif cabextract-1.4/mspack/ChangeLog0000644000175000017500000004040711562533506013462 000000000000002011-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 :) cabextract-1.4/src/0000755000175000017500000000000011562533600011267 500000000000000cabextract-1.4/src/cabextract.c0000644000175000017500000010771211562533506013510 00000000000000/* cabextract 1.4 - a program to extract Microsoft Cabinet files * (C) 2000-2011 Stuart Caie * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* cabextract uses libmspack to access cabinet files. libmspack is * available from http://www.cabextract.org.uk/libmspack/ */ #define _GNU_SOURCE 1 #if HAVE_CONFIG_H #include #include /* everyone has this! */ #if HAVE_SYS_TYPES_H # include #endif #if HAVE_CTYPE_H # include #endif #if HAVE_ERRNO_H # include #endif #if HAVE_FNMATCH_H # include #endif #if HAVE_LIMITS_H # include #endif #if HAVE_STDARG_H # include #endif #if HAVE_STDLIB_H # include #endif #if HAVE_STRING_H # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #if HAVE_UTIME || HAVE_UTIMES # if HAVE_UTIME_H # include # else # include # endif #endif #if HAVE_DIRENT_H # include #else # define dirent direct # if HAVE_SYS_NDIR_H # include # endif # if HAVE_SYS_DIR_H # include # endif # if HAVE_NDIR_H # include # endif #endif #if !STDC_HEADERS # if !HAVE_STRCHR # define strchr index # define strrchr rindex # endif # if !HAVE_STRCASECMP # define strcasecmp strcmpi # endif # if !HAVE_MEMCPY # define memcpy(d,s,n) bcopy((s),(d),(n)) # endif #endif #if HAVE_MKDIR # if MKDIR_TAKES_ONE_ARG # define mkdir(a, b) mkdir(a) # endif #else # if HAVE__MKDIR # define mkdir(a, b) _mkdir(a) # else # error "Don't know how to create a directory on this system." # endif #endif #ifndef HAVE_MKTIME extern time_t mktime(struct tm *tp); #endif #ifndef FNM_CASEFOLD # define FNM_CASEFOLD (0) #endif #include "getopt.h" #endif #include #include /* structures and global variables */ struct option optlist[] = { { "directory", 1, NULL, 'd' }, { "fix", 0, NULL, 'f' }, { "filter", 1, NULL, 'F' }, { "help", 0, NULL, 'h' }, { "list", 0, NULL, 'l' }, { "lowercase", 0, NULL, 'L' }, { "pipe", 0, NULL, 'p' }, { "quiet", 0, NULL, 'q' }, { "single", 0, NULL, 's' }, { "test", 0, NULL, 't' }, { "version", 0, NULL, 'v' }, { NULL, 0, NULL, 0 } }; struct file_mem { struct file_mem *next; dev_t st_dev; ino_t st_ino; char *from; }; struct cabextract_args { int help, lower, pipe, view, quiet, single, fix, test; char *dir, *filter; }; /* global variables */ struct mscab_decompressor *cabd = NULL; struct file_mem *cab_args = NULL; struct file_mem *cab_exts = NULL; struct file_mem *cab_seen = NULL; mode_t user_umask; struct cabextract_args args = { 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL }; /** A special filename. Extracting to this filename will send the output * to standard output instead of a file on disk. The magic happens in * cabx_open() when the STDOUT_FNAME pointer is given as a filename, so * treat this like a constant rather than a string. */ const char *STDOUT_FNAME = "stdout"; /** A special filename. Extracting to this filename will send the output * through an MD5 checksum calculator, instead of a file on disk. The * magic happens in cabx_open() when the TEST_FNAME pointer is given as a * filename, so treat this like a constant rather than a string. */ const char *TEST_FNAME = "test"; /** A global MD5 context, used when a file is written to TEST_FNAME */ struct md5_ctx md5_context; /** The resultant MD5 checksum, used when a file is written to TEST_FNAME */ unsigned char md5_result[16]; /* prototypes */ static int process_cabinet(char *cabname); static void load_spanning_cabinets(struct mscabd_cabinet *basecab, char *basename); static char *find_cabinet_file(char *origcab, char *cabname); static int unix_path_seperators(struct mscabd_file *files); static char *create_output_name(unsigned char *fname, unsigned char *dir, int lower, int isunix, int unicode); static void set_date_and_perm(struct mscabd_file *file, char *filename); static void memorise_file(struct file_mem **fml, char *name, char *from); static int recall_file(struct file_mem *fml, char *name, char **from); static void forget_files(struct file_mem **fml); static int ensure_filepath(char *path); static char *cab_error(struct mscab_decompressor *cd); static struct mspack_file *cabx_open(struct mspack_system *this, const char *filename, int mode); static void cabx_close(struct mspack_file *file); static int cabx_read(struct mspack_file *file, void *buffer, int bytes); static int cabx_write(struct mspack_file *file, void *buffer, int bytes); static int cabx_seek(struct mspack_file *file, off_t offset, int mode); static off_t cabx_tell(struct mspack_file *file); static void cabx_msg(struct mspack_file *file, const char *format, ...); static void *cabx_alloc(struct mspack_system *this, size_t bytes); static void cabx_free(void *buffer); static void cabx_copy(void *src, void *dest, size_t bytes); /** * A cabextract-specific implementation of mspack_system that allows * the NULL filename to be opened for writing as a synonym for writing * to stdout. */ static struct mspack_system cabextract_system = { &cabx_open, &cabx_close, &cabx_read, &cabx_write, &cabx_seek, &cabx_tell, &cabx_msg, &cabx_alloc, &cabx_free, &cabx_copy, NULL }; int main(int argc, char *argv[]) { int i, err; /* parse options */ while ((i = getopt_long(argc, argv, "d:fF:hlLpqstv", optlist, NULL)) != -1) { switch (i) { case 'd': args.dir = optarg; break; case 'f': args.fix = 1; break; case 'F': args.filter = optarg; break; case 'h': args.help = 1; break; case 'l': args.view = 1; break; case 'L': args.lower = 1; break; case 'p': args.pipe = 1; break; case 'q': args.quiet = 1; break; case 's': args.single = 1; break; case 't': args.test = 1; break; case 'v': args.view = 1; break; } } if (args.help) { fprintf(stderr, "Usage: %s [options] [-d dir] \n\n" "This will extract all files from a cabinet or executable cabinet.\n" "For multi-part cabinets, only specify the first file in the set.\n\n", argv[0]); fprintf(stderr, "Options:\n" " -v --version print version / list cabinet\n" " -h --help show this help page\n" " -l --list list contents of cabinet\n" " -t --test test cabinet integrity\n" " -q --quiet only print errors and warnings\n" " -L --lowercase make filenames lowercase\n" " -f --fix fix (some) corrupted cabinets\n"); fprintf(stderr, " -p --pipe pipe extracted files to stdout\n" " -s --single restrict search to cabs on the command line\n" " -F --filter extract only files that match the given pattern\n" " -d --directory extract all files to the given directory\n\n" "cabextract %s (C) 2000-2011 Stuart Caie \n" "This is free software with ABSOLUTELY NO WARRANTY.\n", VERSION); return EXIT_FAILURE; } if (args.test && args.view) { fprintf(stderr, "%s: You cannot use --test and --list at the same time.\n" "Try '%s --help' for more information.\n", argv[0], argv[0]); return EXIT_FAILURE; } if (optind == argc) { /* no arguments other than the options */ if (args.view) { printf("cabextract version %s\n", VERSION); return 0; } else { fprintf(stderr, "%s: No cabinet files specified.\nTry '%s --help' " "for more information.\n", argv[0], argv[0]); return EXIT_FAILURE; } } /* memorise command-line cabs if necessary */ if (args.single) { for (i = optind; i < argc; i++) memorise_file(&cab_args, argv[i], NULL); } /* extracting to stdout implies shutting up on stdout */ if (args.pipe && !args.view) args.quiet = 1; /* open libmspack */ MSPACK_SYS_SELFTEST(err); if (err) { if (err == MSPACK_ERR_SEEK) { fprintf(stderr, "FATAL ERROR: libmspack is compiled for %d-bit file IO,\n" " cabextract is compiled for %d-bit file IO.\n", (sizeof(off_t) == 4) ? 64 : 32, (sizeof(off_t) == 4) ? 32 : 64); } else { fprintf(stderr, "FATAL ERROR: libmspack self-test returned %d\n", err); } return EXIT_FAILURE; } if (!(cabd = mspack_create_cab_decompressor(&cabextract_system))) { fprintf(stderr, "can't create libmspack CAB decompressor\n"); return EXIT_FAILURE; } /* obtain user's umask */ user_umask = umask(0); umask(user_umask); /* turn on/off 'fix MSZIP' mode */ cabd->set_param(cabd, MSCABD_PARAM_FIXMSZIP, args.fix); /* process cabinets */ for (i = optind, err = 0; i < argc; i++) { err += process_cabinet(argv[i]); } /* error summary */ if (!args.quiet) { if (err) printf("\nAll done, errors in processing %d file(s)\n", err); else printf("\nAll done, no errors.\n"); } /* close libmspack */ mspack_destroy_cab_decompressor(cabd); /* empty file-memory lists */ forget_files(&cab_args); forget_files(&cab_exts); forget_files(&cab_seen); return err ? EXIT_FAILURE : EXIT_SUCCESS; } /** * Processes each file argument on the command line, as specified by the * command line options. This does the main bulk of work in cabextract. * * @param basename the file to process * @return the number of files with errors, usually 0 for success or 1 for * failure */ static int process_cabinet(char *basename) { struct mscabd_cabinet *basecab, *cab, *cab2; struct mscabd_file *file; int isunix, fname_offset, viewhdr = 0; char *from, *name; int errors = 0; /* do not process repeat cabinets */ if (recall_file(cab_seen, basename, &from) || recall_file(cab_exts, basename, &from)) { if (!args.quiet) { if (!from) printf("%s: skipping known cabinet\n", basename); else printf("%s: skipping known cabinet (from %s)\n", basename, from); } return 0; /* return success */ } memorise_file(&cab_seen, basename, NULL); /* search the file for cabinets */ if (!(basecab = cabd->search(cabd, basename))) { if (cabd->last_error(cabd)) { fprintf(stderr, "%s: %s\n", basename, cab_error(cabd)); } else { fprintf(stderr, "%s: no valid cabinets found\n", basename); } return 1; } /* iterate over all cabinets found in that file */ for (cab = basecab; cab; cab = cab->next) { /* load all spanning cabinets */ load_spanning_cabinets(cab, basename); /* determine whether UNIX or MS-DOS path seperators are used */ isunix = unix_path_seperators(cab->files); /* print headers */ if (!viewhdr) { if (args.view) { if (!args.quiet) printf("Viewing cabinet: %s\n", basename); printf(" File size | Date Time | Name\n"); printf("-----------+---------------------+-------------\n"); } else { if (!args.quiet) { printf("%s cabinet: %s\n", args.test ? "Testing" : "Extracting", basename); } } viewhdr = 1; } /* the full UNIX output filename includes the output * directory. However, for filtering purposes, we don't want to * include that. So, we work out where the filename part of the * output name begins. This is the same for every extracted file. */ if (args.filter) { fname_offset = args.dir ? (strlen(args.dir) + 1) : 0; } /* process all files */ for (file = cab->files; file; file = file->next) { /* create the full UNIX output filename */ if (!(name = create_output_name( (unsigned char *) file->filename, (unsigned char *) args.dir, args.lower, isunix, file->attribs & MSCAB_ATTRIB_UTF_NAME))) { errors++; continue; } /* if filtering, do so now. skip if file doesn't match filter */ if (args.filter && fnmatch(args.filter, &name[fname_offset], FNM_CASEFOLD)) { free(name); continue; } /* view, extract or test the file */ if (args.view) { printf("%10u | %02d.%02d.%04d %02d:%02d:%02d | %s\n", file->length, file->date_d, file->date_m, file->date_y, file->time_h, file->time_m, file->time_s, name); } else if (args.test) { if (cabd->extract(cabd, file, TEST_FNAME)) { /* file failed to extract */ printf(" %s failed (%s)\n", name, cab_error(cabd)); errors++; } else { /* file extracted OK, print the MD5 checksum in md5_result. Print * the checksum right-aligned to 79 columns if that's possible, * otherwise just print it 2 spaces after the filename and "OK" */ /* " filename OK " is 8 chars + the length of filename, * the MD5 checksum itself is 32 chars. */ int spaces = 79 - (strlen(name) + 8 + 32); printf(" %s OK ", name); while (spaces-- > 0) putchar(' '); printf("%02x%02x%02x%02x%02x%02x%02x%02x" "%02x%02x%02x%02x%02x%02x%02x%02x\n", md5_result[0], md5_result[1], md5_result[2], md5_result[3], md5_result[4], md5_result[5], md5_result[6], md5_result[7], md5_result[8], md5_result[9], md5_result[10],md5_result[11], md5_result[12],md5_result[13],md5_result[14],md5_result[15]); } } else { /* extract the file */ if (args.pipe) { /* extracting to stdout */ if (cabd->extract(cabd, file, STDOUT_FNAME)) { fprintf(stderr, "%s(%s): %s\n", STDOUT_FNAME, name, cab_error(cabd)); errors++; } } else { /* extracting to a regular file */ if (!args.quiet) printf(" extracting %s\n", name); if (!ensure_filepath(name)) { fprintf(stderr, "%s: can't create file path\n", name); errors++; } else { if (cabd->extract(cabd, file, name)) { fprintf(stderr, "%s: %s\n", name, cab_error(cabd)); errors++; } else { set_date_and_perm(file, name); } } } } free(name); } /* for (all files in cab) */ /* free the spanning cabinet filenames [not freed by cabd->close()] */ for (cab2 = cab->prevcab; cab2; cab2 = cab2->prevcab) free((void*)cab2->filename); for (cab2 = cab->nextcab; cab2; cab2 = cab2->nextcab) free((void*)cab2->filename); } /* for (all cabs) */ /* free all loaded cabinets */ cabd->close(cabd, basecab); return errors; } /** * Follows the spanning cabinet chain specified in a cabinet, loading * and attaching the spanning cabinets as it goes. * * @param basecab the base cabinet to start the chain from. * @param basename the full pathname of the base cabinet, so spanning * cabinets can be found in the same path as the base cabinet. * @see find_cabinet_file() */ static void load_spanning_cabinets(struct mscabd_cabinet *basecab, char *basename) { struct mscabd_cabinet *cab, *cab2; char *name; /* load any spanning cabinets -- backwards */ for (cab = basecab; cab->flags & MSCAB_HDR_PREVCAB; cab = cab->prevcab) { if (!(name = find_cabinet_file(basename, cab->prevname))) { fprintf(stderr, "%s: can't find %s\n", basename, cab->prevname); break; } if (args.single && !recall_file(cab_args, name, NULL)) break; if (!args.quiet) { printf("%s: extends backwards to %s (%s)\n", basename, cab->prevname, cab->previnfo); } if (!(cab2 = cabd->open(cabd,name)) || cabd->prepend(cabd, cab, cab2)) { fprintf(stderr, "%s: can't prepend %s: %s\n", basename, cab->prevname, cab_error(cabd)); if (cab2) cabd->close(cabd, cab2); break; } memorise_file(&cab_exts, name, basename); } /* load any spanning cabinets -- forwards */ for (cab = basecab; cab->flags & MSCAB_HDR_NEXTCAB; cab = cab->nextcab) { if (!(name = find_cabinet_file(basename, cab->nextname))) { fprintf(stderr, "%s: can't find %s\n", basename, cab->nextname); break; } if (args.single && !recall_file(cab_args, name, NULL)) break; if (!args.quiet) { printf("%s: extends to %s (%s)\n", basename, cab->nextname, cab->nextinfo); } if (!(cab2 = cabd->open(cabd,name)) || cabd->append(cabd, cab, cab2)) { fprintf(stderr, "%s: can't append %s: %s\n", basename, cab->nextname, cab_error(cabd)); if (cab2) cabd->close(cabd, cab2); break; } memorise_file(&cab_exts, name, basename); } } /** * Matches a cabinet's filename case-insensitively in the filesystem and * returns the case-correct form. * * @param origcab if this is non-NULL, the pathname part of this filename * will be extracted, and the search will be conducted in * that directory. * @param cabname the internal CAB filename to search for. * @return a copy of the full, case-correct filename of the given cabinet * filename, or NULL if the specified filename does not exist on disk. */ static char *find_cabinet_file(char *origcab, char *cabname) { struct dirent *entry; struct stat st_buf; int found = 0, len; char *tail, *cab; DIR *dir; /* ensure we have a cabinet name at all */ if (!cabname || !cabname[0]) return NULL; /* find if there's a directory path in the origcab */ tail = origcab ? strrchr(origcab, '/') : NULL; len = (tail - origcab) + 1; /* allocate memory for our copy */ if (!(cab = malloc((tail ? len : 2) + strlen(cabname) + 1))) return NULL; /* add the directory path from the original cabinet name, or "." */ if (tail) memcpy(cab, origcab, (size_t) len); else cab[0]='.', cab[1]='/', len=2; cab[len] = '\0'; /* try accessing the cabinet with its current name (case-sensitive) */ strcpy(&cab[len], cabname); if (stat(cab, &st_buf) == 0) { found = 1; } else { /* cabinet was not found, look for it in the current dir */ cab[len] = '\0'; if ((dir = opendir(cab))) { while ((entry = readdir(dir))) { if (strcasecmp(cabname, entry->d_name) == 0) { strcat(cab, entry->d_name); found = (stat(cab, &st_buf) == 0); break; } } closedir(dir); } } if (!found || !S_ISREG(st_buf.st_mode)) { /* cabinet not found, or not a regular file */ free(cab); cab = NULL; } return cab; } /** * Determines whether UNIX '/' or MS-DOS '\' path seperators are used in * the cabinet file. The algorithm is as follows: * * Look at all slashes in all filenames. If there are no slashes, MS-DOS * seperators are assumed (it doesn't matter). If all are backslashes, * MS-DOS seperators are assumed. If all are forward slashes, UNIX * seperators are assumed. * * If not all slashes are the same, go through each filename, looking for * the first slash. If the part of the filename up to and including the * slash matches the previous filename, that kind of slash is the * directory seperator. * * @param files list of files in the cab file * @return 0 for MS-DOS seperators, or 1 for UNIX seperators. */ static int unix_path_seperators(struct mscabd_file *files) { struct mscabd_file *fi; char slash=0, backslash=0, *oldname; int oldlen; for (fi = files; fi; fi = fi->next) { char *p; for (p = fi->filename; *p; p++) { if (*p == '/') slash = 1; if (*p == '\\') backslash = 1; } if (slash && backslash) break; } if (slash) { /* slashes, but no backslashes = UNIX */ if (!backslash) return 1; } else { /* no slashes = MS-DOS */ return 0; } /* special case if there's only one file - just take the first slash */ if (!files->next) { char c, *p = fi->filename; while ((c = *p++)) { if (c == '\\') return 0; /* backslash = MS-DOS */ if (c == '/') return 1; /* slash = UNIX */ } /* should not happen - at least one slash was found! */ return 0; } oldname = NULL; oldlen = 0; for (fi = files; fi; fi = fi->next) { char *name = fi->filename; int len = 0; while (name[len]) { if ((name[len] == '\\') || (name[len] == '/')) break; len++; } if (!name[len]) len = 0; else len++; if (len && (len == oldlen)) { if (strncmp(name, oldname, (size_t) len) == 0) return (name[len-1] == '\\') ? 0 : 1; } oldname = name; oldlen = len; } /* default */ return 0; } /** * Creates a UNIX filename from the internal CAB filename and the given * parameters. * * @param fname the internal CAB filename. * @param dir a directory path to prepend to the output filename. * @param lower if non-zero, filename should be made lower-case. * @param isunix if zero, MS-DOS path seperators are used in the internal * CAB filename. If non-zero, UNIX path seperators are used. * @param utf8 if non-zero, the internal CAB filename is encoded in UTF-8. * @return a freshly allocated and created filename, or NULL if there was * not enough memory. * @see unix_path_seperators() */ static char *create_output_name(unsigned char *fname, unsigned char *dir, int lower, int isunix, int utf8) { unsigned char *p, *name, c, *fe, sep, slash; unsigned int x; sep = (isunix) ? '/' : '\\'; /* the path-seperator */ slash = (isunix) ? '\\' : '/'; /* the other slash */ /* length of filename */ x = strlen((char *) fname); /* UTF-8 worst case scenario: tolower() expands all chars from 1 to 6 bytes */ if (utf8) x *= 6; /* length of output directory */ if (dir) x += strlen((char *) dir); x += 2; if (!(name = malloc(x))) { fprintf(stderr, "Can't allocate output filename (%u bytes)\n", x); return NULL; } /* start with blank name */ *name = '\0'; /* add output directory if needed */ if (dir) { strcpy((char *) name, (char *) dir); strcat((char *) name, "/"); } /* remove leading slashes */ while (*fname == sep) fname++; /* copy from fi->filename to new name, converting MS-DOS slashes to UNIX * slashes as we go. Also lowercases characters if needed. */ p = &name[strlen((char *)name)]; /* p = start of output filename */ fe = &fname[strlen((char *)fname)]; /* fe = end of input filename */ if (utf8) { /* UTF-8 translates unicode characters into 1 to 6 bytes. * In binary: * 000000000000000000000000000000sssssss * -> 0sssssss * 00000000000000000000000000ssssstttttt * -> 110sssss 10tttttt * 000000000000000000000ssssttttttuuuuuu * -> 1110ssss 10tttttt 10uuuuuu * 0000000000000000sssttttttuuuuuuvvvvvv * -> 11110sss 10tttttt 10uuuuuu 10vvvvvv * 00000000000ssttttttuuuuuuvvvvvvwwwwww * -> 111110ss 10tttttt 10uuuuuu 10vvvvvv 10wwwwww * 000000sttttttuuuuuuvvvvvvwwwwwwxxxxxx * -> 1111110s 10tttttt 10uuuuuu 10vvvvvv 10wwwwww 10xxxxxx * * Therefore, the inverse is as follows: * First char: * 0x00 - 0x7F = one byte char * 0x80 - 0xBF = invalid * 0xC0 - 0xDF = 2 byte char (next char only 0x80-0xBF is valid) * 0xE0 - 0xEF = 3 byte char (next 2 chars only 0x80-0xBF is valid) * 0xF0 - 0xF7 = 4 byte char (next 3 chars only 0x80-0xBF is valid) * 0xF8 - 0xFB = 5 byte char (next 4 chars only 0x80-0xBF is valid) * 0xFC - 0xFD = 6 byte char (next 5 chars only 0x80-0xBF is valid) * 0xFE - 0xFF = invalid */ do { if (fname > fe) { fprintf(stderr, "error in UTF-8 decode\n"); free(name); return NULL; } /* get next UTF-8 character */ if ((c = *fname++) < 0x80) x = c; else { if ((c >= 0xC0) && (c <= 0xDF)) { x = (c & 0x1F) << 6; x |= *fname++ & 0x3F; } else if ((c >= 0xE0) && (c <= 0xEF)) { x = (c & 0x0F) << 12; x |= (*fname++ & 0x3F) << 6; x |= *fname++ & 0x3F; } else if ((c >= 0xF0) && (c <= 0xF7)) { x = (c & 0x07) << 18; x |= (*fname++ & 0x3F) << 12; x |= (*fname++ & 0x3F) << 6; x |= *fname++ & 0x3F; } else if ((c >= 0xF8) && (c <= 0xFB)) { x = (c & 0x03) << 24; x |= (*fname++ & 0x3F) << 18; x |= (*fname++ & 0x3F) << 12; x |= (*fname++ & 0x3F) << 6; x |= *fname++ & 0x3F; } else if ((c >= 0xFC) && (c <= 0xFD)) { x = (c & 0x01) << 30; x |= (*fname++ & 0x3F) << 24; x |= (*fname++ & 0x3F) << 18; x |= (*fname++ & 0x3F) << 12; x |= (*fname++ & 0x3F) << 6; x |= *fname++ & 0x3F; } else x = '?'; } /* whatever is the path seperator -> '/' * whatever is the other slash -> '\\' * otherwise, if lower is set, the lowercase version */ if (x == sep) x = '/'; else if (x == slash) x = '\\'; else if (lower) x = (unsigned int) tolower((int) x); /* convert unicode character back to UTF-8 */ if (x < 0x80) { *p++ = (unsigned char) x; } else if (x < 0x800) { *p++ = 0xC0 | (x >> 6); *p++ = 0x80 | (x & 0x3F); } else if (x < 0x10000) { *p++ = 0xE0 | (x >> 12); *p++ = 0x80 | ((x >> 6) & 0x3F); *p++ = 0x80 | (x & 0x3F); } else if (x < 0x200000) { *p++ = 0xF0 | (x >> 18); *p++ = 0x80 | ((x >> 12) & 0x3F); *p++ = 0x80 | ((x >> 6) & 0x3F); *p++ = 0x80 | (x & 0x3F); } else if (x < 0x4000000) { *p++ = 0xF8 | (x >> 24); *p++ = 0x80 | ((x >> 18) & 0x3F); *p++ = 0x80 | ((x >> 12) & 0x3F); *p++ = 0x80 | ((x >> 6) & 0x3F); *p++ = 0x80 | (x & 0x3F); } else { *p++ = 0xFC | (x >> 30); *p++ = 0x80 | ((x >> 24) & 0x3F); *p++ = 0x80 | ((x >> 18) & 0x3F); *p++ = 0x80 | ((x >> 12) & 0x3F); *p++ = 0x80 | ((x >> 6) & 0x3F); *p++ = 0x80 | (x & 0x3F); } } while (x); } else { /* regular non-utf8 version */ do { c = *fname++; if (c == sep) c = '/'; else if (c == slash) c = '\\'; else if (lower) c = (unsigned char) tolower((int) c); } while ((*p++ = c)); } /* search for "../" in cab filename part and change to "xx/". This * prevents any unintended directory traversal. */ for (p = &name[dir ? strlen((char *) dir)+1 : 0]; *p; p++) { if ((p[0] == '.') && (p[1] == '.') && (p[2] == '/')) { p[0] = p[1] = 'x'; p += 2; } } return (char *) name; } /** * Sets the last-modified time and file permissions on a file. * * @param file the internal CAB file whose date, time and attributes will * be used. * @param filename the name of the UNIX file whose last-modified time and * file permissions will be set. */ static void set_date_and_perm(struct mscabd_file *file, char *filename) { mode_t mode; struct tm tm; #if HAVE_UTIME struct utimbuf utb; #elif HAVE_UTIMES struct timeval tv[2]; #endif /* set last modified date */ tm.tm_sec = file->time_s; tm.tm_min = file->time_m; tm.tm_hour = file->time_h; tm.tm_mday = file->date_d; tm.tm_mon = file->date_m - 1; tm.tm_year = file->date_y - 1900; tm.tm_isdst = -1; #if HAVE_UTIME utb.actime = utb.modtime = mktime(&tm); utime(filename, &utb); #elif HAVE_UTIMES tv[0].tv_sec = tv[1].tv_sec = mktime(&tm); tv[0].tv_usec = tv[1].tv_usec = 0; utimes(filename, &tv[0]); #endif /* set permissions */ mode = 0444; if ( file->attribs & MSCAB_ATTRIB_EXEC) mode |= 0111; if (!(file->attribs & MSCAB_ATTRIB_RDONLY)) mode |= 0222; chmod(filename, mode & ~user_umask); } /* ------- support functions ------- */ /** * Memorises a file by its device and inode number rather than its name. If * the file does not exist, it will not be memorised. * * @param fml address of the file_mem list that will memorise this file. * @param name name of the file to memorise. * @param from a string that, if not NULL, will be duplicated stored with * the memorised file. * @see recall_file(), forget_files() */ static void memorise_file(struct file_mem **fml, char *name, char *from) { struct file_mem *fm; struct stat st_buf; if (stat(name, &st_buf) != 0) return; if (!(fm = malloc(sizeof(struct file_mem)))) return; fm->st_dev = st_buf.st_dev; fm->st_ino = st_buf.st_ino; fm->from = (from) ? malloc(strlen(from)+1) : NULL; if (fm->from) strcpy(fm->from, from); fm->next = *fml; *fml = fm; } /** * Determines if a file has been memorised before, by its device and inode * number. If the file does not exist, it cannot be recalled. * * @param fml list to search for previously memorised file * @param name name of file to recall. * @param from if non-NULL, this is an address that the associated "from" * description pointer will be stored. * @return non-zero if the file has been previously memorised, zero if the * file is unknown or does not exist. * @see memorise_file(), forget_files() */ static int recall_file(struct file_mem *fml, char *name, char **from) { struct file_mem *fm; struct stat st_buf; if (stat(name, &st_buf) != 0) return 0; for (fm = fml; fm; fm = fm->next) { if ((st_buf.st_ino == fm->st_ino) && (st_buf.st_dev == fm->st_dev)) { if (from) *from = fm->from; return 1; } } return 0; } /** * Frees all memory used by a file_mem list. * * @param fml address of the list to free * @see memorise_file() */ static void forget_files(struct file_mem **fml) { struct file_mem *fm, *next; for (fm = *fml; fm; fm = next) { next = fm->next; free(fm->from); free(fm); } *fml = NULL; } /** * Ensures that all directory components in a filepath exist. New directory * components are created, if necessary. * * @param path the filepath to check * @return non-zero if all directory components in a filepath exist, zero * if components do not exist and cannot be created */ static int ensure_filepath(char *path) { struct stat st_buf; char *p; int ok; for (p = &path[1]; *p; p++) { if (*p != '/') continue; *p = '\0'; ok = (stat(path, &st_buf) == 0) && S_ISDIR(st_buf.st_mode); if (!ok) ok = (mkdir(path, 0777 & ~user_umask) == 0); *p = '/'; if (!ok) return 0; } return 1; } /** * Returns a string with an error message appropriate for the last error * of the CAB decompressor. * * @param cd the CAB decompressor. * @return a constant string with an appropriate error message. */ static char *cab_error(struct mscab_decompressor *cd) { switch (cd->last_error(cd)) { case MSPACK_ERR_OPEN: case MSPACK_ERR_READ: case MSPACK_ERR_WRITE: case MSPACK_ERR_SEEK: return strerror(errno); case MSPACK_ERR_NOMEMORY: return "out of memory"; case MSPACK_ERR_SIGNATURE: return "bad CAB signature"; case MSPACK_ERR_DATAFORMAT: return "error in CAB data format"; case MSPACK_ERR_CHECKSUM: return "checksum error"; case MSPACK_ERR_DECRUNCH: return "decompression error"; } return "unknown error"; } struct mspack_file_p { FILE *fh; const char *name; char regular_file; }; static struct mspack_file *cabx_open(struct mspack_system *this, const char *filename, int mode) { struct mspack_file_p *fh; const char *fmode; /* Use of the STDOUT_FNAME pointer for a filename means the file should * actually be extracted to stdout. Use of the TEST_FNAME pointer for a * filename means the file should only be MD5-summed. */ if (filename == STDOUT_FNAME || filename == TEST_FNAME) { /* only WRITE mode is valid for these special files */ if (mode != MSPACK_SYS_OPEN_WRITE) { return NULL; } } /* ensure that mode is one of READ, WRITE, UPDATE or APPEND */ 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 = malloc(sizeof(struct mspack_file_p)))) { fh->name = filename; if (filename == STDOUT_FNAME) { fh->regular_file = 0; fh->fh = stdout; return (struct mspack_file *) fh; } else if (filename == TEST_FNAME) { fh->regular_file = 0; fh->fh = NULL; md5_init_ctx(&md5_context); return (struct mspack_file *) fh; } else { /* regular file - simply attempt to open it */ fh->regular_file = 1; if ((fh->fh = fopen(filename, fmode))) { return (struct mspack_file *) fh; } } /* error - free file handle and return NULL */ free(fh); } return NULL; } static void cabx_close(struct mspack_file *file) { struct mspack_file_p *this = (struct mspack_file_p *) file; if (this) { if (this->name == TEST_FNAME) { md5_finish_ctx(&md5_context, (void *) &md5_result); } else if (this->regular_file) { fclose(this->fh); } free(this); } } static int cabx_read(struct mspack_file *file, void *buffer, int bytes) { struct mspack_file_p *this = (struct mspack_file_p *) file; if (this && this->regular_file && buffer && bytes >= 0) { size_t count = fread(buffer, 1, (size_t) bytes, this->fh); if (!ferror(this->fh)) return (int) count; } return -1; } static int cabx_write(struct mspack_file *file, void *buffer, int bytes) { struct mspack_file_p *this = (struct mspack_file_p *) file; if (this && buffer && bytes >= 0) { if (this->name == TEST_FNAME) { md5_process_bytes(buffer, (size_t) bytes, &md5_context); return bytes; } else { /* regular files and the stdout writer */ size_t count = fwrite(buffer, 1, (size_t) bytes, this->fh); if (!ferror(this->fh)) return (int) count; } } return -1; } static int cabx_seek(struct mspack_file *file, off_t offset, int mode) { struct mspack_file_p *this = (struct mspack_file_p *) file; if (this && this->regular_file) { 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; } #if HAVE_FSEEKO return fseeko(this->fh, offset, mode); #else return fseek(this->fh, offset, mode); #endif } return -1; } static off_t cabx_tell(struct mspack_file *file) { struct mspack_file_p *this = (struct mspack_file_p *) file; #if HAVE_FSEEKO return (this && this->regular_file) ? (off_t) ftello(this->fh) : 0; #else return (this && this->regular_file) ? (off_t) ftell(this->fh) : 0; #endif } static void cabx_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 *cabx_alloc(struct mspack_system *this, size_t bytes) { return malloc(bytes); } static void cabx_free(void *buffer) { free(buffer); } static void cabx_copy(void *src, void *dest, size_t bytes) { memcpy(dest, src, bytes); } cabextract-1.4/src/cabinfo.c0000644000175000017500000003735111562533506012772 00000000000000/* cabinfo -- dumps useful information from cabinets * (C) 2000-2006 Stuart Caie * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H # include #endif #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_STDLIB_H # include #endif #if HAVE_STRING_H # include #endif #if HAVE_STRINGS_H # include #endif #ifdef HAVE_FSEEKO # define FSEEK fseeko # define FTELL ftello # define FILELEN off_t #else # define FSEEK fseek # define FTELL ftell # define FILELEN long #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 FL "lld" #else # define FL "ld" #endif /* 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) #define cffile_A_RDONLY (0x01) #define cffile_A_HIDDEN (0x02) #define cffile_A_SYSTEM (0x04) #define cffile_A_ARCH (0x20) #define cffile_A_EXEC (0x40) #define cffile_A_NAME_IS_UTF (0x80) FILE *fh; char *filename; FILELEN filelen; void search(); void getinfo(); #define EndGetI32(a) ((((a)[3])<<24)|(((a)[2])<<16)|(((a)[1])<<8)|((a)[0])) #define EndGetI16(a) ((((a)[1])<<8)|((a)[0])) #define GETLONG(n) EndGetI32(&buf[n]) #define GETWORD(n) EndGetI16(&buf[n]) #define GETBYTE(n) ((int)buf[n]) #define GETOFFSET (FTELL(fh)) #define READ(buf,len) if (myread((void *)(buf),(len))) return #define SKIP(offset) if (myseek((offset),SEEK_CUR)) return #define SEEK(offset) if (myseek((offset),SEEK_SET)) return int myread(void *buf, int length) { FILELEN remain = filelen - GETOFFSET; if (length > remain) length = (int) remain; if (fread(buf, 1, length, fh) != length) { perror(filename); return 1; } return 0; } int myseek(FILELEN offset, int mode) { if (FSEEK(fh, offset, mode) != 0) { perror(filename); return 1; } return 0; } int main(int argc, char *argv[]) { printf("Cabinet information dumper by Stuart Caie \n"); if (argc <= 1) { printf("Usage: %s \n", argv[0]); return 1; } if (!(fh = fopen((filename = argv[1]), "rb"))) { perror(filename); return 1; } if (FSEEK(fh, 0, SEEK_END) != 0) { perror(filename); fclose(fh); return 1; } filelen = FTELL(fh); if (FSEEK(fh, 0, SEEK_SET) != 0) { perror(filename); fclose(fh); return 1; } printf("Examining file \"%s\" (%" FL " bytes)...\n", filename, filelen); search(); fclose(fh); return 0; } #define SEARCH_SIZE (32*1024) unsigned char search_buf[SEARCH_SIZE]; void search() { unsigned char *pstart = &search_buf[0], *pend, *p; FILELEN offset, caboff, cablen, foffset, length; unsigned long cablen32, foffset32; int state = 0; for (offset = 0; offset < filelen; 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 = filelen - offset; if (length > SEARCH_SIZE) length = SEARCH_SIZE; /* fill the search buffer with data from disk */ SEEK(offset); READ(&search_buf[0], length); /* read through the entire buffer. */ p = pstart; pend = &search_buf[length]; while (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++ != 0x4D && p < pend); if (p < pend) state = 1; /* if we found tht 'M', advance state */ 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 */ /* bytes 8-11 are the overall length of the cabinet */ case 8: cablen32 = *p++; state++; break; case 9: cablen32 |= *p++ << 8; state++; break; case 10: cablen32 |= *p++ << 16; state++; break; case 11: cablen32 |= *p++ << 24; state++; break; /* we don't care about bytes 12-15 */ /* bytes 16-19 are the offset within the cabinet of the filedata */ case 16: foffset32 = *p++; state++; break; case 17: foffset32 |= *p++ << 8; state++; break; case 18: foffset32 |= *p++ << 16; state++; break; case 19: foffset32 |= *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-pstart) - 20; /* 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 */ foffset = (FILELEN) foffset32; cablen = (FILELEN) cablen32; if ((foffset < cablen) && ((caboff + foffset) < (filelen + 32)) && ((caboff + cablen) < (filelen + 32)) ) { /* found a potential result - try loading it */ printf("Found cabinet header at offset %" FL "\n", caboff); SEEK(caboff); getinfo(); offset = caboff + cablen; length = 0; p = pend; } state = 0; break; default: p++, state++; break; } /* switch state */ } /* while p < pend */ } /* while offset < filelen */ } #define CAB_NAMEMAX (1024) /* UTF translates two-byte unicode characters into 1, 2 or 3 bytes. * %000000000xxxxxxx -> %0xxxxxxx * %00000xxxxxyyyyyy -> %110xxxxx %10yyyyyy * %xxxxyyyyyyzzzzzz -> %1110xxxx %10yyyyyy %10zzzzzz * * Therefore, the inverse is as follows: * First char: * 0x00 - 0x7F = one byte char * 0x80 - 0xBF = invalid * 0xC0 - 0xDF = 2 byte char (next char only 0x80-0xBF is valid) * 0xE0 - 0xEF = 3 byte char (next 2 chars only 0x80-0xBF is valid) * 0xF0 - 0xFF = invalid */ /* translate UTF -> ASCII */ int convertUTF(unsigned char *in) { unsigned char c, *out = in, *end = in + strlen((char *) in) + 1; unsigned int x; do { /* read unicode character */ if ((c = *in++) < 0x80) x = c; else { if (c < 0xC0) return 0; else if (c < 0xE0) { x = (c & 0x1F) << 6; if ((c = *in++) < 0x80 || c > 0xBF) return 0; else x |= (c & 0x3F); } else if (c < 0xF0) { x = (c & 0xF) << 12; if ((c = *in++) < 0x80 || c > 0xBF) return 0; else x |= (c & 0x3F)<<6; if ((c = *in++) < 0x80 || c > 0xBF) return 0; else x |= (c & 0x3F); } else return 0; } /* terrible unicode -> ASCII conversion */ if (x > 127) x = '_'; if (in > end) return 0; /* just in case */ } while ((*out++ = (unsigned char) x)); return 1; } void getinfo() { unsigned char buf[64]; unsigned char namebuf[CAB_NAMEMAX]; char *name; FILELEN offset, base_offset, files_offset, base; int num_folders, num_files, num_blocks = 0; int header_res = 0, folder_res = 0, data_res = 0; int i, x, y; base_offset = GETOFFSET; READ(&buf, cfhead_SIZEOF); x = GETWORD(cfhead_Flags); printf( "\n*** HEADER SECTION ***\n\n" "Cabinet signature = '%4.4s'\n" "Cabinet size = %u bytes\n" "Offset of files = %" FL "\n" "Cabinet format version = %d.%d\n" "Number of folders = %u\n" "Number of files = %u\n" "Header flags = 0x%04x%s%s%s\n" "Set ID = %u\n" "Cabinet set index = %u\n", buf, GETLONG(cfhead_CabinetSize), files_offset = (GETLONG(cfhead_FileOffset) + base_offset), GETBYTE(cfhead_MajorVersion), GETBYTE(cfhead_MinorVersion), num_folders = GETWORD(cfhead_NumFolders), num_files = GETWORD(cfhead_NumFiles), x, ((x & cfheadPREV_CABINET) ? " PREV_CABINET" : ""), ((x & cfheadNEXT_CABINET) ? " NEXT_CABINET" : ""), ((x & cfheadRESERVE_PRESENT) ? " RESERVE_PRESENT" : ""), GETWORD(cfhead_SetID), GETWORD(cfhead_CabinetIndex) ); if (num_folders == 0) { printf("ERROR: no folders\n"); return; } if (num_files == 0) { printf("ERROR: no files\n"); return; } if (buf[0]!='M' || buf[1]!='S' || buf[2]!='C' || buf[3]!='F') printf("WARNING: cabinet doesn't start with MSCF signature\n"); if (GETBYTE(cfhead_MajorVersion) > 1 || GETBYTE(cfhead_MinorVersion) > 3) printf("WARNING: format version > 1.3\n"); if (x & cfheadRESERVE_PRESENT) { READ(&buf, cfheadext_SIZEOF); header_res = GETWORD(cfheadext_HeaderReserved); folder_res = GETBYTE(cfheadext_FolderReserved); data_res = GETBYTE(cfheadext_DataReserved); } printf("Reserved header space = %u\n", header_res); printf("Reserved folder space = %u\n", folder_res); printf("Reserved datablk space = %u\n", data_res); if (header_res > 60000) printf("WARNING: header reserved space > 60000\n"); if (header_res) { printf("[Reserved header: offset %" FL ", size %u]\n", GETOFFSET, header_res); SKIP(header_res); } if (x & cfheadPREV_CABINET) { base = GETOFFSET; READ(&namebuf, CAB_NAMEMAX); SEEK(base + strlen((char *) namebuf) + 1); printf("Previous cabinet file = %s\n", namebuf); if (strlen((char *) namebuf) > 256) printf("WARNING: name length > 256\n"); base = GETOFFSET; READ(&namebuf, CAB_NAMEMAX); SEEK(base + strlen((char *) namebuf) + 1); printf("Previous disk name = %s\n", namebuf); if (strlen((char *) namebuf) > 256) printf("WARNING: name length > 256\n"); } if (x & cfheadNEXT_CABINET) { base = GETOFFSET; READ(&namebuf, CAB_NAMEMAX); SEEK(base + strlen((char *) namebuf) + 1); printf("Next cabinet file = %s\n", namebuf); if (strlen((char *) namebuf) > 256) printf("WARNING: name length > 256\n"); base = GETOFFSET; READ(&namebuf, CAB_NAMEMAX); SEEK(base + strlen((char *) namebuf) + 1); printf("Next disk name = %s\n", namebuf); if (strlen((char *) namebuf) > 256) printf("WARNING: name length > 256\n"); } printf("\n*** FOLDERS SECTION ***\n"); for (i = 0; i < num_folders; i++) { offset = GETOFFSET; READ(&buf, cffold_SIZEOF); switch(GETWORD(cffold_CompType) & cffoldCOMPTYPE_MASK) { case cffoldCOMPTYPE_NONE: name = "stored"; break; case cffoldCOMPTYPE_MSZIP: name = "MSZIP"; break; case cffoldCOMPTYPE_QUANTUM: name = "Quantum"; break; case cffoldCOMPTYPE_LZX: name = "LZX"; break; default: name = "unknown"; break; } printf( "\n[New folder at offset %" FL "]\n" "Offset of folder = %" FL "\n" "Num. blocks in folder = %u\n" "Compression type = 0x%04x [%s]\n", offset, base_offset + GETLONG(cffold_DataOffset), GETWORD(cffold_NumBlocks), GETWORD(cffold_CompType), name ); num_blocks += GETWORD(cffold_NumBlocks); if (folder_res) { printf("[Reserved folder: offset %" FL ", size %u]\n", GETOFFSET, folder_res); SKIP(folder_res); } } printf("\n*** FILES SECTION ***\n"); if (GETOFFSET != files_offset) { printf("WARNING: weird file offset in header\n"); SEEK(files_offset); } for (i = 0; i < num_files; i++) { offset = GETOFFSET; READ(&buf, cffile_SIZEOF); switch (GETWORD(cffile_FolderIndex)) { case cffileCONTINUED_PREV_AND_NEXT: name = "continued from previous and to next cabinet"; break; case cffileCONTINUED_FROM_PREV: name = "continued from previous cabinet"; break; case cffileCONTINUED_TO_NEXT: name = "continued to next cabinet"; break; default: name = "normal folder"; break; } x = GETWORD(cffile_Attribs); base = GETOFFSET; READ(&namebuf, CAB_NAMEMAX); SEEK(base + strlen((char *) namebuf) + 1); if (strlen((char *) namebuf) > 256) printf("WARNING: name length > 256\n"); /* convert filename */ if (x & cffile_A_NAME_IS_UTF) { if (!convertUTF(namebuf)) printf("WARNING: invalid UTF filename"); } printf( "\n[New file at offset %" FL "]\n" "File name = %s\n" "File size = %u bytes\n" "Offset within folder = %u\n" "Folder index = 0x%04x [%s]\n" "Date / time = %02d/%02d/%4d %02d:%02d:%02d\n" "File attributes = 0x%02x %s%s%s%s%s%s\n", offset, namebuf, GETLONG(cffile_UncompressedSize), GETLONG(cffile_FolderOffset), GETWORD(cffile_FolderIndex), name, GETWORD(cffile_Date) & 0x1f, (GETWORD(cffile_Date) >> 5) & 0xf, (GETWORD(cffile_Date) >> 9) + 1980, GETWORD(cffile_Time) >> 11, (GETWORD(cffile_Time) >> 5) & 0x3f, (GETWORD(cffile_Time) << 1) & 0x3e, x, (x & cffile_A_RDONLY) ? "RDONLY " : "", (x & cffile_A_HIDDEN) ? "HIDDEN " : "", (x & cffile_A_SYSTEM) ? "SYSTEM " : "", (x & cffile_A_ARCH) ? "ARCH " : "", (x & cffile_A_EXEC) ? "EXEC " : "", (x & cffile_A_NAME_IS_UTF) ? "UTF-8" : "" ); } printf("\n*** DATABLOCKS SECTION ***\n"); printf("*** Note: offset is BLOCK offset. Add 8 for DATA offset! ***\n\n"); for (i = 0; i < num_blocks; i++) { offset = GETOFFSET; READ(&buf, cfdata_SIZEOF); x = GETWORD(cfdata_CompressedSize); y = GETWORD(cfdata_UncompressedSize); printf("Block %6d: offset %12" FL " / csum %08x / c=%5u / u=%5u%s\n", i, offset, GETLONG(cfdata_CheckSum), x, y, ((x > (32768+6144)) || (y > 32768)) ? " INVALID" : ""); SKIP(x); } } cabextract-1.4/src/cabsplit0000755000175000017500000000450511420325675012746 00000000000000#!/usr/bin/perl -w # cabsplit splits a cabinet into one cabinet per folder. # Mostly useful for debugging. use strict; die "Usage: $0 \n" unless @ARGV; for my $file (@ARGV) { if (open FH, "<$file") { my $err = split_cabinet($file); print "$file: $err\n" if $err; close FH; } else { warn "$file: $!\n"; } } sub split_cabinet { my $fname = $_[0]; my $buf; read FH, $buf, 36; my @hdr = unpack 'V6C2v5', $buf; return "not a cab file" unless $hdr[0] == 0x4643534D; my $num_folders = $hdr[8]; my $num_files = $hdr[9]; my ($folder_resv, $block_resv) = (0, 0); if ($hdr[10] & 0x0004) { read FH, $buf, 4; my @hdr_resv = unpack 'vCC', $buf; seek FH, $hdr_resv[0], 1; $folder_resv = $hdr_resv[1]; $block_resv = $hdr_resv[2]; } read_string(), read_string() if $hdr[10] & 0x0001; read_string(), read_string() if $hdr[10] & 0x0002; # read folders my @folders = map { read FH, $_, 8; seek FH, $folder_resv, 1; $_ } 1 .. $num_folders; # read files my @files; for (1 .. $num_files) { read FH, $buf, 16; my @file = unpack 'V2v4', $buf; my $fname = read_string(); my $folder = $file[2]; if ($folder == 0xFFFD || $folder == 0xFFFF) { $folder = 0 } elsif ($folder == 0xFFFE) { $folder = $num_folders-1 }; $file[2] = 0; push @{$files[$folder]}, pack 'V2v4Z*', @file, $fname; } for my $i (0 .. $#folders) { my ($offset, $cnt) = unpack 'Vv', $folders[$i]; seek FH, $offset, 0; my $blocks = join '', map { read FH, $buf, 8; my $csize = (unpack 'Vvv', $buf)[1]; seek FH, $block_resv, 1; read FH, $_, $csize; $buf . $_; } 1 .. $cnt; my $files = join '', @{$files[$i]}; $hdr[2] = 36 + 8 + length($files) + length($blocks); # cab length $hdr[4] = 36 + 8; # files offset $hdr[8] = 1; # number of folders $hdr[9] = @{$files[$i]}; # number of files $hdr[10] = 0; # flags substr($folders[$i], 0, 4, pack('V', 36 + 8 + length($files))); my $outname = sprintf "%s.%03d", $fname, $i+1; return "can't create $outname: $!" unless open OUT, ">$outname"; print OUT pack('V6C2v5', @hdr) . $folders[$i] . $files . $blocks; close OUT; } return 0; } sub read_string { my $pos = tell FH; my $buf; read FH, $buf, 256; my ($string) = unpack 'Z*', $buf; seek FH, $pos + length($string) + 1, 0; return $string; } cabextract-1.4/src/wince_info0000755000175000017500000001345611515536522013272 00000000000000#!/usr/bin/perl -w # this is complementary to the wince_cab_format.html file, # which gives a full description of all components use strict; my %arch = ( '0', 'none', '103', 'SHx SH3', '104', 'SHx SH4', '386', 'Intel 386', '486', 'Intel 486', '586', 'Intel Pentium', '601', 'PowerPC 601', '603', 'PowerPC 603', '604', 'PowerPC 604', '620', 'PowerPC 620', '821', 'Motorola 821', '1824', 'ARM 720', '2080', 'ARM 820', '2336', 'ARM 920', '2577', 'StrongARM', '4000', 'MIPS R4000', '10003', 'Hitachi SH3', '10004', 'Hitachi SH3E', '10005', 'Hitachi SH4', '21064', 'Alpha 21064', '70001', 'ARM 7TDMI' ); my @ce = ( undef, '\Program Files', '\Windows', '\Windows\Desktop', '\Windows\StartUp', '\My Documents', '\Program Files\Accessories', '\Program Files\Communications', '\Program Files\Games', '\Program Files\Pocket Outlook', '\Program Files\Office', '\Windows\Programs', '\Windows\Programs\Accessories', '\Windows\Programs\Communications', '\Windows\Programs\Games', '\Windows\Fonts', '\Windows\Recent', '\Windows\Favorites' ); my @hkeys = ( undef, 'HKEY_CLASSES_ROOT', 'HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE', 'HKEY_USERS' ); sub hexdump($$) { my $id = $_[0]; my $dat = $_[1]; my $row = 12; for my $pos (0 .. (length($dat)/$row)) { my $seg = substr $dat, $pos * $row, $row; my $hex = join ' ', map { sprintf '%02x', $_ } unpack 'c*', $seg; $seg =~ s/[\000-\037\200-\377]/./g; printf '%s %-'.int($row*3)."s %s\n", $id, $hex, $seg; } } for my $hdrfile (@ARGV) { if (open FH, "<$hdrfile") { my $x; # read fixed-size header read FH, $x, 100; my @hdr = unpack 'V12v6V6v8', $x; if ($hdr[0] == 0x4543534D) { # HEADER section print "$hdrfile HEADER\n"; print " length = $hdr[2] bytes\n"; print " architecture = ".($arch{$hdr[5]} || 'unknown')." ($hdr[5])\n"; print " counts = " . join(',', @hdr[12..17]) . "\n"; print " offsets = " . join(',', @hdr[18..23]) . "\n"; print " strings = " . join(',', @hdr[24..29]) . "\n"; print " unknowns = " . join(',',($hdr[1],@hdr[3..4],@hdr[30..31])) . "\n"; print " min WinCE v. = $hdr[6].$hdr[7]"; print " [build $hdr[10]]" if $hdr[10] > 0; print "\n"; print " max WinCE v. = $hdr[8].$hdr[9]"; print " [build $hdr[11]]" if $hdr[11] > 0; print "\n"; # header STRINGS seek FH, $hdr[24], 0; read FH, $x, $hdr[25]; chop $x; print " app name = $x\n"; seek FH, $hdr[26], 0; read FH, $x, $hdr[27]; chop $x; print " provider = $x\n"; if ($hdr[29] > 0) { seek FH, $hdr[28], 0; read FH, $x, $hdr[29]; chop $x; chop $x; print " unsupported = ".join(',', split /\000/, $x)."\n"; } # STRINGS section print "$hdrfile STRINGS\n"; my @strings; seek FH, $hdr[18], 0; for (1 .. $hdr[12]) { read FH, $x, 4; my ($id, $len) = unpack 'vv', $x; read FH, $strings[$id], $len; chop $strings[$id]; printf " s%02d: %s\n", $id, $strings[$id]; } # DIRS section print "$hdrfile DIRS\n"; my @dirs; seek FH, $hdr[19], 0; for (1 .. $hdr[13]) { read FH, $x, 4; my ($id, $len) = unpack 'vv', $x; read FH, $x, $len; chop $x; chop $x; $dirs[$id] = join '\\', map {$strings[$_]} unpack 'v*', $x; $dirs[$id] =~ s/%CE(\d+)%/$ce[$1]/eg; printf " d%02d: %s\n", $id, $dirs[$id]; } # FILES section print "$hdrfile FILES\n"; my @files; seek FH, $hdr[20], 0; for (1 .. $hdr[14]) { read FH, $x, 12; my ($id, $dirid, $unk, $flags, $len) = unpack 'vvvVv', $x; read FH, $x, $len; chop $x; $files[$id] = join '\\', ($dirs[$dirid], $x); printf " f%02d: %s\n", $id, $files[$id]; printf " unknown=%d flags=0x%08x\n", $unk, $flags; } # REGHIVES section print "$hdrfile REGHIVES\n"; my @reghives; seek FH, $hdr[21], 0; for (1 .. $hdr[15]) { read FH, $x, 8; my ($id, $root, $unk, $len) = unpack 'vvvv', $x; read FH, $x, $len; chop $x; chop $x; $reghives[$id] = join '\\', ($hkeys[$root], (map {$strings[$_]} unpack 'v*', $x)); printf " h%02d: %s\n", $id, $reghives[$id], $unk; } # REGKEYS section print "$hdrfile REGKEYS\n"; seek FH, $hdr[22], 0; for (1 .. $hdr[16]) { read FH, $x, 12; my ($id, $hive, $unk, $flags, $len) = unpack 'vvvVv', $x; read FH, $x, $len; my $name = (split /\000/, $x)[0] || ''; my $data = substr $x, length($name) + 1; printf " k%02d: hive=%s\n", $id, $reghives[$hive]; printf " name=<<%s>> subst=%d flags=0x%08x\n", $name, $unk, $flags; if (($flags & 0x10001) == 0x10001) { $x = unpack 'V', $data; printf " [DWORD] %08x (%d)\n", $x, $x; } elsif (($flags & 0x10001) == 0x10000) { for (split /\000/, $data) {printf " [MULTI_SZ] <<%s>>\n", $_} } elsif (($flags & 0x10001) == 0x00001) { printf " [BINARY] (%d bytes hexdump follows)\n", length($data); hexdump(" ", $data); } else { chop $data; printf " [SZ] %s\n", $data; } } # LINKS section print "$hdrfile LINKS\n"; my @links; seek FH, $hdr[23], 0; for (1 .. $hdr[17]) { read FH, $x, 12; my ($id, $unk, $dir, $fid, $type, $len) = unpack 'vvvvvv', $x; read FH, $x, $len; my $name = join '\\', map {$strings[$_]} unpack 'v*', $x; $name = '%InstallDir%\\'.$name if $dir == 0; $name = $ce[$dir].'\\'.$name if $dir > 0; if ($type == 0) { $fid = ($fid == 0) ? '%InstallDir%' : $dirs[$fid]; } else { $fid = $files[$fid]; } printf " l%02d: src=<<%s>>\n", $id, $fid; printf " dest=<<%s>> (unk=%d)\n", $name, $unk; } print "\n"; } else { print "$hdrfile: not a Windows CE install cabinet header\n"; } close FH; } else { print "$hdrfile: $!\n"; } } cabextract-1.4/src/wince_rename0000755000175000017500000001100611256724256013600 00000000000000#!/usr/bin/perl -w # wince_rename # - when run in a directory containing files extracted from # a Windows CE installation cabinet, it will rename all files # to their "installed" filenames # - the header file (*.000) will be renamed to header.bin # - the setup DLL (*.999) will be renamed to setup.dll # - a REGEDIT4 style file will be made, called setup.reg use strict; # expands a decimal number from 0-999 into a filename with a three digit # decimal number as a file extension, if one exists. Otherwise, undef is # is returned. sub get_fname { my $x = sprintf '*.%03d', $_[0]; my @x = glob $x; if ($#x > 0) { print STDERR "WARNING: more than one '$x' file, using '$x[0]'\n"; } elsif ($#x < 0) { return undef; } return $x[0]; } sub rename_file { print "renaming \"$_[0]\" to \"$_[1]\"\n"; rename $_[0], $_[1] || print STDERR "$_[0]: $!\n"; } # get the *.000 file my $hdrfile = get_fname(0); if (not defined $hdrfile) { print "no header (*.000) file found\n"; exit; } # open the header file if (open FH, "<$hdrfile") { my $x; read FH, $x, 0x64; # read the fixed header # $hdr[0] = "MSCE" signature # $hdr[2] = overall length of the header file # $hdr[5] = target architecture ID # @hdr[6..11] = minimal and maximal versions WinCE versions supported # @hdr[12..17] = number of entries in {STRINGS,DIRS,FILES,HIVES,KEYS,LINKS} # @hdr[18..23] = file offset of {STRINGS,DIRS,FILES,HIVES,KEYS,LINKS} # @hdr[24..25] = {file offset, length} of APPNAME # @hdr[26..27] = {file offset, length} of PROVIDER # @hdr[28..29] = {file offset, length} of UNSUPPORTED # other entries are unknown/undefined my @hdr = unpack 'V12v6V6v8', $x; # does the file begin with "MSCE"? if ($hdr[0] == 0x4543534D) { # print appname and provider seek FH,$hdr[24],0; read FH,$x,$hdr[25]; chop $x; print "Appname: $x\n"; seek FH,$hdr[26],0; read FH,$x,$hdr[27]; chop $x; print "Provider: $x\n"; # RENAME FILES TO INSTALLED FILENAMES: # seek to FILES section and loop for the number of FILES entries seek FH, $hdr[20], 0; for (1 .. $hdr[14]) { # read a FILES entry read FH, $x, 12; my ($id, $dirid, $unk, $flags, $len) = unpack 'vvvVv',$x; read FH, $x, $len; chop $x; # get file with decimal extension, rename it to filename given in # FILES entry rename_file(get_fname($id), $x); } # CREATE REGISTRY KEYS LIST # create "setup.reg" file in REGEDIT4 format, if any KEYS entries if (($hdr[16] > 0) && open REGFH, '>setup.reg') { print REGFH "REGEDIT4\r\n"; my @strs; my @hives; my $lasthive = -1; # seek to STRINGS section and read all STRINGS entries into @strs seek FH, $hdr[18], 0; for (1 .. $hdr[12]) { read FH, $x, 4; my ($id, $len) = unpack 'vv',$x; read FH, $strs[$id], $len; chop $strs[$id]; } # seek to HIVES section and read all HIVES entries into @hives seek FH, $hdr[21], 0; for (1 .. $hdr[15]) { read FH, $x, 8; my ($id, $root, $unk, $len) = unpack 'vvvv',$x; read FH, $x, $len; chop $x; chop $x; $hives[$id] = join '\\',(('HKCR','HKCU','HKLM','HKEY_USERS')[$root-1], (map{$strs[$_]} unpack 'v*', $x)); } # seek to KEYS section and loop for all KEYS entries seek FH, $hdr[22], 0; for (1 .. $hdr[16]) { # read KEYS entry, split off name and data components read FH, $x, 12; my ($id,$hive,$unk,$flags,$len) = unpack 'vvvVv',$x; read FH, $x, $len; my $name = (split /\000/, $x)[0]; my $data = substr $x, length($name) + 1; # print REGEDIT4 entry header for key, print hive header if a # different hive has been entered print REGFH "\r\n[$hives[$hive]]\r\n" unless $lasthive == $hive; print REGFH ''.(($name eq '') ? '@' : "\"$name\"").'='; $lasthive = $hive; # print appropriate REGEDIT4 format for data if (($flags & 0x10001) == 0x10001) { print REGFH sprintf 'dword:%08x', unpack('V', $data); } elsif (($flags & 0x10001) == 0x00001) { print REGFH 'hex:'.join ',',map{sprintf'%02x',$_}unpack 'c*',$data; } else { chop $data; chop $data if (($flags & 0x10001) == 0x10000); $data =~ s/\\/\\\\/g; $data =~ s/\000/\\0/g; $data =~ s/\"/\\\"/g; print REGFH '"'.$data.'"'; } print REGFH "\r\n"; } close REGFH; } } else { print "$hdrfile: not a Windows CE install cabinet header\n"; } close FH; # rename *.000 file to header.bin rename_file($hdrfile, 'header.bin'); # rename *.999 file to setup.dll, if it exists rename_file($x, 'setup.dll') if $x = get_fname(999); } else { print "$hdrfile: $!\n"; } cabextract-1.4/README0000644000175000017500000000341511562250157011306 00000000000000cabextract 1.4 - a program to extract Microsoft Cabinet files. (C) 2000-2010 Stuart Caie This is free software with ABSOLUTELY NO WARRANTY. Cabinet (.CAB) files are a form of archive, which Microsoft use to distribute their software, and things like Windows Font Packs. The cabextract program unpacks these files. For more information, see http://www.cabextract.org.uk/ or run the command 'cabextract --help'. Microsoft cabinet files should not be confused with InstallShield cabinet files. InstallShield files are generally called "_sys.cab", "data1.hdr" "data1.cab", "data2.cab" and so on, and are found in the same directory as "setup.exe". They begin with the magic characters "ISc(" rather than "MSCF". cabextract will print the message "This is probably an InstallShield file." when it finds such a file. The file "doc/magic" in the cabextract source archive includes additional file-identification rules for the UNIX file(1) command, which distinguishes between Microsoft and InstallShield cabinet files. Example usage: Extracting files from a cabinet file: $ cabextract wibble.cab Extracting files from an executable which contains a cabinet file: $ cabextract wibble.exe [cabextract will automatically search executables for embedded cabinets] Extracting files from a set of cabinet files; wib01.cab, wib02.cab, ...: $ cabextract wib01.cab [cabextract will automatically get the names of the other files] Extracting files to a directory of your choice (in this case, 'boogie'): $ cabextract -d boogie wibble.cab [cabextract will create the directory if it does not already exist] Listing files from a cabinet file: $ cabextract -l wibble.cab Testing the integrity of a cabinet file, without extracting it: $ cabextract -t wibble.cab Stuart Caie , May 2011 cabextract-1.4/acinclude.m40000644000175000017500000000721711401031537012612 00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_func_mkdir.html # =========================================================================== # # SYNOPSIS # # AX_FUNC_MKDIR # # DESCRIPTION # # Check whether mkdir() is mkdir or _mkdir, and whether it takes one or # two arguments. # # This macro can define HAVE_MKDIR, HAVE__MKDIR, and MKDIR_TAKES_ONE_ARG, # which are expected to be used as follows: # # #if HAVE_MKDIR # # if MKDIR_TAKES_ONE_ARG # /* MinGW32 */ # # define mkdir(a, b) mkdir(a) # # endif # #else # # if HAVE__MKDIR # /* plain Windows 32 */ # # define mkdir(a, b) _mkdir(a) # # else # # error "Don't know how to create a directory on this system." # # endif # #endif # # LICENSE # # Copyright (c) 2008 Alexandre Duret-Lutz # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 4 AU_ALIAS([AC_FUNC_MKDIR], [AX_FUNC_MKDIR]) AC_DEFUN([AX_FUNC_MKDIR], [AC_CHECK_FUNCS([mkdir _mkdir]) AC_CACHE_CHECK([whether mkdir takes one argument], [ac_cv_mkdir_takes_one_arg], [AC_TRY_COMPILE([ #include #if HAVE_UNISTD_H # include #endif ], [mkdir (".");], [ac_cv_mkdir_takes_one_arg=yes], [ac_cv_mkdir_takes_one_arg=no])]) if test x"$ac_cv_mkdir_takes_one_arg" = xyes; then AC_DEFINE([MKDIR_TAKES_ONE_ARG], 1, [Define if mkdir takes only one argument.]) fi ]) dnl Note: dnl ===== dnl I have not implemented the following suggestion because I don't have dnl access to such a broken environment to test the macro. So I'm just dnl appending the comments here in case you have, and want to fix dnl AX_FUNC_MKDIR that way. dnl dnl |Thomas E. Dickey (dickey@herndon4.his.com) said: dnl | it doesn't cover the problem areas (compilers that mistreat mkdir dnl | may prototype it in dir.h and dirent.h, for instance). dnl | dnl |Alexandre: dnl | Would it be sufficient to check for these headers and #include dnl | them in the AC_TRY_COMPILE block? (and is AC_HEADER_DIRENT dnl | suitable for this?) dnl | dnl |Thomas: dnl | I think that might be a good starting point (with the set of recommended dnl | ifdef's and includes for AC_HEADER_DIRENT, of course). cabextract-1.4/configure.ac0000644000175000017500000000337011562250014012704 00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.57) AC_INIT(cabextract, 1.4, kyzer@4u.net) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([src/cabextract.c]) AC_CONFIG_HEADER([config.h]) # Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_RANLIB AC_EXEEXT # Checks for header files. AC_HEADER_STDC AC_HEADER_TIME AC_HEADER_DIRENT AC_CHECK_HEADERS([ctype.h errno.h fnmatch.h libintl.h limits.h stdlib.h \ string.h strings.h utime.h stdarg.h sys/stat.h sys/time.h sys/types.h \ getopt.h wchar.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_SYS_LARGEFILE # Checks for library functions. AC_FUNC_FNMATCH AC_FUNC_FSEEKO AX_FUNC_MKDIR AC_FUNC_MKTIME AC_CHECK_FUNCS([memcpy strcasecmp strchr utime utimes]) AC_CHECK_FUNCS([getopt_long],,[AC_CHECK_LIB([gnugetopt], [getopt_long], [AC_DEFINE([HAVE_GETOPT_LONG])],[AC_LIBOBJ(getopt) AC_LIBOBJ(getopt1)])]) AC_REPLACE_FNMATCH # use an external libmspack if requested cabextract_external_libmspack=no AC_ARG_WITH([external-libmspack], [AS_HELP_STRING([--with-external-libmspack],[use external libmspack (default no)])], [cabextract_external_libmspack=$withval]) if test "z$cabextract_external_libmspack" != 'zno'; then AC_CHECK_HEADER([mspack.h], ,[AC_MSG_ERROR([Cannot find libmspack header])]) fi if test "z$cabextract_external_libmspack" != 'zno'; then AC_CHECK_LIB([mspack],[mspack_create_cab_compressor], [LIBMSPACK_LIBS=-lmspack], [AC_MSG_ERROR([Cannot find libmspack library])]) fi AC_SUBST([LIBMSPACK_LIBS]) AM_CONDITIONAL([EXTERNAL_LIBMSPACK], [test "z$cabextract_external_libmspack" != 'zno']) AC_CONFIG_FILES([Makefile cabextract.spec]) AC_OUTPUT cabextract-1.4/aclocal.m40000644000175000017500000010351611562533563012276 00000000000000# generated automatically by aclocal 1.11.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009 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_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, [m4_warning([this file was generated for autoconf 2.65. 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, 2003, 2005, 2006, 2007, 2008 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.11' 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.11.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.11.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, 2003, 2005 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, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # 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. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$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, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 # 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. # serial 10 # 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", "GCJ", or "OBJC". # 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 ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" 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'. 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 8's {/usr,}/bin/sh. touch 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 ;; 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, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # 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. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 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"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //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' -e 's/\$U/'"$U"'/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, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 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. # serial 16 # 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. # 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.62])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], [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], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [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([AM_PROG_MKDIR_P])dnl # 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)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl 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 ]) 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, 2003, 2005, 2008 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, 2005 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. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 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. # serial 4 # 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, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # 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. # serial 6 # 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 supports --run. # If it does, 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 --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006 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_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008 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. # serial 4 # _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])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # 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. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # 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 ( 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 rm -f conftest.file 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 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)]) # Copyright (C) 2001, 2003, 2005 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, 2008 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. # serial 2 # _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, 2005 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. # serial 2 # _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. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. 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([acinclude.m4]) cabextract-1.4/Makefile.am0000644000175000017500000000170611420326160012452 00000000000000AUTOMAKE_OPTIONS = no-dependencies EXTRA_DIST = cabextract.spec \ doc/cabextract.1 doc/ja/cabextract.1 \ doc/magic doc/wince_cab_format.html \ fnmatch_.h getopt.h \ mspack/ChangeLog src/cabsplit \ src/wince_info src/wince_rename man_MANS = doc/cabextract.1 mspack_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 if ! EXTERNAL_LIBMSPACK AM_CPPFLAGS = -I$(srcdir)/mspack -DMSPACK_NO_DEFAULT_SYSTEM noinst_LIBRARIES = libmspack.a libmspack_a_SOURCES = $(mspack_sources) else EXTRA_DIST += $(mspack_sources) endif bin_PROGRAMS = cabextract noinst_PROGRAMS = src/cabinfo cabextract_SOURCES = src/cabextract.c md5.h md5.c if ! EXTERNAL_LIBMSPACK cabextract_LDADD = libmspack.a @LIBOBJS@ else cabextract_LDADD = @LIBOBJS@ $(LIBMSPACK_LIBS) endif cabextract-1.4/Makefile.in0000644000175000017500000006731211562533565012510 00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ 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 = : @EXTERNAL_LIBMSPACK_TRUE@am__append_1 = $(mspack_sources) bin_PROGRAMS = cabextract$(EXEEXT) noinst_PROGRAMS = src/cabinfo$(EXEEXT) subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/cabextract.spec.in \ $(srcdir)/config.h.in $(top_srcdir)/configure AUTHORS COPYING \ ChangeLog INSTALL NEWS TODO fnmatch.c getopt.c getopt1.c \ install-sh missing mktime.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.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 = cabextract.spec CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) AR = ar ARFLAGS = cru libmspack_a_AR = $(AR) $(ARFLAGS) libmspack_a_LIBADD = am__libmspack_a_SOURCES_DIST = 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 am__objects_1 = system.$(OBJEXT) cabd.$(OBJEXT) lzxd.$(OBJEXT) \ mszipd.$(OBJEXT) qtmd.$(OBJEXT) @EXTERNAL_LIBMSPACK_FALSE@am_libmspack_a_OBJECTS = $(am__objects_1) libmspack_a_OBJECTS = $(am_libmspack_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) am_cabextract_OBJECTS = cabextract.$(OBJEXT) md5.$(OBJEXT) cabextract_OBJECTS = $(am_cabextract_OBJECTS) am__DEPENDENCIES_1 = @EXTERNAL_LIBMSPACK_FALSE@cabextract_DEPENDENCIES = libmspack.a \ @EXTERNAL_LIBMSPACK_FALSE@ @LIBOBJS@ $(am__empty) @EXTERNAL_LIBMSPACK_TRUE@cabextract_DEPENDENCIES = @LIBOBJS@ \ @EXTERNAL_LIBMSPACK_TRUE@ $(am__DEPENDENCIES_1) src_cabinfo_SOURCES = src/cabinfo.c src_cabinfo_OBJECTS = cabinfo.$(OBJEXT) src_cabinfo_LDADD = $(LDADD) am__dirstamp = $(am__leading_dot)dirstamp DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = am__depfiles_maybe = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libmspack_a_SOURCES) $(cabextract_SOURCES) src/cabinfo.c DIST_SOURCES = $(am__libmspack_a_SOURCES_DIST) $(cabextract_SOURCES) \ src/cabinfo.c 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' man1dir = $(mandir)/man1 NROFF = nroff MANS = $(man_MANS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d "$(distdir)" \ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr "$(distdir)"; }; } DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ 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@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBMSPACK_LIBS = @LIBMSPACK_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ 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@ 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_CC = @ac_ct_CC@ 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_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ 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@ AUTOMAKE_OPTIONS = no-dependencies EXTRA_DIST = cabextract.spec doc/cabextract.1 doc/ja/cabextract.1 \ doc/magic doc/wince_cab_format.html fnmatch_.h getopt.h \ mspack/ChangeLog src/cabsplit src/wince_info src/wince_rename \ $(am__append_1) man_MANS = doc/cabextract.1 mspack_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 @EXTERNAL_LIBMSPACK_FALSE@AM_CPPFLAGS = -I$(srcdir)/mspack -DMSPACK_NO_DEFAULT_SYSTEM @EXTERNAL_LIBMSPACK_FALSE@noinst_LIBRARIES = libmspack.a @EXTERNAL_LIBMSPACK_FALSE@libmspack_a_SOURCES = $(mspack_sources) cabextract_SOURCES = src/cabextract.c md5.h md5.c @EXTERNAL_LIBMSPACK_FALSE@cabextract_LDADD = libmspack.a @LIBOBJS@ @EXTERNAL_LIBMSPACK_TRUE@cabextract_LDADD = @LIBOBJS@ $(LIBMSPACK_LIBS) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .o .obj am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu 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: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi 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: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 cabextract.spec: $(top_builddir)/config.status $(srcdir)/cabextract.spec.in cd $(top_builddir) && $(SHELL) ./config.status $@ clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libmspack.a: $(libmspack_a_OBJECTS) $(libmspack_a_DEPENDENCIES) -rm -f libmspack.a $(libmspack_a_AR) libmspack.a $(libmspack_a_OBJECTS) $(libmspack_a_LIBADD) $(RANLIB) libmspack.a install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) clean-noinstPROGRAMS: -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) cabextract$(EXEEXT): $(cabextract_OBJECTS) $(cabextract_DEPENDENCIES) @rm -f cabextract$(EXEEXT) $(LINK) $(cabextract_OBJECTS) $(cabextract_LDADD) $(LIBS) src/$(am__dirstamp): @$(MKDIR_P) src @: > src/$(am__dirstamp) src/cabinfo$(EXEEXT): $(src_cabinfo_OBJECTS) $(src_cabinfo_DEPENDENCIES) src/$(am__dirstamp) @rm -f src/cabinfo$(EXEEXT) $(LINK) $(src_cabinfo_OBJECTS) $(src_cabinfo_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .c.o: $(COMPILE) -c $< .c.obj: $(COMPILE) -c `$(CYGPATH_W) '$<'` system.o: mspack/system.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o system.o `test -f 'mspack/system.c' || echo '$(srcdir)/'`mspack/system.c system.obj: mspack/system.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o system.obj `if test -f 'mspack/system.c'; then $(CYGPATH_W) 'mspack/system.c'; else $(CYGPATH_W) '$(srcdir)/mspack/system.c'; fi` cabd.o: mspack/cabd.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cabd.o `test -f 'mspack/cabd.c' || echo '$(srcdir)/'`mspack/cabd.c cabd.obj: mspack/cabd.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cabd.obj `if test -f 'mspack/cabd.c'; then $(CYGPATH_W) 'mspack/cabd.c'; else $(CYGPATH_W) '$(srcdir)/mspack/cabd.c'; fi` lzxd.o: mspack/lzxd.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lzxd.o `test -f 'mspack/lzxd.c' || echo '$(srcdir)/'`mspack/lzxd.c lzxd.obj: mspack/lzxd.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lzxd.obj `if test -f 'mspack/lzxd.c'; then $(CYGPATH_W) 'mspack/lzxd.c'; else $(CYGPATH_W) '$(srcdir)/mspack/lzxd.c'; fi` mszipd.o: mspack/mszipd.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mszipd.o `test -f 'mspack/mszipd.c' || echo '$(srcdir)/'`mspack/mszipd.c mszipd.obj: mspack/mszipd.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mszipd.obj `if test -f 'mspack/mszipd.c'; then $(CYGPATH_W) 'mspack/mszipd.c'; else $(CYGPATH_W) '$(srcdir)/mspack/mszipd.c'; fi` qtmd.o: mspack/qtmd.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o qtmd.o `test -f 'mspack/qtmd.c' || echo '$(srcdir)/'`mspack/qtmd.c qtmd.obj: mspack/qtmd.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o qtmd.obj `if test -f 'mspack/qtmd.c'; then $(CYGPATH_W) 'mspack/qtmd.c'; else $(CYGPATH_W) '$(srcdir)/mspack/qtmd.c'; fi` cabextract.o: src/cabextract.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cabextract.o `test -f 'src/cabextract.c' || echo '$(srcdir)/'`src/cabextract.c cabextract.obj: src/cabextract.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cabextract.obj `if test -f 'src/cabextract.c'; then $(CYGPATH_W) 'src/cabextract.c'; else $(CYGPATH_W) '$(srcdir)/src/cabextract.c'; fi` cabinfo.o: src/cabinfo.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cabinfo.o `test -f 'src/cabinfo.c' || echo '$(srcdir)/'`src/cabinfo.c cabinfo.obj: src/cabinfo.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cabinfo.obj `if test -f 'src/cabinfo.c'; then $(CYGPATH_W) 'src/cabinfo.c'; else $(CYGPATH_W) '$(srcdir)/src/cabinfo.c'; fi` install-man1: $(man_MANS) @$(NORMAL_INSTALL) test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" @list=''; test -n "$(man1dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ test -z "$$files" || { \ echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(man1dir)" && rm -f $$files; } ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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 CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ 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" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi $(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 -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__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__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.lzma*) \ lzma -dc $(distdir).tar.lzma | $(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 a+w $(distdir) mkdir $(distdir)/_build mkdir $(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 --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(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__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: @$(am__cd) '$(distuninstallcheck_dir)' \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { 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 $(LIBRARIES) $(PROGRAMS) $(MANS) config.h installdirs: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; 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: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 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) -rm -f src/$(am__dirstamp) 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-binPROGRAMS clean-generic clean-noinstLIBRARIES \ clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 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 -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-man uninstall-man: uninstall-man1 .MAKE: all install-am install-strip .PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ clean-noinstPROGRAMS ctags dist dist-all dist-bzip2 dist-gzip \ dist-lzma dist-shar dist-tarZ dist-xz dist-zip distcheck \ distclean distclean-compile distclean-generic distclean-hdr \ distclean-tags distcleancheck distdir distuninstallcheck dvi \ dvi-am html html-am info info-am install install-am \ install-binPROGRAMS install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-man1 install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-man uninstall-man1 # 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: cabextract-1.4/cabextract.spec.in0000644000175000017500000000157610656151055014035 00000000000000Summary: A program to extract Microsoft Cabinet files Name: cabextract Version: @VERSION@ Release: 1 License: GPL Group: Applications/Archiving Source: http://www.cabextract.org.uk/%{name}-%{version}.tar.gz URL: http://www.cabextract.org.uk/ Vendor: Stuart Caie Packager: Stuart Caie BuildRoot: %{_tmppath}/%{name}-%{version}-root Prefix: /usr %description Cabinet (.CAB) files are a form of archive, which Microsoft use to distribute their software, and things like Windows Font Packs. The cabextract program unpacks these files. %prep %setup %build CFLAGS=${RPM_OPT_FLAGS} ./configure --prefix=%{prefix} make %install rm -rf ${RPM_BUILD_ROOT} %makeinstall %clean [ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT} %files %defattr(0644, root, root, 0755) %doc AUTHORS ChangeLog NEWS README %attr(0755, root, root) %{_bindir}/cabextract %{_mandir}/man1/cabextract.1* cabextract-1.4/config.h.in0000644000175000017500000001362111562533564012457 00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ #undef CRAY_STACKSEG_END /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the `btowc' function. */ #undef HAVE_BTOWC /* Define to 1 if you have the header file. */ #undef HAVE_CTYPE_H /* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. */ #undef HAVE_DECL_GETENV /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H /* Define to 1 if your system has a working POSIX `fnmatch' function. */ #undef HAVE_FNMATCH /* Define to 1 if you have the header file. */ #undef HAVE_FNMATCH_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_GETOPT_H /* Define to 1 if you have the `getopt_long' function. */ #undef HAVE_GETOPT_LONG /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have the `mbsrtowcs' function. */ #undef HAVE_MBSRTOWCS /* Define to 1 if declares mbstate_t. */ #undef HAVE_MBSTATE_T /* Define to 1 if you have the `memcpy' function. */ #undef HAVE_MEMCPY /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `mempcpy' function. */ #undef HAVE_MEMPCPY /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_STDARG_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 `strcasecmp' function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* 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, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `utime' function. */ #undef HAVE_UTIME /* Define to 1 if you have the `utimes' function. */ #undef HAVE_UTIMES /* Define to 1 if you have the header file. */ #undef HAVE_UTIME_H /* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H /* Define to 1 if you have the header file. */ #undef HAVE_WCTYPE_H /* Define to 1 if you have the `wmempcpy' function. */ #undef HAVE_WMEMPCPY /* Define to 1 if you have the `_mkdir' function. */ #undef HAVE__MKDIR /* Define if mkdir takes only one argument. */ #undef MKDIR_TAKES_ONE_ARG /* 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 /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* 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 rpl_fnmatch if the replacement function should be used. */ #undef fnmatch /* 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 a type if does not define. */ #undef mbstate_t /* 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 cabextract-1.4/configure0000755000175000017500000063214011562533564012346 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.65 for cabextract 1.4. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 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. 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 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" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" 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 : # 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. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} 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_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 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=$?; test $as_status -eq 0 && as_status=1 if test "$3"; then as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 fi $as_echo "$as_me: error: $1" >&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; } # 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 -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' 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 if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # 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'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, 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='cabextract' PACKAGE_TARNAME='cabextract' PACKAGE_VERSION='1.4' PACKAGE_STRING='cabextract 1.4' PACKAGE_BUGREPORT='kyzer@4u.net' PACKAGE_URL='' ac_unique_file="src/cabextract.c" # 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_header_list= ac_func_list= ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS EXTERNAL_LIBMSPACK_FALSE EXTERNAL_LIBMSPACK_TRUE LIBMSPACK_LIBS ALLOCA LIBOBJS EGREP GREP CPP RANLIB am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC 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_dependency_tracking enable_largefile with_external_libmspack ' 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=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 $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 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 cabextract 1.4 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/cabextract] --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 _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of cabextract 1.4:";; 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] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --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-external-libmspack use external libmspack (default no) 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 cabextract configure 1.4 generated by GNU Autoconf 2.65 Copyright (C) 2009 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } >/dev/null && { 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; test "x$as_lineno_stack" = x && { as_lineno=; 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_link # 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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; 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.$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;} ( cat <<\_ASBOX ## --------------------------- ## ## Report this to kyzer@4u.net ## ## --------------------------- ## _ASBOX ) | 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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_mongrel # 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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile # 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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; 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; test "x$as_lineno_stack" = x && { as_lineno=; 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 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 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 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 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 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 &5 $as_echo_n "checking for $2... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; 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; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func # ac_fn_c_check_decl LINENO SYMBOL VAR # ------------------------------------ # Tests whether SYMBOL is declared, setting cache variable VAR accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 $as_echo_n "checking whether $2 is declared... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $2 (void) $2; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by cabextract $as_me 1.4, which was generated by GNU Autoconf 2.65. 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 cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX 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 cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX 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 cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX 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 cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX 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 ac_site_file1=$CONFIG_SITE 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" 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 as_fn_append ac_header_list " sys/time.h" as_fn_append ac_header_list " unistd.h" as_fn_append ac_func_list " alarm" # 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.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do for ac_t in install-sh install.sh shtool; do if test -f "$ac_dir/$ac_t"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/$ac_t -c" break 2 fi done 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 test "${ac_cv_path_install+set}" = set; 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 { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$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; } # Just in case sleep 1 echo timestamp > conftest.file # 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 ( 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 rm -f conftest.file 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 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; } 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 --run true"; then am_missing_run="$MISSING --run " 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 test "${ac_cv_prog_STRIP+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_STRIP+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_path_mkdir+set}" = set; 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 { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$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; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac 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 test "${ac_cv_prog_AWK+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; 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 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='cabextract' VERSION='1.4' 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"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' ac_config_headers="$ac_config_headers config.h" # 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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_CC+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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_set_status 77 as_fn_error "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 test "${ac_cv_objext+set}" = set; 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 test "${ac_cv_c_compiler_gnu+set}" = set; 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 test "${ac_cv_prog_cc_g+set}" = set; 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 test "${ac_cv_prog_cc_c89+set}" = set; 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 #include #include /* 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 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='\' 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 test "${am_cv_CC_dependencies_compiler_type+set}" = set; 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'. 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 8's {/usr,}/bin/sh. touch 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 ;; 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 -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 test "${ac_cv_prog_RANLIB+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 # Checks for header files. 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 test "${ac_cv_prog_CPP+set}" = set; 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.$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.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f 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.$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.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; 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" { test -f "$ac_path_GREP" && $as_test_x "$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 test "${ac_cv_path_EGREP+set}" = set; 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" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if test "${ac_cv_header_time+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$as_ac_Header=yes" else eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$as_ac_Header { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Header if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if test "${ac_cv_search_opendir+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' dir; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then : break fi done if test "${ac_cv_search_opendir+set}" = set; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if test "${ac_cv_search_opendir+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' x; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then : break fi done if test "${ac_cv_search_opendir+set}" = set; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi # 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 " eval as_val=\$$as_ac_Header if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in ctype.h errno.h fnmatch.h libintl.h limits.h stdlib.h \ string.h strings.h utime.h stdarg.h sys/stat.h sys/time.h sys/types.h \ getopt.h wchar.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" eval as_val=\$$as_ac_Header if test "x$as_val" = 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 test "${ac_cv_c_const+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* 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. */ char *t; 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 saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; 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 test "${ac_cv_c_inline+set}" = set; 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" = x""yes; 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" = x""yes; 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" = x""yes; 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 test "${ac_cv_sizeof_off_t+set}" = set; 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_set_status 77 as_fn_error "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 # 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 test "${ac_cv_sys_largefile_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : break fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 $as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } if test "${ac_cv_sys_file_offset_bits+set}" = set; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 $as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } if test "${ac_cv_sys_large_files+set}" = set; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 $as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -rf conftest* fi fi # Checks for library functions. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working POSIX fnmatch" >&5 $as_echo_n "checking for working POSIX fnmatch... " >&6; } if test "${ac_cv_func_fnmatch_works+set}" = set; then : $as_echo_n "(cached) " >&6 else # Some versions of Solaris, SCO, and the GNU C Library # have a broken or incompatible fnmatch. # So we run a test program. If we are cross-compiling, take no chance. # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test. if test "$cross_compiling" = yes; then : ac_cv_func_fnmatch_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include # define y(a, b, c) (fnmatch (a, b, c) == 0) # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH) int main () { return (!(y ("a*", "abc", 0) && n ("d*/*1", "d/s/1", FNM_PATHNAME) && y ("a\\\\bc", "abc", 0) && n ("a\\\\bc", "abc", FNM_NOESCAPE) && y ("*x", ".x", 0) && n ("*x", ".x", FNM_PERIOD) && 1)); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_fnmatch_works=yes else ac_cv_func_fnmatch_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fnmatch_works" >&5 $as_echo "$ac_cv_func_fnmatch_works" >&6; } if test $ac_cv_func_fnmatch_works = yes; then : $as_echo "#define HAVE_FNMATCH 1" >>confdefs.h 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 test "${ac_cv_sys_largefile_source+set}" = set; 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 for ac_func in mkdir _mkdir 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" eval as_val=\$$as_ac_var if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mkdir takes one argument" >&5 $as_echo_n "checking whether mkdir takes one argument... " >&6; } if test "${ac_cv_mkdir_takes_one_arg+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_UNISTD_H # include #endif int main () { mkdir ("."); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_mkdir_takes_one_arg=yes else ac_cv_mkdir_takes_one_arg=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_mkdir_takes_one_arg" >&5 $as_echo "$ac_cv_mkdir_takes_one_arg" >&6; } if test x"$ac_cv_mkdir_takes_one_arg" = xyes; then $as_echo "#define MKDIR_TAKES_ONE_ARG 1" >>confdefs.h fi for ac_header in $ac_header_list do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " eval as_val=\$$as_ac_Header if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in $ac_func_list do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" eval as_val=\$$as_ac_var if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5 $as_echo_n "checking for working mktime... " >&6; } if test "${ac_cv_func_working_mktime+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_working_mktime=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Test program from Paul Eggert and Tony Leneis. */ #ifdef TIME_WITH_SYS_TIME # include # include #else # ifdef HAVE_SYS_TIME_H # include # else # include # endif #endif #include #include #ifdef HAVE_UNISTD_H # include #endif #ifndef HAVE_ALARM # define alarm(X) /* empty */ #endif /* Work around redefinition to rpl_putenv by other config tests. */ #undef putenv static time_t time_t_max; static time_t time_t_min; /* Values we'll use to set the TZ environment variable. */ static char *tz_strings[] = { (char *) 0, "TZ=GMT0", "TZ=JST-9", "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00" }; #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0])) /* Return 0 if mktime fails to convert a date in the spring-forward gap. Based on a problem report from Andreas Jaeger. */ static int spring_forward_gap () { /* glibc (up to about 1998-10-07) failed this test. */ struct tm tm; /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" instead of "TZ=America/Vancouver" in order to detect the bug even on systems that don't support the Olson extension, or don't have the full zoneinfo tables installed. */ putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); tm.tm_year = 98; tm.tm_mon = 3; tm.tm_mday = 5; tm.tm_hour = 2; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = -1; return mktime (&tm) != (time_t) -1; } static int mktime_test1 (now) time_t now; { struct tm *lt; return ! (lt = localtime (&now)) || mktime (lt) == now; } static int mktime_test (now) time_t now; { return (mktime_test1 (now) && mktime_test1 ((time_t) (time_t_max - now)) && mktime_test1 ((time_t) (time_t_min + now))); } static int irix_6_4_bug () { /* Based on code from Ariel Faigon. */ struct tm tm; tm.tm_year = 96; tm.tm_mon = 3; tm.tm_mday = 0; tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = -1; mktime (&tm); return tm.tm_mon == 2 && tm.tm_mday == 31; } static int bigtime_test (j) int j; { struct tm tm; time_t now; tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j; now = mktime (&tm); if (now != (time_t) -1) { struct tm *lt = localtime (&now); if (! (lt && lt->tm_year == tm.tm_year && lt->tm_mon == tm.tm_mon && lt->tm_mday == tm.tm_mday && lt->tm_hour == tm.tm_hour && lt->tm_min == tm.tm_min && lt->tm_sec == tm.tm_sec && lt->tm_yday == tm.tm_yday && lt->tm_wday == tm.tm_wday && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) return 0; } return 1; } static int year_2050_test () { /* The correct answer for 2050-02-01 00:00:00 in Pacific time, ignoring leap seconds. */ unsigned long int answer = 2527315200UL; struct tm tm; time_t t; tm.tm_year = 2050 - 1900; tm.tm_mon = 2 - 1; tm.tm_mday = 1; tm.tm_hour = tm.tm_min = tm.tm_sec = 0; tm.tm_isdst = -1; /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" instead of "TZ=America/Vancouver" in order to detect the bug even on systems that don't support the Olson extension, or don't have the full zoneinfo tables installed. */ putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); t = mktime (&tm); /* Check that the result is either a failure, or close enough to the correct answer that we can assume the discrepancy is due to leap seconds. */ return (t == (time_t) -1 || (0 < t && answer - 120 <= t && t <= answer + 120)); } int main () { time_t t, delta; int i, j; /* This test makes some buggy mktime implementations loop. Give up after 60 seconds; a mktime slower than that isn't worth using anyway. */ alarm (60); for (;;) { t = (time_t_max << 1) + 1; if (t <= time_t_max) break; time_t_max = t; } time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max; delta = time_t_max / 997; /* a suitable prime number */ for (i = 0; i < N_STRINGS; i++) { if (tz_strings[i]) putenv (tz_strings[i]); for (t = 0; t <= time_t_max - delta; t += delta) if (! mktime_test (t)) return 1; if (! (mktime_test ((time_t) 1) && mktime_test ((time_t) (60 * 60)) && mktime_test ((time_t) (60 * 60 * 24)))) return 1; for (j = 1; ; j <<= 1) if (! bigtime_test (j)) return 1; else if (INT_MAX / 2 < j) break; if (! bigtime_test (INT_MAX)) return 1; } return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ()); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_working_mktime=yes else ac_cv_func_working_mktime=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_working_mktime" >&5 $as_echo "$ac_cv_func_working_mktime" >&6; } if test $ac_cv_func_working_mktime = no; then case " $LIBOBJS " in *" mktime.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS mktime.$ac_objext" ;; esac fi for ac_func in memcpy strcasecmp strchr utime utimes 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" eval as_val=\$$as_ac_var if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in getopt_long do : ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long" if test "x$ac_cv_func_getopt_long" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETOPT_LONG 1 _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getopt_long in -lgnugetopt" >&5 $as_echo_n "checking for getopt_long in -lgnugetopt... " >&6; } if test "${ac_cv_lib_gnugetopt_getopt_long+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgnugetopt $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 getopt_long (); int main () { return getopt_long (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_gnugetopt_getopt_long=yes else ac_cv_lib_gnugetopt_getopt_long=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_gnugetopt_getopt_long" >&5 $as_echo "$ac_cv_lib_gnugetopt_getopt_long" >&6; } if test "x$ac_cv_lib_gnugetopt_getopt_long" = x""yes; then : $as_echo "#define HAVE_GETOPT_LONG 1" >>confdefs.h else case " $LIBOBJS " in *" getopt.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getopt.$ac_objext" ;; esac case " $LIBOBJS " in *" getopt1.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getopt1.$ac_objext" ;; esac fi fi done # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 $as_echo_n "checking for working alloca.h... " >&6; } if test "${ac_cv_working_alloca_h+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { char *p = (char *) alloca (2 * sizeof (int)); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_working_alloca_h=yes else ac_cv_working_alloca_h=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 $as_echo "$ac_cv_working_alloca_h" >&6; } if test $ac_cv_working_alloca_h = yes; then $as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 $as_echo_n "checking for alloca... " >&6; } if test "${ac_cv_func_alloca_works+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # ifdef _MSC_VER # include # define alloca _alloca # else # ifdef HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ char *alloca (); # endif # endif # endif # endif #endif int main () { char *p = (char *) alloca (1); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_alloca_works=yes else ac_cv_func_alloca_works=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 $as_echo "$ac_cv_func_alloca_works" >&6; } if test $ac_cv_func_alloca_works = yes; then $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h else # The SVR3 libPW and SVR4 libucb both contain incompatible functions # that cause trouble. Some versions do not even contain alloca or # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. ALLOCA=\${LIBOBJDIR}alloca.$ac_objext $as_echo "#define C_ALLOCA 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } if test "${ac_cv_os_cray+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined CRAY && ! defined CRAY2 webecray #else wenotbecray #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "webecray" >/dev/null 2>&1; then : ac_cv_os_cray=yes else ac_cv_os_cray=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 $as_echo "$ac_cv_os_cray" >&6; } if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" eval as_val=\$$as_ac_var if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func _ACEOF break fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 $as_echo_n "checking stack direction for C alloca... " >&6; } if test "${ac_cv_c_stack_direction+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_c_stack_direction=0 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int find_stack_direction () { static char *addr = 0; auto char dummy; if (addr == 0) { addr = &dummy; return find_stack_direction (); } else return (&dummy > addr) ? 1 : -1; } int main () { return find_stack_direction () < 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_stack_direction=1 else ac_cv_c_stack_direction=-1 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 $as_echo "$ac_cv_c_stack_direction" >&6; } cat >>confdefs.h <<_ACEOF #define STACK_DIRECTION $ac_cv_c_stack_direction _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mbstate_t" >&5 $as_echo_n "checking for mbstate_t... " >&6; } if test "${ac_cv_type_mbstate_t+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default # include int main () { mbstate_t x; return sizeof x; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_mbstate_t=yes else ac_cv_type_mbstate_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_mbstate_t" >&5 $as_echo "$ac_cv_type_mbstate_t" >&6; } if test $ac_cv_type_mbstate_t = yes; then $as_echo "#define HAVE_MBSTATE_T 1" >>confdefs.h else $as_echo "#define mbstate_t int" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working POSIX fnmatch" >&5 $as_echo_n "checking for working POSIX fnmatch... " >&6; } if test "${ac_cv_func_fnmatch_works+set}" = set; then : $as_echo_n "(cached) " >&6 else # Some versions of Solaris, SCO, and the GNU C Library # have a broken or incompatible fnmatch. # So we run a test program. If we are cross-compiling, take no chance. # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test. if test "$cross_compiling" = yes; then : ac_cv_func_fnmatch_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include # define y(a, b, c) (fnmatch (a, b, c) == 0) # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH) int main () { return (!(y ("a*", "abc", 0) && n ("d*/*1", "d/s/1", FNM_PATHNAME) && y ("a\\\\bc", "abc", 0) && n ("a\\\\bc", "abc", FNM_NOESCAPE) && y ("*x", ".x", 0) && n ("*x", ".x", FNM_PERIOD) && 1)); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_fnmatch_works=yes else ac_cv_func_fnmatch_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fnmatch_works" >&5 $as_echo "$ac_cv_func_fnmatch_works" >&6; } if test $ac_cv_func_fnmatch_works = yes; then : rm -f "$ac_config_libobj_dir/fnmatch.h" else ac_fn_c_check_decl "$LINENO" "getenv" "ac_cv_have_decl_getenv" "$ac_includes_default" if test "x$ac_cv_have_decl_getenv" = x""yes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_GETENV $ac_have_decl _ACEOF for ac_func in btowc mbsrtowcs mempcpy wmempcpy 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" eval as_val=\$$as_ac_var if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in wchar.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" eval as_val=\$$as_ac_Header if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done case " $LIBOBJS " in *" fnmatch.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS fnmatch.$ac_objext" ;; esac ac_config_links="$ac_config_links $ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h" $as_echo "#define fnmatch rpl_fnmatch" >>confdefs.h fi # use an external libmspack if requested cabextract_external_libmspack=no # Check whether --with-external-libmspack was given. if test "${with_external_libmspack+set}" = set; then : withval=$with_external_libmspack; cabextract_external_libmspack=$withval fi if test "z$cabextract_external_libmspack" != 'zno'; then ac_fn_c_check_header_mongrel "$LINENO" "mspack.h" "ac_cv_header_mspack_h" "$ac_includes_default" if test "x$ac_cv_header_mspack_h" = x""yes; then : else as_fn_error "Cannot find libmspack header" "$LINENO" 5 fi fi if test "z$cabextract_external_libmspack" != 'zno'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mspack_create_cab_compressor in -lmspack" >&5 $as_echo_n "checking for mspack_create_cab_compressor in -lmspack... " >&6; } if test "${ac_cv_lib_mspack_mspack_create_cab_compressor+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmspack $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 mspack_create_cab_compressor (); int main () { return mspack_create_cab_compressor (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_mspack_mspack_create_cab_compressor=yes else ac_cv_lib_mspack_mspack_create_cab_compressor=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_mspack_mspack_create_cab_compressor" >&5 $as_echo "$ac_cv_lib_mspack_mspack_create_cab_compressor" >&6; } if test "x$ac_cv_lib_mspack_mspack_create_cab_compressor" = x""yes; then : LIBMSPACK_LIBS=-lmspack else as_fn_error "Cannot find libmspack library" "$LINENO" 5 fi fi if test "z$cabextract_external_libmspack" != 'zno'; then EXTERNAL_LIBMSPACK_TRUE= EXTERNAL_LIBMSPACK_FALSE='#' else EXTERNAL_LIBMSPACK_TRUE='#' EXTERNAL_LIBMSPACK_FALSE= fi ac_config_files="$ac_config_files Makefile cabextract.spec" 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 test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${EXTERNAL_LIBMSPACK_TRUE}" && test -z "${EXTERNAL_LIBMSPACK_FALSE}"; then as_fn_error "conditional \"EXTERNAL_LIBMSPACK\" 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. 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 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=$?; test $as_status -eq 0 && as_status=1 if test "$3"; then as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 fi $as_echo "$as_me: error: $1" >&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 -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' 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 if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # 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 cabextract $as_me 1.4, which was generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_links="$ac_config_links" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration links: $config_links Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ cabextract config.status 1.4 configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" Copyright (C) 2009 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=$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"` ;; 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" _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" ;; "$ac_config_libobj_dir/fnmatch.h") CONFIG_LINKS="$CONFIG_LINKS $ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "cabextract.spec") CONFIG_FILES="$CONFIG_FILES cabextract.spec" ;; *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_LINKS+set}" = set || CONFIG_LINKS=$config_links test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$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 -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 # 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 {' >"$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 >>"\$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 >>"\$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 < "$tmp/subs1.awk" > "$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 $(srcdir), # ${srcdir} and @srcdir@ 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[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// 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 >"$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_t=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :L $CONFIG_LINKS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$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 "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 >"$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 "$tmp/subs.awk" >$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' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$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 "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$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 "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ || as_fn_error "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$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 "$tmp/config.h" "$ac_file" \ || as_fn_error "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :L) # # CONFIG_LINK # if test "$ac_source" = "$ac_file" && test "$srcdir" = '.'; then : else # Prefer the file from the source tree if names are identical. if test "$ac_source" = "$ac_file" || test ! -r "$ac_source"; then ac_source=$srcdir/$ac_source fi { $as_echo "$as_me:${as_lineno-$LINENO}: linking $ac_source to $ac_file" >&5 $as_echo "$as_me: linking $ac_source to $ac_file" >&6;} if test ! -r "$ac_source"; then as_fn_error "$ac_source: file not found" "$LINENO" 5 fi rm -f "$ac_file" # Try a relative symlink, then a hard link, then a copy. case $srcdir in [\\/$]* | ?:[\\/]* ) ac_rel_source=$ac_source ;; *) ac_rel_source=$ac_top_build_prefix$ac_source ;; esac ln -s "$ac_rel_source" "$ac_file" 2>/dev/null || ln "$ac_source" "$ac_file" 2>/dev/null || cp -p "$ac_source" "$ac_file" || as_fn_error "cannot link or copy $ac_source to $ac_file" "$LINENO" 5 fi ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 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"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //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' -e 's/\$U/'"$U"'/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 } ;; 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 $? 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 cabextract-1.4/AUTHORS0000644000175000017500000000105610656151246011477 00000000000000Principal author: Stuart Caie cabextract uses a cut-down version of the libmspack library, available at http://www.cabextract.org.uk/libmspack/ Japanese manual page by Katsumi Saito. Original manual page and Debian packaging by Eric Sharkey. FreeBSD packaging by Maxim Sovolev. NetBSD packaging by Ben Collver et al. SuSE packaging by Stefan Dirsch. RPM spec file by Soos Peter. cabextract uses GNU versions of the getopt_long(), mktime() and fnmatch() functions, (C) Free Software Foundation, if not found as part of the operating system. cabextract-1.4/COPYING0000644000175000017500000010451311562533565011471 00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . cabextract-1.4/ChangeLog0000644000175000017500000005435411562533532012211 000000000000002011-05-11 Stuart Caie * src/cabinfo.c: changed the largefile detection header to the same as mspack/system.h 2011-04-27 Stuart Caie * src/cabextract.c: changed char* to const char* in line with changes in libmspack. See mspack/ChangeLog for more details. 2011-04-25 Stuart Caie * load_spanning_cabinets(): Print the error code caused by a failed cabinet merge, before ruining the error code by calling cabd->close(). Thanks to Drew D'Addesio for reporting the problem. 2011-01-19 Stuart Caie * doc/wince_cab_format.html: Identified a new file flag in the WinCE header file. Thanks to Paul Sokolovsky for asking me to look into it. 2010-07-19 Stuart Caie * mspack: MS-ZIP recovery now recovers more bytes. Also, when a file fails to unpack because of a read error during decompression, all subsequent files in the same folder will give the same error, instead of claiming to be OK. See mspack/ChangeLog for full details. 2010-07-17 Stuart Caie * src/cabsplit: added new program, cabsplit, which splits cabinet files into one cabinet file per folder. Useful for debugging. 2010-06-17 Stuart Caie * configure.ac: Added --external-libmspack option, which allows you to use the libmspack library installed on your system rather than the copy bundled with cabextract. Thanks to Patrice Dumas for the patch. 2010-06-10 Stuart Caie * mspack: bugs in MS-ZIP and Quantum decoders have been fixed. See mspack/ChangeLog for full details. 2010-05-06 Stuart Caie * configure.ac, cabextract.c: added support for the one-arg mkdir() found in the MinGW32 environment. Thanks to Kevin O'Rourke for reporting this. 2009-09-24 Stuart Caie * doc/wince_cab_format.html, src/wince_info, src/wince_rename: The files in Windows CE cabinets are numbered after the first ID in the FILES section, rather than what I termed the "real ID". Fixed the documentation and the wince tools to match. The purpose of the field previously called "real ID" is now unknown. Thanks to Marco Schindler for discovering this. 2007-08-07 Stuart Caie * all: cabextract and libmspack have moved to the domain www.cabextract.org.uk. Updated the documentation to reflect this. 2007-01-20 Stuart Caie * create_output_name(): add UTF-8 support for 6-byte characters. Apparently they go that far these days. 2007-01-20 Stuart Caie * doc/wince_cab_format.html, src/wince_info: The REGKEYS "unknown" flag appears to be a boolean indicating whether variable substitution should take place. Thanks to Dominique Gallot for discovering it. 2006-06-21 Stuart Caie * create_output_name(): add UTF-8 support for 4-byte characters. 2006-03-01 Stuart Caie * process_cabinets(): on the advice of Mike Mohr, cabextract no longer skips entire cabinets, when create_output_filename() returns NULL, it only skips the affected files now. 2005-10-30 Stuart Caie * src/cabextract.c: added test mode to cabextract, wherein files aren't extracted, only passed through an MD5 checksum generator. cabextract then lists which files passed and which files failed. * process_cabinets(): fixed the problem where filters don't match when -d option is also used. The filters match on the full output-file path, including the -d directory specified. We now trim this off before matching. 2005-10-29 Stuart Caie * fnmatch.c, getopt.c: finally resolved problems with all the GNU replacement functions. Obtained new versions of fnmatch and getopt, removing the need for alloca.c, coded out the requirement for mempcpy in getopt.c (I don't think it was needed anyway, but just to be sure I changed it to use just memcpy). Tested on Mac OS X (both native and using fink), Solaris 8 and Cygwin as well as Debian. * configure.ac: Removed the AC_FUNC_ALLOCA and AC_REPLACE_FUNCS([mempcpy]) 2005-07-05 Stuart Caie * src/cabinfo.c: This can now search and print accurate output for cabinets (and files containing cabinets) over 2GB. 2005-04-21 Stuart Caie * src/cabinfo.c: This now prints if the NAME_IS_UTF flag is set for each file. 2004-10-19 Stuart Caie * create_output_name(): fixed out-by-one error in UTF-8 decoder. All UTF-8 filenames would reach the "error in UTF-8 decode" section, because the test for that section was "pointer >= last_character", not "pointer > last_character". 2004-10-18 Stuart Caie * process_cabinet(): now accepts that failure of create_output_name() is an error, and also lets that function print an error message rather than printing one itself. * create_output_name(): improved the two error messages that could be printed. 2004-10-15 Stuart Caie * create_output_name(): removes leading "./" and "../" as well as leading slashes from the input filename. Thanks to David Banz for pointing this out, as well as http://www.securityfocus.com/bid/11376/ 2004-07-16 Stuart Caie * Makefile.am: added -DMSPACK_NO_DEFAULT_SYSTEM. Why wasn't this in earlier? * src/cabextract.c: added prototypes of the cabx_ functions, removed the prototype of cabextract_system and moved the real cabextract_system to before main(). This is so AIX doesn't fail on seeing an extern and a static definition of the same global. That's messed up! * alloca.c, fnmatch*, getopt*, mempcpy.c: imported these from gcc's latest libiberty. This should fix problems with Cygwin. 2004-03-18 Stuart Caie * process_cabinet(): added missing printf argument when errors on extracting to stdout occur. Thanks to Moritz Barsnick for finding it. 2004-03-08 Stuart Caie * all: tidy-ups for 1.0 release 2003-09-04 Stuart Caie * set_date_and_perm(): implemented the utimes() alternative to utime(). * set_date_and_perm(): sets the date before the permissions are set, in case read-only files really do get -r--r--r-- permissions and your dumb OS won't let the date can't be changed. 2003-08-14 Stuart Caie * wince_cab_format.html: Shaun Jackman worked out six more fields in the header. 2003-08-12 Stuart Caie * cabextract.c: rewrote all function documentation in javadoc / doxygen format. * configure.ac: added AC_FUNC_ALLOCA / @ALLOCA@ / alloca.c because I noticed that fnmatch.c uses alloca(). 2003-08-11 Stuart Caie * main(): Removed the redundant args.list with args.view. I was wondering why cabextract -l file.cab was trying to extract instead of list... 2003-08-06 Stuart Caie * configure.in, Makefile.am: rewrote the configure and build scripts, in the new style. fnmatch sources are now bundled, and now all the support code and tools are in the top directory, leaving src/ with nothing but cabextract code in it. 2003-08-05 Stuart Caie * wince_cab_format.html: converted the WinCE CAB format document from text to HTML. 2003-07-29 Stuart Caie * cabextract.c: now rewritten to use libmspack. * process_cabinet(): the cabinet listing now has space for 10 digits in the size field, for those really big compressed files. The maximum size of a file is 4294967295 bytes. 2003-07-18 Stuart Caie * cabextract.c: started refactoring cabextract to use the libmspack library. Moved everything out of cabextract.c and will start moving things back in as necessary. * doc, mspack: added a doc directory, where fun things like manual pages, magic files and file format documents go. Made a directory for libmspack files. 2003-06-07 Stuart Caie * mspack: started creation of the libmspack library, based on the cabextract code. See http://www.kyz.uklinux.net/libmspack/ for more details about the library. 2003-05-14 Stuart Caie * magic.cabinet: fixed errors in CAB magic definition * magic.wince: added magic file entry for WinCE install format * configure.in: added large file support 2003-04-21 Stuart Caie * ja/cabextract.1: Katsumi Saito kindly translated the updated manual page into Japanese for me. 2003-04-20 Stuart Caie * cabextract.1: finally decided on feature set for cabextract 0.7, so I updated the manual to reflect that. 2003-03-12 Stuart Caie * wince_cab_format.txt: reverse engineered most of the file format for Windows CE installation CAB header files. Windows CE uses normal cabinet files, but the files inside the cabinets use short filenames and a special binary header to specify full filenames, install directories, registry entries and symbolic links. If anyone wants to help fill in the remaining fields, I'm all ears. 2002-11-19 Stuart Caie * cabextract.c: moved the generation of the correct unix filename for an extracted file out of file_open() and into the main process_cabinet() function (it now has a helper function called create_output_name()). This is to make the real filename available outside of file_open(). (See below) * file_close(): chmod() and utime() are now called on the correct filename :) 2002-11-13 Stuart Caie * unix_directory_seperators(): this is a new function added to determine whether the CAB file is using "wrong" UNIX-style forward slashes as directory seperators. Microsoft CAB files use MS-DOS backslashes, however the tools Cablinux and PowerArchiver create CABs with forward-slashes. 2002-09-12 Stuart Caie * file_cabs_in_file(): if the file itself doesn't exist, we no longer print "Not a Microsoft cabinet file" for not finding any cabinets in that file. 2002-09-08 Stuart Caie * cabextract.c: cabextract used to segv if an LZX or Quantum folder came after an MSZIP folder, because the window pointer would be filled in by MSZIP's state. To solve this, I took the window pointers and associated variables out of the state union, and I also started clearing the state structure on startup. I also removed the 'what was the old compression type / free window' code and replaced it with a simple 'free LZX/QTM window if it exists' before ZIP initialisation. 2002-09-08 Stuart Caie * find_cabs_in_file(): if a file begins with "ISc(", cabextract now prints a message about how to unpack InstallShield '.cab' files, which begin with this signature. 2002-09-08 Stuart Caie * cabextract.c: After seeing what some people think the command line syntax is for cabextract is (e.g. http://slashdot.org/comments.pl?sid=39401&cid=4210033) I have decided to be nice to people who don't read manuals, and refuse to extract files given on the command line if they've already been extracted as part of another cabinet. This does preclude the scenario where a file is not only part of a multi-part set, but has a cabinet at offset 0 and _also_ has embedded cabs later on. The new functionality is implemented by the new functions remember_cabinet() and known_cabinet(), which use a simple linked list. If you want the old behaviour of cabextract back, do "find -exec cabextract {} \;". 2002-09-08 Stuart Caie * configure.in: Upgraded my autoconf to one that has the AC_EXEEXT bug fixed (look up AC_EXEEXT xSYM on the Internet :). Now it complains about me writing to LIBOBJS directly, so I use the macro AC_LIBOBJ twice to add getopt and getopt1 to LIBOBJS. 2002-08-20 Stuart Caie * AUTHORS, ChangeLog, NEWS, cabextract.c: fixed mis-spellings of Matthew Russotto's name. * ChangeLog: finished a half-completed changelog entry. 2002-08-12 Stuart Caie * cabextract.c: now prints all errors and warnings to stderr rather that stdout. I finally noticed that perror() prints to stderr, and I want to follow suit. 2002-08-11 Stuart Caie * extract_file(): now prints out the correct cabinet name in error messages, in the case of files which are split over multiple cabinet files and the 2nd or later split cabinet contains the error. * QTMdecompress(): fixed the QTM decoding error - basically, Matthew used the bitstream reading macros from my LZX decompressor. Sadly, these macros can only guarantee at maximum 17 bits available in the bit buffer, and Quantum uses up to 19 bits. I rewrote the Quantum bit buffer macros to be multi-pass (and therefore slower) so they can get the requisite number of bits. * QTMinit(): after fixing the decoding bug, I noticed that files always failed extraction when going to a second folder. It turns out that I forgot to reset QTM's window_posn. * configure.in: added limits.h to the list of checked includes * cabextract.c: ULONG_BITS now defined in terms of CHAR_BIT from rather than fixed to 8 bits per char. Oddly, my system seems to include rather than . So, for people like me, I also define CHAR_BIT to be 8 if it's not already defined. 2002-07-29 Stuart Caie * cabextract.c: The Ministry of Sensible Naming dictates that load_cab() be renamed find_cabs_in_file(), and lose the 'search' argument. Calls to load_cab() where the search argument = 0 (i.e., when loading spanning cabinets) be changed to load_cab_offset(x,0). 2002-07-25 Stuart Caie * load_cab(): Bah! off_t is defined as a signed long int, and not an unsigned long int as I had previously thought. This means the 'valid cabinet' comparisions may fail. I have fixed this by making these comparisons unsigned. * cabinfo.c: added the new search mechanism to cabinfo. 2002-07-25 Stuart Caie * process_cabinet(): rewrote the loading mechanism. Uses the new load_cab() to get a list of cabinets in the base file. Also does bi-directional loading of spanning cabinets. * load_cab(): now takes a 'search' parameter. if search=0, the old loading behaviour is performed, but if search=1, it now does the exhaustive search for all matching cabinets and tries to load them. If a load succeeds, it skips that section of the file. Therefore, all embedded cabinets are found, yet most of the file does not need to be searched. * cabinet_find_header(): removed, see above. Also, in shifting the search, I altered the search mechanism. It now uses a state machine to get around border cases, rather than the flaky 'save the last 20 bytes and put them at the start the next time around'. * cabinet_read_entries(): now checks the MSCF signature, as there is no longer a cabinet_find_header() to do this. 2002-07-23 Stuart Caie * LZXdecompress(), QTMdecompress(): On systems where the LZ window pointer is in "low memory", runsrc (window pointer - match offset) could be below address 0, which wraps around to the end of memory, so it appears runsrc is ahead of the LZ window, and so it does not need 'fixing' before the match copy. Therefore the match data is read from the incorrect, high address. Thanks to the NetBSD team for discovering this and providing the patch. 2002-07-22 Stuart Caie * file_close(): now honours your umask settings when extracting files. Thanks to the NetBSD team for the patch. * cabinet_seek(), cabinet_skip(): these now print errors if fseek() returns an error. * QTMdecompress(): finally! Added an implementation of the Quantum method which was researched and written by Matthew Russotto. Many thanks to him for all the hard work he did to produce this. I tidied up the code to be more my style (and to be quite a bit faster by inlining the bit buffer, H, L and C), but it's still all his code running. * find_next_cabinet_file(): this is a new function which finds the "next cabinet" by opening the directory it would be in and reading each filename case-insensitively. It also handles any such "next cabinets" with directory elements (delimited with MS-DOS backslashes). * process_cabinet(): now uses find_next_cabinet_file() to get the next cabinet file. This function also replaces the hack that gets any directory path which might be embedded in the base cabinet filename (as mentioned on the command line). 2002-07-21 Stuart Caie * file_close(): fixed off-by-one error in setting the extracted file date. Thanks to Claus Rasmussen. 2002-07-20 Stuart Caie * file_open(): now removes any leading slashes from the name of the file to be extracted. Thanks to the James Henstridge and David Leonard for patches. * ensure_filepath(): now does not try to examine the directory "" (i.e. no directory at all) if given an absolute path (one that start with a slash). Thanks to the James Henstridge for the patch. 2002-04-30 Stuart Caie * cabextract.spec.in: changed the fixed version number to @VERSION@ 2002-04-06 Stuart Caie * Makefile.am, configure.in: used the guide no_getopt_long.txt included with the gengetopt package to add getopt_long configuration to cabextract. Hopefully it all works now. Thanks to the many people who pointed out this problem and to the many people who offered solutions. 2001-09-06 Stuart Caie * Makefile.am, configure.in: made cabextract.spec one of the auto- generated files. Now I can do 'make distcheck' here to build a distribution which can be installed using 'rpm -tb cabextract-0.6.tar.gz'. Thanks to Daniel Resare for the know-how. 2001-08-20 Stuart Caie * Makefile.am: added an LDADD line for cabextract's LIBOBJS generated by configure. This means the AC_REPLACE_FUNCS line should actually have an effect. * configure.in: Removed getopt_long and mktime from the AC_CHECK_FUNCS, as this is done anyway. 2001-08-19 Stuart Caie * Makefile.am, configure.in, cabextract.c: moved the GNU getopt sources to become an automatically added dependency if getopt_long() can't be found in the standard library, just like mktime() is handled. The getopt_long(), struct option and optarg and optind definitions are taken from getopt.h if possible. If they're not there, but getopt_long() was found with standard includes files, it's assumed they're defined in the standard include files. Otherwise, we define them ourselves. * cabextract.c: now gets VERSION defined from configure via config.h. * decompress(): if the 'fix' option was used, the output buffer would always be cleared before block decompression. A nice idea, but the MSZIP method likes to keep the output buffer between blocks. Thanks to Fernando Trias for spotting this. Stopped clearing the output buffer. * main(): the 'fix' variable wasn't initialised to zero, so on some architectures, where the stack-space allocated to the variable isn't cleared to zero, you always got the 'fix' option selected. See above for why this was bad. * process_cabinet(): now prints "Finished processing cabinet" when finished extracting, instead of just a blank line. Still prints blank lines for listing files. 2001-08-05 Stuart Caie * Makefile.am: the manpage wasn't included in the distribution. Fixed and re-issued the 0.3 release. 2001-08-02 Stuart Caie * decompress(): now takes a 'fix' flag, which causes MSZIP errors to be ignored. * cabinet_get_entries(): now keeps the printable information about previous and next cabinet parts * process_cabinet(): now prints the printable information about the next cabinet part in a multi-part cabinet * file_open(): now prepends a given directory if wanted, and can make the filename lowercase if wanted. * main(): changed to using getopt_long to parse arguments. Added -L (lowercase), -d (output to directory), -f (fix corrupt cabs), -h (help), -q (quiet) and -v was recycled to become --version, when used on its own. * LZXdecompress(): major bug fixed; the updated R0, R1 and R2 in uncompressed blocks were being stored in the uncomp_state block, not local variables. At the end of the function, the local values are always written back to the uncomp_state block. So the values placed there by the uncompressed block header were always overwritten. Thanks to Pavel Turbin for providing an example of this. * rindex(): this is the BSD precursor of the ANSI standard function strrchr(). Oops! Now uses strrchr(), or rindex() if strrchr() isn't available. * cabinet_find_header(): now prints an error message if it can't find a header. 2001-04-30 Stuart Caie * fixed includes to include both and if they both exist, and made some signedness conversions explicit. This should let cabextract compile with SGI's native compiler. Thanks to Markus Nullmeier for the patch. 2001-03-04 Stuart Caie * main(): now prints the version of cabextract in the copyright line. * cabinet_find_header(): now searches any kind of file, not just files beginning with 'MZ' header. Also, always searches entire file. This slows the search down, but increases the usefulness of the search overall, IMHO. Thanks to Eric Sharkey for pointing this out. * LZXdecompress(): fixed problem in intel decoding: E8 must not appear in the last 10 bytes, not the last 6 bytes... Thanks to Jae Jung who pointed this out to me. I didn't believe him at first, but he was quite right. Also thanks to Antoine Amanieux for providing example files affected by this. * process_cabinet(): now extends multipart cabinet filenames to be in the same directory as the base cabinet. * cabinet_open(): now only lowercases the filename part of a cabinet name, not the path part. 2001-03-03 Stuart Caie * LZXdecompress(): fixed LZX bit buffer exhaustion in where READ_HUFFSYM() requests more bits than the buffer actually contains: top-of-loop overflow check now allows for the input pointer to be 16 bits past the end of the buffer, but checks to ensure none of those 16 bits are actually used. Also increased decomp_state.inbuf by two bytes and clear the two bytes after loaded block in decompress(). Thanks to Jae Jung for pointing out this bug, and for providing example files which exposed the bug. 2001-02-26 Stuart Caie * added configure script / makefile using automake. * file_close(): now sets the timestamp on extracted files. cabextract-1.4/INSTALL0000644000175000017500000003633211562533565011472 00000000000000Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 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 commands `./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. 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 bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /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. cabextract-1.4/NEWS0000644000175000017500000001575011562533532011133 00000000000000New in 1.4: * A bug in the LZX decompressor was fixed. * cabextract is now more tolerant when processing cabinet sets. * cabextract is now compatible with even more compilers, and now supports 64-bit file I/O on platforms where it's completely native, like Mac OS X 10.6 and Fedora x86_64. * cabextract will no longer print "library not compiled to support large files" while reading small files. * The Windows CE installation format document was improved. New in 1.3: * Bugs in the MS-ZIP and Quantum decompressors have been fixed. * MS-ZIP recovery has been improved. * cabextract should now compile with MinGW New in 1.2: * "-t" option: Allows you to test that every file can be extracted without having to extract it. This also prints the MD5 checksum of the file. * UTF-8 filenames are now decoded correctly. * Large files (>2GB) are now searched correctly for cabinets. * Problems with the GNU library code have been fixed. * Several bugs in the LZX and Quantum decompressors have been fixed. New in 1.1: * A security vulnerability has been fixed. If the files within a cabinet file include the directory ".." in their filename, this will be changed to "xx", to prevent directory traversal by a malicious cabinet (e.g. a cabinet with "..\etc\passwd", "..\..\etc\passwd" and so on) * The GNU library code used has been upgraded to the latest from libiberty, so it should now work better with Cygwin. * cabextract should now compile cleanly on AIX. New in 1.0: * The libmspack library is used for all the hard work. You should find cabextract more robust, and fractionally faster. See the libmspack website at http://www.cabextract.org.uk/libmspack/ for more on this library. * Fixed a bug (now moved to libmspack) where CAB files that had two kinds of compression would crash. * CAB files should no longer get "/" and "\" mixed up, even with non MS-DOS cabinet files created by tools like Powerarchiver and Cablinux. * Now ignores CAB files listed on the command line that have already been used as part of a multipart set. You can now type "cabextract *.cab" on your Win95 cabinet set, and cabextract will not extract all the files sixty times over. * Now supports reading and extracting large (more than 2Gb) files. * "-L" option: viewing the archive pays attention to the "-L" flag, and shows the filenames in lowercase. * "-L" option: cabextract now correctly lowercases cabinet files with Unicode filenames. * "-l" option: viewing the archive should always show forward slashes as directory seperators. * "-F" option: Now you can choose which files are extracted from the cab. For example, "cabextract -F '*.wav' music.cab" extracts only WAV files. * "-s" option: Now you can limit which multipart cabinets are used. For example, "cabextract -s WIN98_5*.CAB" will only extract files from WIN98_50.CAB through WIN98_59.CAB. * "-p" option: Now you can extract files to stdout rather than disk. * Now comes with an experimental "wince_info" and "wince_rename" perl scripts in the src/ directory, for examining and processing Windows CE installation cabinet header files. There is also the "cabinfo" command for examining the structure of a cab file. As this information is not very useful to most people, none of these three tools are installed. * Both the English and Japanese manual page have been updated. * cabextract now alerts you if you try to unpack InstallShield cabinets. * The definition of Microsoft cabinet files for UNIX's "magic" file, in doc/magic, has been fixed, and a definition of Windows CE install cabinet header files has also been added. New in 0.6: * Quantum method is now supported! Many thanks to Matthew Russotto for this. * Fixed more build problems on non-glibc systems. I have now followed the 'FSF approved' method for including getopt_long, so hopefully Solaris and all the other OSes won't have a problem building cabextract any more. * Japanese manual page included -- you will have to install the file ja/cabextract.1 by yourself, it's not part of the install process. * Now searches for spanning cabinet files in a case-insensitive way. It also searches in both directions for spanned cabinets (each spanned cabinet can include a 'previous' and 'next' cabinet filename), so you can also specify a cabinet in the middle of a set and get the full set, rather than have to work out what the first cabinet is. * An off-by-one month error in file dates was fixed. * Cabinets with files beginning with "/" (or rather, "\") no longer extract to your root directory. * A better embeded cabinet search algorithm was introduced for finding those elusive cabinets in files and executables :) * Now you can find more than one cabinet in a file (if there is more than one to find), and it will be extracted or listed as normal. * Files and directories created now honour your umask settings. * Errors and warnings are now printed to stderr. New in 0.5: * Fixed build problems on non-glibc systems. New in 0.4: * Fixed a new bug I added by myself to 0.3... :) It corrupts all MS-ZIP compressed cabinets after the first 32k, and it should be very obvious that corruption has taken place. * cabextract should be happier building on Cygwin and other such architectures -- you should be able to "./configure; make; make install" again. This was broken in 0.3 due to the getopt.c / getopt1.c weirdness I copied from GNU hello. * Now prints 'Finished processing cabinet.' after completing the extraction a cabinet. New in 0.3: * Fixed very rare, but invisible decrunching bug... if you have any important things you extracted with cabextract, extract them again to be sure they're not corrupt. * cabextract now tells you if a file isn't a cabinet file. * cabextract now goes on to the next file, if extracting one fails. * cabextract now goes on to the next cabinet, if extracting one fails. * cabextract lets you try to 'fix' some cabinets by skipping over bad blocks rather than failing on them. If you have a corrupt cabinet, try the '-f' option, and see how it goes. * Use the new '-d dir' option to extract cabinets to a given directory. * Use the new '-L' option to turn the extracted filenames to lowercase. * Use the new '-q' option to be quiet while extracting archives. * cabextract now prints more information while it's probing multi-part cabinets New in 0.2: * new even-easier installation: ./configure; make; make install * Extracted files now have their timestamps set * Fixed bug which occured when extracting tiny files * Fixed completely invisible intel E8 decoding bug... if you have any important things you extracted with cabextract, extract them again to be sure they're not corrupt. * cabinet search extended to look through *any* file for cabinets, not just MS-DOS/Windows executables. * Now looks for multipart cabinets in the same directory as the base cabinet. This means you can do stuff like 'cd /tmp && cabextract /cdrom/part01.cab' New in 0.1: * supports MSZIP and LZX compression methods * supports split cabs and cabs embedded in executables * initial release cabextract-1.4/TODO0000644000175000017500000000153511562533546011125 00000000000000Automatic renaming of files in their long form, for Windows CE install cabs. This would probably be another program using libmspack, rather than auto-detected by cabextract. Provide tool for finding OLE2 streams and dumping them. Some InstallShield Wizard use MS CAB files inside MS OLE2 streams. They look normal, but every so often, there's a 512 bytes extra here and a 512 bytes missing there, so the cabinets aren't contiguous. More advanced repair of corrupted CABs? Possible? cabjoin - a new program that will read multipart cabinets and output a single cabinet file containing all parts. Allow reading a cabinet from stdin. Allow an exacting list of files to be matched rather than a single pattern match. Allow more than one pattern match? cabextract should be localised. cabextract should not overwrite the source cabinet files when unpacking. cabextract-1.4/fnmatch.c0000644000175000017500000001222011211025403012165 00000000000000/* fnmatch.c (description) Copyright (C) 1991, 1992, 1993 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 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 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: Free Software Foundation, Inc. 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA */ static const char rcsid[] = "$Id: fnmatch.c,v 1.3 2006-03-01 21:11:32 kyz Exp $"; #ifdef HAVE_CONFIG_H # include "config.h" #endif #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif #include #include #include "fnmatch.h" /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #if defined (_LIBC) || !defined (__GNU_LIBRARY__) #if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) #endif /* Match STRING against the filename pattern PATTERN, returning zero if it matches, nonzero if not. */ int fnmatch (pattern, string, flags) const char *pattern; const char *string; int flags; { register const char *p = pattern, *n = string; register unsigned char c; /* Note that this evalutes C many times. */ #define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c)) #ifdef _WIN32 flags |= FNM_CASEFOLD; #endif while ((c = *p++) != '\0') { c = FOLD (c); switch (c) { case '?': if (*n == '\0') return FNM_NOMATCH; else if ((flags & FNM_FILE_NAME) && *n == '/') return FNM_NOMATCH; else if ((flags & FNM_PERIOD) && *n == '.' && (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) return FNM_NOMATCH; break; case '\\': if (!(flags & FNM_NOESCAPE)) { c = *p++; c = FOLD (c); } if (FOLD ((unsigned char) *n) != c) return FNM_NOMATCH; break; case '*': if ((flags & FNM_PERIOD) && *n == '.' && (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) return FNM_NOMATCH; for (c = *p++; c == '?' || c == '*'; c = *p++, ++n) if (((flags & FNM_FILE_NAME) && *n == '/') || (c == '?' && *n == '\0')) return FNM_NOMATCH; if (c == '\0') return 0; { unsigned char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c; c1 = FOLD (c1); for (--p; *n != '\0'; ++n) if ((c == '[' || FOLD ((unsigned char) *n) == c1) && fnmatch (p, n, flags & ~FNM_PERIOD) == 0) return 0; return FNM_NOMATCH; } case '[': { /* Nonzero if the sense of the character class is inverted. */ register int not; if (*n == '\0') return FNM_NOMATCH; if ((flags & FNM_PERIOD) && *n == '.' && (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) return FNM_NOMATCH; not = (*p == '!' || *p == '^'); if (not) ++p; c = *p++; for (;;) { register unsigned char cstart = c, cend = c; if (!(flags & FNM_NOESCAPE) && c == '\\') cstart = cend = *p++; cstart = cend = FOLD (cstart); if (c == '\0') /* [ (unterminated) loses. */ return FNM_NOMATCH; c = *p++; c = FOLD (c); if ((flags & FNM_FILE_NAME) && c == '/') /* [/] can never match. */ return FNM_NOMATCH; if (c == '-' && *p != ']') { cend = *p++; if (!(flags & FNM_NOESCAPE) && cend == '\\') cend = *p++; if (cend == '\0') return FNM_NOMATCH; cend = FOLD (cend); c = *p++; } if (FOLD ((unsigned char) *n) >= cstart && FOLD ((unsigned char) *n) <= cend) goto matched; if (c == ']') break; } if (!not) return FNM_NOMATCH; break; matched:; /* Skip the rest of the [...] that already matched. */ while (c != ']') { if (c == '\0') /* [... (unterminated) loses. */ return FNM_NOMATCH; c = *p++; if (!(flags & FNM_NOESCAPE) && c == '\\') /* XXX 1003.2d11 is unclear if this is right. */ ++p; } if (not) return FNM_NOMATCH; } break; default: if (c != FOLD ((unsigned char) *n)) return FNM_NOMATCH; } ++n; } if (*n == '\0') return 0; if ((flags & FNM_LEADING_DIR) && *n == '/') /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ return 0; return FNM_NOMATCH; } #endif /* _LIBC or not __GNU_LIBRARY__. */ cabextract-1.4/getopt.c0000644000175000017500000007265610401407004012073 00000000000000/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO # define _NO_PROTO #endif #ifdef HAVE_CONFIG_H # include #endif #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 # include # if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION # define ELIDE_CODE # endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ # include # include #endif /* GNU C library. */ #ifdef VMS # include # if HAVE_STRING_H - 0 # include # endif #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ # ifdef HAVE_LIBINTL_H # include # define _(msgid) gettext (msgid) # else # define _(msgid) (msgid) # endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ int __getopt_initialized; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ # include # define my_index strchr #else # if HAVE_STRING_H # include # endif # if HAVE_STRINGS_H # include # endif /* Avoid depending on library functions or files whose names are inconsistent. */ #ifndef getenv extern char *getenv (); #endif static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ # if (!defined __STDC__ || !__STDC__) && !defined strlen /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); # endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; #ifdef _LIBC /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ /* Defined in getopt_init.c */ extern char *__getopt_nonoption_flags; static int nonoption_flags_max_len; static int nonoption_flags_len; static int original_argc; static char *const *original_argv; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void __attribute__ ((unused)) store_args_and_env (int argc, char *const *argv) { /* XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ original_argc = argc; original_argv = argv; } # ifdef text_set_element text_set_element (__libc_subinit, store_args_and_env); # endif /* text_set_element */ # define SWAP_FLAGS(ch1, ch2) \ if (nonoption_flags_len > 0) \ { \ char __tmp = __getopt_nonoption_flags[ch1]; \ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ __getopt_nonoption_flags[ch2] = __tmp; \ } #else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) #endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ #if defined __STDC__ && __STDC__ static void exchange (char **); #endif static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ #ifdef _LIBC /* First make sure the handling of the `__getopt_nonoption_flags' string can work normally. Our top argument must be in the range of the string. */ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { /* We must extend the array. The user plays games with us and presents new arguments. */ char *new_str = malloc (top + 1); if (new_str == NULL) nonoption_flags_len = nonoption_flags_max_len = 0; else { memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len); memset (new_str + nonoption_flags_max_len, '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } } #endif while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; SWAP_FLAGS (bottom + i, middle + i); } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined __STDC__ && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * _getopt_initialize (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; #ifdef _LIBC if (posixly_correct == NULL && argc == original_argc && argv == original_argv) { if (nonoption_flags_max_len == 0) { if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0') nonoption_flags_max_len = -1; else { const char *orig_str = __getopt_nonoption_flags; int len = nonoption_flags_max_len = strlen (orig_str); if (nonoption_flags_max_len < argc) nonoption_flags_max_len = argc; __getopt_nonoption_flags = (char *) malloc (nonoption_flags_max_len); if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else { memcpy (__getopt_nonoption_flags, orig_str, len); memset (__getopt_nonoption_flags + len, '\0', nonoption_flags_max_len - len); } } } nonoption_flags_len = nonoption_flags_max_len; } else nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { int print_errors = opterr; if (optstring[0] == ':') print_errors = 0; optarg = NULL; if (optind == 0 || !__getopt_initialized) { if (optind == 0) optind = 1; /* Don't scan ARGV[0], the program name. */ optstring = _getopt_initialize (argc, argv, optstring); __getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #ifdef _LIBC # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ && __getopt_nonoption_flags[optind] == '1')) #else # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) return -1; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; optopt = 0; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (print_errors) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); } nextchar += strlen (nextchar); optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (print_errors) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (print_errors) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (print_errors) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); else fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (print_errors) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (print_errors) fprintf (stderr, _("%s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (print_errors) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (print_errors) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* Not ELIDE_CODE. */ cabextract-1.4/getopt1.c0000644000175000017500000000572710401407004012147 00000000000000/* getopt_long and getopt_long_only entry points for GNU getopt. Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 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 Library General Public License as published by the Free Software Foundation; either version 2 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include #endif #include "getopt.h" #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #endif int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } #endif /* Not ELIDE_CODE. */ cabextract-1.4/install-sh0000755000175000017500000003253711562533565012450 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2009-04-28.21; # 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 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 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 trap '(exit $?); exit' 1 2 13 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 starting with `-'. 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 # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # 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-writeable 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 -z "$d" && 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: cabextract-1.4/missing0000755000175000017500000002623311562533565012037 00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009 Free Software Foundation, Inc. # Originally 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 run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] 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 # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; tar*) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar*) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac 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: cabextract-1.4/mktime.c0000644000175000017500000003605707730101326012063 00000000000000/* mktime: convert a `struct tm' to a time_t value Copyright (C) 1993-1997, 1998 Free Software Foundation, Inc. Contributed by Paul Eggert (eggert@twinsun.com). NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Define this to have a standalone program to test this implementation of mktime. */ /* #define DEBUG 1 */ #ifdef HAVE_CONFIG_H # include #endif #ifdef _LIBC # define HAVE_LIMITS_H 1 # define STDC_HEADERS 1 #endif /* Assume that leap seconds are possible, unless told otherwise. If the host has a `zic' command with a `-L leapsecondfilename' option, then it supports leap seconds; otherwise it probably doesn't. */ #ifndef LEAP_SECONDS_POSSIBLE # define LEAP_SECONDS_POSSIBLE 1 #endif #include /* Some systems define `time_t' here. */ #include #if HAVE_LIMITS_H # include #endif #if DEBUG # include # if STDC_HEADERS # include # endif /* Make it work even if the system's libc has its own mktime routine. */ # define mktime my_mktime #endif /* DEBUG */ #ifndef __P # if defined (__GNUC__) || (defined (__STDC__) && __STDC__) # define __P(args) args # else # define __P(args) () # endif /* GCC. */ #endif /* Not __P. */ #ifndef CHAR_BIT # define CHAR_BIT 8 #endif /* The extra casts work around common compiler bugs. */ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) /* The outer cast is needed to work around a bug in Cray C 5.0.3.0. It is necessary at least when t == time_t. */ #define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) #define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) #ifndef INT_MIN # define INT_MIN TYPE_MINIMUM (int) #endif #ifndef INT_MAX # define INT_MAX TYPE_MAXIMUM (int) #endif #ifndef TIME_T_MIN # define TIME_T_MIN TYPE_MINIMUM (time_t) #endif #ifndef TIME_T_MAX # define TIME_T_MAX TYPE_MAXIMUM (time_t) #endif #define TM_YEAR_BASE 1900 #define EPOCH_YEAR 1970 #ifndef __isleap /* Nonzero if YEAR is a leap year (every 4 years, except every 100th isn't, and every 400th is). */ # define __isleap(year) \ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) #endif /* How many days come before each month (0-12). */ const unsigned short int __mon_yday[2][13] = { /* Normal years. */ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, /* Leap years. */ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; static struct tm *ranged_convert __P ((struct tm *(*) __P ((const time_t *, struct tm *)), time_t *, struct tm *)); static time_t ydhms_tm_diff __P ((int, int, int, int, int, const struct tm *)); time_t __mktime_internal __P ((struct tm *, struct tm *(*) (const time_t *, struct tm *), time_t *)); #ifdef _LIBC # define my_mktime_localtime_r __localtime_r #else /* If we're a mktime substitute in a GNU program, then prefer localtime to localtime_r, since many localtime_r implementations are buggy. */ static struct tm *my_mktime_localtime_r __P ((const time_t *, struct tm *)); static struct tm * my_mktime_localtime_r (t, tp) const time_t *t; struct tm *tp; { struct tm *l = localtime (t); if (! l) return 0; *tp = *l; return tp; } #endif /* ! _LIBC */ /* Yield the difference between (YEAR-YDAY HOUR:MIN:SEC) and (*TP), measured in seconds, ignoring leap seconds. YEAR uses the same numbering as TM->tm_year. All values are in range, except possibly YEAR. If TP is null, return a nonzero value. If overflow occurs, yield the low order bits of the correct answer. */ static time_t ydhms_tm_diff (year, yday, hour, min, sec, tp) int year, yday, hour, min, sec; const struct tm *tp; { if (!tp) return 1; else { /* Compute intervening leap days correctly even if year is negative. Take care to avoid int overflow. time_t overflow is OK, since only the low order bits of the correct time_t answer are needed. Don't convert to time_t until after all divisions are done, since time_t might be unsigned. */ int a4 = (year >> 2) + (TM_YEAR_BASE >> 2) - ! (year & 3); int b4 = (tp->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (tp->tm_year & 3); int a100 = a4 / 25 - (a4 % 25 < 0); int b100 = b4 / 25 - (b4 % 25 < 0); int a400 = a100 >> 2; int b400 = b100 >> 2; int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); time_t years = year - (time_t) tp->tm_year; time_t days = (365 * years + intervening_leap_days + (yday - tp->tm_yday)); return (60 * (60 * (24 * days + (hour - tp->tm_hour)) + (min - tp->tm_min)) + (sec - tp->tm_sec)); } } static time_t localtime_offset; /* Convert *TP to a time_t value. */ time_t mktime (tp) struct tm *tp; { #ifdef _LIBC /* POSIX.1 8.1.1 requires that whenever mktime() is called, the time zone names contained in the external variable `tzname' shall be set as if the tzset() function had been called. */ __tzset (); #endif return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset); } /* Use CONVERT to convert *T to a broken down time in *TP. If *T is out of range for conversion, adjust it so that it is the nearest in-range value and then convert that. */ static struct tm * ranged_convert (convert, t, tp) struct tm *(*convert) __P ((const time_t *, struct tm *)); time_t *t; struct tm *tp; { struct tm *r; if (! (r = (*convert) (t, tp)) && *t) { time_t bad = *t; time_t ok = 0; struct tm tm; /* BAD is a known unconvertible time_t, and OK is a known good one. Use binary search to narrow the range between BAD and OK until they differ by 1. */ while (bad != ok + (bad < 0 ? -1 : 1)) { time_t mid = *t = (bad < 0 ? bad + ((ok - bad) >> 1) : ok + ((bad - ok) >> 1)); if ((r = (*convert) (t, tp))) { tm = *r; ok = mid; } else bad = mid; } if (!r && ok) { /* The last conversion attempt failed; revert to the most recent successful attempt. */ *t = ok; *tp = tm; r = tp; } } return r; } /* Convert *TP to a time_t value, inverting the monotonic and mostly-unit-linear conversion function CONVERT. Use *OFFSET to keep track of a guess at the offset of the result, compared to what the result would be for UTC without leap seconds. If *OFFSET's guess is correct, only one CONVERT call is needed. */ time_t __mktime_internal (tp, convert, offset) struct tm *tp; struct tm *(*convert) __P ((const time_t *, struct tm *)); time_t *offset; { time_t t, dt, t0, t1, t2; struct tm tm; /* The maximum number of probes (calls to CONVERT) should be enough to handle any combinations of time zone rule changes, solar time, leap seconds, and oscillations around a spring-forward gap. POSIX.1 prohibits leap seconds, but some hosts have them anyway. */ int remaining_probes = 6; /* Time requested. Copy it in case CONVERT modifies *TP; this can occur if TP is localtime's returned value and CONVERT is localtime. */ int sec = tp->tm_sec; int min = tp->tm_min; int hour = tp->tm_hour; int mday = tp->tm_mday; int mon = tp->tm_mon; int year_requested = tp->tm_year; int isdst = tp->tm_isdst; /* Ensure that mon is in range, and set year accordingly. */ int mon_remainder = mon % 12; int negative_mon_remainder = mon_remainder < 0; int mon_years = mon / 12 - negative_mon_remainder; int year = year_requested + mon_years; /* The other values need not be in range: the remaining code handles minor overflows correctly, assuming int and time_t arithmetic wraps around. Major overflows are caught at the end. */ /* Calculate day of year from year, month, and day of month. The result need not be in range. */ int yday = ((__mon_yday[__isleap (year + TM_YEAR_BASE)] [mon_remainder + 12 * negative_mon_remainder]) + mday - 1); int sec_requested = sec; #if LEAP_SECONDS_POSSIBLE /* Handle out-of-range seconds specially, since ydhms_tm_diff assumes every minute has 60 seconds. */ if (sec < 0) sec = 0; if (59 < sec) sec = 59; #endif /* Invert CONVERT by probing. First assume the same offset as last time. Then repeatedly use the error to improve the guess. */ tm.tm_year = EPOCH_YEAR - TM_YEAR_BASE; tm.tm_yday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0; t0 = ydhms_tm_diff (year, yday, hour, min, sec, &tm); for (t = t1 = t2 = t0 + *offset; (dt = ydhms_tm_diff (year, yday, hour, min, sec, ranged_convert (convert, &t, &tm))); t1 = t2, t2 = t, t += dt) if (t == t1 && t != t2 && (isdst < 0 || tm.tm_isdst < 0 || (isdst != 0) != (tm.tm_isdst != 0))) /* We can't possibly find a match, as we are oscillating between two values. The requested time probably falls within a spring-forward gap of size DT. Follow the common practice in this case, which is to return a time that is DT away from the requested time, preferring a time whose tm_isdst differs from the requested value. In practice, this is more useful than returning -1. */ break; else if (--remaining_probes == 0) return -1; /* If we have a match, check whether tm.tm_isdst has the requested value, if any. */ if (dt == 0 && 0 <= isdst && 0 <= tm.tm_isdst) { int dst_diff = (isdst != 0) - (tm.tm_isdst != 0); if (dst_diff) { /* Move two hours in the direction indicated by the disagreement, probe some more, and switch to a new time if found. The largest known fallback due to daylight savings is two hours: once, in Newfoundland, 1988-10-30 02:00 -> 00:00. */ time_t ot = t - 2 * 60 * 60 * dst_diff; while (--remaining_probes != 0) { struct tm otm; if (! (dt = ydhms_tm_diff (year, yday, hour, min, sec, ranged_convert (convert, &ot, &otm)))) { t = ot; tm = otm; break; } if ((ot += dt) == t) break; /* Avoid a redundant probe. */ } } } *offset = t - t0; #if LEAP_SECONDS_POSSIBLE if (sec_requested != tm.tm_sec) { /* Adjust time to reflect the tm_sec requested, not the normalized value. Also, repair any damage from a false match due to a leap second. */ t += sec_requested - sec + (sec == 0 && tm.tm_sec == 60); if (! (*convert) (&t, &tm)) return -1; } #endif if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3) { /* time_t isn't large enough to rule out overflows in ydhms_tm_diff, so check for major overflows. A gross check suffices, since if t has overflowed, it is off by a multiple of TIME_T_MAX - TIME_T_MIN + 1. So ignore any component of the difference that is bounded by a small value. */ double dyear = (double) year_requested + mon_years - tm.tm_year; double dday = 366 * dyear + mday; double dsec = 60 * (60 * (24 * dday + hour) + min) + sec_requested; /* On Irix4.0.5 cc, dividing TIME_T_MIN by 3 does not produce correct results, ie., it erroneously gives a positive value of 715827882. Setting a variable first then doing math on it seems to work. (ghazi@caip.rutgers.edu) */ const time_t time_t_max = TIME_T_MAX; const time_t time_t_min = TIME_T_MIN; if (time_t_max / 3 - time_t_min / 3 < (dsec < 0 ? - dsec : dsec)) return -1; } *tp = tm; return t; } #ifdef weak_alias weak_alias (mktime, timelocal) #endif #if DEBUG static int not_equal_tm (a, b) struct tm *a; struct tm *b; { return ((a->tm_sec ^ b->tm_sec) | (a->tm_min ^ b->tm_min) | (a->tm_hour ^ b->tm_hour) | (a->tm_mday ^ b->tm_mday) | (a->tm_mon ^ b->tm_mon) | (a->tm_year ^ b->tm_year) | (a->tm_mday ^ b->tm_mday) | (a->tm_yday ^ b->tm_yday) | (a->tm_isdst ^ b->tm_isdst)); } static void print_tm (tp) struct tm *tp; { if (tp) printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d", tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec, tp->tm_yday, tp->tm_wday, tp->tm_isdst); else printf ("0"); } static int check_result (tk, tmk, tl, lt) time_t tk; struct tm tmk; time_t tl; struct tm *lt; { if (tk != tl || !lt || not_equal_tm (&tmk, lt)) { printf ("mktime ("); print_tm (&tmk); printf (")\nyields ("); print_tm (lt); printf (") == %ld, should be %ld\n", (long) tl, (long) tk); return 1; } return 0; } int main (argc, argv) int argc; char **argv; { int status = 0; struct tm tm, tmk, tml; struct tm *lt; time_t tk, tl; char trailer; if ((argc == 3 || argc == 4) && (sscanf (argv[1], "%d-%d-%d%c", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer) == 3) && (sscanf (argv[2], "%d:%d:%d%c", &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer) == 3)) { tm.tm_year -= TM_YEAR_BASE; tm.tm_mon--; tm.tm_isdst = argc == 3 ? -1 : atoi (argv[3]); tmk = tm; tl = mktime (&tmk); lt = localtime (&tl); if (lt) { tml = *lt; lt = &tml; } printf ("mktime returns %ld == ", (long) tl); print_tm (&tmk); printf ("\n"); status = check_result (tl, tmk, tl, lt); } else if (argc == 4 || (argc == 5 && strcmp (argv[4], "-") == 0)) { time_t from = atol (argv[1]); time_t by = atol (argv[2]); time_t to = atol (argv[3]); if (argc == 4) for (tl = from; tl <= to; tl += by) { lt = localtime (&tl); if (lt) { tmk = tml = *lt; tk = mktime (&tmk); status |= check_result (tk, tmk, tl, tml); } else { printf ("localtime (%ld) yields 0\n", (long) tl); status = 1; } } else for (tl = from; tl <= to; tl += by) { /* Null benchmark. */ lt = localtime (&tl); if (lt) { tmk = tml = *lt; tk = tl; status |= check_result (tk, tmk, tl, tml); } else { printf ("localtime (%ld) yields 0\n", (long) tl); status = 1; } } } else printf ("Usage:\ \t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\ \t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\ \t%s FROM BY TO - # Do not test those values (for benchmark).\n", argv[0], argv[0], argv[0]); return status; } #endif /* DEBUG */ /* Local Variables: compile-command: "gcc -DDEBUG -DHAVE_LIMITS_H -DSTDC_HEADERS -Wall -W -O -g mktime.c -o mktime" End: */ cabextract-1.4/md5.h0000644000175000017500000001267410401407360011262 00000000000000/* md5.h - Declaration of functions and data types used for MD5 sum computing library functions. Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _MD5_H #define _MD5_H 1 #include #if defined HAVE_LIMITS_H || _LIBC # include #endif /* The following contortions are an attempt to use the C preprocessor to determine an unsigned integral type that is 32 bits wide. An alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but doing that would require that the configure script compile and *run* the resulting executable. Locally running cross-compiled executables is usually not possible. */ #ifdef _LIBC # include typedef uint32_t md5_uint32; typedef uintptr_t md5_uintptr; #else # if defined __STDC__ && __STDC__ # define UINT_MAX_32_BITS 4294967295U # else # define UINT_MAX_32_BITS 0xFFFFFFFF # endif /* If UINT_MAX isn't defined, assume it's a 32-bit type. This should be valid for all systems GNU cares about because that doesn't include 16-bit systems, and only modern systems (that certainly have ) have 64+-bit integral types. */ # ifndef UINT_MAX # define UINT_MAX UINT_MAX_32_BITS # endif # if UINT_MAX == UINT_MAX_32_BITS typedef unsigned int md5_uint32; # else # if USHRT_MAX == UINT_MAX_32_BITS typedef unsigned short md5_uint32; # else # if ULONG_MAX == UINT_MAX_32_BITS typedef unsigned long md5_uint32; # else /* The following line is intended to evoke an error. Using #error is not portable enough. */ "Cannot determine unsigned 32-bit data type." # endif # endif # endif /* We have to make a guess about the integer type equivalent in size to pointers which should always be correct. */ typedef unsigned long int md5_uintptr; #endif #undef __P #if defined (__STDC__) && __STDC__ #define __P(x) x #else #define __P(x) () #endif /* Structure to save state of computation between the single steps. */ struct md5_ctx { md5_uint32 A; md5_uint32 B; md5_uint32 C; md5_uint32 D; md5_uint32 total[2]; md5_uint32 buflen; char buffer[128]; }; /* * The following three functions are build up the low level used in * the functions `md5_stream' and `md5_buffer'. */ /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ extern void md5_init_ctx __P ((struct md5_ctx *ctx)); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ extern void md5_process_block __P ((const void *buffer, size_t len, struct md5_ctx *ctx)); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ extern void md5_process_bytes __P ((const void *buffer, size_t len, struct md5_ctx *ctx)); /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. IMPORTANT: On some systems it is required that RESBUF be correctly aligned for a 32 bits value. */ extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf)); /* Put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf)); /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ extern int md5_stream __P ((FILE *stream, void *resblock)); /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock)); /* The following is from gnupg-1.0.2's cipher/bithelp.h. */ /* Rotate a 32 bit integer by n bytes */ #if defined __GNUC__ && defined __i386__ static inline md5_uint32 rol(md5_uint32 x, int n) { __asm__("roll %%cl,%0" :"=r" (x) :"0" (x),"c" (n)); return x; } #else # define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) #endif #endif cabextract-1.4/md5.c0000644000175000017500000002624610401407360011255 00000000000000/* md5.c - Functions to compute MD5 message digest of files or memory blocks according to the definition of MD5 in RFC 1321 from April 1992. Copyright (C) 1995, 1996, 2001, 2003 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Written by Ulrich Drepper , 1995. */ #ifdef HAVE_CONFIG_H # include #endif #include #if STDC_HEADERS # include # include #else # ifndef HAVE_MEMCPY # define memcpy(d, s, n) bcopy ((s), (d), (n)) # endif #endif #include #ifdef WORDS_BIGENDIAN # define SWAP(n) \ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) #else # define SWAP(n) (n) #endif #define BLOCKSIZE 4096 /* Ensure that BLOCKSIZE is a multiple of 64. */ #if BLOCKSIZE % 64 != 0 #error "invalid BLOCKSIZE" #endif /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. (RFC 1321, 3.1: Step 1) */ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ void md5_init_ctx (ctx) struct md5_ctx *ctx; { ctx->A = 0x67452301; ctx->B = 0xefcdab89; ctx->C = 0x98badcfe; ctx->D = 0x10325476; ctx->total[0] = ctx->total[1] = 0; ctx->buflen = 0; } /* Put result from CTX in first 16 bytes following RESBUF. The result must be in little endian byte order. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void * md5_read_ctx (ctx, resbuf) const struct md5_ctx *ctx; void *resbuf; { ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C); ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D); return resbuf; } /* Process the remaining bytes in the internal buffer and the usual prolog according to the standard and write the result to RESBUF. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void * md5_finish_ctx (ctx, resbuf) struct md5_ctx *ctx; void *resbuf; { /* Take yet unprocessed bytes into account. */ md5_uint32 bytes = ctx->buflen; size_t pad; /* Now count remaining bytes. */ ctx->total[0] += bytes; if (ctx->total[0] < bytes) ++ctx->total[1]; pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes; memcpy (&ctx->buffer[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3); *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); /* Process last bytes. */ md5_process_block (ctx->buffer, bytes + pad + 8, ctx); return md5_read_ctx (ctx, resbuf); } void md5_process_bytes (buffer, len, ctx) const void *buffer; size_t len; struct md5_ctx *ctx; { /* When we already have some bits in our internal buffer concatenate both inputs first. */ if (ctx->buflen != 0) { size_t left_over = ctx->buflen; size_t add = 128 - left_over > len ? len : 128 - left_over; memcpy (&ctx->buffer[left_over], buffer, add); ctx->buflen += add; if (ctx->buflen > 64) { md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); ctx->buflen &= 63; /* The regions in the following copy operation cannot overlap. */ memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen); } buffer = (const char *) buffer + add; len -= add; } /* Process available complete blocks. */ if (len >= 64) { #if !_STRING_ARCH_unaligned /* To check alignment gcc has an appropriate operator. Other compilers don't. */ # if __GNUC__ >= 2 # define UNALIGNED_P(p) (((md5_uintptr) p) % __alignof__ (md5_uint32) != 0) # else # define UNALIGNED_P(p) (((md5_uintptr) p) % sizeof (md5_uint32) != 0) # endif if (UNALIGNED_P (buffer)) while (len > 64) { memcpy (ctx->buffer, buffer, 64); md5_process_block (ctx->buffer, 64, ctx); buffer = (const char *) buffer + 64; len -= 64; } else #endif { md5_process_block (buffer, len & ~63, ctx); buffer = (const char *) buffer + (len & ~63); len &= 63; } } /* Move remaining bytes in internal buffer. */ if (len > 0) { size_t left_over = ctx->buflen; memcpy (&ctx->buffer[left_over], buffer, len); left_over += len; if (left_over >= 64) { md5_process_block (ctx->buffer, 64, ctx); left_over -= 64; memcpy (ctx->buffer, &ctx->buffer[64], left_over); } ctx->buflen = left_over; } } /* These are the four functions used in the four steps of the MD5 algorithm and defined in the RFC 1321. The first function is a little bit optimized (as found in Colin Plumbs public domain implementation). */ /* #define FF(b, c, d) ((b & c) | (~b & d)) */ #define FF(b, c, d) (d ^ (b & (c ^ d))) #define FG(b, c, d) FF (d, b, c) #define FH(b, c, d) (b ^ c ^ d) #define FI(b, c, d) (c ^ (b | ~d)) /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. */ void md5_process_block (buffer, len, ctx) const void *buffer; size_t len; struct md5_ctx *ctx; { md5_uint32 correct_words[16]; const md5_uint32 *words = buffer; size_t nwords = len / sizeof (md5_uint32); const md5_uint32 *endp = words + nwords; md5_uint32 A = ctx->A; md5_uint32 B = ctx->B; md5_uint32 C = ctx->C; md5_uint32 D = ctx->D; /* First increment the byte count. RFC 1321 specifies the possible length of the file up to 2^64 bits. Here we only compute the number of bytes. Do a double word increment. */ ctx->total[0] += len; if (ctx->total[0] < len) ++ctx->total[1]; /* Process all bytes in the buffer with 64 bytes in each round of the loop. */ while (words < endp) { md5_uint32 *cwp = correct_words; md5_uint32 A_save = A; md5_uint32 B_save = B; md5_uint32 C_save = C; md5_uint32 D_save = D; /* First round: using the given function, the context and a constant the next context is computed. Because the algorithms processing unit is a 32-bit word and it is determined to work on words in little endian byte order we perhaps have to change the byte order before the computation. To reduce the work for the next steps we store the swapped words in the array CORRECT_WORDS. */ #define OP(a, b, c, d, s, T) \ do \ { \ a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ ++words; \ a = rol (a, s); \ a += b; \ } \ while (0) /* Before we start, one word to the strange constants. They are defined in RFC 1321 as T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64, or perl -e 'foreach(1..64){printf "0x%08x\n", int (4294967296 * abs (sin $_))}' */ /* Round 1. */ OP (A, B, C, D, 7, 0xd76aa478); OP (D, A, B, C, 12, 0xe8c7b756); OP (C, D, A, B, 17, 0x242070db); OP (B, C, D, A, 22, 0xc1bdceee); OP (A, B, C, D, 7, 0xf57c0faf); OP (D, A, B, C, 12, 0x4787c62a); OP (C, D, A, B, 17, 0xa8304613); OP (B, C, D, A, 22, 0xfd469501); OP (A, B, C, D, 7, 0x698098d8); OP (D, A, B, C, 12, 0x8b44f7af); OP (C, D, A, B, 17, 0xffff5bb1); OP (B, C, D, A, 22, 0x895cd7be); OP (A, B, C, D, 7, 0x6b901122); OP (D, A, B, C, 12, 0xfd987193); OP (C, D, A, B, 17, 0xa679438e); OP (B, C, D, A, 22, 0x49b40821); /* For the second to fourth round we have the possibly swapped words in CORRECT_WORDS. Redefine the macro to take an additional first argument specifying the function to use. */ #undef OP #define OP(f, a, b, c, d, k, s, T) \ do \ { \ a += f (b, c, d) + correct_words[k] + T; \ a = rol (a, s); \ a += b; \ } \ while (0) /* Round 2. */ OP (FG, A, B, C, D, 1, 5, 0xf61e2562); OP (FG, D, A, B, C, 6, 9, 0xc040b340); OP (FG, C, D, A, B, 11, 14, 0x265e5a51); OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); OP (FG, A, B, C, D, 5, 5, 0xd62f105d); OP (FG, D, A, B, C, 10, 9, 0x02441453); OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); OP (FG, D, A, B, C, 14, 9, 0xc33707d6); OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); OP (FG, B, C, D, A, 8, 20, 0x455a14ed); OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); OP (FG, C, D, A, B, 7, 14, 0x676f02d9); OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); /* Round 3. */ OP (FH, A, B, C, D, 5, 4, 0xfffa3942); OP (FH, D, A, B, C, 8, 11, 0x8771f681); OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); OP (FH, B, C, D, A, 14, 23, 0xfde5380c); OP (FH, A, B, C, D, 1, 4, 0xa4beea44); OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); OP (FH, B, C, D, A, 6, 23, 0x04881d05); OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); /* Round 4. */ OP (FI, A, B, C, D, 0, 6, 0xf4292244); OP (FI, D, A, B, C, 7, 10, 0x432aff97); OP (FI, C, D, A, B, 14, 15, 0xab9423a7); OP (FI, B, C, D, A, 5, 21, 0xfc93a039); OP (FI, A, B, C, D, 12, 6, 0x655b59c3); OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); OP (FI, C, D, A, B, 10, 15, 0xffeff47d); OP (FI, B, C, D, A, 1, 21, 0x85845dd1); OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); OP (FI, C, D, A, B, 6, 15, 0xa3014314); OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); OP (FI, A, B, C, D, 4, 6, 0xf7537e82); OP (FI, D, A, B, C, 11, 10, 0xbd3af235); OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); OP (FI, B, C, D, A, 9, 21, 0xeb86d391); /* Add the starting values of the context. */ A += A_save; B += B_save; C += C_save; D += D_save; } /* Put checksum in context given as argument. */ ctx->A = A; ctx->B = B; ctx->C = C; ctx->D = D; } cabextract-1.4/cabextract.spec0000644000175000017500000000157011562533574013431 00000000000000Summary: A program to extract Microsoft Cabinet files Name: cabextract Version: 1.4 Release: 1 License: GPL Group: Applications/Archiving Source: http://www.cabextract.org.uk/%{name}-%{version}.tar.gz URL: http://www.cabextract.org.uk/ Vendor: Stuart Caie Packager: Stuart Caie BuildRoot: %{_tmppath}/%{name}-%{version}-root Prefix: /usr %description Cabinet (.CAB) files are a form of archive, which Microsoft use to distribute their software, and things like Windows Font Packs. The cabextract program unpacks these files. %prep %setup %build CFLAGS=${RPM_OPT_FLAGS} ./configure --prefix=%{prefix} make %install rm -rf ${RPM_BUILD_ROOT} %makeinstall %clean [ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT} %files %defattr(0644, root, root, 0755) %doc AUTHORS ChangeLog NEWS README %attr(0755, root, root) %{_bindir}/cabextract %{_mandir}/man1/cabextract.1* cabextract-1.4/fnmatch_.h0000644000175000017500000000457210134025745012360 00000000000000/* Copyright 1991, 1992, 1993, 1996 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 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, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _FNMATCH_H #define _FNMATCH_H 1 #ifdef __cplusplus extern "C" { #endif #if defined (__cplusplus) || (defined (__STDC__) && __STDC__) #undef __P #define __P(args) args #else /* Not C++ or ANSI C. */ #undef __P #define __P(args) () /* We can get away without defining `const' here only because in this file it is used only inside the prototype for `fnmatch', which is elided in non-ANSI C where `const' is problematical. */ #endif /* C++ or ANSI C. */ /* We #undef these before defining them because some losing systems (HP-UX A.08.07 for example) define these in . */ #undef FNM_PATHNAME #undef FNM_NOESCAPE #undef FNM_PERIOD /* Bits set in the FLAGS argument to `fnmatch'. */ #define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ #define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ #define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ #if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE) #define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ #define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ #define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ #endif /* Value returned by `fnmatch' if STRING does not match PATTERN. */ #define FNM_NOMATCH 1 /* Match STRING against the filename pattern PATTERN, returning zero if it matches, FNM_NOMATCH if not. */ extern int fnmatch __P ((const char *__pattern, const char *__string, int __flags)); #ifdef __cplusplus } #endif #endif /* fnmatch.h */ cabextract-1.4/getopt.h0000644000175000017500000001361610401407004012067 00000000000000/* Declarations for getopt. Copyright (C) 1989,90,91,92,93,94,96,97,98 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 Library General Public License as published by the Free Software Foundation; either version 2 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GETOPT_H #ifndef __need_getopt # define _GETOPT_H 1 #endif #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { # if defined __STDC__ && __STDC__ const char *name; # else char *name; # endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ # define no_argument 0 # define required_argument 1 # define optional_argument 2 #endif /* need getopt */ /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for options given in OPTS. Return the option character from OPTS just read. Return -1 when there are no more options. For unrecognized options, or options missing arguments, `optopt' is set to the option letter, and '?' is returned. The OPTS string is a list of characters which are recognized option letters, optionally followed by colons, specifying that that letter takes an argument, to be placed in `optarg'. If a letter in OPTS is followed by two colons, its argument is optional. This behavior is specific to the GNU `getopt'. The argument `--' causes premature termination of argument scanning, explicitly telling `getopt' that there are no more options. If OPTS begins with `--', then non-option arguments are treated as arguments to the option '\0'. This behavior is specific to the GNU `getopt'. */ #if defined __STDC__ && __STDC__ # ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int __argc, char *const *__argv, const char *__shortopts); # else /* not __GNU_LIBRARY__ */ extern int getopt (); # endif /* __GNU_LIBRARY__ */ # ifndef __need_getopt extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); extern int getopt_long_only (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only); # endif #else /* not __STDC__ */ extern int getopt (); # ifndef __need_getopt extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); # endif #endif /* __STDC__ */ #ifdef __cplusplus } #endif /* Make sure we later can get all the definitions and declarations. */ #undef __need_getopt #endif /* getopt.h */