/* * Copyright (c) 2000 S.Noda * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose is hereby granted provided * that the above copyright notice and this permission notice appear * in all copies of the software and related documentation. * * NO WARRANTY * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY WARRANTIES; * WITHOUT EVEN THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS * FOR A PARTICULAR PURPOSE. */ #include #include #include #include "unzipdll.h" int UzpMain(int ifnc, char **ifnv, int xfnc, char **xfnv, LPDCL lpCL); int main(int argc, char **argv) { int ifnc, xfnc; char **ifnv, **xfnv; char *x_opt; if (argc < 2) { printf("usage: %s [entry1 [entry2 [...]]] [-x xentry1 [...]]", "muzp"); return 0; } HANDLE hCL = GlobalAlloc(GPTR, (DWORD)sizeof(DCL)); if (!hCL) { return 0; } LPDCL lpCL = (LPDCL)GlobalLock(hCL); if (!lpCL) { GlobalFree(hCL); return 0; } lpCL->ExtractOnlyNewer = 0; // 0, "-u", true for "update" without interaction (extract only newer/new files, without queries) lpCL->SpaceToUnderscore = 0; // 0, '--s', true if convert space to underscore lpCL->PromptToOverwrite = 0; // 0, true if prompt to overwrite is wanted lpCL->fQuiet = 0; // 0, '-q', '-qq', quiet flag. 1 = few messages, 2 = no messages, 0 = all messages lpCL->ncflag = 0; // 0, "-c", write to stdout if true lpCL->ntflag = 0; // 0, "-t", test zip file lpCL->nvflag = 0; // 0, "-v", verbose listing lpCL->nfflag = 0; // 0, "-f", "freshen" (replace existing files by newer versions) lpCL->nzflag = 0; // 0, "-z", display zip file comment lpCL->ndflag = 1; // 1, '--j', all args are files/dir to be extracted lpCL->noflag = 1; // 1, '-o', true if you are to always over-write files, false if not lpCL->naflag = 0; // 0, '-a', do end-of-line translation lpCL->nZIflag = 1; // 0, "-Z", get zip info if true lpCL->C_flag = 0; // 0, '-C', be case insensitive if TRUE lpCL->fPrivilege = 0; // 0, '-X', '-XX', 1 => restore Acl's, 2 => Use privileges lpCL->lpszZipFN = argv[1]; // "-l", "-lv", "-p", "-x", "-xv", '-i', '-n', '-P$$$', '-qd', '-U', '-V' lpCL->lpszExtractDir = NULL; // NULL x_opt = NULL; if (argc > 2) { ifnv = &argv[2]; for (ifnc = 0; ifnc < argc - 2; ifnc++) if (!strcmp("-x", ifnv[ifnc])) { x_opt = ifnv[ifnc]; ifnv[ifnc] = NULL; break; } xfnc = argc - ifnc - 3; if (xfnc > 0) xfnv = &argv[ifnc + 3]; else { xfnc = 0; xfnv = NULL; } } else { ifnc = xfnc = 0; ifnv = xfnv = NULL; } UzpMain(ifnc, ifnv, xfnc, xfnv, lpCL); if (x_opt) { ifnv[ifnc] = x_opt; x_opt = NULL; } GlobalUnlock(hCL); GlobalFree(hCL); exit(1); return 1; }