Annotation of elwix/tools/oldlzma/7zC.txt, revision 1.1.1.1

1.1       misho       1: 7z ANSI-C Decoder 4.16
                      2: ----------------------
                      3: 
                      4: 7z ANSI-C Decoder 4.16 Copyright (C) 1999-2005 Igor Pavlov
                      5: 
                      6: 7z ANSI-C provides 7z/LZMA decoding.
                      7: 7z ANSI-C version is simplified version ported from C++ code.
                      8: 
                      9: LZMA is default and general compression method of 7z format
                     10: in 7-Zip compression program (www.7-zip.org). LZMA provides high 
                     11: compression ratio and very fast decompression.
                     12: 
                     13: 
                     14: LICENSE
                     15: -------
                     16: 
                     17: Read lzma.txt for informaton about license.
                     18: 
                     19: 
                     20: Files
                     21: ---------------------
                     22: 
                     23: 7zAlloc.*    - Allocate and Free
                     24: 7zBuffer.*   - Buffer structure
                     25: 7zCrc.*      - CRC32 code
                     26: 7zDecode.*   - Low level memory->memory decoding
                     27: 7zExtract.*  - High level stream->memory decoding
                     28: 7zHeader.*   - .7z format constants
                     29: 7zIn.*       - .7z archive opening
                     30: 7zItem.*     - .7z structures
                     31: 7zMain.c     - Test application
                     32: 7zMethodID.* - MethodID structure
                     33: 7zTypes.h    - Base types and constants
                     34: 
                     35: 
                     36: How To Use
                     37: ----------
                     38: 
                     39: You must download 7-Zip program from www.7-zip.org.
                     40: 
                     41: You can create .7z archive with 7z.exe or 7za.exe:
                     42: 
                     43:   7za.exe a archive.7z *.htm -r -mx -m0fb=255
                     44: 
                     45: If you have big number of files in archive, and you need fast extracting, 
                     46: you can use partly-solid archives:
                     47:   
                     48:   7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K
                     49: 
                     50: In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only 
                     51: 512KB for extracting one file from such archive.
                     52: 
                     53: 
                     54: Limitations of current version of 7z ANSI-C Decoder
                     55: ---------------------------------------------------
                     56: 
                     57:  - It doesn't support separated "folder" items inside archive.
                     58:    But you still can use files that are in subfolders
                     59:  - It doesn't support empty files (size = 0) inside archive.
                     60:  - It reads only "FileName", "Size", and "CRC" information for each file in archive.
                     61:  - It supports only LZMA and Copy (no compression) methods.
                     62:  - It converts original UTF-16 Unicode file names to UTF-8 Unicode file names.
                     63:  
                     64: These limitations will be fixed in future versions.
                     65: 
                     66: 
                     67: Using 7z ANSI-C Decoder Test application:
                     68: -----------------------------------------
                     69: 
                     70: Usage: 7zDec <command> <archive_name>
                     71: 
                     72: <Command>:
                     73:   e: Extract files from archive
                     74:   l: List contents of archive
                     75:   t: Test integrity of archive
                     76: 
                     77: Example: 
                     78: 
                     79:   7zDec l archive.7z
                     80: 
                     81: lists contents of archive.7z
                     82: 
                     83:   7zDec e archive.7z
                     84: 
                     85: extracts files from archive.7z to current folder.
                     86: 
                     87: 
                     88: How to use .7z Decoder
                     89: ----------------------
                     90: 
                     91: .7z Decoder can be compiled in one of two modes:
                     92: 
                     93: 1) Default mode. In that mode 7z Decoder will read full compressed 
                     94:    block to RAM before decompressing.
                     95:   
                     96: 2) Mode with defined _LZMA_IN_CB. In that mode 7z Decoder can read
                     97:    compressed block by parts. And you can specify desired buffer size. 
                     98:    So memory requirements can be reduced. But decompressing speed will 
                     99:    be 5-10% lower and code size is slightly larger.
                    100: 
                    101:    
                    102: Memory allocation
                    103: ~~~~~~~~~~~~~~~~~
                    104: 
                    105: 7z Decoder uses two memory pools:
                    106: 1) Temporary pool
                    107: 2) Main pool
                    108: Such scheme can allow you to avoid fragmentation of alocated blocks.
                    109: 
                    110: Steps for using 7z decoder
                    111: --------------------------
                    112: 
                    113: Use code at 7zMain.c as example.
                    114: 
                    115: 1) Declare variables:
                    116:   inStream                     /* implements ISzInStream interface */
                    117:   CArchiveDatabaseEx db;       /* 7z archive database structure */
                    118:   ISzAlloc allocImp;           /* memory functions for main pool */
                    119:   ISzAlloc allocTempImp;       /* memory functions for temporary pool */
                    120: 
                    121: 2) call InitCrcTable(); function to initialize CRC structures.
                    122: 
                    123: 3) call SzArDbExInit(&db); function to initialize db structures.
                    124: 
                    125: 4) call SzArchiveOpen(inStream, &db, &allocMain, &allocTemp) to open archive
                    126: 
                    127: This function opens archive "inStream" and reads headers to "db".
                    128: All items in "db" will be allocated with "allocMain" functions.
                    129: SzArchiveOpen function allocates and frees temporary structures by "allocTemp" functions.
                    130: 
                    131: 5) List items or Extract items
                    132: 
                    133:   Listing code:
                    134:   ~~~~~~~~~~~~~
                    135:     {
                    136:       UInt32 i;
                    137:       for (i = 0; i < db.Database.NumFiles; i++)
                    138:       {
                    139:         CFileItem *f = db.Database.Files + i;
                    140:         printf("%10d  %s\n", (int)f->Size, f->Name);
                    141:       }
                    142:     }
                    143: 
                    144:   Extracting code:
                    145:   ~~~~~~~~~~~~~~~~
                    146: 
                    147:   SZ_RESULT SzExtract(
                    148:     ISzInStream *inStream, 
                    149:     CArchiveDatabaseEx *db,
                    150:     UInt32 fileIndex,         /* index of file */
                    151:     UInt32 *blockIndex,       /* index of solid block */
                    152:     Byte **outBuffer,         /* pointer to pointer to output buffer (allocated with allocMain) */
                    153:     size_t *outBufferSize,    /* buffer size for output buffer */
                    154:     size_t *offset,           /* offset of stream for required file in *outBuffer */
                    155:     size_t *outSizeProcessed, /* size of file in *outBuffer */
                    156:     ISzAlloc *allocMain,
                    157:     ISzAlloc *allocTemp);
                    158: 
                    159:   If you need to decompress more than one file, you can send these values from preevious call:
                    160:     blockIndex, 
                    161:     outBuffer, 
                    162:     outBufferSize,
                    163:   You can consider "outBuffer" as cache of solid block. If your archive is solid, 
                    164:   it will increase decompression speed.
                    165: 
                    166:   After decompressing you must free "outBuffer":
                    167:   allocImp.Free(outBuffer);
                    168: 
                    169: 6) call SzArDbExFree(&db, allocImp.Free) to free allocated items in "db".
                    170: 
                    171: 
                    172: 
                    173: 
                    174: Memory requirements for .7z decoding 
                    175: ------------------------------------
                    176: 
                    177: Memory usage for Archive openning:
                    178:   - Temporary pool:
                    179:      - Memory for compressed .7z headers (if _LZMA_IN_CB is not defined)
                    180:      - Memory for uncompressed .7z headers
                    181:      - some other temporary blocks
                    182:   - Main pool:
                    183:      - Memory for database: 
                    184:        Estimated size of one file structures in solid archive:
                    185:          - Size (4 or 8 Bytes)
                    186:          - CRC32 (4 bytes)
                    187:          - Some file information (4 bytes)
                    188:          - File Name (variable length) + pointer + allocation structures
                    189: 
                    190: Memory usage for archive Decompressing:
                    191:   - Temporary pool:
                    192:      - Memory for compressed solid block (if _LZMA_IN_CB is not defined)
                    193:      - Memory for LZMA decompressing structures
                    194:   - Main pool:
                    195:      - Memory for decompressed solid block
                    196:   
                    197: 
                    198: If _LZMA_IN_CB is defined, 7z Decoder will not allocate memory for 
                    199: compressed blocks. Instead of this, you must allocate buffer with desired 
                    200: size before calling 7z Decoder. Use 7zMain.c as example.
                    201: 
                    202: 
                    203: 
                    204: EXIT codes
                    205: -----------
                    206: 
                    207: 7z Decoder functions can return one of the following codes:
                    208: 
                    209: #define SZ_OK (0)
                    210: #define SZE_DATA_ERROR (1)
                    211: #define SZE_OUTOFMEMORY (2)
                    212: #define SZE_CRC_ERROR (3)
                    213: 
                    214: #define SZE_NOTIMPL (4)
                    215: #define SZE_FAIL (5)
                    216: 
                    217: #define SZE_ARCHIVE_ERROR (6)
                    218: 
                    219: 
                    220: 
                    221: LZMA Defines
                    222: ------------
                    223: 
                    224: _LZMA_IN_CB       - Use special callback mode for input stream to reduce memory requirements
                    225: 
                    226: _SZ_FILE_SIZE_64  - define it if you need support for files larger than 4 GB
                    227: _SZ_NO_INT_64     - define it if your compiler doesn't support long long int
                    228: 
                    229: _LZMA_PROB32      - it can increase LZMA decompressing speed on some 32-bit CPUs.
                    230: 
                    231: _SZ_ONE_DIRECTORY - define it if you want to locate all source files to one direcory
                    232: _SZ_ALLOC_DEBUG   - define it if you want to debug alloc/free operations to stderr.
                    233: 
                    234: 
                    235: ---
                    236: 
                    237: http://www.7-zip.org
                    238: http://www.7-zip.org/support.html

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>