home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / c / lsrc310 / source / doku / header.inf < prev    next >
Encoding:
Text File  |  1994-05-23  |  6.0 KB  |  198 lines

  1.  
  2. If this file contains incorrect information or some information is still
  3. missing, please contact Christian_Grunenberg@S2.maus.de (Email). Anyway,
  4. please distribute this file into any network.
  5.  
  6.   A. General archive structure:
  7.  
  8.      (SFX-Loader)
  9.       ? loader (max. 8k)
  10.  
  11.      (Archive comment)
  12.       5 '-com-'
  13.       ? comment (max. 1k)
  14.       1 \0
  15.  
  16.      File-headers (see below)
  17.       ...
  18.  
  19.   B. Header Formats
  20.      (integers are little-endian; i.e. low-order bytes come first)
  21.  
  22. -----------------------------------------------------------------------------
  23.         level-0                 level-1                 level-2
  24. -----------------------------------------------------------------------------
  25.       1 header size           1 header size           2 total header size
  26.       1 header sum            1 header sum
  27.       5 method ID             5 method ID             5 method ID
  28. B     4 packed size           4 skip size             4 packed size
  29.       4 original size         4 original size         4 original size
  30. A     2 time (MS-DOS)         2 time (MS-DOS)         4 time (UNIX style)
  31.       2 date (MS-DOS)         2 date (MS-DOS)
  32. S     1 MS-DOS attribute      1 fixed (0x20)          1 reserved (now 0x20)
  33.       1 level (0x00)          1 level (0x01)          1 level (0x02)
  34. I     1 name length           1 name length
  35.       ? pathname              ? filename
  36. C     (2 file crc)            2 file crc              2 file crc
  37.       (1 OS ID ('U'/'K'))     1 OS ID                 1 OS ID
  38.       (1 minor version)       . ........
  39.       (4 last modified stamp)
  40.       (2 Unix mode)
  41.       (2 Unix uid)
  42.       (2 Unix gid)
  43.                               2 next header size      2 next header size
  44.     *************************************************************************
  45.      22 + ? no crc           27 + ?                  26
  46.      24 + ? with crc
  47.      36 + ? Unix/OS68k extension
  48. -----------------------------------------------------------------------------
  49. EX-                           1 ext-type              1 ext-type
  50. TEN-                          . ........              . ........
  51. SION                          2 next-header size      2 next-header size
  52. -----------------------------------------------------------------------------
  53.  
  54.     Level-0 header:
  55.       Same as LHarc and LArc.  Directory delimiter character is '\'.
  56.  
  57.     Level-1 header:
  58.       Current default header is level 1
  59.  
  60.     Level-2 header:
  61.       Future versions will use this header.
  62.  
  63.     b. Method IDs
  64.  
  65.       -lhd-   LHarc directory method
  66.  
  67.       -lh0-   no compression
  68.  
  69.       -lh1-   4k sliding dictionary(max 60 bytes) + dynamic Huffman
  70.               + fixed encoding of position
  71.  
  72.       -lh2-   8k sliding dictionary(max 256 bytes) + dynamic Huffman
  73.  
  74.       -lh3-   8k sliding dictionary(max 256 bytes) + static Huffman
  75.  
  76.       -lh4-   4k sliding dictionary(max 256 bytes) + static Huffman
  77.               + improved encoding of position and trees
  78.  
  79.       -lh5-   8k sliding dictionary(max 256 bytes) + static Huffman
  80.               + improved encoding of position and trees
  81.  
  82.       -lzs-   2k sliding dictionary(max 17 bytes)
  83.  
  84.       -lz4-   no compression
  85.  
  86.       -lz5-   4k sliding dictionary(max 17 bytes)
  87.  
  88.       -afx-   same as -lz5-
  89.  
  90.     c. OS ID
  91.  
  92.         MS-DOS  'M'
  93.         OS/2    '2'
  94.         OS9     '9'
  95.         OS/68K  'K'
  96.         OS/386  '3'
  97.         HUMAN   'H'
  98.         UNIX    'U'
  99.         CP/M    'C'
  100.         FLEX    'F'
  101.         Mac     'm'
  102.         Runser  'R'
  103.         TownOS  'T'
  104.         XOSK    'X'
  105.         Amiga   'A'
  106.         Atari   'a'
  107.  
  108.   C. Extension
  109.  
  110.     a. OS independent (0x00 - 0x3f)
  111.  
  112.         common header
  113.          1 0x00
  114.          2 header crc
  115.        ( 1 information )
  116.          2 next-header size
  117.  
  118.         filename header
  119.          1 0x01
  120.          ? filename
  121.          2 next-header size
  122.  
  123.         dirname header
  124.          1 0x02
  125.          ? dirname (separated and terminated by 0xff)
  126.          2 next-header size
  127.  
  128.         encryption header
  129.          1 0x20
  130.          1 flag (!=0 -> encryption)
  131.          2 next-header size
  132.  
  133.          Encryption technique:
  134.          ---------------------
  135.          It is based on eXclusive ORing a variable-length key with the data;
  136.          the same technique will recover the original data.
  137.          For anyone wishing to add this feature to another archiver, the
  138.          following fragment of C code demonstrates the technique used:
  139.  
  140.          char *key;            /* ptr to start of variable-length key */
  141.          char *keyptr;         /* work ptr; NULL if no key */
  142.          /*
  143.           * crypt - encryption/decryption routine
  144.           */
  145.          int crypt(int c)      /* c is the CHARACTER to encode */
  146.          {
  147.             if (keyptr) {             /* key supplied ? */
  148.                 if (!*keyptr)         /* at end of key ? */
  149.                     keyptr = key;     /* yes - reinitialise */
  150.                 return c^*keyptr++;   /* XOR it */
  151.             }
  152.             return c;                 /* no key, no change */
  153.          }
  154.  
  155.          Note that encryption takes place IMMEDIATELY before writing the
  156.          archive (i.e. after compression), and decryption takes place
  157.          IMMEDIATELY after reading the archive (i.e. before decompression).
  158.  
  159.         comment header
  160.          1 0x3f
  161.          ? comments
  162.          2 next-header size
  163.  
  164.     b. OS dependent (0x40 - 0x7f)
  165.  
  166.         MS-DOS attribute header
  167.          1 0x40
  168.          2 file attribute
  169.          2 next-header size
  170.  
  171.         Unix-Permission
  172.          1 0x50
  173.          2 permission
  174.          2 next-header size
  175.  
  176.         Unix gid and uid
  177.          1 0x51
  178.          2 gid
  179.          2 uid
  180.          2 next-header size
  181.  
  182.         Unix group name
  183.          1 0x52
  184.          ? group name
  185.          2 next-header size
  186.  
  187.         Unix user name
  188.          1 0x53
  189.          ? user name
  190.          2 next-header size
  191.  
  192.         Unix last modified time
  193.          1 0x54
  194.          4 last modified time (Unix style)
  195.          2 next-header size
  196.  
  197. Note: Archived files are no longer sorted alphabetically.
  198.