Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/qdos/qdos.c view on Meta::CPAN
/*
Copyright (c) 1990-2007 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, these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
qdos.c
QDOS-specific routines for use with Info-ZIP's UnZip 5.3 and later.
Contains: Qstrfix()
QFilename()
QMatch()
chowner()
Qgetch()
QReturn()
LastDir()
screensize()
do_wild() <-- generic enough to put in file_io.c?
mapattr()
mapname()
checkdir()
qfix()
close_outfile()
stamp_file()
getp()
version()
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "unzip.h"
#include "crypt.h"
#include "ttyio.h"
#include <dirent.h>
#include "izqdos.h"
#include "unzvers.h"
#ifndef SFX
char _prog_name[] = "UnZip";
#else
char _prog_name[] = "??Special Flag for unzipsfx hack ??";
#endif
/* sorrid hack at request of GRR follows; hope the compiler stays kind to us */
char _version[] = {UZ_MAJORVER+'0','.',UZ_MINORVER+'0',UZ_PATCHLEVEL+'0'};
char _extra[] = " " UZ_BETALEVEL;
char _copyright[] = "(c) Info-ZIP Group";
char * _endmsg = NULL;
long _stack = 16*1024; /* huge stack (for qdos) */
extern void consetup_title(chanid_t,struct WINDOWDEF *);
void (*_consetup)(chanid_t,struct WINDOWDEF *) = consetup_title;
struct WINDOWDEF _condetails =
{
2,
1,
0,
7,
500,
220,
2,
30
};
static jobid_t chowner(chanid_t chan)
{
extern char *_sys_var;
char *scht;
long *cdb;
long jid;
scht = *((char **)(_sys_var + 0x78));
cdb = *(long **)((long *)scht + (chan & 0xffff));
jid = *(cdb + 2);
return jid;
}
int QReturn(int err)
{
jobid_t me,you;
me = getpid();
you = chowner(getchid(0));
if((me == you) && ((qlflag & 4) == 0))
{
if(isatty(0) && isatty(2) && qlwait)
{
char c = 0;
fputs("Press a key to exit", stderr);
if((io_fbyte(getchid(0), qlwait, &c) == 0) && c == 27)
{
io_fbyte(getchid(0), -1, &c);
}
}
}
if(err > 0) err = -err; /* We like -ve err nos (exclusively, alas) */
exit(err);
}
#ifndef FUNZIP
static int created_dir; /* used in mapname(), checkdir() */
static int renamed_fullpath; /* ditto */
char *Qstrfix (char *p)
{
char *q;
for (q = p; (q = strstr(q, ".zip"));)
{
*q = '_';
q += 4;
}
return p;
}
void QFilename(char *f)
{
char *o,*p,*q = strdup(f);
p = q;
if(*q == '.' && *(q+1) == '/') q += 2;
o = q;
for(;*q;q++)
{
if(*q == '/') *q = '_';
if((qlflag & 1) == 0)
{
if(*q == '.') *q = '_';
}
}
strcpy(f,o);
free(p);
}
int QMatch(uch c1, uch c2)
{
int m =0;
if(c1 != c2)
{
if(c1 == '_' && (c2 == '.' || c2 == '/'))
( run in 2.090 seconds using v1.01-cache-2.11-cpan-364913b4093 )