Announcement

Collapse
No announcement yet.

PKWARE Implode/Explode

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PKWARE Implode/Explode

    Anyone ever do much with these? I have an old DOS C/C++ App I need to edit some of its data files on and it appears to use the implode/explode library. It seams that it extracts pieces of one file to memory then explodes them in memory to work with. I need some way of reading in a portion of the file, exploding it, editing some values, then implode it and write it back out to the original file. I'm not finding too much on it other than on the zlib project it appears someone cracked only the explode side, but that won't really help me.

    The previous developers appeared to have a license for the DOS library, so not sure what PKWARE can assist on that. I emailed them asking what options I have...they will probably want me to invest in the $2000 package they have now that may not even work the same way as the old DOS compression. Anyone know of any API/DLL packages out there or maybe a couple exe files that can implode/explode and I can just write to file then read it and put it back in the original file when done or something....
    sigpic
    Mobile Solutions
    Sys Analyst and Development

    #2
    PKWARE Stuff

    I seem to remember some Delphi libraries that would work.

    I don't know if I still have them (would be on a backup CD somewhere).

    I seem to remeber a place called Delphi Superpages (still there at http://delphi.icm.edu.pl/) where you may find something.
    John,
    --------------------------------
    John Strasser
    Phone: 480 - 273 - 8798

    Comment


      #3
      For PB/DOS, I did a whole "unzip" package file by file which called (SHELLed) the (freeware) command-line PKUNIZIP.EXE program to do it.

      You have to read the file header of the ZIP file to get a list of the files contained in the ZIP archive, but once you have that you can unizip any single file you want.

      What I did was present that list of files on the screen, then you selected one (at a time), and then I unzipped that file (to a temp file?) and then viewed its contents on the screen. All in all it was a pretty cool application*.

      I would think you could shell pkzip.exe (if present) to replace the fles in the archive. (I know I never did this).

      If I have to I can probably find the PB/DOS code for getting the list of files in the archive if you think that would help.

      MCM
      *OK, "for its time" it was a pretty cool application. This must go back to the '93, '94 timeframe.
      Last edited by Michael Mattias; 5 Feb 2008, 05:43 PM.
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


        #4
        PKUNIZP? Freeware?

        I'm not aware of any PKZIP/PKUNZIP version that were freeware. All were shareware:

        PKUNZIP (R) FAST! Extract Utility Version 2.04g 02-01-93
        Copr. 1989-1993 PKWARE Inc. All Rights Reserved. Shareware Version
        PKUNZIP Reg. U.S. Pat. and Tm. Off.

        Comment


          #5
          There was a FREEWARE "unzip" utility not from PKWare. (No doubt still installed on my MS-DOS machine, which still works BTW. It's never seen a 32-bit O/S...MS-DOS 6.22 + Windows 3.11 which runs on top of that. I also have VB3 (Pro) installed on that box, in case I ever get that urge again).

          I never found a freeware "zip" utility, so I paid my ten or twenty bucks to PKware.

          PKWare Inc [was? is?] a hometown company, headquartered in Brown Deer WI, a Milwaukee suburb; so in addition to being scrupulously honest I figured I was helping the locals by registering.

          As for 'modern' times... I KNOW "WinZip" has an extra cost command-line add-on option, because they are constantly email-marketing me to buy it.

          I'm just suggesting there is more than one way to skin a cat... you don't need to work with the PKWare API/Libraries to "extract file, do something with it, put it back."

          This thread is a good example of why questions should always be asked with the "what" and not simply request assistance with a predetermined "how."

          [ADDENDUM]
          Ooh, I am remembering more and more of this... the "unzip" utility had a "list files" command-line option of some kind, which sends that list to STDOUT. I redirected that to a file, and parsed it to get my file list. Then you could SHELL to the utility specifying the name of the file to unzip... unless I'm mistaken, I also specified unzipping that to a file-redirected STDOUT and voila my file now contained the un-archived contents of the file... no risk of overwriting the real file, or having the 'path' stored in the archive put that file somewhere you couldn't find it.
          [/ADDENDUM]


          MCM
          Last edited by Michael Mattias; 6 Feb 2008, 09:22 AM.
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


            #6
            I don't know if this will help, but Info-zip has free ZIP/UNZIP utilities for DOS and/or Windows (and other OSes) at www.zlib.net.

            I've been shelling to their ZIP utility for years and it works very well (for my purposes, at least).

            Jerry

            Comment


              #7
              This isn't a "Zip" format. If it were zip I could do it. It is their Implode/Explode functions. Implode source never has been released/cracked...from what I can tell, and explode has been somewhat cracked and available. One side won't help me though.
              sigpic
              Mobile Solutions
              Sys Analyst and Development

              Comment


                #8
                So use "genuine" WinZip with command-line option?

                I have done jobs for clients where I specified they had to license and install "something" and I never had a bad experience doing that.

                Sure, I had to buy a license myself for whatever it was, but that's the cost of doing business.

                In this case, if they want you to handle "PKZIP Proprietary format" then you should encounter precisely zero resistance. (It can't be more than $100/user.. and I would guess your fee for actually 'doing something' with that data will dwarf that).

                Or, work with the API/Libraries, engaging a professional to get you started on it if necessary.

                MCM
                Last edited by Michael Mattias; 7 Feb 2008, 09:15 AM.
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                  #9
                  There is/was also a 32-bit console edition available from PKWare, the executable of version 2.5 was called pkzip25.exe (both zip and unzip in one exe).

                  BTW, PKWare seems to offer a free unzipper now as well: http://www.pkware.com/index.php?opti...=59&Itemid=103

                  Comment


                    #10
                    I probably should have put this in the DOS forum...everyone is still stuck in the Zip loop. These functions are not Zip, so Zip cannot be used. That includes WinZip, PKzip, WinRAR, etc.
                    sigpic
                    Mobile Solutions
                    Sys Analyst and Development

                    Comment


                      #11
                      DCL Implode comment removed....
                      Last edited by Roy Cline; 16 Feb 2008, 07:49 AM.
                      Roy Cline

                      Comment


                        #12
                        Maybe I can help clarify.

                        To get better help be more specific.
                        If I'm reading you correctly your looking for info on this:
                        "PKWARE Data Compression Library"

                        Google this "PKWARE DCL-compatible compressor and decompressor"
                        and you get a page with some C code that might help if you read C.
                        Or perhapse a PB guru could translate it into PB functions.

                        Google "PKWDCL.DLL" and you will find it and examples in several languages.



                        W.B. - long time listener, first time poster

                        Comment


                          #13
                          Or perhapse a PB guru could translate it into PB functions.
                          ..
                          Google "PKWDCL.DLL" and you will find it and examples in several languages
                          If it's available as a standard DLL there's no reason to convert it to PB, which can natively use functions in any standard DLL. Just create a DECLARE for it and you're in business.

                          MCM
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                            #14
                            The problem here might not be the PB Declare, but the licensing issue. From what I've read, it appears that this DLL is part of the kit that PKWare sells.

                            Comment


                              #15
                              Originally posted by Knuth Konrad View Post
                              The problem here might not be the PB Declare, but the licensing issue. From what I've read, it appears that this DLL is part of the kit that PKWare sells.
                              I came to the same conclusion. $400 might be a bit steep!

                              James

                              Comment


                                #16
                                Actually they are trying to sell it for $1000+ to me, and if used on handhelds, etc a license for each of them that is probably your $400 level. I got them to send me a 30 day version, but nothing in BASIC, only C++...anyone good at converting?

                                Code:
                                //------------------------------------------------------------------------------
                                // pkcdl.h - Header for this library.
                                // PKCDL: $Revision: 23 $   $Modtime: 12/08/03 4:15p $
                                // Copyright 1998-2003 By PKWARE Inc. All Rights Reserved.
                                //------------------------------------------------------------------------------
                                #if !defined ( __PKCDL_H )
                                #define        __PKCDL_H
                                #ifdef __cplusplus
                                   extern "C" {
                                #else
                                      /* #define const */
                                #endif
                                /**
                                 * @file  pkcdl.h
                                 *
                                 * Public header for PKWARE call back data compression functions
                                 */
                                #if !defined (PKCALLBACK)
                                # ifdef _UNIX
                                #  define PKCALLBACK
                                # else
                                #  define  PKCALLBACK __cdecl
                                # endif
                                #endif
                                #if !defined (PKCALL)
                                # ifdef _UNIX
                                #  define PKCALL
                                # else
                                #  define PKCALL __cdecl
                                # endif
                                #endif
                                #if !defined (PKCDL_DECL)
                                # ifdef PKCDLDLL
                                #  define PKCDL_DECL __declspec(dllexport)
                                # else
                                #  define PKCDL_DECL
                                # endif
                                #endif
                                /**
                                 * Read buffer call back function definition.
                                 *
                                 * @param  buf  Pointer the buffer to fill with data
                                 * @param  size  The amount of data to read
                                 * @param  param  User specified call back pointer.
                                 *
                                 * @return  The actual amount of data read, must be less than or equal to
                                 *   size.
                                 */
                                typedef  unsigned int (PKCALLBACK *PKReadBuf)(void*         buf,
                                                                              unsigned int  size,
                                                                              void*         param);
                                /**
                                 * Write buffer call back function definition.
                                 *
                                 * @param  buf  Pointer to the buffer containing the data to write
                                 * @param  size  The size of the buffer
                                 * @param  param  User specified call back pointer.
                                 */
                                typedef  void (PKCALLBACK *PKWriteBuf)(const void*    buf,
                                                                       unsigned int   size,
                                                                       void*          param);
                                /**
                                 * Memory allocation call back function definition.
                                 *
                                 * @param  size  The size of the buffer to allocate
                                 * @param  param  User specified call back pointer.
                                 *
                                 * @return  A pointer to the allocated memory block or NULL if the allocation
                                 *   failed.
                                 */
                                typedef  void* (PKCALLBACK *PKAlloc)(unsigned int size, void* param);
                                /**
                                 * Memory free call back function definition.
                                 *
                                 * @param  pointer  The pointer to release
                                 * @param  param  User specified call back pointer
                                 */
                                typedef  void (PKCALLBACK *PKFree)(void* pointer, void* param);
                                /* encrypt/decrypt */
                                #define CRYPT_BUFFER_SIZE  3
                                /* FLAGS */
                                /** \defgroup Buffer_Type_Values Buffer Type Values
                                 * Defines for getting buffer sizes
                                @{
                                */
                                /** \defgroup Type_Values Type Values
                                @{
                                **/
                                /** Compression */
                                #define PKCMP 0x0000
                                /** Extraction */
                                #define PKEXT 0x8000
                                /** @}
                                */
                                /** \defgroup Algorithm_Values Algorithm Values
                                 * These values correspond to the compression method values as
                                 * stored in a ZIP file. 
                                @{
                                */
                                /** Shrunk */
                                #define SHRUNK       0x0001
                                /** Implode */
                                #define IMPLODE      0x0006
                                /** Deflate */
                                #define DEFLATE      0x0008
                                /** Defalte64 */
                                #define DEFLATE64    0x0009
                                /** DCLImplode */
                                #define DCLIMPLODE   0x000a
                                /** BZIP2 (Unavailable) */
                                #define BZIP2_METHOD 0x000c
                                /** @}
                                */
                                /** @}
                                */
                                /** \defgroup  Data_Type_Values Data Type Values
                                @{
                                */
                                /** Binary */
                                #define CMP_BINARY      0
                                /** ASCII */
                                #define CMP_ASCII       1
                                /** @}
                                */
                                /** \defgroup  Dictionary_Sizes Dictionary Sizes
                                 * Dicitonary Sizes for implode
                                @{
                                */
                                /** Dictionary size of 1024 */
                                #define CMP_IMPLODE_DICT_SIZE1   1024
                                /** Dictionary size of 2048 */
                                #define CMP_IMPLODE_DICT_SIZE2   2048
                                /** Dictionary size of 4096 */
                                #define CMP_IMPLODE_DICT_SIZE3   4096
                                /** @}
                                */
                                /* deflate level */
                                /** Compression level 1 (Super Fast) */
                                #define CMP_DEFLATE_MIN_LEVEL    1 
                                /** Compression Level 9 (Extra) */
                                #define CMP_DEFLATE_MAX_LEVEL    9
                                /** pkzip204g compatibility flag for deflate/inflate */
                                #define CMP_204            1
                                /** \defgroup pkexpl_Dictionary_Sizes pkexpl Dictionary Sizes
                                 * mode and dictionary sizes for pkexpl()
                                @{
                                */
                                /** A 4K sliding dictionary was used */ 
                                #define SD_4K              0
                                /** An 8K sliding dictionary was used */
                                #define SD_8K              2
                                /** 2 Shannon-Fano trees were used to encode the sliding dictionary output */
                                #define SF_2               0
                                /** 3 Shannon-Fano trees were used to encode the sliding dictionary output */
                                #define SF_3               4
                                /** @}
                                */
                                 
                                /** \defgroup  ERROR_CODES Error Codes
                                @{
                                */
                                /** No Error */
                                #define CMP_NO_ERROR          0
                                /** Invalid Dictionary Size */
                                #define CMP_INVALID_DICTSIZE  1
                                /** Invalid dictionary size for DCL Implode functions. 
                                    If this error is encountered during extraction, the data is corrupt, 
                                    or we are not correctly positioned at the beginning of the data*/
                                #define CMP_INVALID_MODE      2
                                /** Reported only during extraction if compressed data appears to be corrupt.*/
                                #define CMP_BAD_DATA          3
                                /** Operation aborted by user. Does not always indicate error condition.
                                    Check total processed sise and crc32 to determine if operation was
                                    really interrupted.*/
                                #define CMP_ABORT             4
                                /** Reported only during extraction if compressed data is appears to be corrupt.*/
                                #define CMP_BAD_TABLE      5
                                /** Reported only during extraction if compressed data is appears to be corrupt.*/
                                #define CMP_BAD_BLOCKTYPE  6
                                /** End of compressed data. This is equivalent of EOF situation. */
                                #define CMP_END_CMP        7
                                /** @}
                                */
                                /* FUNCTIONS */
                                /* HELPER Functions */
                                /**
                                 * Get the size of the buffer needed for the DCL function proposed by the
                                 * type parameter.
                                 *
                                 * @param  uType  Type of function to determine a buffer size for.  Algorithm value 
                                 *   should be combined with compression or extraction 
                                 *   value (PKCMP or PKEXT) using the OR (|) function.
                                 *
                                 * @return  Returns the size required for the buffer.
                                 *
                                 * @see Buffer_Type_Values for possible values for the uType parameter.
                                 */
                                PKCDL_DECL unsigned long PKCALL pkGetBufferSize(unsigned long uType);
                                /**
                                 * Calculate the CRC value for the data buffer.
                                 *
                                 * @param  buffer  The buffer of data to calculate the CRC value for.
                                 *
                                 * @param  size  The size of the buffer of data.
                                 *
                                 * @param  old_crc  The previous CRC value from subsequent calculations.
                                 *
                                 * @return  Returns the new CRC value.
                                 */
                                PKCDL_DECL unsigned long PKCALL pkcrc32(const void*     buffer,
                                                                        unsigned long   size,
                                                                        unsigned long   old_crc);
                                /**
                                 * Calculate the CRC value for a single character.
                                 *
                                 * @param  ch  The character to calculate the CRC value for.
                                 *
                                 * @param  old_crc  The previous CRC value from subsequent calculations.
                                 *
                                 * @return  Returns the new CRC value.
                                 */
                                PKCDL_DECL unsigned long PKCALL pkcrc32ch(unsigned char ch, unsigned long old_crc);
                                 
                                /* COMPRESSION & DECOMPRESSION routines */
                                /**
                                 * Function to compress data using the DCL implode algorithm.
                                 *
                                 * @param  read_buf  Pointer to read buffer function.
                                 *
                                 * @param  write_buf  Pointer to the write buffer function.
                                 *
                                 * @param  work_buf  Pointer to the working buffer.
                                 *
                                 * @param  param  Pointer to the parameter to be passed to the read and 
                                 *    write buffer functions.
                                 *
                                 * @param  type  The data type (ASCII or binary) of the data to be compressed.
                                 *
                                 * @param  dsize  Dictionary size.
                                 *
                                 * @return  Returns the error code for the function.
                                 *
                                 * @see Data_Type_Values for possible values for the type parameter
                                 * @see Dictionary_Size for possible values for dsize
                                 * @see ERROR_CODES for possible return values
                                 *
                                 */
                                PKCDL_DECL unsigned int PKCALL pkimplode(PKReadBuf      read_buf,
                                                                         PKWriteBuf     write_buf,
                                                                         void*          work_buf,
                                                                         void*          param,
                                                                         unsigned int   type,
                                                                         unsigned int   dsize);
                                /**
                                 * Function to decompress data using the DCL implode algorithm.
                                 *
                                 * @param  read_buf  Pointer to read buffer function.
                                 *
                                 * @param  write_buf  Pointer to the write buffer function.
                                 *
                                 * @param  work_buf  Pointer to the working buffer.
                                 *
                                 * @return  Returns the error code for the function.
                                 *
                                 * @see ERROR_CODES for possible return values
                                 *
                                 */
                                PKCDL_DECL unsigned int PKCALL pkexplode(PKReadBuf   read_buf,
                                                                         PKWriteBuf  write_buf,
                                                                         void*       work_buf,
                                                                         void*       param);
                                /**
                                 * Function to reset the DCL implode algorithm.
                                 *
                                 * @param  write_buf  Pointer to the write buffer function.
                                 *
                                 * @param  work_buf  Pointer to the working buffer.
                                 *
                                 * @param  param  Pointer to parameter to be passed to the read and 
                                 *    write buffer functions.
                                 *
                                 * @param  type  The data type (ASCII or binary) of the data to be compressed.
                                 *
                                 * @param  dsize  Dictionary size.
                                 *
                                 * @return  Returns the error code for the function.
                                 *
                                 * @see Data_Type_Values for possible values for the type parameter
                                 * @see Dictionary_Size for possible values for the dsize parameter
                                 * @see ERROR_CODES for possible return values
                                 *
                                 */
                                PKCDL_DECL unsigned int PKCALL pkimplode_reset(PKWriteBuf  write_buf,
                                                                               void*       work_buf,
                                                                               void*       param,
                                                                               unsigned    int type,
                                                                               unsigned    int dsize);
                                /**
                                 * Writes additional data to be compressed using the DCL Implode method
                                 *
                                 * @param  work_buf  Pointer to the working buffer.
                                 * @param  data  Pointer to the data to be compressed
                                 * @param  size  The size of the data to be compressed
                                 *
                                 * @return  Returns the error code for the function.
                                 *
                                 * @see ERROR_CODES for possible return values
                                 *
                                 */
                                PKCDL_DECL unsigned int PKCALL pkimplode_write(void*          work_buf,
                                                                               const void*    data,
                                                                               unsigned int   size);
                                /**
                                 * Finishes the DCL Implode compression operation and flushes any remaining data
                                 * in the compression buffer.
                                 *
                                 * @return  Returns the error code for the function.
                                 *
                                 * @see ERROR_CODES for possible return values
                                 *
                                 */
                                PKCDL_DECL unsigned int PKCALL pkimplode_flush(void* work_buf);
                                 
                                /**
                                 * Function to compress data using the Deflate or Deflate64 algorithms
                                 *
                                 * @param  read_buf  Pointer to read buffer function.
                                 *
                                 * @param  write_buf  Pointer to the write buffer function.
                                 *
                                 * @param  work_buf  Pointer to the working buffer.
                                 *
                                 * @param  param  Pointer to parameter to be passed to the read and 
                                 *    write buffer functions.
                                 *
                                 * @param  level  Level of compression: 1 to 9.
                                 *
                                 * @param  f204  2.04g compatible flag, make false for Deflate64.
                                 *
                                 * @return  Returns the error code for the function.
                                 *
                                 * @see ERROR_CODES for possible return values
                                 *
                                 */
                                PKCDL_DECL unsigned int PKCALL pkdeflate(PKReadBuf      read_buf,
                                                                         PKWriteBuf     write_buf,
                                                                         void*          work_buf,
                                                                         void*          param,
                                                                         unsigned int   level,
                                                                         unsigned int   f204);
                                /**
                                 * Function to reset the Deflate or Deflate64 algorithm to begin 
                                 * compressing data.
                                 *
                                 * @param  write_buf  Pointer to the write buffer function.
                                 *
                                 * @param  work_buf  Pointer to the working buffer.
                                 *
                                 * @param  param  Pointer to parameter to be passed to the read and 
                                 *    write buffer functions.
                                 *
                                 * @param  level  Level of compression: 1 to 9.
                                 *
                                 * @param  f204  2.04g compatible flag.  Make false (0) for deflate64.
                                 *
                                 * @return  Returns the error code for the function.
                                 *
                                 * @see ERROR_CODES for possible return values
                                 *
                                 */
                                PKCDL_DECL unsigned int PKCALL pkdeflate_reset(PKWriteBuf     write_buf,
                                                                               void*          work_buf,
                                                                               void*          param,
                                                                               unsigned int   level,
                                                                               unsigned int   f204);
                                PKCDL_DECL unsigned int PKCALL pkdeflate_write(void*          work_buf,
                                                                               const void*    data,
                                                                               unsigned int   size);
                                PKCDL_DECL unsigned int PKCALL pkdeflate_flush(void* work_buf);
                                /**
                                 * Function to decompress data using the Deflate or Deflate64 algorithm.
                                 *
                                 * @param  read_buf  Pointer to read buffer function.
                                 *
                                 * @param  write_buf  Pointer to the write buffer function.
                                 *
                                 * @param  work_buf  Pointer to the working buffer.
                                 *
                                 * @param  param  Pointer to parameter to be passed to the read and 
                                 *    write buffer functions.
                                 *
                                 * @param  f204  2.04g compatible flag.  Make false (0) for deflate64.
                                 *
                                 * @return  Returns the error code for the function.
                                 *
                                 * @see ERROR_CODES for possible return values
                                 *
                                 */
                                PKCDL_DECL unsigned int PKCALL pkinflate(PKReadBuf      read_buf,
                                                                         PKWriteBuf     write_buf,
                                                                         void*          work_buf,
                                                                         void*          param,
                                                                         unsigned int   f204);
                                /**
                                 * Function to decompress data using the implode algorithm.
                                 *
                                 * @param  read_buf  Pointer to read buffer function.
                                 *
                                 * @param  write_buf  Pointer to the write buffer function.
                                 *
                                 * @param  work_buf  Pointer to the working buffer.
                                 *
                                 * @param  param  Pointer to parameter to be passed to the read and 
                                 *    write buffer functions.
                                 *
                                 * @param  mode  The dictionary size that was originally used to 
                                 *  compress the data.
                                 *
                                 * @return  Returns the error code for the function.
                                 *
                                 * @see pkexpl_Dictionary_Size for possible values for the mode parameter
                                 * @see ERROR_CODES for possible return values
                                 * 
                                 *
                                 */
                                PKCDL_DECL unsigned int PKCALL pkexpl(PKReadBuf      read_buf,
                                                                      PKWriteBuf     write_buf,
                                                                      void*          work_buf,
                                                                      void*          param,
                                                                      unsigned int   mode);
                                /**
                                 * Function to decompress data using the old PKWARE shrink algorithm.
                                 *
                                 * @param  read_buf  Pointer to read buffer function.
                                 *
                                 * @param  write_buf  Pointer to the write buffer function.
                                 *
                                 * @param  work_buf  Pointer to the working buffer.
                                 *
                                 * @param  param  Pointer to parameter to be passed to the read and 
                                 *    write buffer functions.
                                 *
                                 * @return  Returns the error code for the function.
                                 * @see ERROR_CODES for possible return values
                                 */
                                PKCDL_DECL unsigned int PKCALL pkunshrink(PKReadBuf  read_buf,
                                                                          PKWriteBuf write_buf,
                                                                          void*      work_buf,
                                                                          void*      param);
                                #ifdef __cplusplus
                                   }
                                #endif
                                #endif
                                Code:
                                //-----------------------------------------------------------------------------
                                // pkcdl_stream.h - Streaming PKCDL routines
                                // PKCDL: $Revision: 11 $   $Modtime: 12/08/03 4:19p $
                                // Copyright 2002 - 2003 by PKWARE, Inc.  All Rights Reserved.
                                //-----------------------------------------------------------------------------
                                #ifndef _PKCDL_STREAM_H
                                #define _PKCDL_STREAM_H
                                #ifdef __cplusplus
                                   extern "C" {
                                #endif
                                /**
                                 * @file  pkcdl_stream.h
                                 *
                                 * Public header for PKWARE stream data compression functions
                                 */
                                /** \defgroup PK_ACTION PK_ACTION codes
                                 * Action codes for compression
                                @{
                                */
                                #define PK_ACTION_RUN               0
                                #define PK_ACTION_FLUSH             1
                                #define PK_ACTION_FINISH            2
                                /** @}*/
                                /* Allowed flush values */
                                #define PK_NO_FLUSH      0
                                #define PK_PARTIAL_FLUSH 1
                                #define PK_SYNC_FLUSH    2
                                #define PK_FULL_FLUSH    3
                                #define PK_FINISH        4
                                /** \defgroup Stream_Return_Codes Stream Return Codes
                                * Possible error codes for streaming functions
                                @{
                                */
                                /** Return Codes - Normal events */
                                #define PKDCL_OK            0
                                /** All data from the input stream is read*/
                                #define PKDCL_STREAM_END    1
                                /** Need more data (dictionary)*/
                                #define PKDCL_NEED_DICT     2
                                /** Internal flag, not returned to user */
                                #define PKDCL_CONTINUE     10
                                /** Internal flag, not returned to user */
                                #define PKDCL_GET_INPUT    11
                                /* Return Codes - Errors/Special events */
                                /** NULL stream pointer */
                                #define PKDCL_STREAM_NULL_ERROR            (-1)
                                /** Corrupted data */
                                #define PKDCL_STREAM_NULL_STATE_ERROR      (-2)
                                /** Out of memory*/
                                #define PKDCL_STREAM_ALLOC_ERROR           (-3)
                                /** Corrupted data */
                                #define PKDCL_STREAM_LEVEL_ERROR           (-4)
                                /** Corrupted data */
                                #define PKDCL_STREAM_STRATEGY_ERROR        (-5)
                                /** Out of memory*/
                                #define PKDCL_MEM_INT_STATE_ERROR          (-10)
                                /** Internal flag, not returned to user */
                                #define PKDCL_MEM_INT_BUFFER_ERROR         (-11)
                                /** Corrupted data */
                                #define PKDCL_STATUS_ERROR                 (-20)
                                /** Internal flag, not returned to user */
                                #define PKDCL_DATA_IN_ERROR                (-21)
                                /** Internal flag, not returned to user */
                                #define PKDCL_DATA_OUT_ERROR               (-22)
                                /** Internal flag, not returned to user */
                                #define PKDCL_FLUSH_ERROR                  (-23)
                                /** Corrupted data */
                                #define PKDCL_NULL_DICTIONARY_ERROR        (-24)
                                /** Internal flag, not returned to user */
                                #define PKDCL_FINISH_ERROR                 (-25)
                                /** @}*/
                                /** Internal flag, not returned to user */
                                #define DEFLATE_DEFAULT_COMPRESSION    (-1)
                                /** Compression type options */
                                #define DEFLATE_EXE              0x100
                                #if !defined (PKCALL)
                                # ifdef _UNIX
                                #  define PKCALL
                                # else
                                #  define PKCALL __cdecl
                                # endif
                                #endif
                                typedef void *PVOID;
                                /**
                                 * Signature for user defined memory allocation function
                                 *
                                 * @param  opaque  User specified call back pointer.
                                 * @param  item  The number of items to allocate space for
                                 * @param  size  The size of each item
                                 *
                                 * @return  A pointer to the allocated memory
                                 */
                                typedef PVOID (*ALLOC_FUNC)(PVOID opaque, unsigned int items, unsigned int size);
                                /**
                                 * Signature for user defined memory free function
                                 *
                                 * @param  opaque  User specified call back pointer.
                                 * @param  address  The memory location to release.
                                 */
                                typedef void (*FREE_FUNC)(PVOID opaque, PVOID address);
                                struct internal_state;
                                typedef struct internal_state PKINT_STATE;
                                /**
                                 * Compression buffer structure used with streaming compression interfaces.
                                 *
                                 */
                                typedef struct {
                                   /** Pointer to next input byte */
                                   unsigned char* next_in;
                                   /** Number of bytes available in the input buffer */
                                   unsigned int   avail_in;
                                   /** Number of bytes read from the input buffer (least significant) */
                                   unsigned int   total_in_lo32;
                                   /** Number of bytes read from the input buffer (most significant) */
                                   unsigned int   total_in_hi32;
                                   /** Pointer to next output byte */
                                   unsigned char* next_out;
                                   /** Number of bytes available in the output buffer */
                                   unsigned int   avail_out;
                                   /** Number of bytes written to the output buffer (least significant) */
                                   unsigned int   total_out_lo32;
                                   /** Number of bytes written to the output buffer (most significant) */
                                   unsigned int   total_out_hi32;
                                   /** Last error message, or NULL if no error */
                                   char *msg;
                                   /** Internal pointer to state information for the algorithm */
                                   PKINT_STATE *state;
                                   /** Pointer to custom alloc() function */
                                   ALLOC_FUNC   zalloc;
                                   /** Pointer to custom free() function */
                                   FREE_FUNC    zfree;
                                   /** User defined pointer */
                                   void* opaque;
                                   /** CRC32 value of uncompressed data (not currently used) */
                                   unsigned long crc32;
                                }  PKCmpStreamStruct;
                                typedef PKCmpStreamStruct* pPKCmpStream;
                                typedef PKCmpStreamStruct   PKCmpStream;
                                /* ----------------------------------------------------------
                                 * Streaming DCL Implode/Explode Functions
                                 * ----------------------------------------------------------
                                 */
                                /**
                                 * Initializes streaming DCL Implode compression
                                 *
                                 * @param  pStream  Pointer to compression stream structure
                                 * @param  uiTypeOfData  Indicates if the data to be compressed is ASCII or
                                 *   binary (CMP_ASCII or CMP_BINARY).
                                 * @param  uiDictionarySize  Size of the sliding dictionary to use
                                 *         (1024, 2048, or 4096)
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 */
                                int PKCALL pkImplodeStreamInit(PKCmpStream *pStream, int uiTypeOfData,
                                                               int uiDictionarySize);
                                /**
                                 * Performs DCL Implode compression
                                 *
                                 * @param  pStream  Pointer to the compression stream structure.
                                 * @param  action  The compression action must be one of the
                                 *   PK_ACTION codes
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 * @see PK_ACTION for possible values for action
                                 */
                                int PKCALL pkImplodeStream(PKCmpStream *pStream, int action);
                                /**
                                 * Finishes streaming DCL Implode compression and releases memory that
                                 * had been allocated by the compression engine.
                                 *
                                 * @param  pStream  Pointer to the compression stream structure.
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 */
                                int PKCALL pkImplodeStreamEnd(PKCmpStream *pStream);
                                /**
                                 * Initializes streaming DCL Explode decompression
                                 *
                                 * @param  pStream  Pointer to the compression stream structure
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 */
                                int PKCALL pkExplodeStreamInit(PKCmpStream *pStream);
                                /**
                                 * Performs streaming DCL Explode decompression
                                 *
                                 * @param  pStream  Pointer to the compression stream structure
                                 * @param  action  The decompression action must be one of the
                                 *   PK_ACTION codes
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 * @see PK_ACTION for possible values for action
                                 */
                                int PKCALL pkExplodeStream(PKCmpStream *pStream, int action);
                                /**
                                 * Finishes streaming DCL Explode decompression and releases memory that
                                 * had been allocated by the decompression engine.
                                 *
                                 * @param  pStream  Pointer to the compression stream structure
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 */
                                int PKCALL pkExplodeStreamEnd(PKCmpStream *pStream);
                                /* ----------------------------------------------------------------------
                                 * Streaming Deflate and Inflate Functions
                                 * ----------------------------------------------------------------------
                                 */
                                /**
                                 * Initializes streaming Deflate compression
                                 *
                                 * @param  pStream  Pointer to the compression stream structure
                                 * @param  level  The compression level (1-9) that should be used
                                 * @param  deflate  Indicates if standard deflate should be used
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 */
                                int PKCALL pkDeflateStreamInit(PKCmpStream *pStream, int level, char b204);
                                /**
                                 * Performs streaming Deflate decompression
                                 *
                                 * @param  pStream  Pointer to the compression stream structure
                                 * @param  action  The decompression action must be one of the
                                 *   PK_ACTION codes
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 */
                                int PKCALL pkDeflateStream(PKCmpStream *pStream, int action);
                                /**
                                 * Finishes streaming Deflate decompression and releases memory that
                                 * had been allocated by the decompression engine.
                                 *
                                 * @param  pStream  Pointer to the compression stream structure
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 */
                                int PKCALL pkDeflateStreamEnd(PKCmpStream *pStream);
                                /**
                                 * Initializes streaming Inflate compression
                                 *
                                 * @param  pStream  Pointer to the compression stream structure
                                 * @param  b204  Indicates if standard (2.04g) Deflate should be used.
                                 *   Set to false (0) to indicate the deflate64 algorithm.
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 */
                                int PKCALL pkInflateStreamInit(PKCmpStream *pStream, char b204);
                                /**
                                 * Performs streaming Inflate decompression
                                 *
                                 * @param  pStream  Pointer to the compression stream structure
                                 * @param  action  The decompression action must be one of the
                                 *   PK_ACTION codes
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 * @see PK_ACTION for possible values for action
                                 */
                                int PKCALL pkInflateStream(PKCmpStream *pStream, int action);
                                /**
                                 * Finishes streaming Inflate decompression and releases memory that
                                 * had been allocated by the decompression engine.
                                 *
                                 * @param  pStream  Pointer to the compression stream structure
                                 *
                                 * @return  Returns a status code to indicate success or failure.
                                 *
                                 * @see Stream_Return_Codes for possible return values
                                 * @see PK_ACTION for possible values for action
                                 */
                                int PKCALL pkInflateStreamEnd(PKCmpStream *pStream);
                                #ifdef __cplusplus
                                   }
                                #endif
                                #endif // _PKCDL_STREAM_H
                                I think the version I need would be for streams since I'll be manipulating data in memory and not files...
                                sigpic
                                Mobile Solutions
                                Sys Analyst and Development

                                Comment


                                  #17
                                  Not PKWDCL.DLL

                                  If it's available as a standard DLL there's no reason to convert it to PB, which can natively use functions in any standard DLL. Just create a DECLARE for it and you're in business.
                                  The convert was for the reverse engineered C code that uses no DLL.

                                  Comment


                                    #18
                                    Originally posted by William Bingham View Post
                                    The convert was for the reverse engineered C code that uses no DLL.
                                    A search on "PKWARE DCL-compatible compressor and decompressor" does show c code that might be a nice challenge to port to PB. I'm not sure I want to tackle it though!

                                    James

                                    Comment


                                      #19
                                      Hi Roger

                                      I use pkzip but ran into problems with memory limitations on archiving a large number of files into a single compressed file.

                                      If you are going to program for dos, you might want to consider the rar.exe for msdos.

                                      i have been able to add a large number of files to one rar archieve where pkzip would crash and destroy my archieve files.

                                      i had to end up splitting my files into separate pkzip files to be able to use pkzip.

                                      i was doing this from batch files on a computer running msdos 6.22.

                                      Also i had some problems with the way pkzip was using extended/expanded memory and also had other memory related problems with pkzip, buf i forgot exactly what.

                                      I am not sure but i believe rar uses a much smaller memory to run and i had put it through some tough testing for archiving a great number of files.

                                      So if you want to do some shelling to archive docouments, rar might be the way to go.

                                      here is documentation from running RAR /? to retrieve info. Rar also can be run in menu mode, that i never did.


                                      RAR 2.06 Copyright (c) 1993-98 Eugene Roshal 3 December 1998
                                      Shareware version Type RAR -? for help

                                      Usage: RAR <command> -<switch 1> -<switch N> <archive> <files...>
                                      <@listfiles...> <path_to_extract\>
                                      or RAR

                                      <Commands>
                                      a Add files to archive u Update files in archive
                                      f Freshen files in archive m[f] Move to archive [files only]
                                      x Extract files with full path e Extract files to current directory
                                      d Delete files from archive v Verbosely list contents of archive
                                      r Repair archive l List contents of archive
                                      p Print file to stdout s Convert archive to SFX
                                      t Test archive files c Add archive comment
                                      en Enter to archive cf Add files comment
                                      k Lock archive cw Write archive comment to file
                                      rr[N] Add data recovery record

                                      <Switches>
                                      rr[N] Add data recovery record mm[f] Multimedia compression [force]
                                      o+ Overwrite existing files o- Do not overwrite existing files
                                      bw Black & white mode col Color mode
                                      y Assume Yes on all queries sfx Create SFX archives
                                      std Stdout mode b Enable backup archives
                                      f Freshen files u Update files
                                      c- Disable comments show ed Do not add empty directories
                                      ep Exclude paths from names ep1 Exclude base dir from names
                                      tk Keep original archive time tl Set archive time to latest file
                                      cfg- Disable read configuration ems- Disable expanded memory usage
                                      s[e,<N>] Create solid archive
                                      s- Disable solid archiving
                                      r Recurse subdirectories
                                      r0 Recurse subdirectories for wildcard names only
                                      z<file> Read archive comment from file
                                      x<file> Exclude specified file
                                      x@<list> Exclude files in specified list file
                                      v Create volumes with size autodetection
                                      v<N>[k,b,f] Create volumes with size=<N>*1000 [*1024, *1]
                                      vd Erase disk contents before creating volume
                                      p<password> Set password
                                      p- Do not query password
                                      kb Keep broken extracted files
                                      w<path> Assign work directory
                                      m<0..5> Set compression level (0-store...3-default...5-maximal)

                                      Press any key to continue ...
                                      av Put authenticity verification (registered versions only)
                                      av- Disable AV check
                                      ds Disable name sort for solid archive
                                      $[drive] Add/extract volume label
                                      dh Disable file sharing
                                      ac Clear Archive attribute after compression
                                      ao Add files with Archive attribute set

                                      end of help list using RAR /?

                                      this is not the current verison, which is 3.71


                                      paul
                                      Last edited by Paul Purvis; 22 Feb 2008, 05:17 AM.
                                      p purvis

                                      Comment


                                        #20
                                        @paul
                                        Another that did not read the first post.

                                        Roger NEEDS the pk implode/explode for his project!!!

                                        James

                                        Comment

                                        Working...
                                        X
                                        😀
                                        🥰
                                        🤢
                                        😎
                                        😡
                                        👍
                                        👎