Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/unzip.c view on Meta::CPAN
%s\
unzip -fo foo %-6s => quietly replace existing %s if archive file newer\n";
#endif /* ?SFX */
/*****************************/
/* main() / UzpMain() stub */
/*****************************/
int MAIN(argc, argv) /* return PK-type error code (except under VMS) */
int argc;
char *argv[];
{
int r;
CONSTRUCTGLOBALS();
r = unzip(__G__ argc, argv);
DESTROYGLOBALS();
RETURN(r);
}
/*******************************/
/* Primary UnZip entry point */
/*******************************/
int unzip(__G__ argc, argv)
__GDEF
int argc;
char *argv[];
{
#ifndef NO_ZIPINFO
char *p;
#endif
#if (defined(DOS_FLX_H68_NLM_OS2_W32) || !defined(SFX))
int i;
#endif
int retcode, error=FALSE;
#ifndef NO_EXCEPT_SIGNALS
#ifdef REENTRANT
savsigs_info *oldsighandlers = NULL;
# define SET_SIGHANDLER(sigtype, newsighandler) \
if ((retcode = setsignalhandler(__G__ &oldsighandlers, (sigtype), \
(newsighandler))) > PK_WARN) \
goto cleanup_and_exit
#else
# define SET_SIGHANDLER(sigtype, newsighandler) \
signal((sigtype), (newsighandler))
#endif
#endif /* NO_EXCEPT_SIGNALS */
/* initialize international char support to the current environment */
SETLOCALE(LC_CTYPE, "");
#ifdef UNICODE_SUPPORT
/* see if can use UTF-8 Unicode locale */
# ifdef UTF8_MAYBE_NATIVE
{
char *codeset;
# if !(defined(NO_NL_LANGINFO) || defined(NO_LANGINFO_H))
/* get the codeset (character set encoding) currently used */
# include <langinfo.h>
codeset = nl_langinfo(CODESET);
# else /* NO_NL_LANGINFO || NO_LANGINFO_H */
/* query the current locale setting for character classification */
codeset = setlocale(LC_CTYPE, NULL);
if (codeset != NULL) {
/* extract the codeset portion of the locale name */
codeset = strchr(codeset, '.');
if (codeset != NULL) ++codeset;
}
# endif /* ?(NO_NL_LANGINFO || NO_LANGINFO_H) */
/* is the current codeset UTF-8 ? */
if ((codeset != NULL) && (strcmp(codeset, "UTF-8") == 0)) {
/* successfully found UTF-8 char coding */
G.native_is_utf8 = TRUE;
} else {
/* Current codeset is not UTF-8 or cannot be determined. */
G.native_is_utf8 = FALSE;
}
/* Note: At least for UnZip, trying to change the process codeset to
* UTF-8 does not work. For the example Linux setup of the
* UnZip maintainer, a successful switch to "en-US.UTF-8"
* resulted in garbage display of all non-basic ASCII characters.
*/
}
# endif /* UTF8_MAYBE_NATIVE */
/* initialize Unicode */
G.unicode_escape_all = 0;
G.unicode_mismatch = 0;
G.unipath_version = 0;
G.unipath_checksum = 0;
G.unipath_filename = NULL;
#endif /* UNICODE_SUPPORT */
#if (defined(__IBMC__) && defined(__DEBUG_ALLOC__))
extern void DebugMalloc(void);
atexit(DebugMalloc);
#endif
#ifdef MALLOC_WORK
/* The following (rather complex) expression determines the allocation
size of the decompression work area. It simulates what the
combined "union" and "struct" declaration of the "static" work
area reservation achieves automatically at compile time.
Any decent compiler should evaluate this expression completely at
compile time and provide constants to the zcalloc() call.
(For better readability, some subexpressions are encapsulated
in temporarly defined macros.)
*/
# define UZ_SLIDE_CHUNK (sizeof(shrint)+sizeof(uch)+sizeof(uch))
# define UZ_NUMOF_CHUNKS \
(unsigned)(((WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK > HSIZE) ? \
(WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK : HSIZE)
G.area.Slide = (uch *)zcalloc(UZ_NUMOF_CHUNKS, UZ_SLIDE_CHUNK);
# undef UZ_SLIDE_CHUNK
# undef UZ_NUMOF_CHUNKS
G.area.shrink.Parent = (shrint *)G.area.Slide;
G.area.shrink.value = G.area.Slide + (sizeof(shrint)*(HSIZE));
G.area.shrink.Stack = G.area.Slide +
(sizeof(shrint) + sizeof(uch))*(HSIZE);
#endif
/*---------------------------------------------------------------------------
( run in 0.960 second using v1.01-cache-2.11-cpan-ceb78f64989 )