Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/vms/vms.c view on Meta::CPAN
0, /* AST parameter */
&pka_fibdsc, /* P1 = File Info Block */
&pka_fnam, /* P2 = File name (descr) */
&res_nam_len, /* P3 = Resulting name len */
&res_nam_dscr, /* P4 = Resulting name descr */
pka_atr, /* P5 = Attribute descr */
0); /* P6 (not used) */
if ( !ERR(status) )
status = pka_acp_iosb.status;
if (res_nam_len > 0)
{
/* NUL-terminate the resulting file spec. */
G.filename[res_nam_len] = '\0';
}
/* Clear any user-specified version policy flags
* (for the next file to be processed).
*/
pka_fib.FIB$W_NMCTL &= (~(FIB$M_NEWVER| FIB$M_SUPERSEDE));
}
if ( ERR(status) )
{
char buf[NAM_MAXRSS + 128]; /* Name length + message length. */
sprintf(buf, "[ Cannot create (QIO) output file %s ]\n",
G.filename);
vms_msg(__G__ buf, status);
sys$dassgn(pka_devchn);
return OPENOUT_FAILED;
}
#ifdef ASYNCH_QIO
init_buf_ring();
pka_io_pending = FALSE;
#else
locptr = locbuf;
loccnt = 0;
#endif
pka_vbn = 1;
_flush_routine = _flush_qio;
_close_routine = _close_qio;
} /* end if (!uO.cflag) */
return OPENOUT_OK;
}
/* 2008-07-23 SMS.
* Segregated user query function from file re-open functions/code.
*
* There was no code in create_qio_output() to deal with an
* SS$_DUPFILENAME condition, leading to ugly run-time failures, and its
* requirements differ from those of the RMS (non-QIO) functions,
* create_default_output() and create_rms_output().
*
* Whether it makes sense to have a second layer of VMS-specific
* querying after the generic UnZip query in extract.c:
* extract_or_test_entrylist() is another question, but changing that
* looks more scary than just getting the VMS-specific stuff to work
* right (better?).
*/
/* "File exists" handler(s). Ask user about further action. */
/* RMS create new version. */
static int replace_rms_newversion(__GPRO)
{
int ierr;
struct NAM_STRUCT nam;
nam = CC_RMS_NAM; /* Initialize local NAM[L] block. */
outfab->FAB_NAM = &nam; /* Point FAB to local NAM[L]. */
/* Arrange to store the resultant file spec (with new version), so
* that we can extract the actual file version from it, for later
* use in the "extracting:/inflating:/..." message (G.filename).
*/
nam.NAM_RSA = res_nam;
nam.NAM_RSS = sizeof(res_nam);
#ifdef NAML$C_MAXRSS
outfab->fab$l_dna = (char *) -1; /* Using NAML for default name. */
outfab->fab$l_fna = (char *) -1; /* Using NAML for file name. */
#endif /* NAML$C_MAXRSS */
FAB_OR_NAML(*outfab, nam).FAB_OR_NAML_FNA = G.filename;
FAB_OR_NAML(*outfab, nam).FAB_OR_NAML_FNS = strlen(G.filename);
/* Maximize version number. */
outfab->fab$l_fop |= FAB$M_MXV;
/* Create the new-version file. */
ierr = sys$create(outfab);
if (nam.NAM_RSL > 0)
{
/* File spec version pointers.
* Versions must exist, so a simple right-to-left search for ";"
* should work, even on ODS5 extended file specs.
*/
char *semi_col_orig;
char *semi_col_res;
/* NUL-terminate the (complete) resultant file spec. */
res_nam[nam.NAM_RSL] = '\0';
/* Find the versions (";") in the original and resultant file specs. */
semi_col_orig = strrchr(G.filename, ';');
semi_col_res = strrchr(res_nam, ';');
if ((semi_col_orig != NULL) && (semi_col_res != NULL))
{
/* Transfer the resultant version to the original file spec. */
strcpy((semi_col_orig + 1), (semi_col_res + 1));
}
}
return ierr;
unzip-6.0/vms/vms.c view on Meta::CPAN
Info(slide, 1, ((char *)slide, AssumeNo));
/* Handle the NULL answer as "N",
* do not extract any existing files. */
replace_code_all = REPL_NO_EXTRACT;
/* Set a warning indicator. */
replace_code = REPL_NO_EXTRACT | REPL_ERRLV_WARN;
/* We are finished, break out of the query loop. */
break;
}
/* Strip off a trailing newline, to avoid corrupt
* complaints when displaying the answer.
*/
if (answ[strlen(answ) - 1] == '\n')
answ[strlen(answ) - 1] = '\0';
/* Extra newline to avoid having the extracting:/inflating:/...:
* message overwritten by the next query.
*/
Info(slide, 1, ((char *)slide, "\n"));
/* Interpret response. Store upper-case answer for future use. */
switch (answ[0])
{
case 'N':
replace_code_all = REPL_NO_EXTRACT;
case 'n':
/* Do not extract this file. */
replace_code = REPL_NO_EXTRACT;
break;
case 'O':
replace_code_all = REPL_OVERWRITE;
case 'o':
/* Overwrite (supersede) this existing file. */
replace_code = REPL_OVERWRITE;
break;
case 'V':
replace_code_all = REPL_NEW_VERSION;
case 'v':
/* Create a new version of this file. */
replace_code = REPL_NEW_VERSION;
break;
default:
/* Invalid response. Try again. */
Info(slide, 1, ((char *)slide, InvalidResponse, answ));
}
} while (replace_code < 0);
}
return replace_code;
}
#define W(p) (*(unsigned short*)(p))
#define L(p) (*(unsigned long*)(p))
#define EQL_L(a, b) ( L(a) == L(b) )
#define EQL_W(a, b) ( W(a) == W(b) )
/*
* Function find_vms_attrs() scans the ZIP entry extra field, if any,
* and looks for VMS attribute records. Various date-time attributes
* are ignored if set_date_time is FALSE (typically for a directory).
*
* For a set of IZ records, a FAB and various XABs are created and
* chained together.
*
* For a PK record, the pka_atr[] attribute descriptor array is
* populated.
*
* The return value is a VAT_* value, according to the type of extra
* field attribute data found.
*/
static int find_vms_attrs(__GPRO__ int set_date_time)
{
uch *scan = G.extra_field;
struct EB_header *hdr;
int len;
int type=VAT_NONE;
outfab = NULL;
xabfhc = NULL;
xabdat = NULL;
xabrdt = NULL;
xabpro = NULL;
first_xab = last_xab = NULL;
if (scan == NULL)
return VAT_NONE;
len = G.lrec.extra_field_length;
#define LINK(p) {/* Link xaballs and xabkeys into chain */ \
if ( first_xab == NULL ) \
first_xab = (void *) p; \
if ( last_xab != NULL ) \
last_xab->xab$l_nxt = (void *) p; \
last_xab = (void *) p; \
p->xab$l_nxt = NULL; \
}
/* End of macro LINK */
while (len > 0)
{
hdr = (struct EB_header *)scan;
if (EQL_W(&hdr->tag, IZ_SIGNATURE))
{
/*
* Info-ZIP-style extra block decoding.
*/
uch *blk;
unsigned siz;
uch *block_id;
type = VAT_IZ;
siz = hdr->size;
blk = (uch *)(&hdr->data[0]);
block_id = (uch *)(&((struct IZ_block *)hdr)->bid);
if (EQL_L(block_id, FABSIG)) {
outfab = (struct FAB *)extract_izvms_block(__G__ blk,
siz, NULL, (uch *)&cc$rms_fab, FABL);
( run in 1.293 second using v1.01-cache-2.11-cpan-c221a9de4ec )