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

📄 aosvs.c

📁 zip压缩
💻 C
📖 第 1 页 / 共 4 页
字号:
         * check end-buildpath after each append, set warning variable if         * within 20 of FILNAMSIZ; then if var set, do careful check when         * appending.  Clear variable when begin new path. */        if ((end-buildpath) > FILNAMSIZ-3)  /* need '/', one-char name, '\0' */            too_long = TRUE;                /* check if extracting directory? */        /* for AOS/VS, try to create so as to not use searchlist: */        if ( /*stat(buildpath, &G.statbuf)*/ 1) {            if (!G.create_dirs) { /* told not to create (freshening) */                free(buildpath);                return MPN_INF_SKIP;    /* path doesn't exist: nothing to do */            }            if (too_long) {                Info(slide, 1, ((char *)slide,                  "checkdir error:  path too long: %s\n",                  FnFilter1(buildpath)));                free(buildpath);                /* no room for filenames:  fatal */                return MPN_ERR_TOOLONG;            }            /* create the directory */            if (zvs_credir(buildpath,-1L,-1L,-1L,(char *) -1,-1,0L,-1,-1) == -1)            {                Info(slide, 1, ((char *)slide,                  "checkdir error:  cannot create %s\n\                 unable to process %s.\n",                  FnFilter2(buildpath), FnFilter1(G.filename)));                free(buildpath);                /* path didn't exist, tried to create, failed */                return MPN_ERR_SKIP;            }            created_dir = TRUE;        } else if (!S_ISDIR(G.statbuf.st_mode)) {            Info(slide, 1, ((char *)slide,              "checkdir error:  %s exists but is not directory\n\                 unable to process %s.\n",              FnFilter2(buildpath), FnFilter1(G.filename)));            free(buildpath);            /* path existed but wasn't dir */            return MPN_ERR_SKIP;        }        if (too_long) {            Info(slide, 1, ((char *)slide,              "checkdir error:  path too long: %s\n", FnFilter1(buildpath)));            free(buildpath);            /* no room for filenames:  fatal */            return MPN_ERR_TOOLONG;        }        *end++ = '/';        *end = '\0';        Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));        return MPN_OK;    } /* end if (FUNCTION == APPEND_DIR) *//*---------------------------------------------------------------------------    GETPATH:  copy full path to the string pointed at by pathcomp, and free    buildpath.  ---------------------------------------------------------------------------*/    if (FUNCTION == GETPATH) {        strcpy(pathcomp, buildpath);        Trace((stderr, "getting and freeing path [%s]\n",          FnFilter1(pathcomp)));        free(buildpath);        buildpath = end = (char *)NULL;        return MPN_OK;    }/*---------------------------------------------------------------------------    APPEND_NAME:  assume the path component is the filename; append it and    return without checking for existence.  ---------------------------------------------------------------------------*/    if (FUNCTION == APPEND_NAME) {#ifdef SHORT_NAMES        char *old_end = end;#endif        Trace((stderr, "appending filename [%s]\n", FnFilter1(pathcomp)));        while ((*end = *pathcomp++) != '\0') {            ++end;#ifdef SHORT_NAMES  /* truncate name at 14 characters, typically */            if ((end-old_end) > FILENAME_MAX)      /* GRR:  proper constant? */                *(end = old_end + FILENAME_MAX) = '\0';#endif            if ((end-buildpath) >= FILNAMSIZ) {                *--end = '\0';                Info(slide, 1, ((char *)slide,                  "checkdir warning:  path too long; truncating\n\                   %s\n                -> %s\n",                  FnFilter1(G.filename), FnFilter2(buildpath)));                return MPN_INF_TRUNC;   /* filename truncated */            }        }        Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));        /* could check for existence here, prompt for new name... */        return MPN_OK;    }/*---------------------------------------------------------------------------    INIT:  allocate and initialize buffer space for the file currently being    extracted.  If file was renamed with an absolute path, don't prepend the    extract-to path.  ---------------------------------------------------------------------------*//* GRR:  for VMS and TOPS-20, add up to 13 to strlen */    if (FUNCTION == INIT) {        Trace((stderr, "initializing buildpath to "));        if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+1))            == (char *)NULL)            return MPN_NOMEM;        if ((rootlen > 0) && !renamed_fullpath) {            strcpy(buildpath, rootpath);            end = buildpath + rootlen;        } else {            *buildpath = '\0';            end = buildpath;        }        Trace((stderr, "[%s]\n", FnFilter1(buildpath)));        return MPN_OK;    }/*---------------------------------------------------------------------------    ROOT:  if appropriate, store the path in rootpath and create it if    necessary; else assume it's a zipfile member and return.  This path    segment gets used in extracting all members from every zipfile specified    on the command line.  ---------------------------------------------------------------------------*/#if (!defined(SFX) || defined(SFX_EXDIR))    if (FUNCTION == ROOT) {        Trace((stderr, "initializing root path to [%s]\n",          FnFilter1(pathcomp)));        if (pathcomp == (char *)NULL) {            rootlen = 0;            return MPN_OK;        }        if (rootlen > 0)        /* rootpath was already set, nothing to do */            return MPN_OK;        if ((rootlen = strlen(pathcomp)) > 0) {            char *tmproot;            if ((tmproot = (char *)malloc(rootlen+2)) == (char *)NULL) {                rootlen = 0;                return MPN_NOMEM;            }            strcpy(tmproot, pathcomp);            if (tmproot[rootlen-1] == '/') {                tmproot[--rootlen] = '\0';            }            if (rootlen > 0 && (stat(tmproot, &G.statbuf) ||                                !S_ISDIR(G.statbuf.st_mode)))            {   /* path does not exist */                if (!G.create_dirs /* || iswild(tmproot) */ ) {                    free(tmproot);                    rootlen = 0;                    /* skip (or treat as stored file) */                    return MPN_INF_SKIP;                }                /* create the directory (could add loop here scanning tmproot                 * to create more than one level, but why really necessary?) */                if (zvs_credir(tmproot,-1L,-1L,-1L,(char *) -1,-1,0L,-1,-1)                    == -1)                {                    Info(slide, 1, ((char *)slide,                      "checkdir:  cannot create extraction directory: %s\n",                      FnFilter1(tmproot)));                    free(tmproot);                    rootlen = 0;                    /* path didn't exist, tried to create, and failed: */                    /* file exists, or 2+ subdir levels required */                    return MPN_ERR_SKIP;                }            }            tmproot[rootlen++] = '/';            tmproot[rootlen] = '\0';            if ((rootpath = (char *)realloc(tmproot, rootlen+1)) == NULL) {                free(tmproot);                rootlen = 0;                return MPN_NOMEM;            }            Trace((stderr, "rootpath now = [%s]\n", FnFilter1(rootpath)));        }        return MPN_OK;    }#endif /* !SFX || SFX_EXDIR *//*---------------------------------------------------------------------------    END:  free rootpath, immediately prior to program exit.  ---------------------------------------------------------------------------*/    if (FUNCTION == END) {        Trace((stderr, "freeing rootpath\n"));        if (rootlen > 0) {            free(rootpath);            rootlen = 0;        }        return MPN_OK;    }    return MPN_INVALID; /* should never reach */} /* end function checkdir() *//****************************//* Function close_outfile() *//****************************/void close_outfile(__G)    /* GRR: change to return PK-style warning level */    __GDEF{/*---------------------------------------------------------------------------    If symbolic links are supported, allocate a storage area, put the uncom-    pressed "data" in it, and create the link.  Since we know it's a symbolic    link to start with, we shouldn't have to worry about overflowing unsigned    ints with unsigned longs.  ---------------------------------------------------------------------------*/#ifdef SYMLINKS    if (G.symlnk) {        unsigned ucsize = (unsigned)G.lrec.ucsize;        char *linktarget = (char *)malloc((unsigned)G.lrec.ucsize+1);        fclose(G.outfile);                      /* close "data" file... */        G.outfile = fopen(G.filename, FOPR);    /* ...and reopen for reading */        if (!linktarget || fread(linktarget, 1, ucsize, G.outfile) !=                           (int)ucsize)        {            Info(slide, 0x201, ((char *)slide,              "warning:  symbolic link (%s) failed\n", FnFilter1(G.filename)));            if (linktarget)                free(linktarget);            fclose(G.outfile);            return;        }        fclose(G.outfile);                  /* close "data" file for good... */        unlink(G.filename);                 /* ...and delete it */        linktarget[ucsize] = '\0';        if (QCOND2)            Info(slide, 0, ((char *)slide, "-> %s ", FnFilter1(linktarget)));        if (symlink(linktarget, G.filename))  /* create the real link */            perror("symlink error");        free(linktarget);        return;                             /* can't set time on symlinks */    }#endif /* SYMLINKS */    fclose(G.outfile);/*---------------------------------------------------------------------------    Change the file permissions from default ones to those stored in the    zipfile.  ---------------------------------------------------------------------------*/#ifndef NO_CHMOD    if (chmod(G.filename, 0xffff & G.pInfo->file_attr))        perror("chmod (file attributes) error");#endif/*---------------------------------------------------------------------------    AOS/VS only allows setting file times at creation but has its own permis-    sions scheme which is better invoked here if the necessary information    was in fact stored.  In theory, we should look through an entire series    of extra fields that might exist for the same file, but we're not going    to bother.  If we set up other types of extra fields, or if we run into    other environments that add their own stuff to existing entries in ZIP    files, we'll have to.  NOTE:  already copied extra-field stuff into    zzextrafld structure when file was created.  ---------------------------------------------------------------------------*/    if (G.extra_field != NULL) {        if (!memcmp(ZEXTRA_HEADID, zzextrafld.extra_header_id,                    sizeof(zzextrafld.extra_header_id))  &&            !memcmp(ZEXTRA_SENTINEL, zzextrafld.extra_sentinel,                    sizeof(zzextrafld.extra_sentinel))  &&            zzextrafld.fstat_packet.norm_fstat_packet.styp_type != $FLNK)            /* (AOS/VS links don't have ACLs) */        {            /* vs_path was set (in this case) when we created the file */            if (sys_sacl(vs_path, zzextrafld.aclbuf)) {                Info(slide, 0x201, ((char *)slide,                  "error: cannot set ACL for %s\n", FnFilter1(G.filename)));                perror("sys_sacl()");            }        }    }} /* end function close_outfile() */#ifndef SFX/************************//*  Function version()  *//************************/void version(__G)    __GDEF{#if (defined(__GNUC__) && defined(NX_CURRENT_COMPILER_RELEASE))    char cc_namebuf[40];    char cc_versbuf[40];#else#if (defined(CRAY) && defined(_RELEASE))    char cc_versbuf[40];#endif#endif#if ((defined(CRAY) || defined(cray)) && defined(_UNICOS))    char os_namebuf[40];#else#if defined(__NetBSD__)    char os_namebuf[40];#endif#endif    /* Pyramid, NeXT have problems with huge macro expansion, too:  no Info() */    sprintf((char *)slide, LoadFarString(CompiledWith),#ifdef __GNUC__#  ifdef NX_CURRENT_COMPILER_RELEASE      (sprintf(cc_namebuf, "NeXT DevKit %d.%02d ",        NX_CURRENT_COMPILER_RELEASE/100, NX_CURRENT_COMPILER_RELEASE%100),       cc_namebuf),      (strlen(__VERSION__) > 8)? "(gcc)" :        (sprintf(cc_versbuf, "(gcc %s)", __VERSION__), cc_versbuf),#  else      "gcc ", __VERSION__,#  endif#else#  if defined(CRAY) && defined(_RELEASE)      "cc ", (sprintf(cc_versbuf, "version %d", _RELEASE), cc_versbuf),#  else#  ifdef __VERSION__#   ifndef IZ_CC_NAME#    define IZ_CC_NAME "cc "#   endif      IZ_CC_NAME, __VERSION__#  else#   ifndef IZ_CC_NAME#    define IZ_CC_NAME "cc"#   endif      IZ_CC_NAME, "",#  endif#  endif#endif /* ?__GNUC__ */#ifndef IZ_OS_NAME#  define IZ_OS_NAME "Unix"#endif      IZ_OS_NAME,#if defined(sgi) || defined(__sgi)      " (Silicon Graphics IRIX)",#else#ifdef sun#  ifdef sparc#    ifdef __SVR4      " (Sun SPARC/Solaris)",#    else /* may or may not be SunOS */      " (Sun SPARC)",#    endif#  else#  if defined(sun386) || defined(i386)      " (Sun 386i)",#  else#  if defined(mc68020) || defined(__mc68020__)      " (Sun 3)",#  else /* mc68010 or mc68000:  Sun 2 or earlier */      " (Sun 2)",#  endif#  endif#  endif#else#ifdef __hpux      " (HP/UX)",#else#ifdef __osf__      " (DEC OSF/1)",

⌨️ 快捷键说明

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