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

version» Context lines:

pike.git/src/modules/Gz/module.pmod.in:1: - // $Id: module.pmod.in,v 1.16 2005/04/02 19:10:23 nilsson Exp $ + // $Id: module.pmod.in,v 1.17 2008/06/28 17:07:19 nilsson Exp $   #pike __REAL_VERSION__      inherit @module@;      #if constant(@module@.inflate)      //! Low-level implementation of read/write support for GZip files   class _file {    -  static private Stdio.Stream f; -  static private inflate inf; -  static private deflate def; -  static private int level, strategy; -  static private string read_buf; -  static private int file_pos, crc, write_mode, at_eof; +  protected private Stdio.Stream f; +  protected private inflate inf; +  protected private deflate def; +  protected private int level, strategy; +  protected private string read_buf; +  protected private int file_pos, crc, write_mode, at_eof;       constant SEEK_SET = 0;    constant SEEK_CUR = 1;    constant SEEK_END = 2;    -  static int check_header(string|void buf) +  protected int check_header(string|void buf)    {    int magic1, magic2, method, flags, len;       if(!buf) buf="";    string buf_read(int n)    {    if(sizeof(buf)<n)    buf += f->read(min(n-sizeof(buf), 10));    string r = buf[..n-1];    buf = buf[n..];
pike.git/src/modules/Gz/module.pmod.in:65:    if(flags & 2)    if(sizeof(buf_read(2)) != 2)    return 0;       if(sizeof(buf))    fill_read_buffer(buf);       return 1;    }    -  static int make_header() +  protected int make_header()    {    return f->write(sprintf("%1c%1c%1c%1c%4c%1c%1c",    0x1f, 0x8b, 8, 0, 0, 0, 3)) == 10;    }       //! Opens a file for I/O.    //!    //! @param file    //! The filename or an open filedescriptor or Stream for the GZip    //! file to use.
pike.git/src/modules/Gz/module.pmod.in:116:    f = file;    else {    f = Stdio.File();    if(!f->open(file, mode||"rb"))    return 0;    }    return write_mode? make_header() : check_header();    }       //! Opens a gzip file for reading. -  static void create(void|string|Stdio.Stream gzFile, void|string mode) +  protected void create(void|string|Stdio.Stream gzFile, void|string mode)    {    if(!zero_type(gzFile) && !open(gzFile, mode))    error("Failed to open file.\n");    }       //! closes the file    //! @returns    //! 1 if successful    int close()    {
pike.git/src/modules/Gz/module.pmod.in:142:    return 0;    }    inf = 0;    def = 0;    read_buf = "";    Stdio.File oldf = f;    f = 0;    return !oldf || oldf->close();    }    -  static int fill_read_buffer(string|void data) +  protected int fill_read_buffer(string|void data)    {    if(at_eof)    return 0;    string r = data || f->read(16384);    if(!sizeof(r)) {    at_eof = 1;    return 0;    }    if(!inf) inf = inflate(-15);    string b = inf->inflate(r);
pike.git/src/modules/Gz/module.pmod.in:322:    private int is_open = 0;       //! @decl void create(void|string|int|Stdio.Stream file, void|string mode)    //! @param file    //! Filename or filedescriptor of the gzip file to open, or an already    //! open Stream.    //! @param mode    //! mode for the file. Defaults to "rb".    //! @seealso    //! @[open] @[Stdio.File] -  static void create(mixed ... args) { +  protected void create(mixed ... args) {    ::create(@args);       if(sizeof(args)) {    is_open = 1;    }    }    -  static string _sprintf(int t) +  protected string _sprintf(int t)    {    switch(t) {    case 'O':    return sprintf("Gz.File(/*%s open */)", is_open ? "" : " not");    case 't':    return "Gz.File";    default:    return UNDEFINED;    }    }       int close()    {    is_open = 0;    return ::close();    }    -  static void destroy() { +  protected void destroy() {    close();    }       //! @param file    //! Filename or filedescriptor of the gzip file to open, or an already    //! open Stream.    //! @param mode    //! mode for the file. Defaults to "rb".    //! May be one of the following:    //! @dl