📄 windll.c
字号:
{ free(intern_ifv[0]); free(intern_ifv); } FreeDllMem(__G); return PK_BADERR; } for (f_cnt = xfnc; --f_cnt >= 0;) bufsize += strlen(xfnv[f_cnt]) + 1; intern_xfv[0] = (char *)malloc(bufsize); if (intern_xfv[0] == (char *)NULL) { free(intern_xfv); if (ifnc > 0) { free(intern_ifv[0]); free(intern_ifv); } FreeDllMem(__G); return PK_BADERR; } for (f_cnt = 0; ; f_cnt++) { ISO_TO_INTERN(xfnv[f_cnt], intern_xfv[f_cnt]); if ((f_cnt+1) >= xfnc) break; intern_xfv[f_cnt+1] = intern_xfv[f_cnt] + (strlen(intern_xfv[f_cnt]) + 1); } intern_xfv[xfnc] = (char *)NULL; G.pxnames = intern_xfv;#endif /* ?CRTL_CP_IS_ISO */ }/*--------------------------------------------------------------------------- Okey dokey, we have everything we need to get started. Let's roll. ---------------------------------------------------------------------------*/retcode = setjmp(dll_error_return);if (retcode) {#ifndef CRTL_CP_IS_ISO if (xfnc > 0) { free(intern_xfv[0]); free(intern_xfv); } if (ifnc > 0) { free(intern_ifv[0]); free(intern_ifv); }#endif FreeDllMem(__G); return PK_BADERR; }retcode = process_zipfiles(__G);#ifndef CRTL_CP_IS_ISOif (xfnc > 0) { free(intern_xfv[0]); free(intern_xfv); }if (ifnc > 0) { free(intern_ifv[0]); free(intern_ifv); }#endifFreeDllMem(__G);return retcode;}int win_fprintf(zvoid *pG, FILE *file, unsigned int size, char far *buffer){if ((file != stderr) && (file != stdout)) { return write(fileno(file),(char far *)(buffer),size); }if (!fNoPrinting) return G.lpUserFunctions->print((LPSTR)buffer, size);return (int)size;}/********************************** * Function DllMessagePrint() * * * * Send messages to status window * **********************************/#ifdef __BORLANDC__#pragma argsused#endifstatic int UZ_EXP DllMessagePrint(pG, buf, size, flag) zvoid *pG; /* globals struct: always passed */ uch *buf; /* preformatted string to be printed */ ulg size; /* length of string (may include nulls) */ int flag; /* flag bits */{if (!fNoPrinting) return G.lpUserFunctions->print((LPSTR)buf, size);else return (int)size;}#if 0 /* currently unused *//******************************** * Function DllDisplayPrint() * * * * Send files to display window * ********************************/#ifdef __BORLANDC__#pragma argsused#endifint DllDisplayPrint(pG, buf, size, flag) zvoid *pG; /* globals struct: always passed */ uch *buf; /* preformatted string to be printed */ ulg size; /* length of string (may include nulls) */ int flag; /* flag bits */{return (!fNoPrinting ? G.lpUserFunctions->print((LPSTR)buf, size) : (int)size);}#endif /* never *//********************************** * Function UzpPassword() * * * * Prompt for decryption password * **********************************/#ifdef __BORLANDC__#pragma argsused#endifint UZ_EXP UzpPassword(pG, rcnt, pwbuf, size, zfn, efn) zvoid *pG; /* globals struct: always passed */ int *rcnt; /* retry counter */ char *pwbuf; /* buffer for password */ int size; /* size of password buffer */ ZCONST char *zfn; /* name of zip archiv */ ZCONST char *efn; /* name of archiv entry being processed */{#if CRYPT LPSTR m; if (*rcnt == 0) { *rcnt = 2; m = "Enter password for: "; } else { (*rcnt)--; m = "Password incorrect--reenter: "; } return (*G.lpUserFunctions->password)((LPSTR)pwbuf, size, m, (LPSTR)efn);#else /* !CRYPT */ return IZ_PW_ERROR; /* internal error, function should never get called */#endif /* ?CRYPT */} /* end function UzpPassword() *//* Turn off all messages to the calling application */void WINAPI Wiz_NoPrinting(int f){fNoPrinting = f;}/* Dummy sound function for those applications that don't use sound */static void WINAPI DummySound(void){}/* Interface between WINDLL specific service callback functions and the generic DLL's "status report & user interception" callback */#ifdef __BORLANDC__#pragma argsused#endifstatic int WINAPI Wiz_StatReportCB(zvoid *pG, int fnflag, ZCONST char *zfn, ZCONST char *efn, ZCONST zvoid *details){ int rval = UZ_ST_CONTINUE; switch (fnflag) { case UZ_ST_START_EXTRACT: if (G.lpUserFunctions->sound != NULL) (*G.lpUserFunctions->sound)(); break; case UZ_ST_FINISH_MEMBER: if ((G.lpUserFunctions->ServCallBk != NULL) && (*G.lpUserFunctions->ServCallBk)(efn, *((unsigned long *)details))) rval = UZ_ST_BREAK; break; case UZ_ST_IN_PROGRESS: break; default: break; } return rval;}#ifndef SFX#ifndef __16BIT__int WINAPI Wiz_UnzipToMemory(LPSTR zip, LPSTR file, LPUSERFUNCTIONS lpUserFunctions, UzpBuffer *retstr){ int r;#ifndef CRTL_CP_IS_ISO char *intern_zip, *intern_file;#endif CONSTRUCTGLOBALS();#ifndef CRTL_CP_IS_ISO intern_zip = (char *)malloc(strlen(zip)+1); if (intern_zip == NULL) { DESTROYGLOBALS() return PK_MEM; } intern_file = (char *)malloc(strlen(file)+1); if (intern_file == NULL) { DESTROYGLOBALS() free(intern_zip); return PK_MEM; } ISO_TO_INTERN(zip, intern_zip); ISO_TO_INTERN(file, intern_file);# define zip intern_zip# define file intern_file#endif if (!Wiz_Init((zvoid *)&G, lpUserFunctions)) { DESTROYGLOBALS(); return PK_BADERR; } G.redirect_data = 1; r = (unzipToMemory(__G__ zip, file, retstr) == PK_COOL); DESTROYGLOBALS()#ifndef CRTL_CP_IS_ISO# undef file# undef zip free(intern_file); free(intern_zip);#endif if (!r && retstr->strlength) { free(retstr->strptr); retstr->strptr = NULL; } return r;}/* Purpose: Determine if file in archive contains the string szSearch Parameters: archive = archive name file = file contained in the archive. This cannot be a wild card to be meaningful pattern = string to search for cmd = 0 - case-insensitive search 1 - case-sensitve search 2 - case-insensitive, whole words only 3 - case-sensitive, whole words only SkipBin = if true, skip any files that have control characters other than CR, LF, or tab in the first 100 characters. Returns: TRUE if a match is found FALSE if no match is found -1 on error Comments: This does not pretend to be as useful as the standard Unix grep, which returns the strings associated with a particular pattern, nor does it search past the first matching occurrence of the pattern. */int WINAPI Wiz_Grep(LPSTR archive, LPSTR file, LPSTR pattern, int cmd, int SkipBin, LPUSERFUNCTIONS lpUserFunctions){ int retcode = FALSE, compare; ulg i, j, patternLen, buflen; char * sz, *p; UzpBuffer retstr; /* Turn off any windows printing functions, as they may not have been * identified yet. There is no requirement that we initialize the * dll with printing stuff for this. */ Wiz_NoPrinting(TRUE); if (!Wiz_UnzipToMemory(archive, file, lpUserFunctions, &retstr)) { Wiz_NoPrinting(FALSE); return -1; /* not enough memory, file not found, or other error */ } if (SkipBin) { if (retstr.strlength < 100) buflen = retstr.strlength; else buflen = 100; for (i = 0; i < buflen; i++) { if (iscntrl(retstr.strptr[i])) { if ((retstr.strptr[i] != 0x0A) && (retstr.strptr[i] != 0x0D) && (retstr.strptr[i] != 0x09)) { /* OK, we now think we have a binary file of some sort */ free(retstr.strptr); Wiz_NoPrinting(FALSE); return FALSE; } } } } patternLen = strlen(pattern); if (retstr.strlength < patternLen) { free(retstr.strptr); Wiz_NoPrinting(FALSE); return FALSE; } sz = malloc(patternLen + 3); /* add two in case doing whole words only */ if (cmd > 1) { strcpy(sz, " "); strcat(sz, pattern); strcat(sz, " "); } else strcpy(sz, pattern); if ((cmd == 0) || (cmd == 2)) { for (i = 0; i < strlen(sz); i++) sz[i] = toupper(sz[i]); for (i = 0; i < retstr.strlength; i++) retstr.strptr[i] = toupper(retstr.strptr[i]); } for (i = 0; i < (retstr.strlength - patternLen); i++) { p = &retstr.strptr[i]; compare = TRUE; for (j = 0; j < patternLen; j++) { /* We cannot do strncmp here, as we may be dealing with a * "binary" file, such as a word processing file, or perhaps * even a true executable of some sort. */ if (p[j] != sz[j]) { compare = FALSE; break; } } if (compare == TRUE) { retcode = TRUE; break; } } free(sz); free(retstr.strptr); Wiz_NoPrinting(FALSE); /* Turn printing back on */ return retcode;}#endif /* !__16BIT__ */int WINAPI Wiz_Validate(LPSTR archive, int AllCodes){ return UzpValidate((char *)archive, AllCodes);}#endif /* !SFX */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -