亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? zstream.h

?? 一個C語言實現的壓縮解壓的工具代碼
?? H
字號:
/*
 *
 * Copyright (c) 1997
 * Christian Michelsen Research AS
 * Advanced Computing
 * Fantoftvegen 38, 5036 BERGEN, Norway
 * http://www.cmr.no
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  Christian Michelsen Research AS makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 *
 */

#ifndef ZSTREAM__H
#define ZSTREAM__H

/*
 * zstream.h - C++ interface to the 'zlib' general purpose compression library
 * $Id: zstream.h 1.1 1997-06-25 12:00:56+02 tyge Exp tyge $
 */

#include <strstream.h>
#include <string.h>
#include <stdio.h>
#include "zlib.h"

#if defined(_WIN32)
#   include <fcntl.h>
#   include <io.h>
#   define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
#else
#   define SET_BINARY_MODE(file)
#endif

class zstringlen {
public:
    zstringlen(class izstream&);
    zstringlen(class ozstream&, const char*);
    size_t value() const { return val.word; }
private:
    struct Val { unsigned char byte; size_t word; } val;
};

//  ----------------------------- izstream -----------------------------

class izstream
{
    public:
        izstream() : m_fp(0) {}
        izstream(FILE* fp) : m_fp(0) { open(fp); }
        izstream(const char* name) : m_fp(0) { open(name); }
        ~izstream() { close(); }

        /* Opens a gzip (.gz) file for reading.
         * open() can be used to read a file which is not in gzip format;
         * in this case read() will directly read from the file without
         * decompression. errno can be checked to distinguish two error
         * cases (if errno is zero, the zlib error is Z_MEM_ERROR).
         */
        void open(const char* name) {
            if (m_fp) close();
            m_fp = ::gzopen(name, "rb");
        }

        void open(FILE* fp) {
            SET_BINARY_MODE(fp);
            if (m_fp) close();
            m_fp = ::gzdopen(fileno(fp), "rb");
        }

        /* Flushes all pending input if necessary, closes the compressed file
         * and deallocates all the (de)compression state. The return value is
         * the zlib error number (see function error() below).
         */
        int close() {
            int r = ::gzclose(m_fp);
            m_fp = 0; return r;
        }

        /* Binary read the given number of bytes from the compressed file.
         */
        int read(void* buf, size_t len) {
            return ::gzread(m_fp, buf, len);
        }

        /* Returns the error message for the last error which occurred on the
         * given compressed file. errnum is set to zlib error number. If an
         * error occurred in the file system and not in the compression library,
         * errnum is set to Z_ERRNO and the application may consult errno
         * to get the exact error code.
         */
        const char* error(int* errnum) {
            return ::gzerror(m_fp, errnum);
        }

        gzFile fp() { return m_fp; }

    private:
        gzFile m_fp;
};

/*
 * Binary read the given (array of) object(s) from the compressed file.
 * If the input file was not in gzip format, read() copies the objects number
 * of bytes into the buffer.
 * returns the number of uncompressed bytes actually read
 * (0 for end of file, -1 for error).
 */
template <class T, class Items>
inline int read(izstream& zs, T* x, Items items) {
    return ::gzread(zs.fp(), x, items*sizeof(T));
}

/*
 * Binary input with the '>' operator.
 */
template <class T>
inline izstream& operator>(izstream& zs, T& x) {
    ::gzread(zs.fp(), &x, sizeof(T));
    return zs;
}


inline zstringlen::zstringlen(izstream& zs) {
    zs > val.byte;
    if (val.byte == 255) zs > val.word;
    else val.word = val.byte;
}

/*
 * Read length of string + the string with the '>' operator.
 */
inline izstream& operator>(izstream& zs, char* x) {
    zstringlen len(zs);
    ::gzread(zs.fp(), x, len.value());
    x[len.value()] = '\0';
    return zs;
}

inline char* read_string(izstream& zs) {
    zstringlen len(zs);
    char* x = new char[len.value()+1];
    ::gzread(zs.fp(), x, len.value());
    x[len.value()] = '\0';
    return x;
}

// ----------------------------- ozstream -----------------------------

class ozstream
{
    public:
        ozstream() : m_fp(0), m_os(0) {
        }
        ozstream(FILE* fp, int level = Z_DEFAULT_COMPRESSION)
            : m_fp(0), m_os(0) {
            open(fp, level);
        }
        ozstream(const char* name, int level = Z_DEFAULT_COMPRESSION)
            : m_fp(0), m_os(0) {
            open(name, level);
        }
        ~ozstream() {
            close();
        }

        /* Opens a gzip (.gz) file for writing.
         * The compression level parameter should be in 0..9
         * errno can be checked to distinguish two error cases
         * (if errno is zero, the zlib error is Z_MEM_ERROR).
         */
        void open(const char* name, int level = Z_DEFAULT_COMPRESSION) {
            char mode[4] = "wb\0";
            if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level;
            if (m_fp) close();
            m_fp = ::gzopen(name, mode);
        }

        /* open from a FILE pointer.
         */
        void open(FILE* fp, int level = Z_DEFAULT_COMPRESSION) {
            SET_BINARY_MODE(fp);
            char mode[4] = "wb\0";
            if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level;
            if (m_fp) close();
            m_fp = ::gzdopen(fileno(fp), mode);
        }

        /* Flushes all pending output if necessary, closes the compressed file
         * and deallocates all the (de)compression state. The return value is
         * the zlib error number (see function error() below).
         */
        int close() {
            if (m_os) {
                ::gzwrite(m_fp, m_os->str(), m_os->pcount());
                delete[] m_os->str(); delete m_os; m_os = 0;
            }
            int r = ::gzclose(m_fp); m_fp = 0; return r;
        }

        /* Binary write the given number of bytes into the compressed file.
         */
        int write(const void* buf, size_t len) {
            return ::gzwrite(m_fp, (voidp) buf, len);
        }

        /* Flushes all pending output into the compressed file. The parameter
         * _flush is as in the deflate() function. The return value is the zlib
         * error number (see function gzerror below). flush() returns Z_OK if
         * the flush_ parameter is Z_FINISH and all output could be flushed.
         * flush() should be called only when strictly necessary because it can
         * degrade compression.
         */
        int flush(int _flush) {
            os_flush();
            return ::gzflush(m_fp, _flush);
        }

        /* Returns the error message for the last error which occurred on the
         * given compressed file. errnum is set to zlib error number. If an
         * error occurred in the file system and not in the compression library,
         * errnum is set to Z_ERRNO and the application may consult errno
         * to get the exact error code.
         */
        const char* error(int* errnum) {
            return ::gzerror(m_fp, errnum);
        }

        gzFile fp() { return m_fp; }

        ostream& os() {
            if (m_os == 0) m_os = new ostrstream;
            return *m_os;
        }

        void os_flush() {
            if (m_os && m_os->pcount()>0) {
                ostrstream* oss = new ostrstream;
                oss->fill(m_os->fill());
                oss->flags(m_os->flags());
                oss->precision(m_os->precision());
                oss->width(m_os->width());
                ::gzwrite(m_fp, m_os->str(), m_os->pcount());
                delete[] m_os->str(); delete m_os; m_os = oss;
            }
        }

    private:
        gzFile m_fp;
        ostrstream* m_os;
};

/*
 * Binary write the given (array of) object(s) into the compressed file.
 * returns the number of uncompressed bytes actually written
 * (0 in case of error).
 */
template <class T, class Items>
inline int write(ozstream& zs, const T* x, Items items) {
    return ::gzwrite(zs.fp(), (voidp) x, items*sizeof(T));
}

/*
 * Binary output with the '<' operator.
 */
template <class T>
inline ozstream& operator<(ozstream& zs, const T& x) {
    ::gzwrite(zs.fp(), (voidp) &x, sizeof(T));
    return zs;
}

inline zstringlen::zstringlen(ozstream& zs, const char* x) {
    val.byte = 255;  val.word = ::strlen(x);
    if (val.word < 255) zs < (val.byte = val.word);
    else zs < val;
}

/*
 * Write length of string + the string with the '<' operator.
 */
inline ozstream& operator<(ozstream& zs, const char* x) {
    zstringlen len(zs, x);
    ::gzwrite(zs.fp(), (voidp) x, len.value());
    return zs;
}

#ifdef _MSC_VER
inline ozstream& operator<(ozstream& zs, char* const& x) {
    return zs < (const char*) x;
}
#endif

/*
 * Ascii write with the << operator;
 */
template <class T>
inline ostream& operator<<(ozstream& zs, const T& x) {
    zs.os_flush();
    return zs.os() << x;
}

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合色婷婷| 中文字幕日韩一区| 7878成人国产在线观看| 欧美在线观看一区| 欧美一a一片一级一片| av不卡在线观看| av不卡免费在线观看| 成人黄色小视频| 成人免费观看视频| 色综合久久久久久久久| 日本丶国产丶欧美色综合| 91福利国产成人精品照片| 一本一道久久a久久精品| 欧美亚洲一区三区| 8v天堂国产在线一区二区| 日韩欧美国产不卡| 久久久久久久综合色一本| 中文字幕va一区二区三区| 最新久久zyz资源站| 亚洲国产精品久久人人爱| 蜜臀国产一区二区三区在线播放| 美腿丝袜亚洲三区| 成人动漫精品一区二区| 在线观看网站黄不卡| 日韩欧美一区在线观看| 国产欧美一区二区在线观看| 一区二区三区在线免费观看| 日韩高清不卡在线| 91成人看片片| 91麻豆精品国产91久久久资源速度 | 五月天精品一区二区三区| 福利一区二区在线| 中文字幕欧美三区| 丁香激情综合五月| 亚洲国产精品精华液ab| 成人一级黄色片| 亚洲欧洲精品天堂一级| 波多野结衣一区二区三区| 国产精品国产三级国产aⅴ入口 | 亚洲国产高清aⅴ视频| 国产成人精品亚洲午夜麻豆| 久久麻豆一区二区| 成人性生交大片免费看在线播放 | 色综合中文字幕| 亚洲人午夜精品天堂一二香蕉| 91老师片黄在线观看| 亚洲免费电影在线| 9191国产精品| 国产一区二区影院| 中文字幕在线一区| 欧美唯美清纯偷拍| 男人的j进女人的j一区| 久久久国产精华| 91色九色蝌蚪| 亚洲成人激情av| 337p日本欧洲亚洲大胆色噜噜| 成人小视频免费观看| 亚洲综合激情小说| 欧美r级在线观看| 国产成人精品aa毛片| 亚洲精品视频一区| 日韩欧美亚洲国产精品字幕久久久| 黄网站免费久久| 亚洲色图欧洲色图婷婷| 91精品国产麻豆国产自产在线 | 国产精品日韩精品欧美在线| 一本色道**综合亚洲精品蜜桃冫| 日韩福利电影在线| 亚洲欧洲日韩av| 欧美不卡激情三级在线观看| 99在线热播精品免费| 美女网站色91| 亚洲精品中文字幕乱码三区| 欧美成人国产一区二区| 91国偷自产一区二区三区成为亚洲经典| 丝袜亚洲精品中文字幕一区| 欧美激情一区在线| 欧美欧美欧美欧美首页| 成人av网址在线观看| 美女一区二区在线观看| 亚洲综合在线免费观看| 国产欧美精品一区二区色综合 | 国产曰批免费观看久久久| 亚洲精品一二三区| 久久久久久久久久久久电影| 欧美精品电影在线播放| 91美女福利视频| 国产原创一区二区三区| 天天综合网 天天综合色| 亚洲欧美一区二区不卡| 国产日韩精品一区二区三区| 日韩亚洲欧美高清| 欧美午夜一区二区三区| 91老师片黄在线观看| 高清beeg欧美| 国产一区欧美日韩| 久久99精品久久久久婷婷| 亚洲va韩国va欧美va精品| 亚洲精品你懂的| 国产精品国产三级国产普通话三级| 精品国内二区三区| 欧美一区二区免费视频| 欧美日韩午夜影院| 欧美性做爰猛烈叫床潮| 一本大道久久a久久综合婷婷| 国产成人精品一区二| 国产精品夜夜嗨| 国产一区二区三区香蕉| 国产在线播放一区二区三区| 久久精品国产一区二区| 男女男精品网站| 日本不卡一区二区三区高清视频| 香蕉久久夜色精品国产使用方法 | 国产精品视频yy9299一区| 久久亚洲一区二区三区四区| 精品国产自在久精品国产| 欧美一区二区精品| 日韩一级片网址| 日韩欧美国产一区二区在线播放| 欧美一区二区福利在线| 精品国产亚洲在线| 26uuu亚洲综合色欧美| 国产亚洲欧美中文| 国产精品毛片久久久久久| 中文字幕日韩av资源站| 一区二区三区四区av| 亚洲一区二区三区中文字幕| 亚洲国产精品久久久久婷婷884| 香蕉乱码成人久久天堂爱免费| 手机精品视频在线观看| 久久99久久99| 丰满少妇在线播放bd日韩电影| 成人精品免费看| 91免费视频大全| 欧美日本一区二区三区四区| 日韩欧美激情在线| 国产亚洲欧洲一区高清在线观看| 亚洲欧洲精品天堂一级| 亚洲成a人v欧美综合天堂| 麻豆极品一区二区三区| 成人激情免费视频| 欧美日韩一二区| 久久久久国产成人精品亚洲午夜| 亚洲欧美自拍偷拍色图| 亚洲国产精品久久一线不卡| 久久国产精品露脸对白| 91在线精品一区二区| 欧美精选午夜久久久乱码6080| 久久毛片高清国产| 一区二区三区不卡视频| 精品一区二区三区在线观看国产| jlzzjlzz亚洲日本少妇| 欧美精品xxxxbbbb| 国产精品日产欧美久久久久| 亚洲成av人片在www色猫咪| 国产精品影视天天线| 在线日韩av片| 久久久久久久久一| 午夜精品久久久久久久99水蜜桃| 国产麻豆精品一区二区| 欧美性色黄大片| 国产精品午夜在线| 天堂在线亚洲视频| av激情亚洲男人天堂| 日韩片之四级片| 亚洲色图视频网站| 国产一区二区三区免费| 欧美日韩国产精品自在自线| 国产喷白浆一区二区三区| 亚洲国产美女搞黄色| 成人性生交大片免费看视频在线| 日韩欧美亚洲国产另类| 一区二区三区免费在线观看| 国产一区二区在线电影| 91精品婷婷国产综合久久性色| 中文字幕在线观看不卡| 国产麻豆视频一区二区| 日韩三级免费观看| 亚洲高清不卡在线| 99国产一区二区三精品乱码| 久久精子c满五个校花| 麻豆成人久久精品二区三区红 | 9久草视频在线视频精品| 久久久另类综合| 久久精品99国产国产精| 欧美日本韩国一区二区三区视频 | 欧美日韩视频在线第一区| 自拍av一区二区三区| 成人精品高清在线| 国产欧美精品一区| 国产精品系列在线播放| 久久久久久久久久久99999| 精品伊人久久久久7777人| 7777女厕盗摄久久久| 视频一区在线播放| 制服丝袜成人动漫| 日本不卡一区二区| 91精品国产综合久久婷婷香蕉| 日韩国产一区二| 欧美一区二区人人喊爽|