Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/tandem/tanunz.c  view on Meta::CPAN

            }
            tmproot[rootlen++] = TANDEM_DELIMITER;
            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 mkdir() */
/********************/

int mkdir(path, mode)
const char *path;  /* both    */
mode_t mode;       /* ignored */
/*
 * returns:   0 - successful
 *           -1 - failed (errno not set, however)
 */
{
    return 0;
}


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

void close_outfile(__G)    /* GRR: change to return PK-style warning level */
    __GDEF
{
    union {
        iztimes t3;             /* mtime, atime, ctime */
        ztimbuf t2;             /* modtime, actime */
    } zt;
    ulg z_uidgid[2];
    unsigned eb_izux_flg;
    nsk_file_attrs *znsk_attr;
    short err;
    unsigned short len;

    #define alist_items 1
    #define vlist_bytes 2
    short alist[alist_items]={42     };
    unsigned short vlist[alist_items];
    short extra, *err_item=&extra;

    char nsk_work[FILENAME_MAX + 1], *nsk_fname=&nsk_work[0];

    fclose(G.outfile);

    /* Set up Tandem specific file information if present */
    znsk_attr = ef_scan_for_tandem(G.extra_field, G.lrec.extra_field_length);

    /* Currently we do not create 'proper' Tandem files in unzip - we only  */
    /* create unstructured (180) or edit (101) files.  This code allows     */
    /* some limited support for restoration of Tandem file attributes       */

    if (znsk_attr != NULL) {
      /* Reset File Code */
      if (!uO.bflag && !G.pInfo->textmode
          && znsk_attr->filetype == NSK_UNSTRUCTURED) {
        /* leave type 101 files alone */
        vlist[0] = znsk_attr->filecode;

        /* Note that FILE_ALTERLIST_ expect uppercase names and that        */
        /* G.lrec.filename_length is the length of original zipped filename */
        /* not any 'rename' name.  Need to re call strlen and upshift       */
        len = strlen(G.filename);
        err = STRING_UPSHIFT_(G.filename,
                              len,
                              nsk_fname,
                              len);

        err = FILE_ALTERLIST_(nsk_fname,
                              len,
                              alist,
                              alist_items,
                              vlist,
                              vlist_bytes,
                              ,
                              err_item);
      }
    }


/*---------------------------------------------------------------------------
    Convert from MSDOS-format local time and date to Unix-format 32-bit GMT
    time:  adjust base year from 1980 to 1970, do usual conversions from
    yy/mm/dd hh:mm:ss to elapsed seconds, and account for timezone and day-
    light savings time differences.  If we have a Unix extra field, however,
    we're laughing:  both mtime and atime are ours.  On the other hand, we
    then have to check for restoration of UID/GID.
  ---------------------------------------------------------------------------*/

    eb_izux_flg = (G.extra_field ? ef_scan_for_izux(G.extra_field,
                   G.lrec.extra_field_length, 0, G.lrec.last_mod_dos_datetime,
#ifdef IZ_CHECK_TZ
                   (G.tz_is_valid ? &(zt.t3) : NULL),
#else
                   &(zt.t3),
#endif
                   z_uidgid) : 0);
    if (eb_izux_flg & EB_UT_FL_MTIME) {
        TTrace((stderr, "\nclose_outfile:  Unix e.f. modif. time = %ld\n",
          zt.t3.mtime));
    } else {
        zt.t3.mtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
    }
    if (eb_izux_flg & EB_UT_FL_ATIME) {
        TTrace((stderr, "close_outfile:  Unix e.f. access time = %ld\n",
          zt.t3.atime));
    } else {
        zt.t3.atime = zt.t3.mtime;
        TTrace((stderr, "\nclose_outfile:  modification/access times = %ld\n",
          zt.t3.mtime));
    }

/*---------------------------------------------------------------------------
    Change the file's last modified time to that stored in the zipfile.
    Not sure how (yet) or whether it's a good idea to set the last open time
  ---------------------------------------------------------------------------*/

    /* skip restoring time stamps on user's request */
    if (uO.D_flag <= 1) {
        /* set the file's access and modification times */
        if (utime(G.filename, &(zt.t2)))
            if (uO.qflag)
                Info(slide, 0x201, ((char *)slide,
                  "warning:  cannot set times for %s\n",
                  FnFilter1(G.filename)));
            else
                Info(slide, 0x201, ((char *)slide,
                  " (warning) cannot set times"));
    }

/*---------------------------------------------------------------------------
    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

/*---------------------------------------------------------------------------
       if -X option was specified and we have UID/GID info, restore it
       this must come after the file security and modtimes changes - since once
       we have secured the file to somebody else we cannot access it again.
  ---------------------------------------------------------------------------*/

    if (uO.X_flag && eb_izux_flg & EB_UX2_VALID) {
        TTrace((stderr, "close_outfile:  restoring Unix UID/GID info\n"));
        if (chown(G.filename, (uid_t)z_uidgid[0], (gid_t)z_uidgid[1]))
        {
            if (uO.qflag)
                Info(slide, 0x201, ((char *)slide,
                  "warning:  cannot set UID %lu and/or GID %lu for %s\n",
                  z_uidgid[0], z_uidgid[1], FnFilter1(G.filename)));
            else
                Info(slide, 0x201, ((char *)slide,
                  " (warning) cannot set UID %lu and/or GID %lu",
                  z_uidgid[0], z_uidgid[1]));
        }
    }

} /* end function close_outfile() */


#ifndef SFX

/************************/
/*  Function version()  */
/************************/

void version(__G)
    __GDEF
{

    /* Pyramid, NeXT have problems with huge macro expansion, too: no Info() */
    sprintf((char *)slide, LoadFarString(CompiledWith),

    "C ",
    "T9255D44 - (16OCT98)",
    "NonStop ",
    "(Tandem/NSK)",

#ifdef __DATE__
      " on ", __DATE__
#else
      "", ""
#endif
    );

    (*G.message)((zvoid *)&G, slide, (ulg)strlen((char *)slide), 0);

} /* end function version() */

#endif /* !SFX */



( run in 1.509 second using v1.01-cache-2.11-cpan-364913b4093 )