Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/qdos/qdos.c  view on Meta::CPAN

            if (tmproot[rootlen-1] == '/' || tmproot[rootlen-1] == '_') {
                tmproot[--rootlen] = '\0';
            }
            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() */


static void qfix(__G__ ef_ptr, ef_len)
    __GDEF
    uch *ef_ptr;
    unsigned ef_len;
{
    qdosextra qextra;

    while (ef_len >= EB_HEADSIZE)
    {
        qdosextra   *extra = &qextra;
        jbextra     *jbp   = (jbextra *)&qextra;
        unsigned    eb_len = makeword(EB_LEN + ef_ptr);

        if (eb_len > (ef_len - EB_HEADSIZE)) {
            /* discovered some extra field inconsistency! */
            Trace((stderr,
              "qfix: block length %u > rest ef_size %u\n", eb_len,
              ef_len - EB_HEADSIZE));
            break;
        }

        /* Must ensure that we don't use ODD addresses here */

        memcpy(&qextra, ef_ptr, sizeof(qdosextra));
        switch (extra->shortid) {
          case SHORTID:
            if (!strncmp(extra->longid, LONGID, strlen(LONGID)))
            {
                if (eb_len != EXTRALEN)
                    fputs("warning: invalid length in Qdos field", stderr);
                if (extra->header.d_type)
                {
                    fs_heads(fgetchid(G.outfile), (timeout_t)-1,
                             &extra->header, 14);
                    G.pInfo->file_attr |= S_IXUSR;
                }
            }

            if (!strncmp(jbp->longid, JBLONGID, strlen(JBLONGID)))
            {
                if (eb_len != JBEXTRALEN)
                    fputs("warning: invalid length in QZ field", stderr);
                if (jbp->header.d_type)
                {
                    fs_heads(fgetchid(G.outfile), (timeout_t)-1,
                             &jbp->header, 14);
                    G.pInfo->file_attr |= S_IXUSR;
                }
            }
            break;

          default:
            Trace((stderr,"qfix: unknown extra field block, ID=%d\n",
               extra->shortid));
            break;
        }

        /* Skip this extra field block */
        ef_ptr += (eb_len + EB_HEADSIZE);
        ef_len -= (eb_len + EB_HEADSIZE);
    }
}


#ifdef QDOS
#  include <utime.h>
   long timezone = 0;
#endif


/****************************/
/* Function close_outfile() */
/****************************/

void close_outfile(__G)
    __GDEF
{
    union {
        iztimes t3;             /* mtime, atime, ctime */
        struct utimbuf t2;      /* modtime, actime */
    } zt;
#ifdef USE_EF_UT_TIME
    unsigned eb_izux_flg;
#endif

    if (G.extra_field) {
        qfix(__G__ G.extra_field, G.lrec.extra_field_length);
    }

    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");



( run in 1.151 second using v1.01-cache-2.11-cpan-a49fcb8fa48 )