pike.git / src / modules / Gz / module.pmod.in

version» Context lines:

pike.git/src/modules/Gz/module.pmod.in:5:   inherit @module@;      #define DATA_CHUNK_SIZE 64*1024      //! Low-level implementation of read/write support for GZip files   class _file {       protected private Stdio.Stream f;    protected private inflate inf;    protected private deflate def; -  protected private int level, strategy; +  protected private int level, strategy, window_size;    protected private string read_buf;    protected private int file_pos, crc, write_mode, at_eof;       final constant SEEK_SET = 0;    final constant SEEK_CUR = 1;    final constant SEEK_END = 2;       protected int check_header(string|void buf)    {    int magic1, magic2, method, flags, len;
pike.git/src/modules/Gz/module.pmod.in:88:    //! Mode for the fileoperations. Defaults to read only.    //!    //! @note    //! If the object already has been opened, it will first be closed.    int open(string|int|Stdio.Stream file, void|string mode)    {    close();    write_mode = 0;    level = 6;    strategy = DEFAULT_STRATEGY; +  window_size = 15;    if(mode) {    mode = filter(mode, lambda(int n) {    if(n == 'w' || n == 'a')    write_mode = 1;    if(n >= '0' && n <= '9')    level = n - '0';    else if(n == 'f')    strategy = FILTERED;    else if(n == 'h')    strategy = HUFFMAN_ONLY;
pike.git/src/modules/Gz/module.pmod.in:196:    read_buf = read_buf[len..];    file_pos += sizeof(res);    return res;    }       //! Writes the data to the file.    //! @returns    //! the number of bytes written to the file.    int write(string data)    { -  if(!def) def = deflate(-level, strategy); +  if(!def) def = deflate(-level, strategy, window_size);    string comp = def->deflate(data, NO_FLUSH);    if(f->write(comp) != sizeof(comp))    return 0;    else {    file_pos += sizeof(data);    crc = crc32(data, crc);    return sizeof(data);    }    }   
pike.git/src/modules/Gz/module.pmod.in:277:    //! 1 if EOF has been reached.    int(0..1) eof()    {    if(at_eof) return 1;    if(def || write_mode || sizeof(read_buf)) return 0;    while(!sizeof(read_buf) && fill_read_buffer())    ;    return at_eof;    }    -  //! Sets the encoding level and strategy -  //! @param level -  //! Level of the compression. -  //! 0 is the least compression, 9 is max. 8 is default. -  //! @param strategy -  //! Set strategy for encoding to one of the following: -  //! DEFAULT_STRATEGY -  //! FILTERED -  //! HUFFMAN_ONLY -  int setparams(int level, int strategy) -  { -  if(def) { +  //! Sets the encoding level, strategy and window_size. +  //! +  //! @seealso +  //! @[Gz.deflate] +  int setparams(void|int(-9..9) level, void|int strategy, +  void|int(8..15) window_size) { +  if (def) {    string s = def->deflate("", SYNC_FLUSH); -  if(sizeof(s) && f->write(s) != sizeof(s)) +  if (sizeof(s) && f->write(s) != sizeof(s))    return 0;    def = 0;    } -  +  if (!zero_type(level))    _file::level = level; -  +  if (!zero_type(strategy))    _file::strategy = strategy; -  +  if (!zero_type(window_size)) +  _file::window_size = window_size;    return 1;    }      }         //! Allows the user to open a Gzip archive and read and write   //! it's contents in an uncompressed form, emulating the @[Stdio.File]   //! interface.   //! @note