⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 api.c

📁 压缩解压,是unzip540的升级,这个外国网站摘来的源码,是evb编写.
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  Copyright (c) 1990-2004 Info-ZIP.  All rights reserved.  See the accompanying file LICENSE, version 2000-Apr-09 or later  (the contents of which are also included in unzip.h) for terms of use.  If, for some reason, all these files are missing, the Info-ZIP license  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html*//*---------------------------------------------------------------------------  api.c  This module supplies an UnZip engine for use directly from C/C++  programs.  The functions are:    UzpVer *UzpVersion(void);    void UzpVersion2(UzpVer2 *version)    int UzpMain(int argc, char *argv[]);    int UzpAltMain(int argc, char *argv[], UzpInit *init);    int UzpValidate(char *archive, int AllCodes);    void UzpFreeMemBuffer(UzpBuffer *retstr);    int UzpUnzipToMemory(char *zip, char *file, UzpOpts *optflgs,                         UzpCB *UsrFuncts, UzpBuffer *retstr);  non-WINDLL only (a special WINDLL variant is defined in windll/windll.c):    int UzpGrep(char *archive, char *file, char *pattern, int cmd, int SkipBin,                UzpCB *UsrFuncts);  OS/2 only (for now):    int UzpFileTree(char *name, cbList(callBack), char *cpInclude[],          char *cpExclude[]);  You must define `DLL' in order to include the API extensions.  ---------------------------------------------------------------------------*/#ifdef OS2#  define  INCL_DOSMEMMGR#  include <os2.h>#endif#include <setjmp.h>#define UNZIP_INTERNAL#include "unzip.h"#ifdef WINDLL#  ifdef POCKET_UNZIP#    include "wince/intrface.h"#  else#    include "windll/windll.h"#  endif#endif#include "unzvers.h"#ifdef DLL      /* This source file supplies DLL-only interface code. */#ifndef POCKET_UNZIP    /* WinCE pUnZip defines this elsewhere. */jmp_buf dll_error_return;#endif/*---------------------------------------------------------------------------    Documented API entry points  ---------------------------------------------------------------------------*/UzpVer * UZ_EXP UzpVersion()   /* should be pointer to const struct */{    static UzpVer version;     /* doesn't change between calls */    version.structlen = UZPVER_LEN;#ifdef BETA    version.flag = 1;#else    version.flag = 0;#endif    version.betalevel = UZ_BETALEVEL;    version.date = UZ_VERSION_DATE;#ifdef ZLIB_VERSION    version.zlib_version = ZLIB_VERSION;    version.flag |= 2;#else    version.zlib_version = NULL;#endif    /* someday each of these may have a separate patchlevel: */    version.unzip.major = UZ_MAJORVER;    version.unzip.minor = UZ_MINORVER;    version.unzip.patchlevel = UZ_PATCHLEVEL;    version.zipinfo.major = ZI_MAJORVER;    version.zipinfo.minor = ZI_MINORVER;    version.zipinfo.patchlevel = UZ_PATCHLEVEL;    /* these are retained for backward compatibility only: */    version.os2dll.major = UZ_MAJORVER;    version.os2dll.minor = UZ_MINORVER;    version.os2dll.patchlevel = UZ_PATCHLEVEL;    version.windll.major = UZ_MAJORVER;    version.windll.minor = UZ_MINORVER;    version.windll.patchlevel = UZ_PATCHLEVEL;    return &version;}void UZ_EXP UzpVersion2(UzpVer2 *version){    version->structlen = UZPVER_LEN;#ifdef BETA    version->flag = 1;#else    version->flag = 0;#endif    strcpy(version->betalevel, UZ_BETALEVEL);    strcpy(version->date, UZ_VERSION_DATE);#ifdef ZLIB_VERSION    /* Although ZLIB_VERSION is a compile-time constant, we implement an       "overrun-safe" copy because its actual value is not under our control.     */    strncpy(version->zlib_version, ZLIB_VERSION,            sizeof(version->zlib_version) - 1);    version->zlib_version[sizeof(version->zlib_version) - 1] = '\0';    version->flag |= 2;#else    version->zlib_version[0] = '\0';#endif    /* someday each of these may have a separate patchlevel: */    version->unzip.major = UZ_MAJORVER;    version->unzip.minor = UZ_MINORVER;    version->unzip.patchlevel = UZ_PATCHLEVEL;    version->zipinfo.major = ZI_MAJORVER;    version->zipinfo.minor = ZI_MINORVER;    version->zipinfo.patchlevel = UZ_PATCHLEVEL;    /* these are retained for backward compatibility only: */    version->os2dll.major = UZ_MAJORVER;    version->os2dll.minor = UZ_MINORVER;    version->os2dll.patchlevel = UZ_PATCHLEVEL;    version->windll.major = UZ_MAJORVER;    version->windll.minor = UZ_MINORVER;    version->windll.patchlevel = UZ_PATCHLEVEL;}#ifndef SFX#ifndef WINDLLint UZ_EXP UzpAltMain(int argc, char *argv[], UzpInit *init){    int r, (*dummyfn)();    CONSTRUCTGLOBALS();    if (init->structlen >= (sizeof(ulg) + sizeof(dummyfn)) && init->msgfn)        G.message = init->msgfn;    if (init->structlen >= (sizeof(ulg) + 2*sizeof(dummyfn)) && init->inputfn)        G.input = init->inputfn;    if (init->structlen >= (sizeof(ulg) + 3*sizeof(dummyfn)) && init->pausefn)        G.mpause = init->pausefn;    if (init->structlen >= (sizeof(ulg) + 4*sizeof(dummyfn)) && init->userfn)        (*init->userfn)();    /* allow void* arg? */    r = unzip(__G__ argc, argv);    DESTROYGLOBALS();    RETURN(r);}#endif /* !WINDLL */#ifndef __16BIT__void UZ_EXP UzpFreeMemBuffer(UzpBuffer *retstr){    if (retstr != NULL && retstr->strptr != NULL) {        free(retstr->strptr);        retstr->strptr = NULL;        retstr->strlength = 0;    }}#ifndef WINDLLstatic int UzpDLL_Init OF((zvoid *pG, UzpCB *UsrFuncts));static int UzpDLL_Init(pG, UsrFuncts)zvoid *pG;UzpCB *UsrFuncts;{    int (*dummyfn)();    if (UsrFuncts->structlen >= (sizeof(ulg) + sizeof(dummyfn)) &&        UsrFuncts->msgfn)        ((Uz_Globs *)pG)->message = UsrFuncts->msgfn;    else        return FALSE;    if (UsrFuncts->structlen >= (sizeof(ulg) + 2*sizeof(dummyfn)) &&        UsrFuncts->inputfn)        ((Uz_Globs *)pG)->input = UsrFuncts->inputfn;    if (UsrFuncts->structlen >= (sizeof(ulg) + 3*sizeof(dummyfn)) &&        UsrFuncts->pausefn)        ((Uz_Globs *)pG)->mpause = UsrFuncts->pausefn;    if (UsrFuncts->structlen >= (sizeof(ulg) + 4*sizeof(dummyfn)) &&        UsrFuncts->passwdfn)        ((Uz_Globs *)pG)->decr_passwd = UsrFuncts->passwdfn;    if (UsrFuncts->structlen >= (sizeof(ulg) + 5*sizeof(dummyfn)) &&        UsrFuncts->statrepfn)        ((Uz_Globs *)pG)->statreportcb = UsrFuncts->statrepfn;    return TRUE;}int UZ_EXP UzpUnzipToMemory(char *zip, char *file, UzpOpts *optflgs,    UzpCB *UsrFuncts, UzpBuffer *retstr){    int r;#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))    char *intern_zip, *intern_file;#endif    CONSTRUCTGLOBALS();#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))    intern_zip = (char *)malloc(strlen(zip)+1);    if (intern_zip == NULL) {       DESTROYGLOBALS();       return PK_MEM;    }    intern_file = (char *)malloc(strlen(file)+1);    if (intern_file == NULL) {       DESTROYGLOBALS();       free(intern_zip);       return PK_MEM;    }    ISO_TO_INTERN(zip, intern_zip);    ISO_TO_INTERN(file, intern_file);#   define zip intern_zip#   define file intern_file#endif    /* Copy those options that are meaningful for UzpUnzipToMemory, instead of     * a simple "memcpy(G.UzO, optflgs, sizeof(UzpOpts));"     */    uO.pwdarg = optflgs->pwdarg;    uO.aflag = optflgs->aflag;    uO.C_flag = optflgs->C_flag;    uO.qflag = optflgs->qflag;  /* currently,  overridden in unzipToMemory */    if (!UzpDLL_Init((zvoid *)&G, UsrFuncts)) {       DESTROYGLOBALS();       return PK_BADERR;    }    G.redirect_data = 1;    r = (unzipToMemory(__G__ zip, file, retstr) <= PK_WARN);    DESTROYGLOBALS();#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))#  undef file#  undef zip    free(intern_file);    free(intern_zip);#endif    if (!r && retstr->strlength) {       free(retstr->strptr);       retstr->strptr = NULL;    }    return r;}#endif /* !WINDLL */#endif /* !__16BIT__ */#ifdef OS2DLLint UZ_EXP UzpFileTree(char *name, cbList(callBack), char *cpInclude[],                char *cpExclude[]){    int r;    CONSTRUCTGLOBALS();    uO.qflag = 2;    uO.vflag = 1;    uO.C_flag = 1;    G.wildzipfn = name;    G.process_all_files = TRUE;    if (cpInclude) {        char **ptr = cpInclude;        while (*ptr != NULL) ptr++;        G.filespecs = ptr - cpInclude;        G.pfnames = cpInclude, G.process_all_files = FALSE;    }    if (cpExclude) {        char **ptr = cpExclude;        while (*ptr != NULL) ptr++;        G.xfilespecs = ptr - cpExclude;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -