home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip540.zip / windll / windll.doc < prev    next >
Text File  |  1998-06-12  |  11KB  |  256 lines

  1. There are now several entry points to the dll.
  2.  
  3. There is a single "unzipping" entry point of:
  4.  
  5. Wiz_SingleEntryUnzip(int ifnc, char **ifnv, int xfnc, char **xfnv,
  6.                      LPDCL lpDCL, LPUSERFUNCTIONS lpUserFunc)
  7.  
  8. where the arguments are:
  9.  
  10. ifnc       = number of file names being passed. If all files are to be
  11.              extracted, then this can be zero.
  12. ifnv       = file names to be unarchived. Wildcard patterns are recognized
  13.              and expanded. If all files are to be extracted, then this can
  14.              be NULL.
  15. xfnc       = number of "file names to be excluded from processing" being
  16.              passed. If all files are to be extracted, set this to zero.
  17. xfnv       = file names to be excluded from the unarchiving process. Wildcard
  18.              characters are allowed and expanded. If all files are to be
  19.              extracted, set this argument to NULL.
  20. lpDCL      = pointer to a structure with the flags for setting the
  21.              various options, as well as the zip file name.
  22. lpUserFunc = pointer to a structure that contains pointers to functions
  23.              in the calling application, as well as sizes passed back to
  24.              the calling application etc. See below for a detailed description
  25.              of all the parameters
  26.  
  27. The DCL structure is shown below:
  28.  
  29. typedef struct {
  30. int ExtractOnlyNewer;   = true if you are to extract only newer
  31. int SpaceToUnderscore;  = true if convert space to underscore
  32. int PromptToOverwrite;  = true if prompt to overwrite is wanted
  33. int fQuiet;             = quiet flag. 1 = few messages, 2 = no messages, 0 = all messages
  34. int ncflag              = write to stdout if true
  35. int ntflag              = test zip file
  36. int nvflag              = verbose listing
  37. int nUflag              = "update" (extract only newer/new files)
  38. int nzflag              = display zip file comment
  39. int ndflag              = all args are files/dir to be extracted
  40. int noflag              = true if you are to always over-write files, false if not
  41. int naflag              = do end-of-line translation
  42. int nZIflag;            = get zip info if true
  43. int C_flag;             = be case insensitive if TRUE
  44. int fPrivilege          = 1 => restore Acl's, 2 => Use privileges
  45. LPSTR lpszZipFN         = zip file name
  46. LPSTR lpszExtractDir    = Directory to extract to. This should be NULL if you
  47.                           are extracting to the current directory.
  48. } DCL, far * LPDCL;
  49.  
  50. The typedef's for the function pointers in the structure USERFUNCTIONS
  51. are shown immediately below.
  52.  
  53. typedef unsigned short ush;
  54. typedef int (WINAPI DLLPRNT) (LPSTR, unsigned long);
  55. typedef int (WINAPI DLLPASSWORD) (LPSTR, int, LPCSTR, LPCSTR);
  56. typedef int (WINAPI DLLSERVICE) (LPSTR, unsigned long);
  57. typedef void (WINAPI DLLSND) (void);
  58. typedef int (WINAPI DLLREPLACE)(LPSTR);
  59. typedef void (WINAPI DLLMESSAGE)(unsigned long, unsigned long, unsigned,
  60.    unsigned, unsigned, unsigned, unsigned, unsigned,
  61.    char, LPSTR, LPSTR, unsigned long, char);
  62.  
  63. Structure USERFUNCTIONS
  64.  
  65. typedef struct {
  66. DLLPRNT *print;         = a pointer to the application's print routine.
  67. DLLSND *sound;          = a pointer to the application's sound routine. This
  68.                           can be NULL if your application doesn't use
  69.                           sound.
  70. DLLREPLACE *replace     = a pointer to the application's replace routine.
  71. DLLPASSWORD *password   = a pointer to the application's password routine.
  72. DLLMESSAGE *SendApplicationMessage = a pointer to the application's routine
  73.                           for displaying information about specific files
  74.                           in the archive. Used for listing the contents of
  75.                           an archive.
  76. DLLSERVICE *ServCallBk  = Callback function designed to be used for
  77.                           allowing the application to process Windows messages,
  78.                           or canceling the operation, as well as giving the
  79.                           option of a progress indicator. If this function
  80.                           returns a non-zero value, then it will terminate
  81.                           what it is doing. It provides the application with
  82.                           the name of the name of the archive member it has
  83.                           just processed, as well as it's original size.
  84. NOTE: The values below are filled in only when listing the contents of an
  85.       archive.
  86.  
  87. unsigned long TotalSizeComp = value to be filled in by the dll for the
  88.                           compressed total size of the archive. Note this
  89.                           value does not include the size of the archive
  90.                           header and central directory list.
  91. unsigned long TotalSize = value to be filled in by the dll for the total
  92.                           size of all files in the archive.
  93. int CompFactor          = value to be filled in by the dll for the overall
  94.                           compression factor. This could actually be computed
  95.                           from the other values, but it is available.
  96. unsigned int NumMembers = total number of files in the archive.
  97. WORD cchComment;        = flag to be set if archive has a comment
  98. } USERFUNCTIONS, far * LPUSERFUNCTIONS;
  99.  
  100. For examples of how the actual calls to the dll are set up in WiZ, look in
  101. the files action.c and wizmain.c in the WiZ source directory. For a trival
  102. example of how to load and call the dll, look in example.c and example.h.
  103.  
  104. For examples of how the actual loading and unloading of the dll's themselves
  105. was done, look in wizmain.c in the WiZ source directory. Note that WiZ looks
  106. specifically for a particular version number of the dll, and also expects to
  107. find the company name to be Info-ZIP. This is to protect from getting
  108. different versions of the dll loaded, with resulting unknown behavior.
  109.  
  110. Additional entry points:
  111.  
  112.     void WINAPI UzpVersion2(UzpVer far *);
  113.  
  114. where UzpVer is defined as:
  115.  
  116. typedef struct _UzpVer {
  117.     ulg structlen;          /* length of the struct being passed */
  118.     ulg flag;               /* bit 0: is_beta   bit 1: uses_zlib */
  119.     LPSTR betalevel;        /* e.g., "g BETA" or "" */
  120.     LPSTR date;             /* e.g., "4 Sep 95" (beta) or "4 September 1995" */
  121.     LPSTR zlib_version;     /* e.g., "1.0.5" or NULL */
  122.     _version_type unzip;
  123.     _version_type zipinfo;
  124.     _version_type os2dll;
  125.     _version_type windll;
  126. } UzpVer;
  127.  
  128. and _version_type is defined as:
  129.  
  130. typedef struct _ver {
  131.     uch major;              /* e.g., integer 5 */
  132.     uch minor;              /* e.g., 2 */
  133.     uch patchlevel;         /* e.g., 0 */
  134.     uch not_used;
  135. } _version_type;
  136.  
  137.    See api.c for exactly what UzpVersion2 does, but the short version of
  138.    what it does is fill in the version information in the UzpVer structure.
  139.  
  140. void WINAPI Wiz_NoPrinting(int flag)
  141.  
  142.    This entry point simply turns off all messages to the calling application if
  143.    flag is true, and turns them on if flag is false.
  144.  
  145. int WINAPI Wiz_Validate(LPSTR archive, int AllCodes)
  146.  
  147.    If AllCodes is FALSE, then Unz_Validate returns TRUE if archive points to a
  148.    valid archive, and FALSE otherwise. If AllCodes is TRUE, then Unz_Validate
  149.    returns whatever error code process_zipfiles returns, without evaluating it.
  150.  
  151. int WINAPI Wiz_UnzipToMemory(LPSTR zip, LPSTR file, LPUSERFUNCTIONS lpUserFunc,
  152.                              UzpBuffer *retstr)
  153.  
  154.    Where UzpBuffer is defined as:
  155.  
  156.    typedef struct _UzpBuffer {
  157.       ulg strlength; /* length of string */
  158.       char * strptr; /* pointer to string */
  159.    } UzpBuffer
  160.  
  161.    Pass the name of the zip file in zip and the name of the file you wish to
  162.    extract in file. UzpUnzipToMemory will create a buffer and return it in
  163.    *retstr. 0 on return indicates failure.
  164.  
  165. int WINAPI Wiz_Grep(LPSTR archive, LPSTR file, LPSTR pattern, int cmd,
  166.                     int SkipBin, LPUSERFUNCTIONS lpUserFunc)
  167.  
  168.    Pass the name of the zip file in "zip", the name of the zip entry you wish
  169.    to perform the "grep" on in "file", and the string you wish to look for in
  170.    "pattern". There are four possible options for code:
  171.  
  172.    0 => case insensitive search
  173.    1 => case sensitive search
  174.    2 => case insensitive search, whole words only
  175.    3 => case sensitive search, whole words only
  176.  
  177.    If SkipBin is TRUE, then any binary (loosely interpreted) files will be
  178.    ignored.
  179.  
  180.    lpUserFunc is a pointer to a USERFUNCTION structure as shown above.
  181.  
  182.    UzpGrep returns:
  183.  
  184.    -1 => error such as unable to allocate memory, unable to find file, etc.
  185.     0 => match not found, based on the search criteria
  186.     1 => match found, based on the search criteria
  187.  
  188. There is an additional function call that does not specifically deal with
  189. "unzipping", but is a quite useful function that is currently used in Wiz
  190. itself in several places. This call is currently only available in the
  191. static library, not in the DLL.
  192.  
  193. Match the pattern (wildcard) against the string (fixed):
  194.  
  195.   match(string, pattern, ignore_case);
  196.  
  197.   returns TRUE if string matches pattern, FALSE otherwise.  In the pattern:
  198.  
  199.      `*' matches any sequence of characters (zero or more)
  200.      `?' matches any single character
  201.      [SET] matches any character in the specified set,
  202.      [!SET] or [^SET] matches any character not in the specified set.
  203.  
  204.   A set is composed of characters or ranges; a range looks like ``character
  205.   hyphen character'' (as in 0-9 or A-Z).  [0-9a-zA-Z_] is the minimal set of
  206.   characters allowed in the [..] pattern construct.  Other characters are
  207.   allowed (i.e., 8-bit characters) if your system will support them.
  208.  
  209.   To suppress the special syntactic significance of any of ``[]*?!^-\'', in-
  210.   side or outside a [..] construct, and match the character exactly, precede
  211.   it with a ``\'' (backslash).
  212.  
  213. The remaining functions are linked together. Their use would be as
  214. follows (explanations for each function are shown further below):
  215.  
  216.     #include "windll.h"
  217.     #include "structs.h"
  218.     MyApiCallingRoutine()
  219.     {
  220.         CREATEGLOBALS();
  221.         .
  222.         .
  223.         .
  224.         Wiz_Init(pG, lpUserFunctions); /* Set up user functions */
  225.         /* zvoid *pG, LPUSERFUNCTIONS lpUserFunctions */
  226.         .
  227.         .
  228.         .
  229.         Wiz_SetOpts(pG, C); /* Set up unzipping options */
  230.         /* zvoid *pG, LPDCL C */
  231.         .
  232.         .
  233.         .
  234.         Wiz_Unzip(pG, ifnc, ifnv, xfnc, xfnv); /* Unzip files */
  235.         .
  236.         .
  237.         .
  238.         DESTROYGLOBALS();
  239.     }
  240.  
  241. Each entry point is as defined below:
  242.  
  243.     BOOL WINAPI Wiz_Init(zvoid *, LPUSERFUNCTIONS);
  244.  
  245.     BOOL WINAPI Wiz_SetOpts(zvoid *, LPDCL);
  246.  
  247.     int WINAPI Wiz_Unzip(zvoid *, int, char **, int, char **);
  248.  
  249. Note that you should use either windll_unzip OR the series of calls
  250. described above. Using both, depending on how you do it, could cause
  251. problems.
  252.  
  253. Last revised June 13, 1998.
  254.  
  255. Mike White
  256.