Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/cmsmvs/vmmvs.c view on Meta::CPAN
/*
Copyright (c) 1990-2005 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
*/
/*---------------------------------------------------------------------------
vmmvs.c (for both VM/CMS and MVS)
Contains: vmmvs_open_infile()
open_outfile()
close_outfile()
close_infile()
getVMMVSexfield()
do_wild()
mapattr()
mapname()
checkdir()
check_for_newer()
stat()
version()
---------------------------------------------------------------------------*/
#define __VMMVS_C /* identifies this source module */
#define UNZIP_INTERNAL
#include "unzip.h"
/********************************/
/* Function vmmvs_open_infile() */
/********************************/
FILE *vmmvs_open_infile(__G)
__GDEF
{
FILE *fzip;
G.tempfn = NULL;
fzip = fopen(G.zipfn, FOPR);
#if 0
/* Let's try it without the convert for a while -- RG Hartwig */
if ((fzip = fopen(G.zipfn,"rb,recfm=fb")) == NULL) {
size_t cnt;
char *buf;
FILE *in, *out;
if ((buf = (char *)malloc(32768)) == NULL) return NULL;
if ((G.tempfn = tmpnam(NULL)) == NULL) return NULL;
if ((in = fopen(G.zipfn,"rb")) != NULL &&
(out = fopen(G.tempfn,"wb,recfm=fb,lrecl=1")) != NULL) {
Trace((stdout,"Converting ZIP file to fixed record format...\n"));
while (!feof(in)) {
cnt = fread(buf,1,32768,in);
if (cnt) fwrite(buf,1,cnt,out);
}
}
else {
free(buf);
fclose(out);
fclose(in);
return NULL;
}
free(buf);
fclose(out);
fclose(in);
fzip = fopen(G.tempfn,"rb,recfm=fb");
if (fzip == NULL) return NULL;
/* Update the G.ziplen value since it might have changed after
the reformatting copy. */
fseek(fzip,0L,SEEK_SET);
fseek(fzip,0L,SEEK_END);
G.ziplen = ftell(fzip);
}
unzip-6.0/cmsmvs/vmmvs.c view on Meta::CPAN
strcat(newfilename, pathcomp);
}
strcat(newfilename, "(");
strcat(newfilename, start_fname);
strcat(newfilename, ")");
}
else {
strcat(newfilename, ".");
strcat(newfilename, pathcomp);
}
if (quoted)
strcat(newfilename, "'");
Trace((stdout, "new dataset : %s\n", newfilename));
strcpy(pathcomp, newfilename);
#endif /* ?VM_CMS */
}
return MPN_OK;
}
/*---------------------------------------------------------------------------
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 check_for_newer() */ /* used for overwriting/freshening/updating */
/******************************/
int check_for_newer(__G__ filename) /* return 1 if existing file is newer */
__GDEF /* or equal; 0 if older; -1 if doesn't */
char *filename; /* exist yet */
{
FILE *stream;
if ((stream = fopen(filename, FOPR)) != NULL) {
fclose(stream);
/* File exists, assume it is "newer" than archive entry. */
return EXISTS_AND_NEWER;
}
/* File does not exist. */
return DOES_NOT_EXIST;
} /* end function check_for_newer() */
/*********************/
/* Function stat() */
/*********************/
int stat(const char *path, struct stat *buf)
{
FILE *fp;
char fname[PATH_MAX];
time_t ltime;
if ((fp = fopen(path, FOPR)) != NULL) {
fldata_t fdata;
if (fldata( fp, fname, &fdata ) == 0) {
buf->st_dev = fdata.__device;
buf->st_mode = *(short *)(&fdata);
}
/* Determine file size by seeking to EOF */
fseek(fp,0L,SEEK_END);
buf->st_size = ftell(fp);
fclose(fp);
/* set time fields in stat buf to current time. */
time(<ime);
buf->st_atime =
buf->st_mtime =
buf->st_ctime = ltime;
/* File exists, return success */
return 0;
}
return 1;
}
#ifdef STAND_ALONE
/***************************/
/* Function main_vmmvs() */
/***************************/
/* This function is called as main() to parse arguments */
/* into argc and argv. This is required for stand-alone */
/* execution. This calls the "real" main() when done. */
int MAIN_VMMVS(void)
{
int argc=0;
char *argv[50];
int iArgLen;
char argstr[256];
char **pEPLIST, *pCmdStart, *pArgStart, *pArgEnd;
/* Get address of extended parameter list from S/370 Register 0 */
pEPLIST = (char **)__xregs(0);
/* Null-terminate the argument string */
pCmdStart = *(pEPLIST+0);
pArgStart = *(pEPLIST+1);
pArgEnd = *(pEPLIST+2);
iArgLen = pArgEnd - pCmdStart + 1;
/* Make a copy of the command string */
memcpy(argstr, pCmdStart, iArgLen);
( run in 0.459 second using v1.01-cache-2.11-cpan-5511b514fd6 )