home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip52.zip / wizdll / wizunz.c < prev    next >
C/C++ Source or Header  |  1996-04-29  |  6KB  |  193 lines

  1. /* Windows Info-ZIP UnZip DLL module
  2.  *
  3.  * Author: Mike White
  4.  *
  5.  * Original: 1996
  6.  *
  7.  * This module has essentially the entry point for "unzipping" a zip file. It
  8.  * also contains "fake" calls for the sound and printing functions in WizUnZip,
  9.  * which are simply passed on to the application calling the dll.
  10.  */
  11.  
  12. /*
  13.  
  14. A pointer to this structure is passed to the DLL when it is called.
  15.  
  16. typedef int (far *DLLPRNT) (FILE *, unsigned int, char *);
  17. typedef void (far *DLLSND) (void);
  18.  
  19. typedef struct {
  20. DLLPRNT print;          = a pointer to the application's print routine.
  21. DLLSND sound;           = a pointer to the application's sound routine.
  22. FILE *Stdout;           = stdout for the calling application
  23. LPUMB lpUMB;            = stucture shown below
  24. HWND hWndList;          = application's handle for a list box to display
  25.                           the contents of an archive in
  26. HWND hWndMain;          = application's main window
  27. HWND hInst;             = application's instance
  28. int ExtractOnlyNewer;   = true if you are to extract only newer
  29. int Overwrite;          = true if always overwrite files
  30. int SpaceToUnderscore;  = true if convert space to underscore
  31. int PromptToOverwrite;  = true if prompt to overwrite is wanted
  32. int ncflag              = write to stdout if true
  33. int ntflag              = test zip file
  34. int nvflag              = verbose listing
  35. int nUflag              = "update" (extract only newer/new files
  36. int nzflag              = display zip file comment
  37. int ndflag              = all args are files/dir to be extracted
  38. int noflag              =
  39. int naflag              = do ASCII-EBCDIC and/or end of line translation
  40. int argc                =
  41. LPSTR lpszZipFN         = zip file name
  42. char **FNV              = file name vector to list of files to extract
  43. } DCL, _far *LPDCL;
  44.  
  45. LPUMB structure referred to above:
  46. typedef struct
  47. {
  48. char szFileName[WIZUNZIP_MAX_PATH]; = fully-qualified archive file name
  49.                                       in OEM char set
  50. char szDirName[WIZUNZIP_MAX_PATH];  = directory of archive file in ANSI char set
  51. char szUnzipToDirName[WIZUNZIP_MAX_PATH];    = extraction ("unzip to") directory
  52.                                                name in ANSI
  53. char szUnzipToDirNameTmp[WIZUNZIP_MAX_PATH]; = temp extraction ("unzip to")
  54.                                                directory name in ANSI
  55. char szUnzipFromDirName[WIZUNZIP_MAX_PATH];  = extraction ("unzip from")
  56.                                                directory name in ANSI
  57. char szTotalsLine[80];              = text for totals of zip archive
  58. char szBuffer[OPTIONS_BUFFER_LEN];  = option strings from .INI, & general
  59.                                       scratch buf
  60. char szSoundName[WIZUNZIP_MAX_PATH];= wave file name or sound from .INI file
  61. char szPassword[81];                = password for encrypted files
  62. LPSTR lpPassword;                   = pointer to szPassword. This is passed
  63.                                       only to allow common usage between the
  64.                                       DLL and WizUnZip as a stand-alone
  65.                                       application. It is not used
  66. OPENFILENAME ofn;                   = archive open file name structure
  67. OPENFILENAME wofn;                  = wave open file name struct
  68. MSG msg;                            =
  69. OFSTRUCT of;                        = archive open file struct
  70. OFSTRUCT wof;                       = wave open file struct
  71. } UMB, __far *LPUMB;
  72. */
  73.  
  74. #define UNZIP_INTERNAL
  75. #include <windows.h>
  76. #include "unzip.h"
  77. #include "version.h"
  78. #include "wingui\wizunzip.h"
  79. #include "wizdll\wizdll.h"
  80.  
  81. LPUMB lpumb;
  82.  
  83. DLLPRNT lpPrint;
  84. DLLSND lpSound;
  85.  
  86. FILE *orig_stdout;
  87.  
  88. /*  DLL Entry Point */
  89.  
  90. #ifdef __BORLANDC__
  91. #pragma warn -par
  92. #endif
  93. #if defined WIN32
  94. BOOL WINAPI DllEntryPoint( HINSTANCE hinstDll,
  95.                            DWORD fdwRreason,
  96.                            LPVOID plvReserved)
  97. #else
  98. int FAR PASCAL LibMain( HINSTANCE hInstance,
  99.                         WORD wDataSegment,
  100.                         WORD wHeapSize,
  101.                         LPSTR lpszCmdLine )
  102. #endif
  103. {
  104. #ifndef WIN32
  105. /* The startup code for the DLL initializes the local heap(if there is one)
  106.  * with a call to LocalInit which locks the data segment.
  107.  */
  108.  
  109. if ( wHeapSize != 0 )
  110.    {
  111.    UnlockData( 0 );
  112.    }
  113. #endif
  114. return 1;   /* Indicate that the DLL was initialized successfully. */
  115. }
  116.  
  117. int FAR PASCAL WEP ( int bSystemExit )
  118. {
  119. return 1;
  120. }
  121. #ifdef __BORLANDC__
  122. #pragma warn .par
  123. #endif
  124.  
  125. /* DLL calls */
  126.  
  127. WINAPI DllProcessZipFiles(DCL far*C)
  128. {
  129. int retcode;
  130. if (C->lpszZipFN == NULL) /* Something has screwed up, we don't have a filename */
  131.     return PK_NOZIP;
  132.  
  133. CONSTRUCTGLOBALS();
  134.  
  135. lpDCL = C;
  136. lpumb = C->lpUMB;
  137. lpPrint = C->print;
  138. lpSound = C->sound;
  139. hWndList = C->hWndList;
  140. hWndMain = C->hWndMain;
  141. hInst = C->hInst;
  142. orig_stdout = C->Stdout;
  143.  
  144. G.key = (char *)NULL;
  145.  
  146. FSetUpToProcessZipFile(C);
  147. retcode = process_zipfiles(__G);
  148. TakeDownFromProcessZipFile();
  149.  
  150. DESTROYGLOBALS();
  151. return retcode;
  152. }
  153.  
  154. WINAPI GetDllVersion(DWORD far *dwVersion)
  155. {
  156. *dwVersion = MAKELONG(DLL_MINOR, DLL_MAJOR);
  157. return;
  158. }
  159.  
  160. void SoundDuring(void)
  161. {
  162. #ifdef __BORLANDC__
  163. #pragma warn -pro
  164. #endif
  165. lpSound();
  166. #ifdef __BORLANDC__
  167. #pragma warn .pro
  168. #endif
  169. }
  170. int win_fprintf(FILE *file, unsigned int size, char *buffer)
  171. {
  172. if ((file == stderr) || (file == stdout))
  173.    {
  174.    file = orig_stdout;
  175. #ifdef __BORLANDC__
  176. #pragma warn -pro
  177. #endif
  178.    /* If this is a message of any sort, or "unzip" to stdout, then it needs
  179.     * to be sent to the calling application for processing.
  180.     */
  181.    return lpPrint(file, size, buffer);
  182. #ifdef __BORLANDC__
  183. #pragma warn .pro
  184. #endif
  185.    }
  186. else
  187.    {
  188.    write(fileno(file),(char *)(buffer),size);
  189.    return size;
  190.    }
  191. }
  192.  
  193.