"Fossies" - the Fresh Open Source Software Archive

Member "IO-Compress-2.093/lib/IO/Compress/Gzip/Constants.pm" (7 Dec 2019, 3903 Bytes) of package /linux/privat/IO-Compress-2.093.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Constants.pm" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.092_vs_2.093.

    1 package IO::Compress::Gzip::Constants;
    2 
    3 use strict ;
    4 use warnings;
    5 use bytes;
    6 
    7 require Exporter;
    8 
    9 our ($VERSION, @ISA, @EXPORT, %GZIP_OS_Names);
   10 our ($GZIP_FNAME_INVALID_CHAR_RE, $GZIP_FCOMMENT_INVALID_CHAR_RE);
   11 
   12 $VERSION = '2.093';
   13 
   14 @ISA = qw(Exporter);
   15 
   16 @EXPORT= qw(
   17 
   18     GZIP_ID_SIZE
   19     GZIP_ID1
   20     GZIP_ID2
   21 
   22     GZIP_FLG_DEFAULT
   23     GZIP_FLG_FTEXT
   24     GZIP_FLG_FHCRC
   25     GZIP_FLG_FEXTRA
   26     GZIP_FLG_FNAME
   27     GZIP_FLG_FCOMMENT
   28     GZIP_FLG_RESERVED
   29 
   30     GZIP_CM_DEFLATED
   31 
   32     GZIP_MIN_HEADER_SIZE
   33     GZIP_TRAILER_SIZE
   34 
   35     GZIP_MTIME_DEFAULT
   36     GZIP_XFL_DEFAULT
   37     GZIP_FEXTRA_HEADER_SIZE
   38     GZIP_FEXTRA_MAX_SIZE
   39     GZIP_FEXTRA_SUBFIELD_HEADER_SIZE
   40     GZIP_FEXTRA_SUBFIELD_ID_SIZE
   41     GZIP_FEXTRA_SUBFIELD_LEN_SIZE
   42     GZIP_FEXTRA_SUBFIELD_MAX_SIZE
   43 
   44     $GZIP_FNAME_INVALID_CHAR_RE
   45     $GZIP_FCOMMENT_INVALID_CHAR_RE
   46 
   47     GZIP_FHCRC_SIZE
   48 
   49     GZIP_ISIZE_MAX
   50     GZIP_ISIZE_MOD_VALUE
   51 
   52 
   53     GZIP_NULL_BYTE
   54 
   55     GZIP_OS_DEFAULT
   56 
   57     %GZIP_OS_Names
   58 
   59     GZIP_MINIMUM_HEADER
   60 
   61     );
   62 
   63 # Constant names derived from RFC 1952
   64 
   65 use constant GZIP_ID_SIZE                     => 2 ;
   66 use constant GZIP_ID1                         => 0x1F;
   67 use constant GZIP_ID2                         => 0x8B;
   68 
   69 use constant GZIP_MIN_HEADER_SIZE             => 10 ;# minimum gzip header size
   70 use constant GZIP_TRAILER_SIZE                => 8 ;
   71 
   72 
   73 use constant GZIP_FLG_DEFAULT                 => 0x00 ;
   74 use constant GZIP_FLG_FTEXT                   => 0x01 ;
   75 use constant GZIP_FLG_FHCRC                   => 0x02 ; # called CONTINUATION in gzip
   76 use constant GZIP_FLG_FEXTRA                  => 0x04 ;
   77 use constant GZIP_FLG_FNAME                   => 0x08 ;
   78 use constant GZIP_FLG_FCOMMENT                => 0x10 ;
   79 #use constant GZIP_FLG_ENCRYPTED              => 0x20 ; # documented in gzip sources
   80 use constant GZIP_FLG_RESERVED                => (0x20 | 0x40 | 0x80) ;
   81 
   82 use constant GZIP_XFL_DEFAULT                 => 0x00 ;
   83 
   84 use constant GZIP_MTIME_DEFAULT               => 0x00 ;
   85 
   86 use constant GZIP_FEXTRA_HEADER_SIZE          => 2 ;
   87 use constant GZIP_FEXTRA_MAX_SIZE             => 0xFFFF ;
   88 use constant GZIP_FEXTRA_SUBFIELD_ID_SIZE     => 2 ;
   89 use constant GZIP_FEXTRA_SUBFIELD_LEN_SIZE    => 2 ;
   90 use constant GZIP_FEXTRA_SUBFIELD_HEADER_SIZE => GZIP_FEXTRA_SUBFIELD_ID_SIZE +
   91                                                  GZIP_FEXTRA_SUBFIELD_LEN_SIZE;
   92 use constant GZIP_FEXTRA_SUBFIELD_MAX_SIZE    => GZIP_FEXTRA_MAX_SIZE - 
   93                                                  GZIP_FEXTRA_SUBFIELD_HEADER_SIZE ;
   94 
   95 
   96 if (ord('A') == 193)
   97 {
   98     # EBCDIC 
   99     $GZIP_FNAME_INVALID_CHAR_RE = '[\x00-\x3f\xff]';
  100     $GZIP_FCOMMENT_INVALID_CHAR_RE = '[\x00-\x0a\x11-\x14\x16-\x3f\xff]';
  101     
  102 }
  103 else
  104 {
  105     $GZIP_FNAME_INVALID_CHAR_RE       =  '[\x00-\x1F\x7F-\x9F]';
  106     $GZIP_FCOMMENT_INVALID_CHAR_RE    =  '[\x00-\x09\x11-\x1F\x7F-\x9F]';
  107 }            
  108 
  109 use constant GZIP_FHCRC_SIZE        => 2 ; # aka CONTINUATION in gzip
  110 
  111 use constant GZIP_CM_DEFLATED       => 8 ;
  112 
  113 use constant GZIP_NULL_BYTE         => "\x00";
  114 use constant GZIP_ISIZE_MAX         => 0xFFFFFFFF ;
  115 use constant GZIP_ISIZE_MOD_VALUE   => GZIP_ISIZE_MAX + 1 ;
  116 
  117 # OS Names sourced from http://www.gzip.org/format.txt
  118 
  119 use constant GZIP_OS_DEFAULT=> 0xFF ;
  120 %GZIP_OS_Names = (
  121     0   => 'MS-DOS',
  122     1   => 'Amiga',
  123     2   => 'VMS',
  124     3   => 'Unix',
  125     4   => 'VM/CMS',
  126     5   => 'Atari TOS',
  127     6   => 'HPFS (OS/2, NT)',
  128     7   => 'Macintosh',
  129     8   => 'Z-System',
  130     9   => 'CP/M',
  131     10  => 'TOPS-20',
  132     11  => 'NTFS (NT)',
  133     12  => 'SMS QDOS',
  134     13  => 'Acorn RISCOS',
  135     14  => 'VFAT file system (Win95, NT)',
  136     15  => 'MVS',
  137     16  => 'BeOS',
  138     17  => 'Tandem/NSK',
  139     18  => 'THEOS',
  140     GZIP_OS_DEFAULT()   => 'Unknown',
  141     ) ;
  142 
  143 use constant GZIP_MINIMUM_HEADER =>   pack("C4 V C C",  
  144         GZIP_ID1, GZIP_ID2, GZIP_CM_DEFLATED, GZIP_FLG_DEFAULT,
  145         GZIP_MTIME_DEFAULT, GZIP_XFL_DEFAULT, GZIP_OS_DEFAULT) ;
  146 
  147 
  148 1;