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

📄 qdos.c

📁 完整的解压zip文件的源码。包含密码功能
💻 C
📖 第 1 页 / 共 3 页
字号:
/*---------------------------------------------------------------------------  qdos.c  QDOS-specific routines for use with Info-ZIP's UnZip 5.3 and later.  Contains:  Qstrfix()             QFilename()             QMatch()             chowner()             Qgetch()             QReturn()             LastDir()             do_wild()           <-- generic enough to put in file_io.c?             mapattr()             mapname()             checkdir()             qfix()             close_outfile()             stamp_file()             getp()             version()  ---------------------------------------------------------------------------*/#define UNZIP_INTERNAL#include "unzip.h"#include "crypt.h"#include "ttyio.h"#include <dirent.h>#include "izqdos.h"#include "version.h"#ifndef SFXchar _prog_name[] = "UnZip";#elsechar _prog_name[] = "??Special Flag for unzipsfx hack  ??";#endif/* sorrid hack at request of GRR follows; hope the compiler stays kind to us */char _version[] = {UZ_MAJORVER+'0','.',UZ_MINORVER+'0',PATCHLEVEL+'0'};char _extra[] = " " BETALEVEL;char _copyright[] = "(c) Info-ZIP Group";char *  _endmsg = NULL;long _stack = 16*1024;         /* huge stack (for qdos) */extern void consetup_title(chanid_t,struct WINDOWDEF *);void (*_consetup)(chanid_t,struct WINDOWDEF *) = consetup_title;struct WINDOWDEF _condetails ={    2,    1,    0,    7,    500,    220,    2,    30};static jobid_t chowner(chanid_t chan){    extern char *_sys_var;    char *scht;    long *cdb;    long jid;    scht = *((char **)(_sys_var + 0x78));    cdb = *(long **)((long *)scht  + (chan & 0xffff));    jid = *(cdb + 2);    return jid;}int QReturn(int err){    jobid_t me,you;    me = getpid();    you = chowner(getchid(0));    if((me == you) && ((qlflag & 4) == 0))    {        if(isatty(0) && isatty(2) && qlwait)        {            char c = 0;            fputs("Press a key to exit", stderr);            if((io_fbyte(getchid(0), qlwait, &c) == 0) && c == 27)            {                io_fbyte(getchid(0), -1, &c);            }        }    }    exit(err);}#ifndef FUNZIPstatic int created_dir;        /* used in mapname(), checkdir() */static int renamed_fullpath;   /* ditto */char *Qstrfix (char *p){    char *q;    for (q = p; (q = strstr(q, ".zip"));)    {        memcpy(q, "_zip", 4);        q += 4;    }    return p;}void QFilename(char *f){    char *o,*p,*q = strdup(f);    p = q;    if(*q == '.' && *(q+1) == '/') q += 2;    o = q;    for(;*q;q++)    {        if(*q == '/') *q = '_';        if((qlflag & 1) == 0)        {            if(*q == '.') *q = '_';        }    }    strcpy(f,o);    free(p);}int QMatch(uch c1, uch c2){    int m =0;    if(c1 != c2)    {        if(c1 == '_' && (c2 == '.' || c2 == '/'))        {            m = 1;        }    }    else    {        m = 1;    }    return m;}int Qgetch(void){    char ch;    if(io_fbyte(getchid(0), -1, &ch) < 0)    {        return EOF;    }    else    {        return (int) ch;    }}#ifndef SFXchar *LastDir(char *ws){    char *p;    char *q = ws;    struct stat s;    for(p = ws; *p; p++)    {        if(*p == '_')        {            char c;            p++;            c = *p;            *p = 0;            if(stat(ws, &s) == 0 && S_ISDIR(s.st_mode))            {                q = p;            }            *p = c;        }    }    return q;}/**********************//* Function do_wild() */   /* for porting:  dir separator; match(ignore_case) *//**********************/char *do_wild(__G__ wildspec)    __GDEF    char *wildspec;         /* only used first time on a given dir */{    static DIR *dir = (DIR *)NULL;    static char *dirname, *wildname, matchname[FILNAMSIZ];    static int firstcall=TRUE, have_dirname, dirnamelen;    struct dirent *file;    char basedir[40];    /* Even when we're just returning wildspec, we *always* do so in     * matchname[]--calling routine is allowed to append four characters     * to the returned string, and wildspec may be a pointer to argv[].     */    if (firstcall) {        /* first call:  must initialize everything */        char *ws = NULL, *us = NULL;        firstcall = FALSE;        /* break the wildspec into a directory part and a wildcard filename */        ws = (char *) iswild(wildspec);        if(ws == NULL)        {            strcpy(matchname, wildspec);            return matchname;        }        us = LastDir(wildspec);        if(us == wildspec)        {            dirname = basedir;            getcwd(basedir, sizeof(basedir)-1);            dirnamelen = strlen(basedir);            have_dirname = FALSE;            wildname = wildspec;        } else {            wildname = us;     /* point at character after '/' */            dirnamelen = wildname - wildspec;            if ((dirname = (char *)malloc(dirnamelen+1)) == (char *)NULL) {                Info(slide, 0x201, ((char *)slide,                  "warning:  cannot allocate wildcard buffers\n"));                strcpy(matchname, wildspec);                return matchname;   /* but maybe filespec was not a wildcard */            }            strncpy(dirname, wildspec, dirnamelen);            dirname[dirnamelen] = '\0';   /* terminate for strcpy below */            have_dirname = TRUE;        }        if ((dir = opendir(dirname)) != (DIR *)NULL) {            while ((file = readdir(dir)) != (struct dirent *)NULL) {                if (match(file->d_name, wildname, 2)) {  /* 0 == case sens. */                    if (have_dirname) {                        strcpy(matchname, dirname);                        strcpy(matchname+dirnamelen, file->d_name);                    } else                        strcpy(matchname, file->d_name);                    return matchname;                }            }            /* if we get to here directory is exhausted, so close it */            closedir(dir);            dir = (DIR *)NULL;        }        /* return the raw wildspec in case that works (e.g., directory not         * searchable, but filespec was not wild and file is readable) */        strcpy(matchname, wildspec);        return matchname;    }    /* last time through, might have failed opendir but returned raw wildspec */    if (dir == (DIR *)NULL) {        firstcall = TRUE;  /* nothing left to try--reset for new wildspec */        if (have_dirname)            free(dirname);        return (char *)NULL;    }    /* If we've gotten this far, we've read and matched at least one entry     * successfully (in a previous call), so dirname has been copied into     * matchname already.     */    while ((file = readdir(dir)) != (struct dirent *)NULL)        if (match(file->d_name, wildname, 2)) {   /* 0 == don't ignore case */            if (have_dirname) {                /* strcpy(matchname, dirname); */                strcpy(matchname+dirnamelen, file->d_name);            } else                strcpy(matchname, file->d_name);            return matchname;        }    closedir(dir);     /* have read at least one dir entry; nothing left */    dir = (DIR *)NULL;    firstcall = TRUE;  /* reset for new wildspec */    if (have_dirname)        free(dirname);    return (char *)NULL;} /* end function do_wild() */#endif /* !SFX *//**********************//* Function mapattr() *//**********************/int mapattr(__G)    __GDEF{    ulg tmp = G.crec.external_file_attributes;    switch (G.pInfo->hostnum) {        case AMIGA_:            tmp = (unsigned)(tmp>>17 & 7);   /* Amiga RWE bits */            G.pInfo->file_attr = (unsigned)(tmp<<6 | tmp<<3 | tmp);            break;        case QDOS_:        case UNIX_:        case VMS_:        case ACORN_:        case ATARI_:        case BEOS_:            G.pInfo->file_attr = (unsigned)(tmp >> 16);            if (G.pInfo->file_attr != 0 || !G.extra_field) {                return 0;            } else {                /* Some (non-Info-ZIP) implementations of Zip for Unix and                   VMS (and probably others ??) leave 0 in the upper 16-bit                   part of the external_file_attributes field. Instead, they                   store file permission attributes in some extra field.                   As a work-around, we search for the presence of one of                   these extra fields and fall back to the MSDOS compatible                   part of external_file_attributes if one of the known                   e.f. types has been detected.

⌨️ 快捷键说明

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