Branch: Tag:

2003-04-15

2003-04-15 13:39:31 by Marcus Comstedt <marcus@mc.pp.se>

Fixed CRC handling when parameters are changed in mid-stream.

Rev: src/modules/Gz/module.pmod.in:1.10

1: - // $Id: module.pmod.in,v 1.9 2003/04/14 17:10:57 marcus Exp $ + // $Id: module.pmod.in,v 1.10 2003/04/15 13:39:31 marcus Exp $   #pike __REAL_VERSION__      inherit @module@;
99:    }    }    file_pos = 0; +  crc = crc32("");    if(objectp(file))    f = file;    else {
150:    string res = read_buf[..len-1];    read_buf = read_buf[len..];    file_pos += sizeof(res); +  crc = crc32(res, crc);    return res;    }   
158:    //! the number of bytes written to the file.    int write(string data)    { -  if(!def) { def = deflate(-level, strategy); crc = crc32(""); } +  if(!def) def = deflate(-level, strategy);    string comp = def->deflate(data, NO_FLUSH);    if(f->write(comp) != sizeof(comp))    return 0;
203:    return -1;    file_pos = 0;    read_buf = ""; +  crc = crc32("");    while(pos > 0) {    string r = read(pos>16384? 16384:pos);    if(!sizeof(r))
245:    int setparams(int level, int strategy)    {    if(def) { -  string s = def->deflate("", FINISH); +  string s = def->deflate("", SYNC_FLUSH);    if(sizeof(s) && f->write(s) != sizeof(s))    return 0;    def = 0;