mirror of
https://github.com/jmarshall23/Hellfire.git
synced 2026-08-12 07:50:53 +02:00
Initial commit.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,142 @@
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
|
||||
* The examples provided show how the PKWARE Data Compression Library is
|
||||
implemented. These examples show how to do "file-to-file" compression,
|
||||
"memory-to-memory" compression, and disk spanning. We recommend that
|
||||
you run the examples with a debugger, and set breakpoints in the I/O
|
||||
callback functions. These functions handle the data I/O, and can be
|
||||
modified to compress or extract data from any device, not just from a file.
|
||||
|
||||
|
||||
* Visual C++ users
|
||||
|
||||
* To build a Visual C++ project, load the Visual Workbench, and open
|
||||
the .MAK file through the "Open" menu item under "Project." This
|
||||
will automatically update the makefile to the path of where the
|
||||
examples are installed.
|
||||
|
||||
* To make a VC++ .MAK file, add all the files in the example directory
|
||||
with the extensions: *.c*, *.rc, *.def, *.lib
|
||||
|
||||
* Borland C++ 4.x users
|
||||
|
||||
* Borland .IDE files are provided for each example on the distribution
|
||||
disk. You must set your include and library directories by going into
|
||||
the OPTIONS | PROJECT | DIRECTORIES window.
|
||||
|
||||
* If you are making your own .IDE file, add all the files in the current
|
||||
directory to the project with the extensions: *.c*, *.rc, *.def, *.lib.
|
||||
|
||||
|
||||
* DLL examples
|
||||
|
||||
If you will be using the DLL examples, make sure that IMPLODE.DLL and/or
|
||||
IMPBORL.DLL is in your user path.
|
||||
|
||||
|
||||
Directory Structure for the examples:
|
||||
|
||||
ÀÄÄÄEXAMPLES
|
||||
ÃÄÄÄCMDLINE
|
||||
³ ÃÄÄÄFIL2FIL
|
||||
³ ÃÄÄÄMEM2MEM
|
||||
³ ÀÄÄÄMULTFILE
|
||||
ÃÄÄÄGUI
|
||||
³ ÃÄÄÄFIL2FIL
|
||||
³ ÀÄÄÄMEM2MEM
|
||||
ÃÄÄÄMFC
|
||||
³ ÃÄÄÄFIL2FIL
|
||||
³ ³ ÀÄÄÄRES
|
||||
³ ÃÄÄÄMEM2MEM
|
||||
³ ³ ÀÄÄÄRES
|
||||
³ ÃÄÄÄMULTFILE
|
||||
³ ³ ÀÄÄÄRES
|
||||
³ ÀÄÄÄSPAN
|
||||
³ ÀÄÄÄRES
|
||||
ÀÄÄÄOWL
|
||||
ÃÄÄÄMEM2MEM
|
||||
ÀÄÄÄSPAN
|
||||
|
||||
|
||||
CMDLINE Examples
|
||||
----------------
|
||||
|
||||
FIL2FIL => This example shows how to compress and uncompress from one
|
||||
file to another. Requires the TEST.IN file in the executable
|
||||
directory to run.
|
||||
|
||||
MEM2MEM => This example shows how to compress and uncompress from one
|
||||
memory buffer to another. TEST.IN must be less than 62K bytes.
|
||||
|
||||
MULTFILE => This example shows how to compress multiple files into one file,
|
||||
then uncompress the file. The multiple files must be specified
|
||||
on the command line.
|
||||
|
||||
|
||||
GUI Examples
|
||||
------------
|
||||
|
||||
FIL2FIL => SDK Windows example. Requires the TEST.IN file in the executable
|
||||
directory to run.
|
||||
|
||||
MEM2MEM => SDK Windows example. Requires the TEST.IN file in the executable
|
||||
directory to run. This example shows how to compress and
|
||||
uncompress from one memory buffer to another.
|
||||
|
||||
|
||||
MFC Examples
|
||||
------------
|
||||
|
||||
FIL2FIL => Written using Visual C++ with MFC and the static link library.
|
||||
Requires the TEST.IN file in the executable directory to run.
|
||||
This example also contains debugging statements to help display
|
||||
how the PKWARE Data Compression Library calls the read and write
|
||||
routines repeatedly.
|
||||
|
||||
MEM2MEM => This example shows how to compress and uncompress from one
|
||||
memory buffer to another. Written using Visual C++ with MFC
|
||||
(also uses MFC DLL). Prompts for file to load, which must be
|
||||
less than 62K bytes.
|
||||
|
||||
MULTFILE => This example shows how to compress multiple files into one file,
|
||||
then uncompress the file. Written using Visual C++ with MFC
|
||||
(also uses MFC DLL).
|
||||
|
||||
SPAN => Written using Visual C++ with MFC (also uses MFC DLL). This
|
||||
example uses MULTFILE as a base, but includes disk spanning.
|
||||
All files are extracted to a temporary directory, C:\TEMP\.
|
||||
To change the extract directory, modify the global variable
|
||||
"UncompressDir" in MAINFRM.CPP.
|
||||
|
||||
|
||||
OWL Examples
|
||||
------------
|
||||
|
||||
MEM2MEM => This example shows how to compress and uncompress from one
|
||||
memory buffer to another. Written using Borland C++ 4.5 with OWL.
|
||||
Prompts for file to load, which must be less than 62K bytes.
|
||||
|
||||
|
||||
SPAN => Written using Borland C++ 4.5 with OWL. This example compresses
|
||||
multiple files and includes disk spanning. All files are
|
||||
extracted to a temporary directory, C:\TEMP\. To change the
|
||||
extract directory, modify the global variable "UncompressDir"
|
||||
in SPANAPP.CPP.
|
||||
|
||||
|
||||
Directions on Using MULTFILE and SPAN Programs:
|
||||
|
||||
To compress multiple files: Select Compress Files from the File
|
||||
menu, and use the Shift and Ctrl keys with the mouse to
|
||||
highlight multiple files. Select OK after selecting the files.
|
||||
Enter the path and name of file to compress the selected files
|
||||
to.
|
||||
|
||||
To uncompress a file: Select Uncompress Files from the File menu,
|
||||
and enter or select the file to uncompress, then select the OK
|
||||
button. The files will be uncompressed in the same directory.
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program using Borland compiler and DLL
|
||||
:
|
||||
|
||||
bcc32 example.c ..\..\..\impborli.lib
|
||||
@@ -0,0 +1,132 @@
|
||||
/***************************************************************
|
||||
PKWARE Data Compression Library (R) for Win32
|
||||
Copyright 1991,1992,1994,1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.
|
||||
***************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "implode.h"
|
||||
|
||||
/* Define a structure containing data to be passed to the callback
|
||||
functions through the user defined parameter.
|
||||
*/
|
||||
|
||||
struct PassedParam
|
||||
{
|
||||
unsigned int CmpPhase;
|
||||
FILE *InFile;
|
||||
FILE *OutFile;
|
||||
unsigned long CRC;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
Routine to supply data to the implode() or explode() routines.
|
||||
When this routine returns 0 bytes read, the implode() or explode()
|
||||
routines will terminate. Also calculate the CRC-32 on the original
|
||||
uncompressed data during the implode() call.
|
||||
*/
|
||||
|
||||
unsigned int ReadData(char *Buff, unsigned int *Size, void *Param)
|
||||
{
|
||||
size_t Read;
|
||||
struct PassedParam *Par = (struct PassedParam *)Param;
|
||||
|
||||
Read = fread(Buff, 1, *Size, Par->InFile);
|
||||
if (Par->CmpPhase)
|
||||
Par->CRC = crc32(Buff, (unsigned int *)&Read, &Par->CRC);
|
||||
|
||||
return (unsigned int)Read;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
Routine to write compressed data output from implode() or
|
||||
uncompressed data from explode(). Also calculate the CRC on
|
||||
the uncompressed data during the explode() call.
|
||||
*/
|
||||
|
||||
void WriteData(char *Buff, unsigned int *Size, void *Param)
|
||||
{
|
||||
struct PassedParam *Par = (struct PassedParam *)Param;
|
||||
|
||||
fwrite(Buff, 1, *Size, Par->OutFile);
|
||||
if (!Par->CmpPhase)
|
||||
Par->CRC = crc32(Buff, Size, &Par->CRC);
|
||||
}
|
||||
|
||||
int cdecl main(void)
|
||||
{
|
||||
char *WorkBuff; /* buffer for compression tables */
|
||||
unsigned int Error;
|
||||
unsigned int type; /* ASCII or Binary compression */
|
||||
unsigned int dsize; /* Dictionary Size. 1,2 or 4K */
|
||||
unsigned long OrgCRC; /* CRC of original input file */
|
||||
struct PassedParam Param; /* Parameters passed to callback functions */
|
||||
|
||||
/* Open the input file */
|
||||
Param.InFile = fopen("test.in","rb");
|
||||
if (Param.InFile == NULL)
|
||||
{
|
||||
puts("Unable to open input file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create the output compressed file */
|
||||
Param.OutFile = fopen("test.cmp","wb");
|
||||
|
||||
/* Allocate memory for implode work buffer */
|
||||
WorkBuff = (char *)malloc(CMP_BUFFER_SIZE);
|
||||
if (WorkBuff == NULL)
|
||||
{
|
||||
puts("Unable to allocate work buffer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize CRC */
|
||||
Param.CmpPhase = 1;
|
||||
Param.CRC = (unsigned long) -1;
|
||||
|
||||
type = CMP_ASCII; /* Use ASCII compression */
|
||||
dsize = 4096; /* Use 4K dictionary */
|
||||
|
||||
puts("Calling Implode");
|
||||
implode(ReadData, WriteData, WorkBuff, &Param, &type, &dsize);
|
||||
puts("Done Compressing");
|
||||
|
||||
OrgCRC = ~Param.CRC;
|
||||
free(WorkBuff);
|
||||
|
||||
fclose(Param.InFile);
|
||||
fclose(Param.OutFile);
|
||||
|
||||
/* Compression done, now try extracting the compressed file */
|
||||
|
||||
WorkBuff = (char *)malloc(EXP_BUFFER_SIZE);
|
||||
if (WorkBuff == NULL)
|
||||
{
|
||||
puts("Unable to allocate work buffer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Param.InFile = fopen("test.cmp","rb"); /* Compressed file */
|
||||
Param.OutFile = fopen("test.ext","wb"); /* File to extract to */
|
||||
|
||||
/* Initialize CRC */
|
||||
Param.CmpPhase = 0;
|
||||
Param.CRC = (unsigned long) -1;
|
||||
|
||||
puts("Calling Explode");
|
||||
Error = explode(ReadData, WriteData, WorkBuff, &Param);
|
||||
|
||||
Param.CRC = ~Param.CRC;
|
||||
free(WorkBuff);
|
||||
fclose(Param.InFile);
|
||||
fclose(Param.OutFile);
|
||||
|
||||
printf("Uncompression completed - Error %d\n", Error);
|
||||
printf("Original CRC=%08lx Uncompressed CRC=%08lx\n",OrgCRC,Param.CRC);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/***************************************************************
|
||||
PKWARE Data Compression Library (R) for Win32
|
||||
Copyright 1991,1992,1994,1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.
|
||||
***************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned int implode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param,
|
||||
unsigned int *type,
|
||||
unsigned int *dsize);
|
||||
|
||||
|
||||
unsigned int explode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param);
|
||||
|
||||
unsigned long crc32(char *buffer, unsigned int *size, unsigned long *old_crc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // End of 'extern "C"' declaration
|
||||
#endif
|
||||
|
||||
|
||||
#define CMP_BUFFER_SIZE 36312
|
||||
#define EXP_BUFFER_SIZE 12596
|
||||
|
||||
#define CMP_BINARY 0
|
||||
#define CMP_ASCII 1
|
||||
|
||||
#define CMP_NO_ERROR 0
|
||||
#define CMP_INVALID_DICTSIZE 1
|
||||
#define CMP_INVALID_MODE 2
|
||||
#define CMP_BAD_DATA 3
|
||||
#define CMP_ABORT 4
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program
|
||||
:
|
||||
|
||||
cl example.c ..\..\..\implode.lib
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program using Borland compiler
|
||||
:
|
||||
|
||||
bcc32 example.c ..\..\..\impborl.lib
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program using DLL
|
||||
:
|
||||
|
||||
cl example.c ..\..\..\implodei.lib
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program using Borland compiler and DLL
|
||||
:
|
||||
|
||||
bcc32 mem2mem.c ..\..\..\impborli.lib
|
||||
@@ -0,0 +1,44 @@
|
||||
/***************************************************************
|
||||
PKWARE Data Compression Library (R) for Win32
|
||||
Copyright 1991,1992,1994,1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.
|
||||
***************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned int implode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param,
|
||||
unsigned int *type,
|
||||
unsigned int *dsize);
|
||||
|
||||
|
||||
unsigned int explode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param);
|
||||
|
||||
unsigned long crc32(char *buffer, unsigned int *size, unsigned long *old_crc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // End of 'extern "C"' declaration
|
||||
#endif
|
||||
|
||||
|
||||
#define CMP_BUFFER_SIZE 36312
|
||||
#define EXP_BUFFER_SIZE 12596
|
||||
|
||||
#define CMP_BINARY 0
|
||||
#define CMP_ASCII 1
|
||||
|
||||
#define CMP_NO_ERROR 0
|
||||
#define CMP_INVALID_DICTSIZE 1
|
||||
#define CMP_INVALID_MODE 2
|
||||
#define CMP_BAD_DATA 3
|
||||
#define CMP_ABORT 4
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program
|
||||
:
|
||||
|
||||
cl mem2mem.c ..\..\..\implode.lib
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program using Borland compiler
|
||||
:
|
||||
|
||||
bcc32 mem2mem.c ..\..\..\impborl.lib
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program using DLL
|
||||
:
|
||||
|
||||
cl mem2mem.c ..\..\..\implodei.lib
|
||||
@@ -0,0 +1,286 @@
|
||||
/*************************************************************************
|
||||
Example to interface the PKWARE Data Compression Library (R)
|
||||
Copyright 1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off
|
||||
Version 1.11
|
||||
|
||||
This example takes a file from the disk (file must be <= 62K),
|
||||
compresses the file to memory, and then expands the compressed
|
||||
data back into another memory buffer. This data is then written
|
||||
to a file called test.ext, that can be compared to the original file.
|
||||
*************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "implode.h"
|
||||
|
||||
#define BUFFERSIZE ((long)(62 * 1024)) /* File size limit */
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
|
||||
typedef struct PassedParam
|
||||
{
|
||||
char *pSource; /* Pointer to source buffer */
|
||||
char *pDestination; /* Pointer to destination buffer */
|
||||
unsigned long SourceOffset; /* Offset into the source buffer */
|
||||
unsigned long DestinationOffset; /* Offset into the destination buffer */
|
||||
unsigned long CompressedSize; /* Need this for extracting! */
|
||||
unsigned long UnCompressedSize; /* Size of uncompressed data file */
|
||||
unsigned long BufferSize;
|
||||
unsigned long Crc; /* Calculated CRC value */
|
||||
unsigned long OrigCrc; /* Original CRC value of data */
|
||||
} PARAM;
|
||||
|
||||
|
||||
/*
|
||||
** BufferSize defines the maximum size allowed for output of compressed
|
||||
** data from implode(), or uncompressed data from explode(). Notice that
|
||||
** if you are compressing files that compress to a size greater than
|
||||
** BufferSize, an error message will result. You can modify the value of
|
||||
** BufferSize if you need a bigger buffer. If you know your maximum file
|
||||
** size, you can adjust BUFFERSIZE. This will allow for larger, or smaller
|
||||
** maximum values of BufferSize.
|
||||
*/
|
||||
|
||||
/* Routine to read uncompressed data. Used only by implode().
|
||||
** This routine reads the data that is to be compressed.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
ReadUnCompressed(char *buff, unsigned int *size, void *Param)
|
||||
{
|
||||
PARAM *Ptr = (PARAM *) Param;
|
||||
|
||||
if (Ptr->UnCompressedSize == 0L)
|
||||
{
|
||||
/* This will terminate the compression or extraction process */
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (Ptr->UnCompressedSize < (unsigned long)*size)
|
||||
{
|
||||
*size = (unsigned int)Ptr->UnCompressedSize;
|
||||
}
|
||||
|
||||
memcpy(buff, Ptr->pSource + Ptr->SourceOffset, *size);
|
||||
Ptr->SourceOffset += (unsigned long)*size;
|
||||
Ptr->UnCompressedSize -= (unsigned long)*size;
|
||||
Ptr->Crc = crc32(buff, size, &Ptr->Crc);
|
||||
|
||||
return(*size);
|
||||
}
|
||||
|
||||
/* Routine to read compressed data. Used only by explode().
|
||||
** This routine reads the compressed data that is to be uncompressed.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
ReadCompressed(char *buff, unsigned int *size, void *Param)
|
||||
{
|
||||
PARAM *Ptr = (PARAM *) Param;
|
||||
|
||||
if (Ptr->CompressedSize == 0L)
|
||||
{
|
||||
/* This will terminate the compression or extraction process */
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (Ptr->CompressedSize < (unsigned long)*size)
|
||||
{
|
||||
*size = (unsigned int)Ptr->CompressedSize;
|
||||
}
|
||||
|
||||
memcpy(buff, Ptr->pSource + Ptr->SourceOffset, *size);
|
||||
Ptr->SourceOffset += (unsigned long)*size;
|
||||
Ptr->CompressedSize -= (unsigned long)*size;
|
||||
|
||||
return(*size);
|
||||
}
|
||||
|
||||
/* Routime to write compressed data. Used only by implode().
|
||||
** This routine writes the compressed data to a memory buffer.
|
||||
*/
|
||||
|
||||
void
|
||||
WriteCompressed(char *buff, unsigned int *size, void *Param)
|
||||
{
|
||||
PARAM *Ptr = (PARAM *) Param;
|
||||
|
||||
if (Ptr->CompressedSize + (unsigned long)*size > Ptr->BufferSize)
|
||||
{
|
||||
puts("Compressed data will overflow buffer. Increase size of buffer!");
|
||||
exit(1);
|
||||
}
|
||||
memcpy(Ptr->pDestination + Ptr->DestinationOffset, buff, *size);
|
||||
Ptr->DestinationOffset += (unsigned long)*size;
|
||||
Ptr->CompressedSize += (unsigned long)*size;
|
||||
}
|
||||
|
||||
/* Routine to write uncompressed data. Used only by explode().
|
||||
** This routine writes the uncompressed data to a memory buffer.
|
||||
*/
|
||||
|
||||
void
|
||||
WriteUnCompressed(char *buff, unsigned int *size, void *Param)
|
||||
{
|
||||
PARAM *Ptr = (PARAM *) Param;
|
||||
|
||||
if (Ptr->CompressedSize + (unsigned long)*size > Ptr->BufferSize)
|
||||
{
|
||||
puts("Compressed data will overflow buffer. Increase size of buffer!");
|
||||
exit(1);
|
||||
}
|
||||
memcpy(Ptr->pDestination + Ptr->DestinationOffset, buff, *size);
|
||||
Ptr->DestinationOffset += (unsigned long)*size;
|
||||
Ptr->UnCompressedSize += (unsigned long)*size;
|
||||
Ptr->Crc = crc32(buff, size, &Ptr->Crc);
|
||||
}
|
||||
|
||||
void
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *WorkBuff; /* Buffer for compression tables */
|
||||
char *InFileName;
|
||||
char *temp;
|
||||
unsigned int error;
|
||||
unsigned int bytes_read;
|
||||
unsigned int type;
|
||||
unsigned int dsize;
|
||||
unsigned int written;
|
||||
PARAM Param;
|
||||
FILE *InFile;
|
||||
FILE *OutFile;
|
||||
|
||||
/* Use the first command line argument as the name of the file
|
||||
** to read as the data source. If no filename is given, default
|
||||
** to use "test.in"
|
||||
*/
|
||||
if (argc > 1)
|
||||
{
|
||||
InFileName = argv[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
InFileName = "test.in";
|
||||
}
|
||||
|
||||
/* Open the file so it's contents can be read into memory. */
|
||||
if ((InFile = fopen(InFileName, "rb")) == NULL)
|
||||
{
|
||||
puts("Unable to open input file.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Determine the size of the file, and rewind to beginning of file. */
|
||||
if (fseek(InFile, 0L, SEEK_END))
|
||||
{
|
||||
puts("Unable to determine input file size.");
|
||||
exit(1);
|
||||
}
|
||||
Param.UnCompressedSize = ftell(InFile);
|
||||
fseek(InFile, 0L, SEEK_SET);
|
||||
|
||||
if (Param.UnCompressedSize > BUFFERSIZE)
|
||||
{
|
||||
fclose(InFile);
|
||||
printf("Cannot compress files larger than %d.\n",BUFFERSIZE);
|
||||
exit(1);
|
||||
}
|
||||
Param.BufferSize = Param.UnCompressedSize;
|
||||
Param.CompressedSize = 0L;
|
||||
|
||||
/* Allocate memory buffers to hold the compressed and uncompressed
|
||||
** contents of the data file.
|
||||
*/
|
||||
Param.pSource = (char *)malloc(Param.BufferSize);
|
||||
Param.pDestination = (char *)malloc(Param.BufferSize);
|
||||
|
||||
/* We make the destination buffer the same size as the source buffer.
|
||||
** You should determine what compression ratios you achieve with your
|
||||
** specific data. You may only need a destination buffer about one half
|
||||
** the size of the source buffer (assuming 50% compression).
|
||||
*/
|
||||
|
||||
if (Param.pSource == NULL || Param.pDestination == NULL)
|
||||
{
|
||||
puts("Unable to allocate source & destination buffers.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Read the contents of the file into the uncompressed data buffer. */
|
||||
fread((void *)Param.pSource, 1, Param.UnCompressedSize, InFile);
|
||||
fclose(InFile);
|
||||
|
||||
/* Allocate the buffer used by implode() for compression tables. */
|
||||
WorkBuff = (char *)malloc(CMP_BUFFER_SIZE);
|
||||
if (WorkBuff == NULL)
|
||||
{
|
||||
puts("Unable to allocate work buffer.");
|
||||
return;
|
||||
}
|
||||
|
||||
puts("Calling Implode");
|
||||
type = CMP_ASCII;
|
||||
dsize = 1024;
|
||||
|
||||
Param.SourceOffset = 0L;
|
||||
Param.DestinationOffset = 0L;
|
||||
Param.Crc = (unsigned long) -1;
|
||||
implode(ReadUnCompressed,WriteCompressed,WorkBuff,&Param,&type,&dsize);
|
||||
Param.OrigCrc = ~Param.Crc;
|
||||
free(WorkBuff);
|
||||
|
||||
/* Since the imploding is done, the data in the compressed buffer
|
||||
** will be used as the source for the exploding process.
|
||||
*/
|
||||
temp = Param.pSource;
|
||||
Param.pSource = Param.pDestination;
|
||||
Param.pDestination = temp;
|
||||
|
||||
/* Clear buffer containing original uncompressed data */
|
||||
memset(Param.pDestination, 0, Param.UnCompressedSize);
|
||||
|
||||
/* Allocate the buffer used by explode() for compression tables. */
|
||||
WorkBuff = (char *)malloc(EXP_BUFFER_SIZE);
|
||||
if (WorkBuff == NULL)
|
||||
{
|
||||
puts("Unable to allocate work buffer.");
|
||||
return;
|
||||
}
|
||||
Param.SourceOffset = 0L;
|
||||
Param.DestinationOffset = 0L;
|
||||
Param.UnCompressedSize = 0L;
|
||||
Param.Crc = (unsigned long) -1;
|
||||
|
||||
/* Now try extracting the compressed file data */
|
||||
puts("Calling Explode");
|
||||
error = explode(ReadCompressed,WriteUnCompressed,WorkBuff,&Param);
|
||||
Param.Crc = ~Param.Crc;
|
||||
|
||||
if (error || (Param.Crc != Param.OrigCrc))
|
||||
{
|
||||
puts("Error in compressed data!");
|
||||
}
|
||||
printf("Original CRC=%lx Uncompressed CRC=%lx\n",Param.OrigCrc, Param.Crc);
|
||||
|
||||
/* The uncompressed data is now in pDestination. Lets write this to a file
|
||||
** called test.ext. We can compare this buffer to the original input file.
|
||||
*/
|
||||
|
||||
if ((OutFile = fopen("test.ext", "wb+")) == NULL)
|
||||
{
|
||||
puts("Unable to open output file.");
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite((void *)Param.pDestination, 1, Param.UnCompressedSize, OutFile);
|
||||
fclose(OutFile);
|
||||
}
|
||||
|
||||
/* Free buffers */
|
||||
free(WorkBuff);
|
||||
free(Param.pSource);
|
||||
free(Param.pDestination);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program using Borland compiler and DLL
|
||||
:
|
||||
|
||||
bcc32 multfile.c ..\..\..\impborli.lib
|
||||
@@ -0,0 +1,44 @@
|
||||
/***************************************************************
|
||||
PKWARE Data Compression Library (R) for Win32
|
||||
Copyright 1991,1992,1994,1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.
|
||||
***************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned int implode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param,
|
||||
unsigned int *type,
|
||||
unsigned int *dsize);
|
||||
|
||||
|
||||
unsigned int explode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param);
|
||||
|
||||
unsigned long crc32(char *buffer, unsigned int *size, unsigned long *old_crc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // End of 'extern "C"' declaration
|
||||
#endif
|
||||
|
||||
|
||||
#define CMP_BUFFER_SIZE 36312
|
||||
#define EXP_BUFFER_SIZE 12596
|
||||
|
||||
#define CMP_BINARY 0
|
||||
#define CMP_ASCII 1
|
||||
|
||||
#define CMP_NO_ERROR 0
|
||||
#define CMP_INVALID_DICTSIZE 1
|
||||
#define CMP_INVALID_MODE 2
|
||||
#define CMP_BAD_DATA 3
|
||||
#define CMP_ABORT 4
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program
|
||||
:
|
||||
|
||||
cl multfile.c ..\..\..\implode.lib
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program using Borland compiler
|
||||
:
|
||||
|
||||
bcc32 multfile.c ..\..\..\impborl.lib
|
||||
@@ -0,0 +1,5 @@
|
||||
:
|
||||
: Make file for example program using DLL
|
||||
:
|
||||
|
||||
cl multfile.c ..\..\..\implodei.lib
|
||||
@@ -0,0 +1,479 @@
|
||||
/*************************************************************************
|
||||
Example to interface the PKWARE Data Compression Library (R)
|
||||
Copyright 1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off
|
||||
Version 1.11
|
||||
|
||||
This example compresses a set of one or more files into a single
|
||||
output file. The set of files is taken from the command line. Each
|
||||
file is compressed, and written to the output file. A record
|
||||
holding information for each file is written to the output file along
|
||||
with the compressed data. The name of the compressed output file
|
||||
created by this program is PKWDCL.CMP.
|
||||
**************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "implode.h"
|
||||
|
||||
#define BUFSIZE 2048 /* Work buffer */
|
||||
#define TEMPNAME "PKWDCL.TMP" /* Temporary file */
|
||||
#define COMPRESSED_FILE_NAME "PKWDCL.CMP" /* Name of compressed output file */
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
|
||||
|
||||
/*
|
||||
** Structure definitions
|
||||
*/
|
||||
|
||||
typedef struct FileHeader
|
||||
{
|
||||
char signature[4]; /* Signature in case of errors */
|
||||
char filename[13]; /* File name */
|
||||
unsigned long CompSize; /* Compressed size of file */
|
||||
unsigned long UnCompSize; /* Original size of file */
|
||||
unsigned long Crc; /* Crc value for file */
|
||||
} HEADER;
|
||||
/*
|
||||
** This structure will be written to the compressed output file and
|
||||
** will record information for each input file that is compressed
|
||||
** into the output file.
|
||||
*/
|
||||
|
||||
typedef struct PassedParam
|
||||
{
|
||||
FILE *InFile; /* Pointer to file for reading data */
|
||||
FILE *OutFile; /* Pointer to file for writing data */
|
||||
FILE *Destination; /* Pointer to compressed output file */
|
||||
int Imploding; /* Flag indicating compression or */
|
||||
/* uncompression is in progress. */
|
||||
unsigned long Crc; /* CRC value for current file. */
|
||||
unsigned long OrigCrc; /* Original CRC for a file */
|
||||
unsigned long CompressedFileSize; /* Size of compressed file */
|
||||
unsigned long UnCompressedFileSize;/* Original file size */
|
||||
} PARAM;
|
||||
/*
|
||||
** This structure is used to pass values shared between the main
|
||||
** application and the callback functions called by implode() and
|
||||
** explode().
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
** Function Prototypes
|
||||
*/
|
||||
unsigned long FileSize(FILE *);
|
||||
void ReadHeader(FILE *, HEADER *);
|
||||
void SkipFile(FILE *, unsigned long);
|
||||
void Expand(char *,int);
|
||||
void CompressFile(char *, char *, PARAM *);
|
||||
void AppendFile(FILE *,unsigned long);
|
||||
void WriteHeader(char *, PARAM *);
|
||||
void Compress(char *,int, char **);
|
||||
|
||||
|
||||
/* The ReadBuff function is used by the implode() and explode()
|
||||
** functions to read a stream of data that will be either
|
||||
** compressed, or uncompressed.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
ReadBuff(char *buff, unsigned int *size, void *Param)
|
||||
{
|
||||
PARAM *Ptr = (PARAM *) Param;
|
||||
unsigned int Read = 0;
|
||||
|
||||
/* This function may ask for up to 4K of data at a time. If your archive
|
||||
** file contains several compressed files, you may read too much. For
|
||||
** example, your first compressed file in the archive may be 100 bytes.
|
||||
** So you do not want to read more than 100 bytes or you'll be unable to
|
||||
** uncompress the second file, since you will not be located at the
|
||||
** beginning of the file any longer. We will use the variable
|
||||
** "CompressedFileSize" to check for this condition.
|
||||
*/
|
||||
|
||||
if (Ptr->Imploding == FALSE)
|
||||
{
|
||||
/* If we are exploding data, and the number of bytes left in the
|
||||
** compressed file is less than the number of bytes requested, then
|
||||
** set the number of bytes requested to the bytes remaining in the
|
||||
** compressed file.
|
||||
*/
|
||||
|
||||
/* Set size to bytes left */
|
||||
|
||||
if ((unsigned long)*size > Ptr->CompressedFileSize)
|
||||
{
|
||||
*size = (unsigned)Ptr->CompressedFileSize;
|
||||
}
|
||||
|
||||
/* Subtract the number of bytes read from the total size of the
|
||||
** compressed file.
|
||||
*/
|
||||
|
||||
Ptr->CompressedFileSize -= (unsigned long)*size;
|
||||
}
|
||||
|
||||
/* Read 'size' bytes from input source */
|
||||
Read = fread(buff, 1, *size, Ptr->InFile);
|
||||
|
||||
if (Ptr->Imploding == FALSE)
|
||||
{
|
||||
/* Check the CRC value of data as it's uncompressed. */
|
||||
Ptr->Crc = crc32(buff, &Read, &Ptr->Crc);
|
||||
}
|
||||
|
||||
/* Return the number of bytes read from the input source */
|
||||
return(Read);
|
||||
}
|
||||
|
||||
/* The WriteBuff function is used by the implode() and explode()
|
||||
** functions to write a stream of data that has been either
|
||||
** compressed, or uncompressed.
|
||||
*/
|
||||
|
||||
void
|
||||
WriteBuff(char *buff, unsigned int *size, void *Param)
|
||||
{
|
||||
/* If compressing data, add the number of bytes to 'CompressedFileSize'.
|
||||
** We need to keep track of the size of the compressed file.
|
||||
*/
|
||||
|
||||
PARAM *Ptr = (PARAM *) Param;
|
||||
int Written;
|
||||
|
||||
if (Ptr->Imploding)
|
||||
{
|
||||
Ptr->CompressedFileSize += (unsigned long)*size;
|
||||
}
|
||||
|
||||
/* Write the data to the file. If we are Imploding, this is compressed
|
||||
** data. Otherwise it is uncompressed data.
|
||||
*/
|
||||
|
||||
Written = fwrite((void *)buff, 1, *size, Ptr->OutFile);
|
||||
if (Written != *size)
|
||||
{
|
||||
puts("Failed to write compressed data");
|
||||
}
|
||||
if (Ptr->Imploding == TRUE)
|
||||
{
|
||||
/* Calculate the CRC value of data as it's compressed. */
|
||||
Ptr->Crc = crc32(buff, size, &Ptr->Crc);
|
||||
}
|
||||
}
|
||||
|
||||
/* The ReadHeader function is used to read a HEADER data structure
|
||||
** from the compressed output file. This HEADER record contains the
|
||||
** information about the compressed file.
|
||||
*/
|
||||
void
|
||||
ReadHeader(FILE *pFile, HEADER *header)
|
||||
{
|
||||
fread(header, 1, sizeof(HEADER), pFile);
|
||||
}
|
||||
|
||||
/* The SkipFile function is used to skip over a file that is in
|
||||
** the compressed output file if that file is not to be uncompressed.
|
||||
*/
|
||||
void
|
||||
SkipFile(FILE *pFile, unsigned long Size)
|
||||
{
|
||||
fseek(pFile, Size, SEEK_CUR);
|
||||
}
|
||||
|
||||
/* The FileSize function is used to determine the number of
|
||||
** bytes in a file that is to be compressed.
|
||||
*/
|
||||
unsigned long
|
||||
FileSize(FILE *pFile)
|
||||
{
|
||||
unsigned long Size;
|
||||
|
||||
if (fseek(pFile, 0L, SEEK_END))
|
||||
{
|
||||
puts("Unable to determine input file size.");
|
||||
}
|
||||
Size = ftell(pFile);
|
||||
fseek(pFile, 0L, SEEK_SET);
|
||||
|
||||
return(Size);
|
||||
}
|
||||
|
||||
/* The Expand function is used to uncompress the files that were
|
||||
** written to the compressed output file. A prompt is displayed
|
||||
** for each file allowing the user to skip the file if it is not
|
||||
** to be uncompressed.
|
||||
*/
|
||||
void
|
||||
Expand(char *WorkBuff, int Files)
|
||||
{
|
||||
HEADER header;
|
||||
PARAM Param;
|
||||
int error;
|
||||
int i;
|
||||
int FileCount;
|
||||
char ch;
|
||||
char s[80];
|
||||
|
||||
memset( &Param, 0, sizeof(Param) );
|
||||
|
||||
Param.InFile = fopen(COMPRESSED_FILE_NAME, "rb");
|
||||
if (Param.InFile == NULL)
|
||||
{
|
||||
printf("Unable to open compressed output file %s\n",COMPRESSED_FILE_NAME);
|
||||
}
|
||||
|
||||
for (FileCount = 1; FileCount < Files; FileCount++)
|
||||
{
|
||||
Param.CompressedFileSize = 0L;
|
||||
ReadHeader(Param.InFile,&header);
|
||||
|
||||
/* Display a message and ask if you wish to extract this file */
|
||||
sprintf(s,"Extract file %s ? File is %lu bytes. (Y/N)",
|
||||
header.filename, header.UnCompSize);
|
||||
puts(s);
|
||||
|
||||
/* We need to remember how many bytes are in this compressed data
|
||||
** stream. We don't want to read too many bytes.
|
||||
*/
|
||||
Param.CompressedFileSize = header.CompSize;
|
||||
Param.OrigCrc = header.Crc;
|
||||
Param.Imploding = FALSE;
|
||||
|
||||
do
|
||||
{
|
||||
ch = toupper(getchar());
|
||||
}
|
||||
while(ch != 'Y' && ch != 'N');
|
||||
if (ch == 'Y')
|
||||
{
|
||||
/* If the file is to be uncompressed, create new, empty file
|
||||
** of the same name where the uncompressed contents of the
|
||||
** file will be written.
|
||||
*/
|
||||
Param.OutFile = fopen(header.filename, "wb+");
|
||||
if (Param.OutFile == NULL)
|
||||
{
|
||||
printf("Unable to open output data file %s\n",header.filename);
|
||||
/* Skip past this file and go on to the next one. */
|
||||
SkipFile(Param.InFile,Param.CompressedFileSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call explode to uncompress the file. */
|
||||
Param.Crc = (unsigned long) -1;
|
||||
error = explode(ReadBuff,WriteBuff,WorkBuff,&Param);
|
||||
Param.Crc = ~Param.Crc;
|
||||
if (error || (Param.OrigCrc != Param.Crc))
|
||||
{
|
||||
printf("Error in compressed file %s!\n",header.filename);
|
||||
}
|
||||
printf("Expanding file %s Original CRC = %lx Uncompressed CRC = %lx\n",header.filename,Param.OrigCrc,Param.Crc);
|
||||
/* Close the file we just created */
|
||||
fclose(Param.OutFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Skip past this file and go on to the next one. */
|
||||
SkipFile(Param.InFile,Param.CompressedFileSize);
|
||||
}
|
||||
}
|
||||
fclose(Param.InFile);
|
||||
}
|
||||
|
||||
/* The CompressFile function is used to compress a file into a
|
||||
** temporary file.
|
||||
*/
|
||||
void
|
||||
CompressFile(char *file, char *WorkBuff, PARAM *Param)
|
||||
{
|
||||
unsigned int type; /* Compression type */
|
||||
unsigned int dsize; /* Dictionary size */
|
||||
|
||||
/* Set the compression type to BINARY compression */
|
||||
type = CMP_BINARY;
|
||||
|
||||
/* Set the compression dictionary size to 4K */
|
||||
dsize = 4096;
|
||||
|
||||
/* Open the file to be compressed. */
|
||||
Param->InFile = fopen(file, "rb");
|
||||
if (Param->InFile == NULL)
|
||||
{
|
||||
puts("Unable to open input file");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Open the temporary file where the compressed data will be written. */
|
||||
Param->OutFile = fopen(TEMPNAME, "wb+");
|
||||
if (Param->OutFile == NULL)
|
||||
{
|
||||
printf("Unable to open temporary output file %s\n",Param->OutFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
Param->Crc = (unsigned long) -1;
|
||||
Param->UnCompressedFileSize = FileSize(Param->InFile);
|
||||
|
||||
/* Call implode() to compress the file. */
|
||||
implode(ReadBuff,WriteBuff,WorkBuff,Param,&type,&dsize);
|
||||
printf("Compressing file %s", file);
|
||||
printf(" File size = %ld bytes Compressed size = %ld bytes\n",
|
||||
Param->UnCompressedFileSize,Param->CompressedFileSize);
|
||||
|
||||
/* Close the temp file and the file being compressed */
|
||||
Param->OrigCrc = ~Param->Crc;
|
||||
fclose(Param->InFile);
|
||||
fclose(Param->OutFile);
|
||||
}
|
||||
}
|
||||
|
||||
/* The AppendFile function is used to copy the compressed data from
|
||||
** the temporary file to the compressed output file after the
|
||||
** header record for the file has been written.
|
||||
*/
|
||||
|
||||
void
|
||||
AppendFile(FILE *pDest,unsigned long Size)
|
||||
{
|
||||
char buf[BUFSIZE];
|
||||
unsigned long left;
|
||||
unsigned int Read;
|
||||
unsigned int written;
|
||||
FILE *pFile;
|
||||
|
||||
/* Keep track of the number of bytes that need to be appended */
|
||||
left = Size;
|
||||
|
||||
/* Open the temporary file containing the compressed input file
|
||||
** data. The contents of this file are then written to the
|
||||
** final output file.
|
||||
*/
|
||||
if ((pFile = fopen(TEMPNAME, "rb")) != NULL)
|
||||
{
|
||||
do
|
||||
{
|
||||
Read = fread(buf, 1, BUFSIZE, pFile);
|
||||
written = fwrite(buf, 1, Read, pDest);
|
||||
left -= (unsigned long)written;
|
||||
}
|
||||
while (left && written);
|
||||
fclose(pFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unable to open temporary file %s\n",TEMPNAME);
|
||||
}
|
||||
}
|
||||
|
||||
/* The WriteHeader function is used to format and write the
|
||||
** record header for each file compressed into the compressed
|
||||
** output file.
|
||||
*/
|
||||
void
|
||||
WriteHeader(char *filename, PARAM *Param)
|
||||
{
|
||||
HEADER header;
|
||||
int Written;
|
||||
|
||||
/* Save the filename and compressed file size in the structure */
|
||||
strcpy(header.filename, filename);
|
||||
header.CompSize = Param->CompressedFileSize;
|
||||
header.UnCompSize = Param->UnCompressedFileSize;
|
||||
header.Crc = Param->OrigCrc;
|
||||
|
||||
/* Save a signature, can be used to help rebuild a damaged file */
|
||||
header.signature[0] = 'D';
|
||||
header.signature[1] = 'H';
|
||||
header.signature[2] = 9;
|
||||
header.signature[3] = 2;
|
||||
|
||||
/* Write the data to the compressed archive file */
|
||||
Written = fwrite(&header, 1, sizeof(HEADER), Param->Destination);
|
||||
if (Written != sizeof(HEADER))
|
||||
{
|
||||
puts("Failed to write compressed file header record.");
|
||||
}
|
||||
}
|
||||
|
||||
/* The Compress function is used to compress each file specified
|
||||
** on the command line.
|
||||
*/
|
||||
void
|
||||
Compress(char *WorkBuff, int Files, char** FileList)
|
||||
{
|
||||
PARAM Param;
|
||||
int FileCount;
|
||||
|
||||
memset( &Param, 0, sizeof(Param) );
|
||||
|
||||
/* Open the file that will be the final output file for all
|
||||
** of the compressed input files.
|
||||
*/
|
||||
Param.Destination = fopen(COMPRESSED_FILE_NAME, "wb+");
|
||||
if (Param.Destination == NULL)
|
||||
{
|
||||
printf("Unable to open compressed output file %s\n",COMPRESSED_FILE_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For each file specified on the command line, compress the file,
|
||||
** write a header record for the file, then write the compressed
|
||||
** file data to the output file.
|
||||
*/
|
||||
for (FileCount = 1; FileCount < Files; FileCount++)
|
||||
{
|
||||
Param.Imploding = TRUE;
|
||||
Param.CompressedFileSize = 0L;
|
||||
Param.OrigCrc = 0L;
|
||||
CompressFile(FileList[FileCount], WorkBuff,&Param);
|
||||
WriteHeader(FileList[FileCount], &Param);
|
||||
AppendFile(Param.Destination,Param.CompressedFileSize);
|
||||
}
|
||||
|
||||
if( Param.InFile )
|
||||
fclose(Param.InFile);
|
||||
fclose(Param.Destination);
|
||||
unlink(TEMPNAME);
|
||||
}
|
||||
}
|
||||
|
||||
/* The main function simply allocates a work buffer needed for
|
||||
** calling the implode() and explode() functions, and then
|
||||
** calls the functions will compress and uncompress the
|
||||
** files specified on the commandline.
|
||||
*/
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *WorkBuff; /* Buffer for compression tables */
|
||||
|
||||
if( argc < 2 )
|
||||
{
|
||||
printf( "Usage: multfile filename(s)\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allocate the memory needed for implode(). The explode() routine
|
||||
** will use this same buffer, although it can generally use a
|
||||
** smaller sized buffer.
|
||||
*/
|
||||
WorkBuff = (char *)malloc(CMP_BUFFER_SIZE);
|
||||
|
||||
if (WorkBuff == NULL)
|
||||
{
|
||||
puts("Unable to allocate work buffer");
|
||||
return 1;
|
||||
}
|
||||
Compress(WorkBuff,argc,argv); /* Call Compress, pass the allocated memory */
|
||||
Expand(WorkBuff,argc); /* Call Expand, pass the allocated memory. */
|
||||
free(WorkBuff); /* Free the allocated memory */
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/***************************************************************
|
||||
PKWARE Data Compression Library (R) for Win32
|
||||
Copyright 1991,1992,1994,1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.
|
||||
***************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned int implode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param,
|
||||
unsigned int *type,
|
||||
unsigned int *dsize);
|
||||
|
||||
|
||||
unsigned int explode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param);
|
||||
|
||||
unsigned long crc32(char *buffer, unsigned int *size, unsigned long *old_crc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // End of 'extern "C"' declaration
|
||||
#endif
|
||||
|
||||
|
||||
#define CMP_BUFFER_SIZE 36312
|
||||
#define EXP_BUFFER_SIZE 12596
|
||||
|
||||
#define CMP_BINARY 0
|
||||
#define CMP_ASCII 1
|
||||
|
||||
#define CMP_NO_ERROR 0
|
||||
#define CMP_INVALID_DICTSIZE 1
|
||||
#define CMP_INVALID_MODE 2
|
||||
#define CMP_BAD_DATA 3
|
||||
#define CMP_ABORT 4
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
nmake makefile.msc
|
||||
@@ -0,0 +1 @@
|
||||
nmake makefdll.msc
|
||||
@@ -0,0 +1,18 @@
|
||||
ALL : WinDCL.exe
|
||||
|
||||
WinDCL.res : WinDCL.rc resource.h
|
||||
rc -r WinDCL.rc
|
||||
|
||||
WinDCL.obj : WinDCL.c WinDCL.h
|
||||
cl -c /D "_X86_" /D "WIN32" WinDCL.c
|
||||
|
||||
# rc WinDCL.res
|
||||
|
||||
LINK32_OBJS= \
|
||||
WINDCL.res \
|
||||
WINDCL.OBJ \
|
||||
|
||||
WinDcl.exe : WinDCL.res WinDCL.obj
|
||||
link /SUBSYSTEM:windows /INCREMENTAL:no /MACHINE:I386 /OUT:"windcl.exe" \
|
||||
$(LINK32_OBJS) ..\..\..\IMPLODEI.LIB
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
ALL : WinDCL.exe
|
||||
|
||||
WinDCL.res : WinDCL.rc resource.h
|
||||
rc -r WinDCL.rc
|
||||
|
||||
WinDCL.obj : WinDCL.c WinDCL.h
|
||||
cl -c /D "_X86_" /D "WIN32" WinDCL.c
|
||||
|
||||
# rc WinDCL.res
|
||||
|
||||
LINK32_OBJS= \
|
||||
WINDCL.res \
|
||||
WINDCL.OBJ \
|
||||
|
||||
WinDcl.exe : WinDCL.res WinDCL.obj
|
||||
link /SUBSYSTEM:windows /INCREMENTAL:no /MACHINE:I386 /OUT:"windcl.exe" \
|
||||
$(LINK32_OBJS) ..\..\..\IMPLODE.LIB
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#define IDM_TEST_DCL 1000
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "resource.h"
|
||||
#include "WinDCL.h"
|
||||
#include "implode.h"
|
||||
|
||||
void TestDLL(void);
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma argsused
|
||||
#endif
|
||||
|
||||
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
|
||||
{
|
||||
WNDCLASS wndclass;
|
||||
MSG msg;
|
||||
|
||||
// Get rid of any compiler warnings
|
||||
lpszCmdLine = lpszCmdLine;
|
||||
|
||||
hInst = hInstance;
|
||||
|
||||
// Register the DCL Test window Class
|
||||
if(!hPrevInstance)
|
||||
{
|
||||
wndclass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wndclass.lpfnWndProc = WndProc;
|
||||
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = hInst;
|
||||
wndclass.hIcon = LoadIcon(hInst, "WinDCL");
|
||||
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wndclass.lpszMenuName = "WinDCL";
|
||||
wndclass.lpszClassName = "WinDCL";
|
||||
|
||||
if (!RegisterClass(&wndclass))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// create Main window
|
||||
hWndMain = CreateWindow(
|
||||
"WinDCL",
|
||||
"DCL Example", // no title
|
||||
WS_CAPTION | // Title and Min/Max
|
||||
WS_SYSMENU | // Add system menu box
|
||||
WS_MINIMIZEBOX | // Add minimize box
|
||||
WS_MAXIMIZEBOX | // Add maximize box
|
||||
WS_THICKFRAME | // thick sizeable frame
|
||||
WS_CLIPCHILDREN | // don't draw in child windows areas
|
||||
WS_VISIBLE | // window created visible
|
||||
WS_OVERLAPPED,
|
||||
CW_USEDEFAULT, 0, // Use default X, Y
|
||||
CW_USEDEFAULT, 0, // Use default X, Y
|
||||
NULL, // Parent window's handle
|
||||
NULL, // Default to Class Menu
|
||||
hInst, // Instance of window
|
||||
NULL); // Create struct for WM_CREATE
|
||||
|
||||
// Did the Create Work??
|
||||
if(hWndMain == NULL)
|
||||
return 0;
|
||||
|
||||
ShowWindow(hWndMain, nCmdShow);
|
||||
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (Message)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
if (wParam == IDM_TEST_DCL)
|
||||
TestDLL();
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, Message, wParam, lParam);
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
UINT ProcessInBuffer(PCHAR buffer, UINT *iSize, void *pParam)
|
||||
{
|
||||
LPIOFILEBLOCK lpFileIOBlock;
|
||||
unsigned int iRead;
|
||||
|
||||
lpFileIOBlock = (LPIOFILEBLOCK) pParam;
|
||||
|
||||
iRead = fread(buffer, 1, *iSize, lpFileIOBlock->InFile );
|
||||
|
||||
if( iRead > 0 && lpFileIOBlock->bDoCRC == DO_CRC_INSTREAM )
|
||||
lpFileIOBlock->dwCRC = crc32(buffer, &iRead, &lpFileIOBlock->dwCRC);
|
||||
|
||||
return iRead;
|
||||
}
|
||||
|
||||
void ProcessOutBuffer(PCHAR buffer, UINT *iSize, void *pParam)
|
||||
{
|
||||
LPIOFILEBLOCK lpFileIOBlock;
|
||||
unsigned int iWrite;
|
||||
|
||||
lpFileIOBlock = (LPIOFILEBLOCK) pParam;
|
||||
|
||||
iWrite = fwrite( buffer, 1, *iSize, lpFileIOBlock->OutFile );
|
||||
|
||||
if( lpFileIOBlock->bDoCRC == DO_CRC_OUTSTREAM )
|
||||
lpFileIOBlock->dwCRC = crc32(buffer, &iWrite, &lpFileIOBlock->dwCRC);
|
||||
}
|
||||
|
||||
void TestDLL()
|
||||
{
|
||||
int iStatus;
|
||||
char szVerbose[128];
|
||||
IOFILEBLOCK FileIOBlock;
|
||||
HGLOBAL hWorkBuff;
|
||||
PCHAR pWorkBuff;
|
||||
unsigned int type; /* ASCII or Binary compression */
|
||||
unsigned int dsize; /* Dictionary Size. 1,2 or 4K */
|
||||
|
||||
type = CMP_ASCII; /* Use ASCII compression */
|
||||
dsize = 4096; /* Use 4K dictionary */
|
||||
|
||||
// allocate the memory block for the scratch pad
|
||||
if( (hWorkBuff = GlobalAlloc(GHND, CMP_BUFFER_SIZE)) == NULL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((pWorkBuff = (LPSTR) GlobalLock(hWorkBuff)) == NULL)
|
||||
{
|
||||
GlobalFree(hWorkBuff);
|
||||
return;
|
||||
}
|
||||
|
||||
// setup structure used by ProcessReadBuffer() and ProcessWriteBuffer()
|
||||
FileIOBlock.InFile = fopen( "Test.in", "rb" );
|
||||
FileIOBlock.OutFile = fopen( "Test.cmp", "wb" );
|
||||
FileIOBlock.bDoCRC = DO_CRC_INSTREAM;
|
||||
FileIOBlock.dwCRC = ~((DWORD)0); // Pre-condition CRC
|
||||
|
||||
if( (FileIOBlock.InFile != NULL) && (FileIOBlock.OutFile != NULL) )
|
||||
{
|
||||
MessageBox(NULL, "Ready to implode", "Notice", MB_OK);
|
||||
|
||||
iStatus = implode(ProcessInBuffer,
|
||||
ProcessOutBuffer,
|
||||
pWorkBuff,
|
||||
&FileIOBlock,
|
||||
&type, &dsize );
|
||||
|
||||
if( iStatus != 0 )
|
||||
{
|
||||
wsprintf(szVerbose, "Implode Error: %d", iStatus );
|
||||
MessageBox(NULL, szVerbose, "Error", MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Post-condition CRC
|
||||
if (FileIOBlock.bDoCRC == DO_CRC_INSTREAM)
|
||||
{
|
||||
FileIOBlock.dwCRC = ~FileIOBlock.dwCRC;
|
||||
wsprintf(szVerbose, "CRC of input file: %lX", FileIOBlock.dwCRC);
|
||||
MessageBox(NULL, szVerbose, "Notice", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(FileIOBlock.OutFile);
|
||||
fclose(FileIOBlock.InFile);
|
||||
|
||||
if( iStatus == 0 )
|
||||
{
|
||||
// setup structure used by ProcessReadBuffer() and ProcessWriteBuffer()
|
||||
FileIOBlock.InFile = fopen( "Test.cmp", "rb" );
|
||||
FileIOBlock.OutFile = fopen( "Test.ext", "wb" );
|
||||
FileIOBlock.bDoCRC = DO_CRC_OUTSTREAM;
|
||||
FileIOBlock.dwCRC = ~((DWORD)0); // Pre-condition CRC
|
||||
|
||||
MessageBox(NULL, "Ready to explode", "Notice", MB_OK);
|
||||
iStatus = explode(ProcessInBuffer,
|
||||
ProcessOutBuffer,
|
||||
pWorkBuff,
|
||||
&FileIOBlock );
|
||||
|
||||
if( iStatus != 0 )
|
||||
{
|
||||
wsprintf(szVerbose, "Explode Error: %d", iStatus );
|
||||
MessageBox(NULL, szVerbose, "Error", MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Post-condition CRC
|
||||
if (FileIOBlock.bDoCRC == DO_CRC_OUTSTREAM)
|
||||
{
|
||||
FileIOBlock.dwCRC = ~FileIOBlock.dwCRC;
|
||||
wsprintf(szVerbose, "CRC of exploded file: %lX", FileIOBlock.dwCRC);
|
||||
MessageBox(NULL, szVerbose, "Notice", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(FileIOBlock.OutFile);
|
||||
fclose(FileIOBlock.InFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( FileIOBlock.InFile != NULL )
|
||||
{
|
||||
fclose( FileIOBlock.InFile );
|
||||
}
|
||||
|
||||
if( FileIOBlock.OutFile != NULL )
|
||||
{
|
||||
fclose( FileIOBlock.OutFile );
|
||||
}
|
||||
|
||||
MessageBox(NULL, "The file TEST.IN must be in the current directory", "Error", MB_OK);
|
||||
}
|
||||
|
||||
GlobalUnlock(hWorkBuff);
|
||||
GlobalFree(hWorkBuff);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
#define DO_CRC_INSTREAM 1
|
||||
#define DO_CRC_OUTSTREAM 2
|
||||
|
||||
#define WM_FAILEDVALIDATE (WM_USER + 1)
|
||||
|
||||
typedef struct IOFILEBLOCK {
|
||||
FILE *InFile;
|
||||
FILE *OutFile;
|
||||
BOOL bDoCRC;
|
||||
DWORD dwCRC;
|
||||
}IOFILEBLOCK, *LPIOFILEBLOCK;
|
||||
|
||||
HWND hInst;
|
||||
HWND hWndMain;
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 766 B |
Binary file not shown.
@@ -0,0 +1,9 @@
|
||||
#include "resource.h"
|
||||
|
||||
WinDcl ICON "WinDcl.ico"
|
||||
|
||||
WinDCL MENU
|
||||
BEGIN
|
||||
MENUITEM "&Test DCL", IDM_TEST_DCL
|
||||
END
|
||||
|
||||
@@ -0,0 +1,497 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "implode.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COMPRESSING = 1,
|
||||
UNCOMPRESSING
|
||||
} FILEMODE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PBYTE Buffer; // POINTER TO BUFFER
|
||||
UINT CurPos; // CURRENT POSITION IN BUFFER
|
||||
UINT BuffSize; // SIZE OF THE BUFFER
|
||||
} BUFFER_BLOCK, *PBUFFER_BLOCK;
|
||||
|
||||
// STRUCT TO PASS TO THE FILE IO FUNCTIONS
|
||||
typedef struct
|
||||
{
|
||||
BUFFER_BLOCK FileBuff; // FILE BUFFER
|
||||
BUFFER_BLOCK cmpBuff; // COMPRESSION BUFFER
|
||||
BUFFER_BLOCK uncmpBuff; // UNCOMPRESSION BUFFER
|
||||
FILEMODE mode;
|
||||
ULONG ulCrc; // CRC
|
||||
UINT nCompressSize;
|
||||
BOOL ErrorOccurred; // ERROR FLAG
|
||||
} DATABLOCK, *PDATABLOCK;
|
||||
|
||||
UINT DataType = CMP_ASCII; // GLOBAL FOR DATA TYPE FOR COMPRESSION
|
||||
UINT DictSize = 4096; // GLOBAL FOR DICTIONARY SIZE FOR COMPRESSION
|
||||
|
||||
static int iLineCnt; // CURRENT LINE TO OUTPUT STRING
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: ReadBuffer()
|
||||
*
|
||||
* Purpose: To handle calls from the Data Compression Library for
|
||||
* read requests. If compressing, then the data read is
|
||||
* in uncompressed form. If compressing, then the data
|
||||
* read is data that was previously compressed. This
|
||||
* function is called until zero is returned.
|
||||
*
|
||||
* Parameters: buffer -> Address of buffer to read the data into
|
||||
* iSize -> Number of bytes to read into buffer
|
||||
* dwParam -> User-defined parameter, in this case a
|
||||
* pointer to the DATABLOCK
|
||||
*
|
||||
* Returns: Number of bytes actually read, or zero on EOF
|
||||
*
|
||||
*********************************************************************/
|
||||
UINT ReadBuffer( PCHAR buffer, UINT *iSize, void *pParam )
|
||||
{
|
||||
PDATABLOCK pDataBlock;
|
||||
PBUFFER_BLOCK pBufferBlock;
|
||||
UINT iRead;
|
||||
UINT Num2Read = *iSize;
|
||||
|
||||
pDataBlock = (PDATABLOCK) pParam;
|
||||
|
||||
// IF AN ERROR OCCURRED
|
||||
if( pDataBlock->ErrorOccurred == TRUE )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( pDataBlock->mode == COMPRESSING )
|
||||
{
|
||||
// SINCE COMPRESSING THEN WANT TO WRITE DATA TO THE COMPRESSION BUFFER
|
||||
pBufferBlock = &pDataBlock->FileBuff;
|
||||
}
|
||||
else
|
||||
{
|
||||
// SINCE COMPRESSING THEN WANT TO WRITE DATA TO THE UNCOMPRESSION BUFFER
|
||||
pBufferBlock = &pDataBlock->cmpBuff;
|
||||
}
|
||||
|
||||
if( pBufferBlock->CurPos < pBufferBlock->BuffSize )
|
||||
{
|
||||
UINT BytesLeft = pBufferBlock->BuffSize - pBufferBlock->CurPos;
|
||||
|
||||
// IF REQUESTING MORE BYTES THAN ARE LEFT
|
||||
if( BytesLeft < Num2Read )
|
||||
{
|
||||
// SET NUMBER OF BYTES TO COPY TO WHAT IS LEFT
|
||||
Num2Read = BytesLeft;
|
||||
}
|
||||
|
||||
// COPY BYTES AND UPDATE COUNTER
|
||||
memcpy( buffer, (pBufferBlock->Buffer + pBufferBlock->CurPos), Num2Read );
|
||||
pBufferBlock->CurPos += Num2Read;
|
||||
|
||||
iRead = Num2Read;
|
||||
}
|
||||
else // ELSE - NOTHING LEFT IN BUFFER SO RETURN 0
|
||||
{
|
||||
iRead = 0;
|
||||
}
|
||||
|
||||
// IF COMPRESSING, THEN CALCULATE THE CRC
|
||||
if( pDataBlock->mode == COMPRESSING )
|
||||
{
|
||||
pDataBlock->ulCrc = crc32( buffer, &iRead, &pDataBlock->ulCrc );
|
||||
}
|
||||
|
||||
return iRead;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: WriteBuffer()
|
||||
*
|
||||
* Purpose: To handle calls from the Data Compression Library for
|
||||
* write requests.
|
||||
*
|
||||
* Parameters: buffer -> Address of buffer to write data from
|
||||
* iSize -> Number of bytes to write
|
||||
* dwParam -> User-defined parameter, in this case a
|
||||
* pointer to the DATABLOCK
|
||||
*
|
||||
* Returns: Zero, the return value is not used by the Data
|
||||
* Compression Library
|
||||
*
|
||||
*********************************************************************/
|
||||
void WriteBuffer( PCHAR buffer, UINT *iSize, void *pParam )
|
||||
{
|
||||
PDATABLOCK pDataBlock;
|
||||
PBUFFER_BLOCK pBufferBlock;
|
||||
UINT Num2Write;
|
||||
|
||||
Num2Write = *iSize;
|
||||
|
||||
pDataBlock = (PDATABLOCK) pParam;
|
||||
|
||||
// IF AN ERROR OCCURRED
|
||||
if( pDataBlock->ErrorOccurred == TRUE )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( pDataBlock->mode == COMPRESSING )
|
||||
{
|
||||
// SINCE COMPRESSING THEN WANT TO WRITE DATA TO THE COMPRESSION BUFFER
|
||||
pBufferBlock = &pDataBlock->cmpBuff;
|
||||
|
||||
// SINCE COMPRESSING, KEEP A TOTAL OF THE COMPRESSED FILE SIZE
|
||||
pDataBlock->nCompressSize += Num2Write;
|
||||
}
|
||||
else
|
||||
{
|
||||
// SINCE COMPRESSING THEN WANT TO WRITE DATA TO THE UNCOMPRESSION BUFFER
|
||||
pBufferBlock = &pDataBlock->uncmpBuff;
|
||||
}
|
||||
|
||||
// IF NOT OUT OF BUFFER SPACE
|
||||
if( pBufferBlock->CurPos < pBufferBlock->BuffSize )
|
||||
{
|
||||
// IF WRITING MORE BYTES THAN ARE LEFT
|
||||
if( (pBufferBlock->BuffSize - pBufferBlock->CurPos) < Num2Write )
|
||||
{
|
||||
MessageBox( NULL, "Out of buffer space - #1", "Compression Error", MB_OK );
|
||||
pDataBlock->ErrorOccurred = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
// COPY BYTES AND UPDATE COUNTER
|
||||
memcpy( (pBufferBlock->Buffer + pBufferBlock->CurPos),
|
||||
buffer, Num2Write );
|
||||
pBufferBlock->CurPos += Num2Write;
|
||||
}
|
||||
else // ELSE - NOTHING LEFT IN BUFFER SO RETURN 0
|
||||
{
|
||||
MessageBox( NULL, "Out of buffer space - #2", "Compression Error", MB_OK );
|
||||
pDataBlock->ErrorOccurred = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
// IF COMPRESSING, THEN CALCULATE THE CRC
|
||||
if (pDataBlock->mode == UNCOMPRESSING )
|
||||
{
|
||||
pDataBlock->ulCrc = crc32( buffer, &Num2Write, &pDataBlock->ulCrc );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: CompressMemToMem()
|
||||
*
|
||||
* Purpose: To compress a buffer to another buffer in memory.
|
||||
*
|
||||
*
|
||||
* Parameters: HWnd -> Handle to window
|
||||
* pDC -> Pointer to a device context
|
||||
* pulCrc -> Pointer to DWORD buffer to return the CRC
|
||||
* of the compressed file before compression
|
||||
* pnCompressedSize -> Number of bytes in the compressed
|
||||
* buffer
|
||||
* pFileBuffer -> Pointer to buffer to compress
|
||||
* pCompressedBuffer -> Pointer to buffer to place
|
||||
* compressed data
|
||||
* BuffSize -> Size of the buffers (both are allocated
|
||||
* for same number of bytes)
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int CompressMemToMem( HWND hWnd, HDC hDC, ULONG *pulCrc,
|
||||
UINT *pnCompressedSize, PBYTE pFileBuffer,
|
||||
PBYTE pCompressedBuffer, UINT BuffSize )
|
||||
{
|
||||
int iStatus;
|
||||
int rc = 1;
|
||||
char szVerbose[128];
|
||||
DATABLOCK DataBlock;
|
||||
HGLOBAL hWorkBuff;
|
||||
PCHAR pWorkBuff;
|
||||
|
||||
// allocate the memory block for the scratch pad
|
||||
if( (hWorkBuff = GlobalAlloc(GHND, CMP_BUFFER_SIZE)) == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((pWorkBuff = (LPSTR) GlobalLock(hWorkBuff)) == NULL)
|
||||
{
|
||||
GlobalFree(hWorkBuff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset( &DataBlock, 0, sizeof(DataBlock) );
|
||||
|
||||
// SETUP STRUCTURE USED BY ProcessReadBuffer() AND ProcessWriteBuffer()
|
||||
DataBlock.mode = COMPRESSING;
|
||||
DataBlock.ulCrc = ~((DWORD)0); // Pre-condition CRC
|
||||
|
||||
// SETUP BUFFER BLOCK FOR FILE BUFFER
|
||||
DataBlock.FileBuff.Buffer = pFileBuffer;
|
||||
DataBlock.FileBuff.BuffSize = BuffSize;
|
||||
|
||||
// SETUP BUFFER BLOCK FOR COMPRESSION BUFFER
|
||||
DataBlock.cmpBuff.Buffer = pCompressedBuffer;
|
||||
DataBlock.cmpBuff.BuffSize = BuffSize;
|
||||
|
||||
wsprintf( szVerbose, "Compressing %u byte buffer to memory ", BuffSize );
|
||||
TextOut( hDC, 10, (iLineCnt++ * 20) + 5, szVerbose, strlen(szVerbose) );
|
||||
|
||||
// COMPRESS THE FILE
|
||||
iStatus = implode( ReadBuffer, WriteBuffer,
|
||||
pWorkBuff, &DataBlock, &DataType, &DictSize );
|
||||
|
||||
// IF THERE WAS AN ERROR COMPRESSING FILE
|
||||
if( iStatus || DataBlock.ErrorOccurred )
|
||||
{
|
||||
wsprintf( szVerbose, "Error occurred while imploding - %d ", iStatus );
|
||||
MessageBox( hWnd, szVerbose, "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
else // ELSE - COMPRESSION WAS SUCCESSFUL
|
||||
{
|
||||
// POST-CONDITION CRC
|
||||
DataBlock.ulCrc = ~DataBlock.ulCrc;
|
||||
|
||||
// RETURN CRC
|
||||
*pulCrc = DataBlock.ulCrc;
|
||||
|
||||
// RETURN COMPRESSED BUFFER SIZE
|
||||
*pnCompressedSize = DataBlock.nCompressSize;
|
||||
|
||||
wsprintf( szVerbose, "Compressed file to memory -> CRC = %08lX ",
|
||||
DataBlock.ulCrc );
|
||||
TextOut( hDC, 10, (iLineCnt++ * 20) + 5, szVerbose, strlen(szVerbose) );
|
||||
}
|
||||
|
||||
GlobalUnlock(hWorkBuff);
|
||||
GlobalFree(hWorkBuff);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: ExpandMemToMem()
|
||||
*
|
||||
* Purpose: To expand a compressed buffer to a buffer in memory.
|
||||
*
|
||||
*
|
||||
* Parameters: HWnd -> Handle to window
|
||||
* pDC -> Pointer to a device context
|
||||
* pulCrc -> Pointer to DWORD buffer to return the CRC
|
||||
* of the compressed file after uncompression
|
||||
* pCompressedBuffer -> Pointer to buffer to place
|
||||
* compressed data
|
||||
* nCompressedSize -> Number of bytes in the compressed
|
||||
* buffer
|
||||
* pUncompressedBuffer -> Pointer to buffer to place
|
||||
* uncompressed data
|
||||
* BuffSize -> Size of the uncompressed buffer
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int ExpandMemToMem( HWND hWnd, HDC hDC, ULONG *pulCrc,
|
||||
PBYTE pCompressedBuffer, UINT nCompressedSize,
|
||||
PBYTE pUncompressedBuffer, UINT BuffSize )
|
||||
{
|
||||
int iStatus;
|
||||
int rc = 1;
|
||||
char szVerbose[128];
|
||||
DATABLOCK DataBlock;
|
||||
HGLOBAL hWorkBuff;
|
||||
PCHAR pWorkBuff;
|
||||
|
||||
// allocate the memory block for the scratch pad
|
||||
if( (hWorkBuff = GlobalAlloc(GHND, CMP_BUFFER_SIZE)) == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((pWorkBuff = (LPSTR) GlobalLock(hWorkBuff)) == NULL)
|
||||
{
|
||||
GlobalFree(hWorkBuff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset( &DataBlock, 0, sizeof(DataBlock) );
|
||||
|
||||
// SETUP STRUCTURE USED BY ProcessReadBuffer() AND ProcessWriteBuffer()
|
||||
DataBlock.mode = UNCOMPRESSING;
|
||||
DataBlock.ulCrc = ~((DWORD)0); // Pre-condition CRC
|
||||
|
||||
// SETUP BUFFER BLOCK FOR COMPRESSION BUFFER
|
||||
DataBlock.cmpBuff.Buffer = pCompressedBuffer;
|
||||
DataBlock.cmpBuff.BuffSize = nCompressedSize;
|
||||
|
||||
// SETUP BUFFER BLOCK FOR UNCOMPRESSION BUFFER
|
||||
DataBlock.uncmpBuff.Buffer = pUncompressedBuffer;
|
||||
DataBlock.uncmpBuff.BuffSize = BuffSize;
|
||||
|
||||
wsprintf( szVerbose, "Compressed buffer size = %u ", nCompressedSize );
|
||||
TextOut( hDC, 10, (iLineCnt++ * 20) + 5, szVerbose, strlen(szVerbose) );
|
||||
|
||||
TextOut( hDC, 10, (iLineCnt++ * 20) + 5, "Uncompressing buffer to memory ", 32 );
|
||||
|
||||
// UNCOMPRESS THE FILE
|
||||
iStatus = explode( ReadBuffer, WriteBuffer, pWorkBuff, &DataBlock );
|
||||
|
||||
// IF THERE WAS AN ERROR UNCOMPRESSING FILE
|
||||
if( iStatus || DataBlock.ErrorOccurred )
|
||||
{
|
||||
wsprintf( szVerbose, "Error occurred while exploding - %d ", iStatus );
|
||||
MessageBox( hWnd, szVerbose, "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
else // ELSE - UNCOMPRESSION WAS SUCCESSFUL
|
||||
{
|
||||
// POST-CONDITION CRC
|
||||
DataBlock.ulCrc = ~DataBlock.ulCrc;
|
||||
|
||||
// RETURN CRC
|
||||
*pulCrc = DataBlock.ulCrc;
|
||||
|
||||
wsprintf( szVerbose, "Uncompressed file to memory -> CRC = %08lX ",
|
||||
DataBlock.ulCrc );
|
||||
TextOut( hDC, 10, (iLineCnt++ * 20) + 5, szVerbose, strlen(szVerbose) );
|
||||
}
|
||||
|
||||
GlobalUnlock(hWorkBuff);
|
||||
GlobalFree(hWorkBuff);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: MemToMemExample()
|
||||
*
|
||||
* Purpose: To load a file into memory. Then compress and uncompress
|
||||
* the buffer in memory.
|
||||
*
|
||||
*
|
||||
* Parameters: HWnd -> Handle to window
|
||||
* pDC -> Pointer to a device context
|
||||
* pszFilename -> Name of file to load
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int MemToMemExample( HWND hWnd, HDC hDC, PCHAR pszFilename )
|
||||
{
|
||||
FILE *InFile;
|
||||
int rc=1; // RETURN CODE
|
||||
UINT BufferSize;
|
||||
UINT cmpSize;
|
||||
PBYTE pFileBuffer; // BUFFER FOR FILE DATA
|
||||
PBYTE pCompressedBuffer; // BUFFER FOR THE COMPRESSED DATA
|
||||
PBYTE pUncompressedBuffer; // BUFFER FOR THE UNCOMPRESSED DATA
|
||||
DWORD cmpCrc; // CRC OF FILE BEFORE COMPRESSION
|
||||
DWORD uncmpCrc; // CRC OF FILE AFTER UNCOMPRESSION
|
||||
fpos_t FileSize;
|
||||
|
||||
|
||||
iLineCnt = 0;
|
||||
|
||||
// OPEN THE FILE
|
||||
InFile = fopen( pszFilename, "rb" );
|
||||
if( InFile == NULL )
|
||||
{
|
||||
MessageBox( hWnd, "Error opening file for compression", "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek( InFile, 0, SEEK_END );
|
||||
|
||||
// CHECK IF FILE IS TOO LARGE
|
||||
if( fgetpos( InFile, &FileSize ) || FileSize > 64000U )
|
||||
{
|
||||
MessageBox( hWnd, "File is too large to compress to memory", "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek( InFile, 0, SEEK_SET );
|
||||
|
||||
BufferSize = (UINT) FileSize;
|
||||
|
||||
// ALLOCATE BUFFER MEMORY
|
||||
pFileBuffer = (PBYTE) malloc(BufferSize);
|
||||
pCompressedBuffer = (PBYTE) malloc(BufferSize);
|
||||
pUncompressedBuffer = (PBYTE) malloc(BufferSize);
|
||||
|
||||
// IF SUCCESSFULLY ALLOCATED MEMORY
|
||||
if( (pFileBuffer != NULL) &&
|
||||
(pCompressedBuffer != NULL) &&
|
||||
(pUncompressedBuffer != NULL) )
|
||||
{
|
||||
// READ FILE
|
||||
fread( pFileBuffer, 1, BufferSize, InFile );
|
||||
|
||||
// IF COMPRESSED OK
|
||||
if( CompressMemToMem( hWnd, hDC, &cmpCrc, &cmpSize,
|
||||
pFileBuffer, pCompressedBuffer, BufferSize ) )
|
||||
{
|
||||
// IF ERROR UNCOMPRESSING
|
||||
if( !ExpandMemToMem( hWnd, hDC, &uncmpCrc,
|
||||
pCompressedBuffer, cmpSize,
|
||||
pUncompressedBuffer, BufferSize ) )
|
||||
{
|
||||
MessageBox( hWnd, "Error uncompressing to memory", "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox( hWnd, "Error compressing to memory", "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( pFileBuffer != NULL )
|
||||
{
|
||||
free(pFileBuffer);
|
||||
}
|
||||
|
||||
if( pCompressedBuffer != NULL )
|
||||
{
|
||||
free(pCompressedBuffer);
|
||||
}
|
||||
|
||||
if( pUncompressedBuffer != NULL )
|
||||
{
|
||||
free(pUncompressedBuffer);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
int MemToMemExample( HWND hWnd, CDC *pDC, LPSTR lpszFilename );
|
||||
@@ -0,0 +1,44 @@
|
||||
/***************************************************************
|
||||
PKWARE Data Compression Library (R) for Win32
|
||||
Copyright 1991,1992,1994,1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.
|
||||
***************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned int implode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param,
|
||||
unsigned int *type,
|
||||
unsigned int *dsize);
|
||||
|
||||
|
||||
unsigned int explode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param);
|
||||
|
||||
unsigned long crc32(char *buffer, unsigned int *size, unsigned long *old_crc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // End of 'extern "C"' declaration
|
||||
#endif
|
||||
|
||||
|
||||
#define CMP_BUFFER_SIZE 36312
|
||||
#define EXP_BUFFER_SIZE 12596
|
||||
|
||||
#define CMP_BINARY 0
|
||||
#define CMP_ASCII 1
|
||||
|
||||
#define CMP_NO_ERROR 0
|
||||
#define CMP_INVALID_DICTSIZE 1
|
||||
#define CMP_INVALID_MODE 2
|
||||
#define CMP_BAD_DATA 3
|
||||
#define CMP_ABORT 4
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
nmake makefile.msc
|
||||
@@ -0,0 +1 @@
|
||||
nmake makefdll.msc
|
||||
@@ -0,0 +1,22 @@
|
||||
ALL : WINDCL.EXE
|
||||
|
||||
WINDCL.RES : WINDCL.RC RESOURCE.H
|
||||
rc -r WinDCL.rc
|
||||
|
||||
WINDCL.OBJ : WINDCL.C WINDCL.H
|
||||
cl -c /D "_X86_" /D "WIN32" WinDCL.c
|
||||
|
||||
DCL.OBJ : DCL.C DCL.H
|
||||
cl -c /D "_X86_" /D "WIN32" DCL.C
|
||||
|
||||
# rc WinDCL.res
|
||||
|
||||
LINK32_OBJS= \
|
||||
WINDCL.res \
|
||||
WINDCL.OBJ \
|
||||
DCL.OBJ
|
||||
|
||||
WINDCL.EXE : WINDCL.RES WINDCL.OBJ DCL.OBJ
|
||||
link /SUBSYSTEM:windows /INCREMENTAL:no /MACHINE:I386 /OUT:"windcl.exe" \
|
||||
$(LINK32_OBJS) ..\..\..\IMPLODEI.LIB GDI32.LIB
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
ALL : WINDCL.EXE
|
||||
|
||||
WINDCL.RES : WINDCL.RC RESOURCE.H
|
||||
rc -r WinDCL.rc
|
||||
|
||||
WINDCL.OBJ : WINDCL.C WINDCL.H
|
||||
cl -c /D "_X86_" /D "WIN32" WinDCL.c
|
||||
|
||||
DCL.OBJ : DCL.C DCL.H
|
||||
cl -c /D "_X86_" /D "WIN32" DCL.C
|
||||
|
||||
# rc WinDCL.res
|
||||
|
||||
LINK32_OBJS= \
|
||||
WINDCL.res \
|
||||
WINDCL.OBJ \
|
||||
DCL.OBJ
|
||||
|
||||
WINDCL.EXE : WINDCL.RES WINDCL.OBJ DCL.OBJ
|
||||
link /SUBSYSTEM:windows /INCREMENTAL:no /MACHINE:I386 /OUT:"windcl.exe" \
|
||||
$(LINK32_OBJS) ..\..\..\IMPLODE.LIB GDI32.LIB
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#define IDM_TEST_DCL 1000
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "resource.h"
|
||||
#include "WinDCL.h"
|
||||
#include "implode.h"
|
||||
|
||||
void TestDLL(void);
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma argsused
|
||||
#endif
|
||||
|
||||
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
|
||||
{
|
||||
WNDCLASS wndclass;
|
||||
MSG msg;
|
||||
|
||||
// Get rid of any compiler warnings
|
||||
lpszCmdLine = lpszCmdLine;
|
||||
|
||||
hInst = hInstance;
|
||||
|
||||
// Register the DCL Test window Class
|
||||
if(!hPrevInstance)
|
||||
{
|
||||
wndclass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wndclass.lpfnWndProc = WndProc;
|
||||
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = hInst;
|
||||
wndclass.hIcon = LoadIcon(hInst, "WinDCL");
|
||||
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wndclass.lpszMenuName = "WinDCL";
|
||||
wndclass.lpszClassName = "WinDCL";
|
||||
|
||||
if (!RegisterClass(&wndclass))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// create Main window
|
||||
hWndMain = CreateWindow(
|
||||
"WinDCL",
|
||||
"DCL Example", // no title
|
||||
WS_CAPTION | // Title and Min/Max
|
||||
WS_SYSMENU | // Add system menu box
|
||||
WS_MINIMIZEBOX | // Add minimize box
|
||||
WS_MAXIMIZEBOX | // Add maximize box
|
||||
WS_THICKFRAME | // thick sizeable frame
|
||||
WS_CLIPCHILDREN | // don't draw in child windows areas
|
||||
WS_VISIBLE | // window created visible
|
||||
WS_OVERLAPPED,
|
||||
CW_USEDEFAULT, 0, // Use default X, Y
|
||||
CW_USEDEFAULT, 0, // Use default X, Y
|
||||
NULL, // Parent window's handle
|
||||
NULL, // Default to Class Menu
|
||||
hInst, // Instance of window
|
||||
NULL); // Create struct for WM_CREATE
|
||||
|
||||
// Did the Create Work??
|
||||
if(hWndMain == NULL)
|
||||
return 0;
|
||||
|
||||
ShowWindow(hWndMain, nCmdShow);
|
||||
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (Message)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
if (wParam == IDM_TEST_DCL)
|
||||
{
|
||||
HDC hDC;
|
||||
|
||||
hDC = GetDC( hWnd );
|
||||
SetBkMode( hDC, TRANSPARENT );
|
||||
MemToMemExample( hWnd, hDC, "TEST.IN" );
|
||||
ReleaseDC( hWnd, hDC );
|
||||
}
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, Message, wParam, lParam);
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
HWND hInst;
|
||||
HWND hWndMain;
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
int MemToMemExample( HWND hWnd, HDC hDC, PCHAR pszFilename );
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 766 B |
Binary file not shown.
@@ -0,0 +1,9 @@
|
||||
#include "resource.h"
|
||||
|
||||
WinDcl ICON "WinDcl.ico"
|
||||
|
||||
WinDCL MENU
|
||||
BEGIN
|
||||
MENUITEM "&Test DCL", IDM_TEST_DCL
|
||||
END
|
||||
|
||||
@@ -0,0 +1,424 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// compdlg.cpp : implementation file
|
||||
//
|
||||
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <stdio.h>
|
||||
#include "dcl.h"
|
||||
|
||||
// Start, Added by PKWARE
|
||||
#include "implode.h"
|
||||
#include "PKstruct.h"
|
||||
#include "compdlg.h"
|
||||
|
||||
static char CancelCompression[] = "Cancel Compression";
|
||||
|
||||
#define DO_CRC_INSTREAM 1
|
||||
#define DO_CRC_OUTSTREAM 2
|
||||
|
||||
void ProcessOutBuffer(PCHAR buffer, UINT *iSize, void *Param);
|
||||
UINT ProcessInBuffer(PCHAR buffer, UINT *iSize, void *pParam);
|
||||
|
||||
void PKCompressFile(void);
|
||||
// End, added by PKWARE
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCompDlg dialog
|
||||
|
||||
|
||||
CCompDlg::CCompDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CCompDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CCompDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CCompDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CCompDlg)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCompDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CCompDlg)
|
||||
ON_BN_CLICKED(IDC_BUTTON1, OnCompressButton)
|
||||
ON_BN_CLICKED(IDC_BUTTON2, OnTestButton)
|
||||
ON_BN_CLICKED(IDC_BUTTON3, OnClearButton)
|
||||
ON_BN_CLICKED(IDC_BUTTON4, OnDebugButton)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCompDlg message handlers
|
||||
BOOL CCompDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
SetDlgItemText(IDC_EDIT1, "TEST.IN");
|
||||
SetDlgItemText(IDC_EDIT9, "?");
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON2), FALSE); // Disable the Extract button
|
||||
DebugMessages = FALSE;
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
}
|
||||
|
||||
// Function to add an item to the listbox. The listbox is then scrolled to display this item
|
||||
void CCompDlg::PKLBMessage(char *message)
|
||||
{
|
||||
SendDlgItemMessage(IDC_LIST1, LB_ADDSTRING, 0, (LONG)(PCHAR)(const char *)message);
|
||||
int Items = (int)SendDlgItemMessage(IDC_LIST1, LB_GETCOUNT, 0,0);
|
||||
SendDlgItemMessage(IDC_LIST1, LB_SETCURSEL, Items-1, 0); // Show this item
|
||||
}
|
||||
|
||||
void CCompDlg::OnCompressButton()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
ClearMessages(); // Clear listbox and filesizes
|
||||
PKCompressFile(); // Start compression
|
||||
}
|
||||
|
||||
void CCompDlg::OnTestButton()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
SendDlgItemMessage(IDC_LIST1, LB_RESETCONTENT, 0, 0L); // Clear the listbox
|
||||
PKLBMessage("Extracting file...");
|
||||
PKExtractFile(); // Start extraction
|
||||
}
|
||||
|
||||
void CCompDlg::OnClearButton()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
ClearMessages();
|
||||
}
|
||||
|
||||
void CCompDlg::OnCancel()
|
||||
{
|
||||
// TODO: Add extra cleanup here
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
// Function to calculate the percentage of compression without using floating point math
|
||||
int GetPercent(unsigned long top, unsigned long bottom)
|
||||
{
|
||||
int percent;
|
||||
unsigned long bot;
|
||||
|
||||
if (top == 0L)
|
||||
return(0);
|
||||
|
||||
bot = bottom ? bottom : 1L;
|
||||
|
||||
if (top > 400000000L) // 400,000,000
|
||||
percent = (int)(top / (bot / 100L));
|
||||
else if (top > 40000000L) // 40,000,000
|
||||
percent = int((top * 10L) / (bot / 10L));
|
||||
else
|
||||
percent = int((top * 100L) / bot);
|
||||
|
||||
return(percent > 100 ? 100 : percent);
|
||||
}
|
||||
|
||||
void CCompDlg::ClearMessages()
|
||||
{
|
||||
SendDlgItemMessage(IDC_LIST1, LB_RESETCONTENT, 0, 0L); // Clear the listbox
|
||||
SetDlgItemText(IDC_EDIT2, (PCHAR)""); // Clear all the edit boxes
|
||||
SetDlgItemText(IDC_EDIT3, (PCHAR)"");
|
||||
SetDlgItemText(IDC_EDIT4, (PCHAR)"");
|
||||
SetDlgItemText(IDC_EDIT5, (PCHAR)"");
|
||||
SetDlgItemText(IDC_EDIT6, (PCHAR)"");
|
||||
SetDlgItemText(IDC_EDIT7, (PCHAR)"");
|
||||
SetDlgItemText(IDC_EDIT8, (PCHAR)"");
|
||||
}
|
||||
|
||||
// This function is called by the implode and explode functions.
|
||||
UINT ProcessInBuffer(PCHAR buffer, UINT *iSize, void *pParam)
|
||||
{
|
||||
PIOFILEBLOCK pFileIOBlock;
|
||||
unsigned int iRead;
|
||||
|
||||
pFileIOBlock = (PIOFILEBLOCK) pParam;
|
||||
|
||||
if (pFileIOBlock->PKAbortOperation) // Set this variable to abort compression or extraction
|
||||
return 0;
|
||||
|
||||
iRead = fread( buffer, 1, *iSize, pFileIOBlock->InFile ); // Read data from disk
|
||||
|
||||
if (pFileIOBlock->DebugMessages) // Debugging messages on ?
|
||||
{
|
||||
char s[80];
|
||||
wsprintf(s, "Asked to read %u bytes, actually read %u bytes", *iSize, iRead);
|
||||
SendDlgItemMessage(pFileIOBlock->hWindow, IDC_LIST1, LB_ADDSTRING, 0, (LONG)(PCHAR)(const char *)s);
|
||||
int Items = (int)SendDlgItemMessage(pFileIOBlock->hWindow, IDC_LIST1, LB_GETCOUNT, 0, 0);
|
||||
SendDlgItemMessage(pFileIOBlock->hWindow, IDC_LIST1, LB_SETCURSEL, Items-1, 0);
|
||||
}
|
||||
|
||||
if( iRead > 0 && pFileIOBlock->bDoCRC == DO_CRC_INSTREAM)
|
||||
pFileIOBlock->dwCRC = crc32(buffer, &iRead, &pFileIOBlock->dwCRC);
|
||||
|
||||
return iRead;
|
||||
}
|
||||
|
||||
// This function is called by the implode and explode functions.
|
||||
void ProcessOutBuffer(PCHAR buffer, UINT *iSize, void *pParam)
|
||||
{
|
||||
PIOFILEBLOCK pFileIOBlock;
|
||||
unsigned int iWrite;
|
||||
|
||||
pFileIOBlock = (PIOFILEBLOCK) pParam;
|
||||
|
||||
if (pFileIOBlock->PKAbortOperation) // Set this variable to abort compression or extraction
|
||||
return;
|
||||
|
||||
iWrite = fwrite( buffer, 1, *iSize, pFileIOBlock->OutFile ); // Write the data to disk
|
||||
|
||||
if (pFileIOBlock->DebugMessages) // Debugging messages on ?
|
||||
{
|
||||
char s[80];
|
||||
wsprintf(s, "Asked to write %u bytes, actually wrote %u bytes", iSize, iWrite);
|
||||
SendDlgItemMessage(pFileIOBlock->hWindow, IDC_LIST1, LB_ADDSTRING, 0, (LONG)(PCHAR)(const char *)s);
|
||||
int Items = (int)SendDlgItemMessage(pFileIOBlock->hWindow, IDC_LIST1, LB_GETCOUNT, 0, 0);
|
||||
SendDlgItemMessage(pFileIOBlock->hWindow, IDC_LIST1, LB_SETCURSEL, Items-1, 0);
|
||||
}
|
||||
|
||||
if( iWrite > 0 && pFileIOBlock->bDoCRC == DO_CRC_OUTSTREAM)
|
||||
pFileIOBlock->dwCRC = crc32(buffer, &iWrite, &pFileIOBlock->dwCRC);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void CCompDlg::PKCompressFile()
|
||||
{
|
||||
int iStatus;
|
||||
UINT CompType = CMP_ASCII, DictSize;
|
||||
char szVerbose[128], FileName[80];
|
||||
fpos_t FileSize = 0, CompressedFileSize;
|
||||
static char *Comp[] = { "Binary", "ASCII" };
|
||||
|
||||
FileIOBlock.hWindow = m_hWnd; // Used in the read and write routines
|
||||
FileIOBlock.DebugMessages = DebugMessages;
|
||||
FileIOBlock.PKAbortOperation = FALSE;
|
||||
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON1), FALSE); // Disable buttons
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON2), FALSE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON3), FALSE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON4), FALSE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDCANCEL), FALSE);
|
||||
|
||||
HANDLE hScratchPad;
|
||||
PCHAR pScratchPad;
|
||||
|
||||
// allocate the memory block for the scratch pad
|
||||
if( (hScratchPad = GlobalAlloc(GHND, CMP_BUFFER_SIZE)) == NULL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( (pScratchPad = (PCHAR) GlobalLock(hScratchPad)) == NULL )
|
||||
{
|
||||
GlobalFree(hScratchPad);
|
||||
return;
|
||||
}
|
||||
|
||||
int LoopCnt;
|
||||
|
||||
for( LoopCnt=0, CompType = CMP_ASCII; LoopCnt < 2; LoopCnt++, CompType = CMP_BINARY )
|
||||
{
|
||||
for (DictSize = 1024; DictSize <= 4096; DictSize *= 2) // Dictionary size
|
||||
{
|
||||
FileIOBlock.InFile = FileIOBlock.OutFile = NULL; // Initialize
|
||||
|
||||
GetDlgItemText(IDC_EDIT1, FileName, 80);
|
||||
FileIOBlock.InFile = fopen(FileName, "rb" ); // Open the source file
|
||||
|
||||
if( FileIOBlock.InFile == NULL ) // Error opening file
|
||||
{
|
||||
char s[80];
|
||||
wsprintf(s, "Error opening file %s.", (PCHAR)FileName);
|
||||
PKLBMessage(s);
|
||||
break;
|
||||
}
|
||||
|
||||
if( FileSize == 0 )
|
||||
{
|
||||
fseek(FileIOBlock.InFile, 0L, SEEK_END); // Get the filesize
|
||||
fgetpos(FileIOBlock.InFile, &FileSize ); // Get the filesize
|
||||
fseek(FileIOBlock.InFile, 0L, SEEK_SET); // Rewind the file
|
||||
wsprintf(szVerbose, "%ld", (PCHAR)FileSize); // Uncompressed size
|
||||
SetDlgItemText(IDC_EDIT9, szVerbose);
|
||||
}
|
||||
|
||||
FileIOBlock.OutFile = fopen( "Test.cmp", "wb" );
|
||||
FileIOBlock.bDoCRC = DO_CRC_INSTREAM;
|
||||
FileIOBlock.dwCRC = ~((DWORD)0); // Pre-condition CRC
|
||||
|
||||
if( (FileIOBlock.InFile != NULL) && (FileIOBlock.OutFile != NULL))
|
||||
{
|
||||
iStatus = implode( ProcessInBuffer, ProcessOutBuffer, pScratchPad,
|
||||
&FileIOBlock, &CompType, &DictSize );
|
||||
|
||||
// Check the value of iStatus for errors
|
||||
|
||||
// Post-condition CRC
|
||||
if (FileIOBlock.bDoCRC == DO_CRC_INSTREAM)
|
||||
{
|
||||
CString CRCvalue;
|
||||
FileIOBlock.dwCRC = ~FileIOBlock.dwCRC;
|
||||
InputCRC = FileIOBlock.dwCRC;
|
||||
wsprintf(szVerbose, "%lX", FileIOBlock.dwCRC);
|
||||
SetDlgItemText(IDC_EDIT8, szVerbose); // Display CRC
|
||||
}
|
||||
|
||||
fgetpos(FileIOBlock.OutFile, &CompressedFileSize ); // Get the filesize
|
||||
|
||||
fclose(FileIOBlock.OutFile); // Close the files
|
||||
fclose(FileIOBlock.InFile);
|
||||
|
||||
wsprintf(szVerbose, "%ld", CompressedFileSize);
|
||||
|
||||
if (CompType == CMP_ASCII)
|
||||
{
|
||||
if (DictSize == 1024)
|
||||
SetDlgItemText(IDC_EDIT2, szVerbose);
|
||||
else if (DictSize == 2048)
|
||||
SetDlgItemText(IDC_EDIT3, szVerbose);
|
||||
else
|
||||
SetDlgItemText(IDC_EDIT4, szVerbose);
|
||||
}
|
||||
else // Binary
|
||||
{
|
||||
if (DictSize == 1024)
|
||||
SetDlgItemText(IDC_EDIT5, szVerbose);
|
||||
else if (DictSize == 2048)
|
||||
SetDlgItemText(IDC_EDIT6, szVerbose);
|
||||
else
|
||||
SetDlgItemText(IDC_EDIT7, szVerbose);
|
||||
}
|
||||
wsprintf(szVerbose, "Using %d dictionary, %s compression. File Compressed %d%%.",
|
||||
DictSize, (PCHAR)Comp[CompType], 100 - GetPercent(CompressedFileSize, FileSize));
|
||||
PKLBMessage(szVerbose);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GlobalUnlock(hScratchPad);
|
||||
GlobalFree(hScratchPad);
|
||||
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON1), TRUE); // Reset the buttons
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON2), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON3), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON4), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDCANCEL), TRUE);
|
||||
}
|
||||
|
||||
void CCompDlg::PKExtractFile()
|
||||
{
|
||||
int iStatus;
|
||||
|
||||
FileIOBlock.hWindow = m_hWnd; // Used in the read and write routines
|
||||
FileIOBlock.DebugMessages = DebugMessages;
|
||||
FileIOBlock.PKAbortOperation = FALSE;
|
||||
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON1), FALSE); // Disable the buttons
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON2), FALSE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON3), FALSE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON4), FALSE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDCANCEL), FALSE);
|
||||
|
||||
HANDLE hScratchPad;
|
||||
PCHAR pScratchPad;
|
||||
|
||||
// allocate the memory block for the scratch pad
|
||||
if( (hScratchPad = GlobalAlloc(GHND, EXP_BUFFER_SIZE)) == NULL )
|
||||
{
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON1), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON2), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON3), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON4), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDCANCEL), TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
if( (pScratchPad = (PCHAR) GlobalLock(hScratchPad)) == NULL )
|
||||
{
|
||||
GlobalFree(hScratchPad);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON1), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON2), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON3), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON4), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDCANCEL), TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
FileIOBlock.InFile = FileIOBlock.OutFile = NULL;
|
||||
|
||||
// setup structure used by ProcessReadBuffer() and ProcessWriteBuffer()
|
||||
FileIOBlock.InFile = fopen( "Test.cmp", "rb" );
|
||||
|
||||
if( FileIOBlock.InFile == NULL )
|
||||
{
|
||||
int Items = (int)SendDlgItemMessage(IDC_LIST1, LB_GETCOUNT, 0,0);
|
||||
SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, Items, (LONG)(PCHAR)(const char *)"The file TEST.CMP was not found, you must compress a file first.");
|
||||
}
|
||||
else
|
||||
{
|
||||
FileIOBlock.OutFile = fopen( "Test.ext", "wb" );
|
||||
FileIOBlock.bDoCRC = DO_CRC_OUTSTREAM;
|
||||
FileIOBlock.dwCRC = ~((DWORD)0); // Pre-condition CRC
|
||||
|
||||
iStatus = explode( ProcessInBuffer, ProcessOutBuffer, pScratchPad, &FileIOBlock );
|
||||
|
||||
// Check the value of iStatus for errors
|
||||
|
||||
// Post-condition CRC
|
||||
if (FileIOBlock.bDoCRC == DO_CRC_OUTSTREAM)
|
||||
{
|
||||
FileIOBlock.dwCRC = ~FileIOBlock.dwCRC;
|
||||
if (InputCRC != FileIOBlock.dwCRC)
|
||||
PKLBMessage("File fails the CRC check!");
|
||||
else
|
||||
PKLBMessage("File tests OK.");
|
||||
}
|
||||
|
||||
if( FileIOBlock.OutFile != NULL )
|
||||
fclose(FileIOBlock.OutFile);
|
||||
if( FileIOBlock.InFile != NULL )
|
||||
fclose(FileIOBlock.InFile);
|
||||
|
||||
PKLBMessage("Done extracting.");
|
||||
}
|
||||
|
||||
GlobalUnlock(hScratchPad);
|
||||
GlobalFree(hScratchPad);
|
||||
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON1), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON2), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON3), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON4), TRUE);
|
||||
::EnableWindow(::GetDlgItem(m_hWnd, IDCANCEL), TRUE);
|
||||
}
|
||||
|
||||
void CCompDlg::OnDebugButton()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
DebugMessages = !DebugMessages;
|
||||
::SetWindowText(::GetDlgItem(m_hWnd, IDC_BUTTON4), DebugMessages ? (PCHAR)"Debug Messages = On" : (PCHAR)"Debug Messages = Off");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// compdlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCompDlg dialog
|
||||
|
||||
#include "pkstruct.h"
|
||||
|
||||
class CCompDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CCompDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CCompDlg)
|
||||
enum { IDD = IDD_DIALOG1 };
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CCompDlg)
|
||||
afx_msg void OnCompressButton();
|
||||
afx_msg void OnTestButton();
|
||||
afx_msg void OnClearButton();
|
||||
virtual void OnCancel();
|
||||
virtual void PKCompressFile(); // Added by PKWARE
|
||||
virtual void PKExtractFile(); // Added by PKWARE
|
||||
virtual void ClearMessages(); // Added by PKWARE
|
||||
virtual void PKLBMessage(char *); // Added by PKWARE
|
||||
afx_msg void OnDebugButton();
|
||||
virtual BOOL OnInitDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
BOOL DebugMessages; // Added by PKWARE
|
||||
unsigned long InputCRC; // Added by PKWARE
|
||||
IOFILEBLOCK FileIOBlock; // Added by PKWARE
|
||||
};
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// dcl.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "dcl.h"
|
||||
|
||||
#include "mainfrm.h"
|
||||
#include "dcldoc.h"
|
||||
#include "dclview.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDclApp, CWinApp)
|
||||
//{{AFX_MSG_MAP(CDclApp)
|
||||
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard file based document commands
|
||||
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
|
||||
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclApp construction
|
||||
|
||||
CDclApp::CDclApp()
|
||||
{
|
||||
// TODO: add construction code here,
|
||||
// Place all significant initialization in InitInstance
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CDclApp object
|
||||
|
||||
CDclApp NEAR theApp;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclApp initialization
|
||||
|
||||
BOOL CDclApp::InitInstance()
|
||||
{
|
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need.
|
||||
|
||||
SetDialogBkColor(); // Set dialog background color to gray
|
||||
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views.
|
||||
|
||||
CSingleDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CSingleDocTemplate(
|
||||
IDR_MAINFRAME,
|
||||
RUNTIME_CLASS(CDclDoc),
|
||||
RUNTIME_CLASS(CMainFrame), // main SDI frame window
|
||||
RUNTIME_CLASS(CDclView));
|
||||
AddDocTemplate(pDocTemplate);
|
||||
|
||||
// create a new (empty) document
|
||||
OnFileNew();
|
||||
|
||||
if (m_lpCmdLine[0] != '\0')
|
||||
{
|
||||
// TODO: add command line processing here
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
class CAboutDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
CAboutDlg();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CAboutDlg)
|
||||
enum { IDD = IDD_ABOUTBOX };
|
||||
//}}AFX_DATA
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//{{AFX_MSG(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CAboutDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CAboutDlg)
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// App command to run the dialog
|
||||
void CDclApp::OnAppAbout()
|
||||
{
|
||||
CAboutDlg aboutDlg;
|
||||
aboutDlg.DoModal();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclApp commands
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// dcl.h : main header file for the DCL application
|
||||
//
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclApp:
|
||||
// See dcl.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CDclApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CDclApp();
|
||||
|
||||
// Overrides
|
||||
virtual BOOL InitInstance();
|
||||
|
||||
// Implementation
|
||||
|
||||
//{{AFX_MSG(CDclApp)
|
||||
afx_msg void OnAppAbout();
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,264 @@
|
||||
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "DCL.MAK" CFG="Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "Win32 Debug"
|
||||
MTL=MkTypLib.exe
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 1
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "WinRel"
|
||||
# PROP BASE Intermediate_Dir "WinRel"
|
||||
# PROP Use_MFC 1
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "WinRel"
|
||||
# PROP Intermediate_Dir "WinRel"
|
||||
OUTDIR=.\WinRel
|
||||
INTDIR=.\WinRel
|
||||
|
||||
ALL : $(OUTDIR)/DCL.exe $(OUTDIR)/DCL.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /win32
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /YX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FR /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /YX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /c
|
||||
# SUBTRACT CPP /Fr
|
||||
CPP_PROJ=/nologo /MT /W3 /GX /YX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
|
||||
"_MBCS" /Fp$(OUTDIR)/"DCL.pch" /Fo$(INTDIR)/ /c
|
||||
CPP_OBJS=.\WinRel/
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
RSC_PROJ=/l 0x409 /fo$(INTDIR)/"DCL.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_SBRS= \
|
||||
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"DCL.bsc"
|
||||
|
||||
$(OUTDIR)/DCL.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 oldnames.lib /NOLOGO /STACK:0x10240 /SUBSYSTEM:windows /MACHINE:IX86
|
||||
# ADD LINK32 oldnames.lib implode.lib /NOLOGO /STACK:0x10240 /SUBSYSTEM:windows /MACHINE:IX86
|
||||
# SUBTRACT LINK32 /INCREMENTAL:yes
|
||||
LINK32_FLAGS=oldnames.lib implode.lib /NOLOGO /STACK:0x10240 /SUBSYSTEM:windows\
|
||||
/INCREMENTAL:no /PDB:$(OUTDIR)/"DCL.pdb" /MACHINE:IX86 /OUT:$(OUTDIR)/"DCL.exe"\
|
||||
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/DCL.res \
|
||||
$(INTDIR)/STDAFX.OBJ \
|
||||
$(INTDIR)/DCL.OBJ \
|
||||
$(INTDIR)/MAINFRM.OBJ \
|
||||
$(INTDIR)/DCLDOC.OBJ \
|
||||
$(INTDIR)/DCLVIEW.OBJ \
|
||||
$(INTDIR)/COMPDLG.OBJ
|
||||
|
||||
$(OUTDIR)/DCL.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 1
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "WinDebug"
|
||||
# PROP BASE Intermediate_Dir "WinDebug"
|
||||
# PROP Use_MFC 1
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "WinDebug"
|
||||
# PROP Intermediate_Dir "WinDebug"
|
||||
OUTDIR=.\WinDebug
|
||||
INTDIR=.\WinDebug
|
||||
|
||||
ALL : $(OUTDIR)/DCL.exe $(OUTDIR)/DCL.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /win32
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /c
|
||||
# SUBTRACT CPP /Fr
|
||||
CPP_PROJ=/nologo /MT /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
|
||||
/D "_MBCS" /Fp$(OUTDIR)/"DCL.pch" /Fo$(INTDIR)/ /Fd$(OUTDIR)/"DCL.pdb" /c
|
||||
CPP_OBJS=.\WinDebug/
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
RSC_PROJ=/l 0x409 /fo$(INTDIR)/"DCL.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_SBRS= \
|
||||
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"DCL.bsc"
|
||||
|
||||
$(OUTDIR)/DCL.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 oldnames.lib /NOLOGO /STACK:0x10240 /SUBSYSTEM:windows /DEBUG /MACHINE:IX86
|
||||
# ADD LINK32 oldnames.lib implode.lib /NOLOGO /STACK:0x10240 /SUBSYSTEM:windows /INCREMENTAL:no /DEBUG /MACHINE:IX86
|
||||
LINK32_FLAGS=oldnames.lib implode.lib /NOLOGO /STACK:0x10240 /SUBSYSTEM:windows\
|
||||
/INCREMENTAL:no /PDB:$(OUTDIR)/"DCL.pdb" /DEBUG /MACHINE:IX86\
|
||||
/OUT:$(OUTDIR)/"DCL.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/DCL.res \
|
||||
$(INTDIR)/STDAFX.OBJ \
|
||||
$(INTDIR)/DCL.OBJ \
|
||||
$(INTDIR)/MAINFRM.OBJ \
|
||||
$(INTDIR)/DCLDOC.OBJ \
|
||||
$(INTDIR)/DCLVIEW.OBJ \
|
||||
$(INTDIR)/COMPDLG.OBJ
|
||||
|
||||
$(OUTDIR)/DCL.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Group "Source Files"
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DCL.RC
|
||||
DEP_DCL_R=\
|
||||
.\RES\DCL.ICO\
|
||||
.\RES\TOOLBAR.BMP\
|
||||
.\RESOURCE.H\
|
||||
.\RES\DCL.RC2
|
||||
|
||||
$(INTDIR)/DCL.res : $(SOURCE) $(DEP_DCL_R) $(INTDIR)
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\STDAFX.CPP
|
||||
DEP_STDAF=\
|
||||
.\STDAFX.H
|
||||
|
||||
$(INTDIR)/STDAFX.OBJ : $(SOURCE) $(DEP_STDAF) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DCL.CPP
|
||||
DEP_DCL_C=\
|
||||
.\STDAFX.H\
|
||||
.\DCL.H\
|
||||
.\MAINFRM.H\
|
||||
.\DCLDOC.H\
|
||||
.\DCLVIEW.H\
|
||||
.\RESOURCE.H
|
||||
|
||||
$(INTDIR)/DCL.OBJ : $(SOURCE) $(DEP_DCL_C) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MAINFRM.CPP
|
||||
DEP_MAINF=\
|
||||
.\STDAFX.H\
|
||||
.\DCL.H\
|
||||
.\MAINFRM.H\
|
||||
.\RESOURCE.H
|
||||
|
||||
$(INTDIR)/MAINFRM.OBJ : $(SOURCE) $(DEP_MAINF) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DCLDOC.CPP
|
||||
DEP_DCLDO=\
|
||||
.\STDAFX.H\
|
||||
.\DCL.H\
|
||||
.\DCLDOC.H\
|
||||
.\RESOURCE.H
|
||||
|
||||
$(INTDIR)/DCLDOC.OBJ : $(SOURCE) $(DEP_DCLDO) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DCLVIEW.CPP
|
||||
DEP_DCLVI=\
|
||||
.\STDAFX.H\
|
||||
.\DCL.H\
|
||||
.\DCLDOC.H\
|
||||
.\DCLVIEW.H\
|
||||
.\COMPDLG.H\
|
||||
.\RESOURCE.H\
|
||||
.\PKSTRUCT.H
|
||||
|
||||
$(INTDIR)/DCLVIEW.OBJ : $(SOURCE) $(DEP_DCLVI) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\COMPDLG.CPP
|
||||
DEP_COMPD=\
|
||||
.\STDAFX.H\
|
||||
.\DCL.H\
|
||||
.\implode.h\
|
||||
.\PKSTRUCT.H\
|
||||
.\COMPDLG.H\
|
||||
.\RESOURCE.H
|
||||
|
||||
$(INTDIR)/COMPDLG.OBJ : $(SOURCE) $(DEP_COMPD) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Project
|
||||
################################################################################
|
||||
@@ -0,0 +1,255 @@
|
||||
//Microsoft App Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""res\\dcl.rc2"" // non-App Studio edited resources\r\n"
|
||||
"\r\n"
|
||||
"#include ""afxres.rc"" \011// Standard components\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
IDR_MAINFRAME ICON DISCARDABLE "RES\\DCL.ICO"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDR_MAINFRAME BITMAP MOVEABLE PURE "RES\\TOOLBAR.BMP"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "Compress...", COMP_DIALOG
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About Dcl...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
|
||||
BEGIN
|
||||
"N", ID_FILE_NEW, VIRTKEY,CONTROL
|
||||
"O", ID_FILE_OPEN, VIRTKEY,CONTROL
|
||||
"S", ID_FILE_SAVE, VIRTKEY,CONTROL
|
||||
"Z", ID_EDIT_UNDO, VIRTKEY,CONTROL
|
||||
"X", ID_EDIT_CUT, VIRTKEY,CONTROL
|
||||
"C", ID_EDIT_COPY, VIRTKEY,CONTROL
|
||||
"V", ID_EDIT_PASTE, VIRTKEY,CONTROL
|
||||
VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT
|
||||
VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT
|
||||
VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL
|
||||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT
|
||||
VK_F6, ID_NEXT_PANE, VIRTKEY
|
||||
VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT
|
||||
END
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 34, 22, 217, 55
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About Dcl"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
|
||||
LTEXT "Dcl Application Version 1.0",IDC_STATIC,40,10,119,8
|
||||
LTEXT "Copyright \251 1994,1995",IDC_STATIC,40,25,119,8
|
||||
DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 248, 258
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "PKWARE Data Compression Library for Win32"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
PUSHBUTTON "Exit",IDCANCEL,153,237,87,13
|
||||
LISTBOX IDC_LIST1,2,121,238,67,LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
DEFPUSHBUTTON "Compress",IDC_BUTTON1,3,194,94,28
|
||||
PUSHBUTTON "Extract Compressed file",IDC_BUTTON2,3,226,94,28
|
||||
EDITTEXT IDC_EDIT1,7,16,115,12,ES_AUTOHSCROLL
|
||||
LTEXT "ASCII",IDC_STATIC,52,42,20,10
|
||||
LTEXT "Binary",IDC_STATIC,99,42,20,10
|
||||
EDITTEXT IDC_EDIT2,52,55,42,13,ES_AUTOHSCROLL | ES_READONLY
|
||||
EDITTEXT IDC_EDIT3,52,70,42,13,ES_AUTOHSCROLL | ES_READONLY
|
||||
EDITTEXT IDC_EDIT4,52,85,42,13,ES_AUTOHSCROLL | ES_READONLY
|
||||
EDITTEXT IDC_EDIT5,99,55,42,13,ES_AUTOHSCROLL | ES_READONLY
|
||||
EDITTEXT IDC_EDIT6,99,70,42,13,ES_AUTOHSCROLL | ES_READONLY
|
||||
EDITTEXT IDC_EDIT7,99,85,42,13,ES_AUTOHSCROLL | ES_READONLY
|
||||
LTEXT "1K Dictionary",IDC_STATIC,5,58,44,9
|
||||
LTEXT "2K Dictionary",IDC_STATIC,5,73,43,9
|
||||
LTEXT "4K Dictionary",IDC_STATIC,5,87,43,9
|
||||
LTEXT "Messages",IDC_STATIC,2,108,58,9
|
||||
PUSHBUTTON "Clear Messages",IDC_BUTTON3,153,194,87,13
|
||||
LTEXT "CRC32",IDC_STATIC,150,43,30,10
|
||||
EDITTEXT IDC_EDIT8,150,55,45,13,ES_AUTOHSCROLL | ES_READONLY
|
||||
LTEXT "Input File",IDC_STATIC,7,4,59,9
|
||||
PUSHBUTTON "Debug Messages = Off",IDC_BUTTON4,153,210,87,13
|
||||
LTEXT "File Size",IDC_STATIC,150,4,30,8
|
||||
EDITTEXT IDC_EDIT9,150,16,45,12,ES_AUTOHSCROLL | ES_READONLY
|
||||
END
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
IDR_MAINFRAME "Dcl Win32 Application\nDcl\nDcl Document\n\n\nDcl.Document\nDcl Document"
|
||||
END
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_APP_TITLE "Dcl Win32 Application"
|
||||
AFX_IDS_IDLEMESSAGE "Ready"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_INDICATOR_EXT "EXT"
|
||||
ID_INDICATOR_CAPS "CAP"
|
||||
ID_INDICATOR_NUM "NUM"
|
||||
ID_INDICATOR_SCRL "SCRL"
|
||||
ID_INDICATOR_OVR "OVR"
|
||||
ID_INDICATOR_REC "REC"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_NEW "Create a new document"
|
||||
ID_FILE_OPEN "Open an existing document"
|
||||
ID_FILE_CLOSE "Close the active document"
|
||||
ID_FILE_SAVE "Save the active document"
|
||||
ID_FILE_SAVE_AS "Save the active document with a new name"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_APP_ABOUT "Display program information, version number and copyright"
|
||||
ID_APP_EXIT "Quit the application; prompts to save documents"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_MRU_FILE1 "Open this document"
|
||||
ID_FILE_MRU_FILE2 "Open this document"
|
||||
ID_FILE_MRU_FILE3 "Open this document"
|
||||
ID_FILE_MRU_FILE4 "Open this document"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_NEXT_PANE "Switch to the next window pane"
|
||||
ID_PREV_PANE "Switch back to the previous window pane"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_EDIT_CLEAR "Erase the selection"
|
||||
ID_EDIT_CLEAR_ALL "Erase everything"
|
||||
ID_EDIT_COPY "Copy the selection and put it on the Clipboard"
|
||||
ID_EDIT_CUT "Cut the selection and put it on the Clipboard"
|
||||
ID_EDIT_FIND "Find the specified text"
|
||||
ID_EDIT_PASTE "Insert Clipboard contents"
|
||||
ID_EDIT_REPEAT "Repeat the last action"
|
||||
ID_EDIT_REPLACE "Replace specific text with different text"
|
||||
ID_EDIT_SELECT_ALL "Select the entire document"
|
||||
ID_EDIT_UNDO "Undo the last action"
|
||||
ID_EDIT_REDO "Redo the previously undone action"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_VIEW_TOOLBAR "Show or hide the toolbar"
|
||||
ID_VIEW_STATUS_BAR "Show or hide the status bar"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCSIZE "Change the window size"
|
||||
AFX_IDS_SCMOVE "Change the window position"
|
||||
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
|
||||
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
|
||||
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
|
||||
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
|
||||
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCRESTORE "Restore the window to normal size"
|
||||
AFX_IDS_SCTASKLIST "Activate Task List"
|
||||
END
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#include "res\dcl.rc2" // non-App Studio edited resources
|
||||
|
||||
#include "afxres.rc" // Standard components
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// dcldoc.cpp : implementation of the CDclDoc class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "dcl.h"
|
||||
|
||||
#include "dcldoc.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(CDclDoc, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDclDoc, CDocument)
|
||||
//{{AFX_MSG_MAP(CDclDoc)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclDoc construction/destruction
|
||||
|
||||
CDclDoc::CDclDoc()
|
||||
{
|
||||
// TODO: add one-time construction code here
|
||||
}
|
||||
|
||||
CDclDoc::~CDclDoc()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CDclDoc::OnNewDocument()
|
||||
{
|
||||
if (!CDocument::OnNewDocument())
|
||||
return FALSE;
|
||||
|
||||
// TODO: add reinitialization code here
|
||||
// (SDI documents will reuse this document)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclDoc serialization
|
||||
|
||||
void CDclDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
// TODO: add storing code here
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: add loading code here
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CDclDoc::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void CDclDoc::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclDoc commands
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// dcldoc.h : interface of the CDclDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CDclDoc : public CDocument
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CDclDoc();
|
||||
DECLARE_DYNCREATE(CDclDoc)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CDclDoc();
|
||||
virtual void Serialize(CArchive& ar); // overridden for document i/o
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual BOOL OnNewDocument();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CDclDoc)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// dclview.cpp : implementation of the CDclView class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "dcl.h"
|
||||
|
||||
#include "dcldoc.h"
|
||||
#include "dclview.h"
|
||||
#include "compdlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclView
|
||||
|
||||
IMPLEMENT_DYNCREATE(CDclView, CView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDclView, CView)
|
||||
//{{AFX_MSG_MAP(CDclView)
|
||||
ON_COMMAND(COMP_DIALOG, OnDialog)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclView construction/destruction
|
||||
|
||||
CDclView::CDclView()
|
||||
{
|
||||
// TODO: add construction code here
|
||||
}
|
||||
|
||||
CDclView::~CDclView()
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclView drawing
|
||||
|
||||
void CDclView::OnDraw(CDC* pDC)
|
||||
{
|
||||
CDclDoc* pDoc = GetDocument();
|
||||
ASSERT_VALID(pDoc);
|
||||
|
||||
// TODO: add draw code for native data here
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclView diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CDclView::AssertValid() const
|
||||
{
|
||||
CView::AssertValid();
|
||||
}
|
||||
|
||||
void CDclView::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CView::Dump(dc);
|
||||
}
|
||||
|
||||
CDclDoc* CDclView::GetDocument() // non-debug version is inline
|
||||
{
|
||||
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDclDoc)));
|
||||
return (CDclDoc*)m_pDocument;
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDclView message handlers
|
||||
|
||||
void CDclView::OnDialog()
|
||||
{
|
||||
// TODO: Add your command handler code here
|
||||
CCompDlg dlg;
|
||||
dlg.DoModal();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// dclview.h : interface of the CDclView class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CDclView : public CView
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CDclView();
|
||||
DECLARE_DYNCREATE(CDclView)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
CDclDoc* GetDocument();
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CDclView();
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CDclView)
|
||||
afx_msg void OnDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
#ifndef _DEBUG // debug version in dclview.cpp
|
||||
inline CDclDoc* CDclView::GetDocument()
|
||||
{ return (CDclDoc*)m_pDocument; }
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,44 @@
|
||||
/***************************************************************
|
||||
PKWARE Data Compression Library (R) for Win32
|
||||
Copyright 1991,1992,1994,1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.
|
||||
***************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned int implode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param,
|
||||
unsigned int *type,
|
||||
unsigned int *dsize);
|
||||
|
||||
|
||||
unsigned int explode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param);
|
||||
|
||||
unsigned long crc32(char *buffer, unsigned int *size, unsigned long *old_crc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // End of 'extern "C"' declaration
|
||||
#endif
|
||||
|
||||
|
||||
#define CMP_BUFFER_SIZE 36312
|
||||
#define EXP_BUFFER_SIZE 12596
|
||||
|
||||
#define CMP_BINARY 0
|
||||
#define CMP_ASCII 1
|
||||
|
||||
#define CMP_NO_ERROR 0
|
||||
#define CMP_INVALID_DICTSIZE 1
|
||||
#define CMP_INVALID_MODE 2
|
||||
#define CMP_BAD_DATA 3
|
||||
#define CMP_ABORT 4
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mainfrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "dcl.h"
|
||||
|
||||
#include "mainfrm.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
|
||||
//{{AFX_MSG_MAP(CMainFrame)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
ON_WM_CREATE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// arrays of IDs used to initialize control bars
|
||||
|
||||
// toolbar buttons - IDs are command buttons
|
||||
static UINT BASED_CODE buttons[] =
|
||||
{
|
||||
// same order as in the bitmap 'toolbar.bmp'
|
||||
ID_FILE_NEW,
|
||||
ID_FILE_OPEN,
|
||||
ID_FILE_SAVE,
|
||||
ID_SEPARATOR,
|
||||
ID_EDIT_PASTE,
|
||||
ID_SEPARATOR,
|
||||
ID_FILE_PRINT,
|
||||
ID_APP_ABOUT,
|
||||
};
|
||||
|
||||
static UINT BASED_CODE indicators[] =
|
||||
{
|
||||
ID_SEPARATOR, // status line indicator
|
||||
ID_INDICATOR_CAPS,
|
||||
ID_INDICATOR_NUM,
|
||||
ID_INDICATOR_SCRL,
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame()
|
||||
{
|
||||
// TODO: add member initialization code here
|
||||
}
|
||||
|
||||
CMainFrame::~CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
{
|
||||
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
if (!m_wndToolBar.Create(this) ||
|
||||
!m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
|
||||
!m_wndToolBar.SetButtons(buttons,
|
||||
sizeof(buttons)/sizeof(UINT)))
|
||||
{
|
||||
TRACE("Failed to create toolbar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
if (!m_wndStatusBar.Create(this) ||
|
||||
!m_wndStatusBar.SetIndicators(indicators,
|
||||
sizeof(indicators)/sizeof(UINT)))
|
||||
{
|
||||
TRACE("Failed to create status bar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMainFrame::AssertValid() const
|
||||
{
|
||||
CFrameWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFrameWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mainfrm.h : interface of the CMainFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CMainFrame : public CFrameWnd
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CMainFrame();
|
||||
DECLARE_DYNCREATE(CMainFrame)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMainFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected: // control bar embedded members
|
||||
CStatusBar m_wndStatusBar;
|
||||
CToolBar m_wndToolBar;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMainFrame)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
#ifndef __PKSTRUCT__
|
||||
#define __PKSTRUCT__ 1
|
||||
|
||||
typedef struct IOFILEBLOCK
|
||||
{
|
||||
FILE *InFile;
|
||||
FILE *OutFile;
|
||||
BOOL bDoCRC;
|
||||
DWORD dwCRC;
|
||||
BOOL DebugMessages;
|
||||
HWND hWindow;
|
||||
BOOL PKAbortOperation;
|
||||
}
|
||||
*PIOFILEBLOCK;
|
||||
|
||||
#endif
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 768 B |
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// DCL.RC2 - resources App Studio does not edit directly
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#error this file is not editable by App Studio
|
||||
#endif //APSTUDIO_INVOKED
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Version stamp for this .EXE
|
||||
|
||||
#include "ver.h"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG|VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE
|
||||
#else
|
||||
FILEFLAGS 0 // final version
|
||||
#endif
|
||||
FILEOS VOS_DOS_WINDOWS16
|
||||
FILETYPE VFT_APP
|
||||
FILESUBTYPE 0 // not used
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "DCL MFC Application\0"
|
||||
VALUE "FileVersion", "1.0.001\0"
|
||||
VALUE "InternalName", "DCL\0"
|
||||
VALUE "LegalCopyright", "\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename","DCL.EXE\0"
|
||||
VALUE "ProductName", "DCL\0"
|
||||
VALUE "ProductVersion", "1.0.001\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
// English language (0x409) and the Windows ANSI codepage (1252)
|
||||
END
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Add additional manually edited resources here...
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// App Studio generated include file.
|
||||
// Used by DCL.RC
|
||||
//
|
||||
#define IDR_MAINFRAME 2
|
||||
#define IDD_ABOUTBOX 100
|
||||
#define IDD_DIALOG1 102
|
||||
#define IDC_LIST1 1000
|
||||
#define IDC_BUTTON1 1001
|
||||
#define IDC_BUTTON2 1002
|
||||
#define IDC_EDIT1 1003
|
||||
#define IDC_EDIT2 1004
|
||||
#define IDC_EDIT3 1005
|
||||
#define IDC_EDIT4 1006
|
||||
#define IDC_EDIT5 1007
|
||||
#define IDC_EDIT6 1008
|
||||
#define IDC_EDIT7 1009
|
||||
#define IDC_BUTTON3 1010
|
||||
#define IDC_EDIT8 1011
|
||||
#define IDC_BUTTON4 1012
|
||||
#define IDC_EDIT9 1013
|
||||
#define COMP_DIALOG 32771
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 32772
|
||||
#define _APS_NEXT_CONTROL_VALUE 1014
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,5 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// stdafx.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
@@ -0,0 +1,7 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions (including VB)
|
||||
@@ -0,0 +1,479 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* DCL.cpp - File to call various DCL DLL functions
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dos.h>
|
||||
|
||||
#include "implode.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COMPRESSING = 1,
|
||||
UNCOMPRESSING
|
||||
} FILEMODE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PBYTE Buffer; // POINTER TO BUFFER
|
||||
UINT CurPos; // CURRENT POSITION IN BUFFER
|
||||
UINT BuffSize; // SIZE OF THE BUFFER
|
||||
} BUFFER_BLOCK, *PBUFFER_BLOCK;
|
||||
|
||||
// STRUCT TO PASS TO THE FILE IO FUNCTIONS
|
||||
typedef struct
|
||||
{
|
||||
BUFFER_BLOCK FileBuff; // FILE BUFFER
|
||||
BUFFER_BLOCK cmpBuff; // COMPRESSION BUFFER
|
||||
BUFFER_BLOCK uncmpBuff; // UNCOMPRESSION BUFFER
|
||||
FILEMODE mode;
|
||||
DWORD dwCrc; // CRC
|
||||
UINT nCompressSize;
|
||||
BOOL ErrorOccurred; // ERROR FLAG
|
||||
} DATABLOCK, *PDATABLOCK;
|
||||
|
||||
UINT DataType = CMP_ASCII; // GLOBAL FOR DATA TYPE FOR COMPRESSION
|
||||
UINT DictSize = 4096; // GLOBAL FOR DICTIONARY SIZE FOR COMPRESSION
|
||||
|
||||
static int iLineCnt; // CURRENT LINE TO OUTPUT STRING
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: ReadBuffer()
|
||||
*
|
||||
* Purpose: To handle calls from the Data Compression Library for
|
||||
* read requests. If compressing, then the data read is
|
||||
* in uncompressed form. If compressing, then the data
|
||||
* read is data that was previously compressed. This
|
||||
* function is called until zero is returned.
|
||||
*
|
||||
* Parameters: buffer -> Address of buffer to read the data into
|
||||
* iSize -> Number of bytes to read into buffer
|
||||
* dwParam -> User-defined parameter, in this case a
|
||||
* pointer to the DATABLOCK
|
||||
*
|
||||
* Returns: Number of bytes actually read, or zero on EOF
|
||||
*
|
||||
*********************************************************************/
|
||||
UINT ReadBuffer(PCHAR buffer, UINT *iSize, void *pParam)
|
||||
{
|
||||
PDATABLOCK pDataBlock;
|
||||
PBUFFER_BLOCK pBufferBlock;
|
||||
UINT iRead;
|
||||
|
||||
pDataBlock = (PDATABLOCK) pParam;
|
||||
|
||||
// IF AN ERROR OCCURRED
|
||||
if( pDataBlock->ErrorOccurred == TRUE )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( pDataBlock->mode == COMPRESSING )
|
||||
{
|
||||
// SINCE COMPRESSING THEN WANT TO WRITE DATA TO THE COMPRESSION BUFFER
|
||||
pBufferBlock = &pDataBlock->FileBuff;
|
||||
}
|
||||
else
|
||||
{
|
||||
// SINCE COMPRESSING THEN WANT TO WRITE DATA TO THE UNCOMPRESSION BUFFER
|
||||
pBufferBlock = &pDataBlock->cmpBuff;
|
||||
}
|
||||
|
||||
if( pBufferBlock->CurPos < pBufferBlock->BuffSize )
|
||||
{
|
||||
UINT BytesLeft = pBufferBlock->BuffSize - pBufferBlock->CurPos;
|
||||
|
||||
// IF REQUESTING MORE BYTES THAN ARE LEFT
|
||||
if( BytesLeft < *iSize )
|
||||
{
|
||||
// SET NUMBER OF BYTES TO COPY TO WHAT IS LEFT
|
||||
*iSize = BytesLeft;
|
||||
}
|
||||
|
||||
// COPY BYTES AND UPDATE COUNTER
|
||||
memcpy( buffer, (pBufferBlock->Buffer + pBufferBlock->CurPos), *iSize );
|
||||
pBufferBlock->CurPos += *iSize;
|
||||
|
||||
iRead = *iSize;
|
||||
}
|
||||
else // ELSE - NOTHING LEFT IN BUFFER SO RETURN 0
|
||||
{
|
||||
iRead = 0;
|
||||
}
|
||||
|
||||
// IF COMPRESSING, THEN CALCULATE THE CRC
|
||||
if( pDataBlock->mode == COMPRESSING )
|
||||
{
|
||||
pDataBlock->dwCrc = crc32( buffer, &iRead, &pDataBlock->dwCrc );
|
||||
}
|
||||
|
||||
return iRead;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: WriteBuffer()
|
||||
*
|
||||
* Purpose: To handle calls from the Data Compression Library for
|
||||
* write requests.
|
||||
*
|
||||
* Parameters: buffer -> Address of buffer to write data from
|
||||
* iSize -> Number of bytes to write
|
||||
* dwParam -> User-defined parameter, in this case a
|
||||
* pointer to the DATABLOCK
|
||||
*
|
||||
* Returns: Zero, the return value is not used by the Data
|
||||
* Compression Library
|
||||
*
|
||||
*********************************************************************/
|
||||
void WriteBuffer(PCHAR buffer, UINT *iSize, void *pParam)
|
||||
{
|
||||
PDATABLOCK pDataBlock;
|
||||
PBUFFER_BLOCK pBufferBlock;
|
||||
|
||||
pDataBlock = (PDATABLOCK) pParam;
|
||||
|
||||
// IF AN ERROR OCCURRED
|
||||
if( pDataBlock->ErrorOccurred == TRUE )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( pDataBlock->mode == COMPRESSING )
|
||||
{
|
||||
// SINCE COMPRESSING THEN WANT TO WRITE DATA TO THE COMPRESSION BUFFER
|
||||
pBufferBlock = &pDataBlock->cmpBuff;
|
||||
|
||||
// SINCE COMPRESSING, KEEP A TOTAL OF THE COMPRESSED FILE SIZE
|
||||
pDataBlock->nCompressSize += *iSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// SINCE COMPRESSING THEN WANT TO WRITE DATA TO THE UNCOMPRESSION BUFFER
|
||||
pBufferBlock = &pDataBlock->uncmpBuff;
|
||||
}
|
||||
|
||||
// IF NOT OUT OF BUFFER SPACE
|
||||
if( pBufferBlock->CurPos < pBufferBlock->BuffSize )
|
||||
{
|
||||
// IF WRITING MORE BYTES THAN ARE LEFT
|
||||
if( (pBufferBlock->BuffSize - pBufferBlock->CurPos) < *iSize )
|
||||
{
|
||||
MessageBox( NULL, "Out of buffer space - #1", "Compression Error", MB_OK );
|
||||
pDataBlock->ErrorOccurred = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
// COPY BYTES AND UPDATE COUNTER
|
||||
memcpy( (pBufferBlock->Buffer + pBufferBlock->CurPos),
|
||||
buffer, *iSize );
|
||||
pBufferBlock->CurPos += *iSize;
|
||||
}
|
||||
else // ELSE - NOTHING LEFT IN BUFFER SO RETURN 0
|
||||
{
|
||||
MessageBox( NULL, "Out of buffer space - #2", "Compression Error", MB_OK );
|
||||
pDataBlock->ErrorOccurred = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
// IF COMPRESSING, THEN CALCULATE THE CRC
|
||||
if (pDataBlock->mode == UNCOMPRESSING )
|
||||
{
|
||||
pDataBlock->dwCrc = crc32( buffer, iSize, &pDataBlock->dwCrc );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: CompressMemToMem()
|
||||
*
|
||||
* Purpose: To compress a buffer to another buffer in memory.
|
||||
*
|
||||
*
|
||||
* Parameters: HWnd -> Handle to window
|
||||
* pDC -> Pointer to a device context
|
||||
* pdwCrc -> Pointer to DWORD buffer to return the CRC
|
||||
* of the compressed file before compression
|
||||
* pnCompressedSize -> Number of bytes in the compressed
|
||||
* buffer
|
||||
* pFileBuffer -> Pointer to buffer to compress
|
||||
* pCompressedBuffer -> Pointer to buffer to place
|
||||
* compressed data
|
||||
* BuffSize -> Size of the buffers (both are allocated
|
||||
* for same number of bytes)
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int CompressMemToMem( HWND hWnd, CDC *pDC, DWORD *pdwCrc,
|
||||
UINT *pnCompressedSize, PBYTE pFileBuffer,
|
||||
PBYTE pCompressedBuffer, UINT BuffSize )
|
||||
{
|
||||
int iStatus;
|
||||
int rc = 1;
|
||||
char szVerbose[128];
|
||||
DATABLOCK DataBlock;
|
||||
PCHAR pScratchPad;
|
||||
|
||||
if( (pScratchPad = (PCHAR) new char[CMP_BUFFER_SIZE]) == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset( &DataBlock, 0, sizeof(DataBlock) );
|
||||
|
||||
// SETUP STRUCTURE USED BY ProcessReadBuffer() AND ProcessWriteBuffer()
|
||||
DataBlock.mode = COMPRESSING;
|
||||
DataBlock.dwCrc = ~((DWORD)0); // Pre-condition CRC
|
||||
|
||||
// SETUP BUFFER BLOCK FOR FILE BUFFER
|
||||
DataBlock.FileBuff.Buffer = pFileBuffer;
|
||||
DataBlock.FileBuff.BuffSize = BuffSize;
|
||||
|
||||
// SETUP BUFFER BLOCK FOR COMPRESSION BUFFER
|
||||
DataBlock.cmpBuff.Buffer = pCompressedBuffer;
|
||||
DataBlock.cmpBuff.BuffSize = BuffSize;
|
||||
|
||||
wsprintf( szVerbose, "Compressing %u byte buffer to memory ", BuffSize );
|
||||
pDC->TextOut( 10, (iLineCnt++ * 20) + 5, szVerbose );
|
||||
|
||||
// COMPRESS THE FILE
|
||||
iStatus = implode( ReadBuffer, WriteBuffer,
|
||||
pScratchPad, &DataBlock, &DataType, &DictSize );
|
||||
|
||||
// IF THERE WAS AN ERROR COMPRESSING FILE
|
||||
if( iStatus || DataBlock.ErrorOccurred )
|
||||
{
|
||||
// DISPLAY ERROR STRING IF ERROR OCCURRED IN IMPLODE
|
||||
wsprintf( szVerbose, "Error occurred while imploding - %d ", iStatus );
|
||||
MessageBox( hWnd, szVerbose, "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
else // ELSE - COMPRESSION WAS SUCCESSFUL
|
||||
{
|
||||
// POST-CONDITION CRC
|
||||
DataBlock.dwCrc = ~DataBlock.dwCrc;
|
||||
|
||||
// RETURN CRC
|
||||
*pdwCrc = DataBlock.dwCrc;
|
||||
|
||||
// RETURN COMPRESSED BUFFER SIZE
|
||||
*pnCompressedSize = DataBlock.nCompressSize;
|
||||
|
||||
wsprintf( szVerbose, "Compressed file to memory -> CRC = %08lX ",
|
||||
DataBlock.dwCrc );
|
||||
pDC->TextOut( 10, (iLineCnt++ * 20) + 5, szVerbose );
|
||||
}
|
||||
|
||||
delete pScratchPad;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: ExpandMemToMem()
|
||||
*
|
||||
* Purpose: To expand a compressed buffer to a buffer in memory.
|
||||
*
|
||||
*
|
||||
* Parameters: HWnd -> Handle to window
|
||||
* pDC -> Pointer to a device context
|
||||
* pdwCrc -> Pointer to DWORD buffer to return the CRC
|
||||
* of the compressed file after uncompression
|
||||
* pCompressedBuffer -> Pointer to buffer to place
|
||||
* compressed data
|
||||
* nCompressedSize -> Number of bytes in the compressed
|
||||
* buffer
|
||||
* pUncompressedBuffer -> Pointer to buffer to place
|
||||
* uncompressed data
|
||||
* BuffSize -> Size of the uncompressed buffer
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int ExpandMemToMem( HWND hWnd, CDC *pDC, DWORD *pdwCrc,
|
||||
PBYTE pCompressedBuffer, UINT nCompressedSize,
|
||||
PBYTE pUncompressedBuffer, UINT BuffSize )
|
||||
{
|
||||
int iStatus;
|
||||
int rc = 1;
|
||||
char szVerbose[128];
|
||||
DATABLOCK DataBlock;
|
||||
PCHAR pScratchPad;
|
||||
|
||||
if( (pScratchPad = (PCHAR) new char[CMP_BUFFER_SIZE]) == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset( &DataBlock, 0, sizeof(DataBlock) );
|
||||
|
||||
// SETUP STRUCTURE USED BY ProcessReadBuffer() AND ProcessWriteBuffer()
|
||||
DataBlock.mode = UNCOMPRESSING;
|
||||
DataBlock.dwCrc = ~((DWORD)0); // Pre-condition CRC
|
||||
|
||||
// SETUP BUFFER BLOCK FOR COMPRESSION BUFFER
|
||||
DataBlock.cmpBuff.Buffer = pCompressedBuffer;
|
||||
DataBlock.cmpBuff.BuffSize = nCompressedSize;
|
||||
|
||||
// SETUP BUFFER BLOCK FOR UNCOMPRESSION BUFFER
|
||||
DataBlock.uncmpBuff.Buffer = pUncompressedBuffer;
|
||||
DataBlock.uncmpBuff.BuffSize = BuffSize;
|
||||
|
||||
wsprintf( szVerbose, "Compressed buffer size = %u ", nCompressedSize );
|
||||
pDC->TextOut( 10, (iLineCnt++ * 20) + 5, szVerbose );
|
||||
|
||||
pDC->TextOut( 10, (iLineCnt++ * 20) + 5, "Uncompressing buffer to memory " );
|
||||
|
||||
// UNCOMPRESS THE FILE
|
||||
iStatus = explode( ReadBuffer, WriteBuffer, pScratchPad, &DataBlock );
|
||||
|
||||
// IF THERE WAS AN ERROR UNCOMPRESSING FILE
|
||||
if( iStatus || DataBlock.ErrorOccurred )
|
||||
{
|
||||
wsprintf( szVerbose, "Error occurred while exploding - %d ", iStatus );
|
||||
MessageBox( hWnd, szVerbose, "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
else // ELSE - UNCOMPRESSION WAS SUCCESSFUL
|
||||
{
|
||||
// POST-CONDITION CRC
|
||||
DataBlock.dwCrc = ~DataBlock.dwCrc;
|
||||
|
||||
// RETURN CRC
|
||||
*pdwCrc = DataBlock.dwCrc;
|
||||
|
||||
wsprintf( szVerbose, "Uncompressed file to memory -> CRC = %08lX ",
|
||||
DataBlock.dwCrc );
|
||||
pDC->TextOut( 10, (iLineCnt++ * 20) + 5, szVerbose );
|
||||
}
|
||||
|
||||
delete pScratchPad;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: MemToMemExample()
|
||||
*
|
||||
* Purpose: To load a file into memory. Then compress and uncompress
|
||||
* the buffer in memory.
|
||||
*
|
||||
*
|
||||
* Parameters: HWnd -> Handle to window
|
||||
* pDC -> Pointer to a device context
|
||||
* pszFilename -> Name of file to load
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int MemToMemExample( HWND hWnd, CDC *pDC, PCHAR pszFilename )
|
||||
{
|
||||
ASSERT( hWnd );
|
||||
ASSERT_VALID( pDC );
|
||||
|
||||
CFile InFile;
|
||||
int rc=1; // RETURN CODE
|
||||
UINT BufferSize;
|
||||
UINT cmpSize;
|
||||
PBYTE pFileBuffer; // BUFFER FOR FILE DATA
|
||||
PBYTE pCompressedBuffer; // BUFFER FOR THE COMPRESSED DATA
|
||||
PBYTE pUncompressedBuffer; // BUFFER FOR THE UNCOMPRESSED DATA
|
||||
DWORD cmpCrc; // CRC OF FILE BEFORE COMPRESSION
|
||||
DWORD uncmpCrc; // CRC OF FILE AFTER UNCOMPRESSION
|
||||
|
||||
|
||||
iLineCnt = 0;
|
||||
|
||||
// OPEN THE FILE
|
||||
if( !InFile.Open( pszFilename,
|
||||
CFile::modeRead | CFile::shareExclusive | CFile::typeBinary ) )
|
||||
{
|
||||
MessageBox( hWnd, "Error opening file for compression", "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CHECK IF FILE IS TOO LARGE
|
||||
if( InFile.GetLength() > 64000U )
|
||||
{
|
||||
MessageBox( hWnd, "File is too large to compress to memory", "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BufferSize = (UINT) InFile.GetLength();
|
||||
|
||||
// ALLOCATE BUFFER MEMORY
|
||||
pFileBuffer = (PBYTE) new char[BufferSize];
|
||||
pCompressedBuffer = (PBYTE) new char[BufferSize];
|
||||
pUncompressedBuffer = (PBYTE) new char[BufferSize];
|
||||
|
||||
// IF SUCCESSFULLY ALLOCATED MEMORY
|
||||
if( (pFileBuffer != NULL) &&
|
||||
(pCompressedBuffer != NULL) &&
|
||||
(pUncompressedBuffer != NULL) )
|
||||
{
|
||||
// READ FILE
|
||||
InFile.Read( pFileBuffer, BufferSize );
|
||||
|
||||
// IF COMPRESSED OK
|
||||
if( CompressMemToMem( hWnd, pDC, &cmpCrc, &cmpSize,
|
||||
pFileBuffer, pCompressedBuffer, BufferSize ) )
|
||||
{
|
||||
// IF ERROR UNCOMPRESSING
|
||||
if( !ExpandMemToMem( hWnd, pDC, &uncmpCrc,
|
||||
pCompressedBuffer, cmpSize,
|
||||
pUncompressedBuffer, BufferSize ) )
|
||||
{
|
||||
MessageBox( hWnd, "Error uncompressing to memory", "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox( hWnd, "Error compressing to memory", "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( pFileBuffer != NULL )
|
||||
{
|
||||
delete pFileBuffer;
|
||||
}
|
||||
|
||||
if( pCompressedBuffer != NULL )
|
||||
{
|
||||
delete pCompressedBuffer;
|
||||
}
|
||||
|
||||
if( pUncompressedBuffer != NULL )
|
||||
{
|
||||
delete pUncompressedBuffer;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1994,1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
int MemToMemExample( HWND hWnd, CDC *pDC, PCHAR lpszFilename );
|
||||
@@ -0,0 +1,44 @@
|
||||
/***************************************************************
|
||||
PKWARE Data Compression Library (R) for Win32
|
||||
Copyright 1991,1992,1994,1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.
|
||||
***************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned int implode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param,
|
||||
unsigned int *type,
|
||||
unsigned int *dsize);
|
||||
|
||||
|
||||
unsigned int explode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param);
|
||||
|
||||
unsigned long crc32(char *buffer, unsigned int *size, unsigned long *old_crc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // End of 'extern "C"' declaration
|
||||
#endif
|
||||
|
||||
|
||||
#define CMP_BUFFER_SIZE 36312
|
||||
#define EXP_BUFFER_SIZE 12596
|
||||
|
||||
#define CMP_BINARY 0
|
||||
#define CMP_ASCII 1
|
||||
|
||||
#define CMP_NO_ERROR 0
|
||||
#define CMP_INVALID_DICTSIZE 1
|
||||
#define CMP_INVALID_MODE 2
|
||||
#define CMP_BAD_DATA 3
|
||||
#define CMP_ABORT 4
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mainfrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "mem2mem.h"
|
||||
|
||||
#include "mainfrm.h"
|
||||
#include "DCL.H"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
|
||||
//{{AFX_MSG_MAP(CMainFrame)
|
||||
ON_WM_CREATE()
|
||||
ON_COMMAND(IDM_TEST, OnTest)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// arrays of IDs used to initialize control bars
|
||||
|
||||
// toolbar buttons - IDs are command buttons
|
||||
static UINT BASED_CODE buttons[] =
|
||||
{
|
||||
// same order as in the bitmap 'toolbar.bmp'
|
||||
ID_FILE_NEW,
|
||||
ID_FILE_OPEN,
|
||||
ID_FILE_SAVE,
|
||||
ID_SEPARATOR,
|
||||
ID_EDIT_CUT,
|
||||
ID_EDIT_COPY,
|
||||
ID_EDIT_PASTE,
|
||||
ID_SEPARATOR,
|
||||
ID_FILE_PRINT,
|
||||
ID_APP_ABOUT,
|
||||
};
|
||||
|
||||
static UINT BASED_CODE indicators[] =
|
||||
{
|
||||
ID_SEPARATOR, // status line indicator
|
||||
ID_INDICATOR_CAPS,
|
||||
ID_INDICATOR_NUM,
|
||||
ID_INDICATOR_SCRL,
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame()
|
||||
{
|
||||
// TODO: add member initialization code here
|
||||
}
|
||||
|
||||
CMainFrame::~CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
{
|
||||
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
if (!m_wndStatusBar.Create(this) ||
|
||||
!m_wndStatusBar.SetIndicators(indicators,
|
||||
sizeof(indicators)/sizeof(UINT)))
|
||||
{
|
||||
TRACE("Failed to create status bar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMainFrame::AssertValid() const
|
||||
{
|
||||
CFrameWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFrameWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
|
||||
void CMainFrame::OnTest()
|
||||
{
|
||||
CFileDialog FileDlg( TRUE, NULL, "*.*" );
|
||||
|
||||
if( FileDlg.DoModal() == IDOK )
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
// GET DC AND SET THE TEXT BACKGROUND COLOR TO WINDOW BACKGROUND COLOR
|
||||
CClientDC dc(this);
|
||||
COLORREF bkGroundColor = dc.GetPixel( 0, 0 );
|
||||
dc.SetBkColor( bkGroundColor );
|
||||
|
||||
hWnd = CWnd::GetSafeHwnd();
|
||||
|
||||
MemToMemExample( hWnd, &dc, (LPSTR)(const char *)FileDlg.GetPathName() );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mainfrm.h : interface of the CMainFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CMainFrame : public CFrameWnd
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CMainFrame();
|
||||
DECLARE_DYNCREATE(CMainFrame)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMainFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected: // control bar embedded members
|
||||
CStatusBar m_wndStatusBar;
|
||||
CToolBar m_wndToolBar;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMainFrame)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg void OnTest();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mem2mdoc.cpp : implementation of the CMem2memDoc class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "mem2mem.h"
|
||||
|
||||
#include "mem2mdoc.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMem2memDoc, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMem2memDoc, CDocument)
|
||||
//{{AFX_MSG_MAP(CMem2memDoc)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memDoc construction/destruction
|
||||
|
||||
CMem2memDoc::CMem2memDoc()
|
||||
{
|
||||
// TODO: add one-time construction code here
|
||||
}
|
||||
|
||||
CMem2memDoc::~CMem2memDoc()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CMem2memDoc::OnNewDocument()
|
||||
{
|
||||
if (!CDocument::OnNewDocument())
|
||||
return FALSE;
|
||||
|
||||
// TODO: add reinitialization code here
|
||||
// (SDI documents will reuse this document)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memDoc serialization
|
||||
|
||||
void CMem2memDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
// TODO: add storing code here
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: add loading code here
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMem2memDoc::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void CMem2memDoc::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memDoc commands
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mem2mdoc.h : interface of the CMem2memDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CMem2memDoc : public CDocument
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CMem2memDoc();
|
||||
DECLARE_DYNCREATE(CMem2memDoc)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMem2memDoc();
|
||||
virtual void Serialize(CArchive& ar); // overridden for document i/o
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual BOOL OnNewDocument();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMem2memDoc)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mem2mem.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "mem2mem.h"
|
||||
|
||||
#include "mainfrm.h"
|
||||
#include "mem2mdoc.h"
|
||||
#include "mem2mvw.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMem2memApp, CWinApp)
|
||||
//{{AFX_MSG_MAP(CMem2memApp)
|
||||
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard file based document commands
|
||||
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
|
||||
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memApp construction
|
||||
|
||||
CMem2memApp::CMem2memApp()
|
||||
{
|
||||
// TODO: add construction code here,
|
||||
// Place all significant initialization in InitInstance
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CMem2memApp object
|
||||
|
||||
CMem2memApp NEAR theApp;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memApp initialization
|
||||
|
||||
BOOL CMem2memApp::InitInstance()
|
||||
{
|
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need.
|
||||
|
||||
SetDialogBkColor(); // Set dialog background color to gray
|
||||
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views.
|
||||
|
||||
CSingleDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CSingleDocTemplate(
|
||||
IDR_MAINFRAME,
|
||||
RUNTIME_CLASS(CMem2memDoc),
|
||||
RUNTIME_CLASS(CMainFrame), // main SDI frame window
|
||||
RUNTIME_CLASS(CMem2memView));
|
||||
AddDocTemplate(pDocTemplate);
|
||||
|
||||
// create a new (empty) document
|
||||
OnFileNew();
|
||||
|
||||
if (m_lpCmdLine[0] != '\0')
|
||||
{
|
||||
// TODO: add command line processing here
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
class CAboutDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
CAboutDlg();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CAboutDlg)
|
||||
enum { IDD = IDD_ABOUTBOX };
|
||||
//}}AFX_DATA
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//{{AFX_MSG(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CAboutDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CAboutDlg)
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// App command to run the dialog
|
||||
void CMem2memApp::OnAppAbout()
|
||||
{
|
||||
CAboutDlg aboutDlg;
|
||||
aboutDlg.DoModal();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memApp commands
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mem2mem.h : main header file for the MEM2MEM application
|
||||
//
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memApp:
|
||||
// See mem2mem.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CMem2memApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CMem2memApp();
|
||||
|
||||
// Overrides
|
||||
virtual BOOL InitInstance();
|
||||
|
||||
// Implementation
|
||||
|
||||
//{{AFX_MSG(CMem2memApp)
|
||||
afx_msg void OnAppAbout();
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,283 @@
|
||||
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MEM2MEM.MAK" CFG="Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "Win32 Debug"
|
||||
MTL=MkTypLib.exe
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 2
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "WinRel"
|
||||
# PROP BASE Intermediate_Dir "WinRel"
|
||||
# PROP Use_MFC 2
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "WinRel"
|
||||
# PROP Intermediate_Dir "WinRel"
|
||||
OUTDIR=.\WinRel
|
||||
INTDIR=.\WinRel
|
||||
|
||||
ALL : $(OUTDIR)/MEM2MEM.exe $(OUTDIR)/MEM2MEM.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /win32
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /YX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"STDAFX.H" /c
|
||||
# SUBTRACT CPP /Fr
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
|
||||
"_AFXDLL" /D "_MBCS" /Fp$(OUTDIR)/"MEM2MEM.pch" /Yu"STDAFX.H" /Fo$(INTDIR)/ /c
|
||||
CPP_OBJS=.\WinRel/
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
|
||||
RSC_PROJ=/l 0x409 /fo$(INTDIR)/"MEM2MEM.res" /d "NDEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_SBRS= \
|
||||
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"MEM2MEM.bsc"
|
||||
|
||||
$(OUTDIR)/MEM2MEM.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 oldnames.lib pkwdcl.lib /NOLOGO /STACK:0x10240 /SUBSYSTEM:windows /MACHINE:IX86
|
||||
# ADD LINK32 oldnames.lib implodei.lib /NOLOGO /STACK:0x10240 /SUBSYSTEM:windows /MACHINE:IX86
|
||||
# SUBTRACT LINK32 /INCREMENTAL:yes
|
||||
LINK32_FLAGS=oldnames.lib implodei.lib /NOLOGO /STACK:0x10240\
|
||||
/SUBSYSTEM:windows /INCREMENTAL:no /PDB:$(OUTDIR)/"MEM2MEM.pdb" /MACHINE:IX86\
|
||||
/OUT:$(OUTDIR)/"MEM2MEM.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/MEM2MEM.res \
|
||||
$(INTDIR)/STDAFX.OBJ \
|
||||
$(INTDIR)/MEM2MEM.OBJ \
|
||||
$(INTDIR)/MAINFRM.OBJ \
|
||||
$(INTDIR)/MEM2MDOC.OBJ \
|
||||
$(INTDIR)/MEM2MVW.OBJ \
|
||||
$(INTDIR)/DCL.OBJ
|
||||
|
||||
$(OUTDIR)/MEM2MEM.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 2
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "WinDebug"
|
||||
# PROP BASE Intermediate_Dir "WinDebug"
|
||||
# PROP Use_MFC 2
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "WinDebug"
|
||||
# PROP Intermediate_Dir "WinDebug"
|
||||
OUTDIR=.\WinDebug
|
||||
INTDIR=.\WinDebug
|
||||
|
||||
ALL : $(OUTDIR)/MEM2MEM.exe $(OUTDIR)/MEM2MEM.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /win32
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"STDAFX.H" /c
|
||||
# SUBTRACT CPP /Fr
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
|
||||
"_AFXDLL" /D "_MBCS" /Fp$(OUTDIR)/"MEM2MEM.pch" /Yu"STDAFX.H" /Fo$(INTDIR)/\
|
||||
/Fd$(OUTDIR)/"MEM2MEM.pdb" /c
|
||||
CPP_OBJS=.\WinDebug/
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
|
||||
RSC_PROJ=/l 0x409 /fo$(INTDIR)/"MEM2MEM.res" /d "_DEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_SBRS= \
|
||||
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"MEM2MEM.bsc"
|
||||
|
||||
$(OUTDIR)/MEM2MEM.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 oldnames.lib pkwdcl.lib /NOLOGO /STACK:0x10240 /SUBSYSTEM:windows /DEBUG /MACHINE:IX86
|
||||
# ADD LINK32 oldnames.lib implodei.lib /NOLOGO /STACK:0x10240 /SUBSYSTEM:windows /INCREMENTAL:no /DEBUG /MACHINE:IX86
|
||||
LINK32_FLAGS=oldnames.lib implodei.lib /NOLOGO /STACK:0x10240\
|
||||
/SUBSYSTEM:windows /INCREMENTAL:no /PDB:$(OUTDIR)/"MEM2MEM.pdb" /DEBUG\
|
||||
/MACHINE:IX86 /OUT:$(OUTDIR)/"MEM2MEM.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/MEM2MEM.res \
|
||||
$(INTDIR)/STDAFX.OBJ \
|
||||
$(INTDIR)/MEM2MEM.OBJ \
|
||||
$(INTDIR)/MAINFRM.OBJ \
|
||||
$(INTDIR)/MEM2MDOC.OBJ \
|
||||
$(INTDIR)/MEM2MVW.OBJ \
|
||||
$(INTDIR)/DCL.OBJ
|
||||
|
||||
$(OUTDIR)/MEM2MEM.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Group "Source Files"
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MEM2MEM.RC
|
||||
DEP_MEM2M=\
|
||||
.\RES\MEM2MEM.ICO\
|
||||
.\RES\TOOLBAR.BMP\
|
||||
.\RESOURCE.H\
|
||||
.\RES\MEM2MEM.RC2
|
||||
|
||||
$(INTDIR)/MEM2MEM.res : $(SOURCE) $(DEP_MEM2M) $(INTDIR)
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\STDAFX.CPP
|
||||
DEP_STDAF=\
|
||||
.\STDAFX.H
|
||||
|
||||
!IF "$(CFG)" == "Win32 Release"
|
||||
|
||||
# ADD BASE CPP /Yc"STDAFX.H"
|
||||
# ADD CPP /Yc"STDAFX.H"
|
||||
|
||||
$(INTDIR)/STDAFX.OBJ : $(SOURCE) $(DEP_STDAF) $(INTDIR)
|
||||
$(CPP) /nologo /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
|
||||
"_AFXDLL" /D "_MBCS" /Fp$(OUTDIR)/"MEM2MEM.pch" /Yc"STDAFX.H" /Fo$(INTDIR)/ /c\
|
||||
$(SOURCE)
|
||||
|
||||
!ELSEIF "$(CFG)" == "Win32 Debug"
|
||||
|
||||
# ADD BASE CPP /Yc"STDAFX.H"
|
||||
# ADD CPP /Yc"STDAFX.H"
|
||||
|
||||
$(INTDIR)/STDAFX.OBJ : $(SOURCE) $(DEP_STDAF) $(INTDIR)
|
||||
$(CPP) /nologo /MD /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
|
||||
"_AFXDLL" /D "_MBCS" /Fp$(OUTDIR)/"MEM2MEM.pch" /Yc"STDAFX.H" /Fo$(INTDIR)/\
|
||||
/Fd$(OUTDIR)/"MEM2MEM.pdb" /c $(SOURCE)
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MEM2MEM.CPP
|
||||
DEP_MEM2ME=\
|
||||
.\STDAFX.H\
|
||||
.\MEM2MEM.H\
|
||||
.\MAINFRM.H\
|
||||
.\MEM2MDOC.H\
|
||||
.\MEM2MVW.H\
|
||||
.\RESOURCE.H
|
||||
|
||||
$(INTDIR)/MEM2MEM.OBJ : $(SOURCE) $(DEP_MEM2ME) $(INTDIR)\
|
||||
$(INTDIR)/STDAFX.OBJ
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MAINFRM.CPP
|
||||
DEP_MAINF=\
|
||||
.\STDAFX.H\
|
||||
.\MEM2MEM.H\
|
||||
.\MAINFRM.H\
|
||||
.\DCL.H\
|
||||
.\RESOURCE.H
|
||||
|
||||
$(INTDIR)/MAINFRM.OBJ : $(SOURCE) $(DEP_MAINF) $(INTDIR) $(INTDIR)/STDAFX.OBJ
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MEM2MDOC.CPP
|
||||
DEP_MEM2MD=\
|
||||
.\STDAFX.H\
|
||||
.\MEM2MEM.H\
|
||||
.\MEM2MDOC.H\
|
||||
.\RESOURCE.H
|
||||
|
||||
$(INTDIR)/MEM2MDOC.OBJ : $(SOURCE) $(DEP_MEM2MD) $(INTDIR)\
|
||||
$(INTDIR)/STDAFX.OBJ
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MEM2MVW.CPP
|
||||
DEP_MEM2MV=\
|
||||
.\STDAFX.H\
|
||||
.\MEM2MEM.H\
|
||||
.\MEM2MDOC.H\
|
||||
.\MEM2MVW.H\
|
||||
.\RESOURCE.H
|
||||
|
||||
$(INTDIR)/MEM2MVW.OBJ : $(SOURCE) $(DEP_MEM2MV) $(INTDIR)\
|
||||
$(INTDIR)/STDAFX.OBJ
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DCL.CPP
|
||||
DEP_DCL_C=\
|
||||
.\STDAFX.H\
|
||||
.\PKWDCL.H
|
||||
|
||||
$(INTDIR)/DCL.OBJ : $(SOURCE) $(DEP_DCL_C) $(INTDIR) $(INTDIR)/STDAFX.OBJ
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Project
|
||||
################################################################################
|
||||
@@ -0,0 +1,209 @@
|
||||
//Microsoft App Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""res\\mem2mem.rc2"" // non-App Studio edited resources\r\n"
|
||||
"\r\n"
|
||||
"#include ""afxres.rc"" \011// Standard components\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
IDR_MAINFRAME ICON DISCARDABLE "RES\\MEM2MEM.ICO"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDR_MAINFRAME BITMAP MOVEABLE PURE "RES\\TOOLBAR.BMP"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Test", IDM_TEST
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About Mem2mem...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 34, 22, 217, 55
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About Mem2mem"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
|
||||
LTEXT "Mem2mem Application Version 1.0",IDC_STATIC,40,10,119,8
|
||||
LTEXT "Copyright \251 1995",IDC_STATIC,40,25,119,8
|
||||
DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP
|
||||
END
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
IDR_MAINFRAME "Mem2mem Windows Application\n\nMem2me Document\n\n\nMem2me.Document\nMem2me Document"
|
||||
END
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_APP_TITLE "Mem2mem Windows Application"
|
||||
AFX_IDS_IDLEMESSAGE "Ready"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_INDICATOR_EXT "EXT"
|
||||
ID_INDICATOR_CAPS "CAP"
|
||||
ID_INDICATOR_NUM "NUM"
|
||||
ID_INDICATOR_SCRL "SCRL"
|
||||
ID_INDICATOR_OVR "OVR"
|
||||
ID_INDICATOR_REC "REC"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_NEW "Create a new document"
|
||||
ID_FILE_OPEN "Open an existing document"
|
||||
ID_FILE_CLOSE "Close the active document"
|
||||
ID_FILE_SAVE "Save the active document"
|
||||
ID_FILE_SAVE_AS "Save the active document with a new name"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_APP_ABOUT "Display program information, version number and copyright"
|
||||
ID_APP_EXIT "Quit the application; prompts to save documents"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_MRU_FILE1 "Open this document"
|
||||
ID_FILE_MRU_FILE2 "Open this document"
|
||||
ID_FILE_MRU_FILE3 "Open this document"
|
||||
ID_FILE_MRU_FILE4 "Open this document"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_NEXT_PANE "Switch to the next window pane"
|
||||
ID_PREV_PANE "Switch back to the previous window pane"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_EDIT_CLEAR "Erase the selection"
|
||||
ID_EDIT_CLEAR_ALL "Erase everything"
|
||||
ID_EDIT_COPY "Copy the selection and put it on the Clipboard"
|
||||
ID_EDIT_CUT "Cut the selection and put it on the Clipboard"
|
||||
ID_EDIT_FIND "Find the specified text"
|
||||
ID_EDIT_PASTE "Insert Clipboard contents"
|
||||
ID_EDIT_REPEAT "Repeat the last action"
|
||||
ID_EDIT_REPLACE "Replace specific text with different text"
|
||||
ID_EDIT_SELECT_ALL "Select the entire document"
|
||||
ID_EDIT_UNDO "Undo the last action"
|
||||
ID_EDIT_REDO "Redo the previously undone action"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_VIEW_TOOLBAR "Show or hide the toolbar"
|
||||
ID_VIEW_STATUS_BAR "Show or hide the status bar"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCSIZE "Change the window size"
|
||||
AFX_IDS_SCMOVE "Change the window position"
|
||||
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
|
||||
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
|
||||
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
|
||||
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
|
||||
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCRESTORE "Restore the window to normal size"
|
||||
AFX_IDS_SCTASKLIST "Activate Task List"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDM_TEST "Test compression to and from memory"
|
||||
END
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#include "res\mem2mem.rc2" // non-App Studio edited resources
|
||||
|
||||
#include "afxres.rc" // Standard components
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mem2mvw.cpp : implementation of the CMem2memView class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "mem2mem.h"
|
||||
|
||||
#include "mem2mdoc.h"
|
||||
#include "mem2mvw.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memView
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMem2memView, CView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMem2memView, CView)
|
||||
//{{AFX_MSG_MAP(CMem2memView)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memView construction/destruction
|
||||
|
||||
CMem2memView::CMem2memView()
|
||||
{
|
||||
// TODO: add construction code here
|
||||
}
|
||||
|
||||
CMem2memView::~CMem2memView()
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memView drawing
|
||||
|
||||
void CMem2memView::OnDraw(CDC* pDC)
|
||||
{
|
||||
CMem2memDoc* pDoc = GetDocument();
|
||||
ASSERT_VALID(pDoc);
|
||||
|
||||
// TODO: add draw code for native data here
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memView diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMem2memView::AssertValid() const
|
||||
{
|
||||
CView::AssertValid();
|
||||
}
|
||||
|
||||
void CMem2memView::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CView::Dump(dc);
|
||||
}
|
||||
|
||||
CMem2memDoc* CMem2memView::GetDocument() // non-debug version is inline
|
||||
{
|
||||
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMem2memDoc)));
|
||||
return (CMem2memDoc*)m_pDocument;
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMem2memView message handlers
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mem2mvw.h : interface of the CMem2memView class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CMem2memView : public CView
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CMem2memView();
|
||||
DECLARE_DYNCREATE(CMem2memView)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
CMem2memDoc* GetDocument();
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMem2memView();
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMem2memView)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
#ifndef _DEBUG // debug version in mem2mvw.cpp
|
||||
inline CMem2memDoc* CMem2memView::GetDocument()
|
||||
{ return (CMem2memDoc*)m_pDocument; }
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 768 B |
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// MEM2MEM.RC2 - resources App Studio does not edit directly
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#error this file is not editable by App Studio
|
||||
#endif //APSTUDIO_INVOKED
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Version stamp for this .EXE
|
||||
|
||||
#include "ver.h"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG|VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE
|
||||
#else
|
||||
FILEFLAGS 0 // final version
|
||||
#endif
|
||||
FILEOS VOS_DOS_WINDOWS16
|
||||
FILETYPE VFT_APP
|
||||
FILESUBTYPE 0 // not used
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "MEM2MEM MFC Application\0"
|
||||
VALUE "FileVersion", "1.0.001\0"
|
||||
VALUE "InternalName", "MEM2MEM\0"
|
||||
VALUE "LegalCopyright", "\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename","MEM2MEM.EXE\0"
|
||||
VALUE "ProductName", "MEM2MEM\0"
|
||||
VALUE "ProductVersion", "1.0.001\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
// English language (0x409) and the Windows ANSI codepage (1252)
|
||||
END
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Add additional manually edited resources here...
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// App Studio generated include file.
|
||||
// Used by MEM2MEM.RC
|
||||
//
|
||||
#define IDR_MAINFRAME 2
|
||||
#define IDD_ABOUTBOX 100
|
||||
#define IDM_TEST 32771
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 32772
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,5 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// stdafx.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
@@ -0,0 +1,7 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions (including VB)
|
||||
@@ -0,0 +1,705 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* DCL.cpp - File to call various DCL DLL functions
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dos.h>
|
||||
|
||||
#include "implode.h"
|
||||
|
||||
#define TEMPFILENAME "~~~.$$$" // TEMPORARY FILENAME TO CREATE
|
||||
#define APPENDBUFSIZE 32000 // SIZE OF BUFFER TO ALLOCATE FOR APPENDING
|
||||
// A COMPRESSED FILE TO .MCF FILE
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COMPRESSING = 1,
|
||||
UNCOMPRESSING
|
||||
} FILEMODE;
|
||||
|
||||
|
||||
// STRUCT TO PASS TO THE FILE IO FUNCTIONS
|
||||
typedef struct
|
||||
{
|
||||
CFile *InFile;
|
||||
CFile *OutFile;
|
||||
CDC *pDC;
|
||||
BYTE nPrevNdx;
|
||||
BYTE nCnt;
|
||||
DWORD dwCompressSize;
|
||||
FILEMODE mode;
|
||||
DWORD dwCrc;
|
||||
}IOFILEBLOCK, *PIOFILEBLOCK;
|
||||
|
||||
// FOUR LETTER IDENTIFIER TO IDENTIFY A FILE AS
|
||||
// A .MCF (MULTIPLE COMPRESSED FILES) FILE
|
||||
char MCF_FILEHEADER[] = { "MCFX" };
|
||||
|
||||
#pragma pack(2)
|
||||
|
||||
// HEADER FOR EACH FILE COMPRESSED INTO THE .MCF FILE
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwCompressSize; // SIZE OF FILE COMPRESSED
|
||||
DWORD dwCrc; // THE CRC OF THE FILE BEFORE COMPRESSION
|
||||
char filename[13]; // NAME OF THE FILE
|
||||
}CMP_FILEHEADER, *PCMP_FILEHEADER;
|
||||
|
||||
#pragma pack(8)
|
||||
|
||||
/*
|
||||
* FORMAT OF .MCF FILE:
|
||||
*
|
||||
* .MCF FILEHEADER => MCFX
|
||||
* COMPRESSED FILE FILEHEADER => { CMP_FILEHEADER }
|
||||
* FOLLOWED BY { ... COMPRESSED FILE DATA ... }
|
||||
* COMPRESSED FILE FILEHEADER => { CMP_FILEHEADER }
|
||||
* FOLLOWED BY { ... COMPRESSED FILE DATA ... }
|
||||
* COMPRESSED FILE FILEHEADER => { CMP_FILEHEADER }
|
||||
* FOLLOWED BY { ... COMPRESSED FILE DATA ... }
|
||||
* AND SO ON
|
||||
*
|
||||
*/
|
||||
|
||||
static char *pszActiveString[] = { "|", "/", "-", "\\" };
|
||||
|
||||
UINT DataType = CMP_ASCII; // GLOBAL FOR DATA TYPE FOR COMPRESSION
|
||||
UINT DictSize = 4096; // GLOBAL FOR DICTIONARY SIZE FOR COMPRESSION
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: ProcessMessages()
|
||||
*
|
||||
* Purpose: To allow Windows to process window messages which
|
||||
* allows the user to multitask will compressing and
|
||||
* uncompressing files.
|
||||
*
|
||||
* Returns: Nothing
|
||||
*
|
||||
*********************************************************************/
|
||||
void ProcessMessages(void)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
|
||||
{
|
||||
if (msg.message == WM_QUIT)
|
||||
return;
|
||||
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: ProcessInBuffer()
|
||||
*
|
||||
* Purpose: To handle calls from the Data Compression Library for
|
||||
* read requests. If compressing, then the data read is
|
||||
* in uncompressed form. If compressing, then the data
|
||||
* read is data that was previously compressed. This
|
||||
* function is called until zero is returned.
|
||||
*
|
||||
* Parameters: buffer -> Address of buffer to read the data into
|
||||
* iSize -> Number of bytes to read into buffer
|
||||
* dwParam -> User-defined parameter, in this case a
|
||||
* pointer to the IOFILEBLOCK
|
||||
*
|
||||
* Returns: Number of bytes actually read, or zero on EOF
|
||||
*
|
||||
*********************************************************************/
|
||||
UINT ProcessInBuffer( PCHAR buffer, UINT *iSize, void *pParam)
|
||||
{
|
||||
PIOFILEBLOCK pFileIOBlock;
|
||||
UINT iRead;
|
||||
UINT ndx;
|
||||
|
||||
pFileIOBlock = (PIOFILEBLOCK) pParam;
|
||||
|
||||
// DISPLAY ROTATING LINE
|
||||
ndx = (pFileIOBlock->nCnt >> 4) & 3;
|
||||
if( ndx != pFileIOBlock->nPrevNdx )
|
||||
{
|
||||
pFileIOBlock->pDC->TextOut( 10,2, pszActiveString[ndx] );
|
||||
pFileIOBlock->nPrevNdx = ndx;
|
||||
}
|
||||
pFileIOBlock->nCnt++;
|
||||
|
||||
// THIS FUNCTION MAY ASK FOR UP TO 4K OF DATA AT A TIME. IF YOUR
|
||||
// ARCHIVE FILE CONTAINS SEVERAL COMPRESSED FILES, YOU MAY READ TOO
|
||||
// MUCH. FOR EXAMPLE, YOUR FIRST COMPRESSED FILE IN THE ARCHIVE MAY
|
||||
// BE 100 BYTES. SO YOU DO NOT WANT TO READ MORE THAN 100 BYTES OR
|
||||
// YOU WILL BE UNABLE TO UNCOMPRESS THE SECOND FILE, SINCE YOU WILL
|
||||
// NOT BE LOCATED AT THE BEGINNING OF THE FILE ANY LONGER.
|
||||
// WE WILL USE THE VARIABLE "dwCompressSize" TO CHECK FOR THIS
|
||||
// CONDITION.
|
||||
if( pFileIOBlock->mode == UNCOMPRESSING )
|
||||
{
|
||||
// IF DCL REQUESTED MORE BYTES THAN ARE LEFT IN COMPRESSED FILE, THEN
|
||||
// SET THE NUMBER OF BYTES TO READ TO THE AMOUNT LEFT IN THE BUFFER
|
||||
if( (DWORD) *iSize > pFileIOBlock->dwCompressSize )
|
||||
*iSize = (UINT) pFileIOBlock->dwCompressSize;
|
||||
|
||||
pFileIOBlock->dwCompressSize -= (DWORD) *iSize;
|
||||
}
|
||||
|
||||
// READ BUFFER FROM DISK
|
||||
iRead = (UINT)pFileIOBlock->InFile->Read( buffer, *iSize );
|
||||
|
||||
// IF COMPRESSING, THEN CALCULATE THE CRC
|
||||
if( pFileIOBlock->mode == COMPRESSING )
|
||||
{
|
||||
pFileIOBlock->dwCrc = crc32( buffer, &iRead, &pFileIOBlock->dwCrc );
|
||||
}
|
||||
|
||||
// ENTER MESSAGE LOOP TO PROCESS BACKGROUND MESSAGES
|
||||
// AND SIMULATE MULTITASKING
|
||||
ProcessMessages();
|
||||
|
||||
return iRead;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: ProcessOutBuffer()
|
||||
*
|
||||
* Purpose: To handle calls from the Data Compression Library for
|
||||
* write requests.
|
||||
*
|
||||
* Parameters: buffer -> Address of buffer to write data from
|
||||
* iSize -> Number of bytes to write
|
||||
* dwParam -> User-defined parameter, in this case a
|
||||
* pointer to the IOFILEBLOCK
|
||||
*
|
||||
* Returns: Zero, the return value is not used by the Data
|
||||
* Compression Library
|
||||
*
|
||||
*********************************************************************/
|
||||
void ProcessOutBuffer(PCHAR buffer, UINT *iSize, void *pParam)
|
||||
{
|
||||
PIOFILEBLOCK pFileIOBlock;
|
||||
UINT ndx;
|
||||
|
||||
pFileIOBlock = (PIOFILEBLOCK) pParam;
|
||||
|
||||
// DISPLAY ROTATING LINE PACIFIER
|
||||
ndx = (pFileIOBlock->nCnt >> 4) & 3;
|
||||
if( ndx != pFileIOBlock->nPrevNdx )
|
||||
{
|
||||
pFileIOBlock->pDC->TextOut( 10,2, pszActiveString[ndx] );
|
||||
pFileIOBlock->nPrevNdx = ndx;
|
||||
}
|
||||
pFileIOBlock->nCnt++;
|
||||
|
||||
// WRITE BUFFER TO DISK
|
||||
pFileIOBlock->OutFile->Write(buffer, *iSize);
|
||||
|
||||
// IF COMPRESSING, THEN KEEP A TOTAL OF THE COMPRESSED FILE SIZE
|
||||
if (pFileIOBlock->mode == COMPRESSING )
|
||||
{
|
||||
pFileIOBlock->dwCompressSize += (DWORD) *iSize;
|
||||
}
|
||||
else // ELSE UNCOMPRESSING, SO CALCULATE CRC ON THE UNCOMPRESSED DATA
|
||||
{
|
||||
pFileIOBlock->dwCrc = crc32(buffer, iSize, &pFileIOBlock->dwCrc);
|
||||
}
|
||||
|
||||
// ENTER MESSAGE LOOP TO PROCESS BACKGROUND MESSAGES
|
||||
// AND SIMULATE MULTITASKING
|
||||
ProcessMessages();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: CompressFile()
|
||||
*
|
||||
* Purpose: To compress file to a separate temporary file.
|
||||
*
|
||||
*
|
||||
* Parameters: HWnd -> Handle to window
|
||||
* pDC -> Pointer to a device context
|
||||
* pdwCrc -> Pointer to DWORD buffer to return the CRC
|
||||
* of the compressed file before compression
|
||||
* pdwCompFileSize -> Pointer to DWORD buffer to return
|
||||
* the size of the compressed file
|
||||
* pszFileToCompress -> Name of file to compress
|
||||
* OutputFile -> Name of file to write compressed data to
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int CompressFile( HWND hWnd, CDC *pDC, DWORD *pdwCrc,
|
||||
DWORD *pdwCompFileSize, PCHAR pszFileToCompress,
|
||||
PCHAR OutputFile )
|
||||
{
|
||||
int iStatus;
|
||||
int rc = 1;
|
||||
char szVerbose[128];
|
||||
IOFILEBLOCK FileIOBlock;
|
||||
PCHAR pScratchPad;
|
||||
|
||||
if( (pScratchPad = (PCHAR) new char[CMP_BUFFER_SIZE]) == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// OPEN THE INPUT AND OUTPUT FILES
|
||||
FileIOBlock.InFile = new CFile;
|
||||
FileIOBlock.OutFile = new CFile;
|
||||
|
||||
// SETUP STRUCTURE USED BY ProcessReadBuffer() AND ProcessWriteBuffer()
|
||||
FileIOBlock.mode = COMPRESSING;
|
||||
FileIOBlock.dwCompressSize = 0;
|
||||
FileIOBlock.pDC = pDC;
|
||||
FileIOBlock.nCnt = 0;
|
||||
FileIOBlock.nPrevNdx = 0;
|
||||
FileIOBlock.dwCrc = ~((DWORD)0); // Pre-condition CRC
|
||||
|
||||
pDC->TextOut( 10,2, " " );
|
||||
|
||||
// OPEN THE FILES
|
||||
if (FileIOBlock.InFile->Open( pszFileToCompress, CFile::modeRead | CFile::shareExclusive | CFile::typeBinary) &&
|
||||
FileIOBlock.OutFile->Open( OutputFile, CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive | CFile::typeBinary))
|
||||
{
|
||||
wsprintf( szVerbose, "Compressing file: %s ", pszFileToCompress );
|
||||
pDC->TextOut( 10,40, szVerbose );
|
||||
|
||||
// ONLY COMPRESS IF FILE IS NOT A ZERO LENGTH FILE
|
||||
if( FileIOBlock.InFile->GetLength() )
|
||||
{
|
||||
// COMPRESS THE FILE
|
||||
iStatus = implode( ProcessInBuffer, ProcessOutBuffer, pScratchPad,
|
||||
&FileIOBlock, &DataType, &DictSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
// SINCE THIS IS A ZERO LENGTH FILE, THERE IS NOTHING TO COMPRESS
|
||||
// SET STATUS TO NO ERROR
|
||||
iStatus = 0;
|
||||
}
|
||||
|
||||
// IF THERE WAS AN ERROR COMPRESSING FILE
|
||||
if( iStatus )
|
||||
{
|
||||
// DISPLAY ERROR STRING FROM DLL
|
||||
wsprintf( szVerbose, "Error occurred while imploding - %d ", iStatus );
|
||||
MessageBox( hWnd, szVerbose, "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
else // ELSE - COMPRESSION WAS SUCCESSFUL
|
||||
{
|
||||
// POST-CONDITION CRC
|
||||
FileIOBlock.dwCrc = ~FileIOBlock.dwCrc;
|
||||
|
||||
// RETURN CRC
|
||||
*pdwCrc = FileIOBlock.dwCrc;
|
||||
|
||||
// RETURN COMPRESSED FILE SIZE
|
||||
*pdwCompFileSize = FileIOBlock.dwCompressSize;
|
||||
}
|
||||
|
||||
FileIOBlock.OutFile->Close();
|
||||
FileIOBlock.InFile->Close();
|
||||
}
|
||||
else // ELSE - ERROR OPENING FILES
|
||||
{
|
||||
MessageBox( hWnd, "Error opening files for compression", "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
// CLEAN-UP
|
||||
delete FileIOBlock.InFile;
|
||||
delete FileIOBlock.OutFile;
|
||||
delete pScratchPad;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: ExpandFile()
|
||||
*
|
||||
* Purpose: To uncompress file from a .MCF file. The .MCF file will
|
||||
* have been read upto the compressed data stream.
|
||||
*
|
||||
* Parameters: HWnd -> Handle to window
|
||||
* pDC -> Pointer to a device context
|
||||
* pdwCrc -> Pointer to DWORD buffer to return the CRC
|
||||
* of the compressed file before compression
|
||||
* dwCompFileSize -> Size of the compressed file
|
||||
* pMcfFile -> Pointer to already opened .MCF file
|
||||
* OutputFile -> Name of file to write uncompressed data to
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int ExpandFile( HWND hWnd, CDC *pDC, DWORD *pdwCrc,
|
||||
DWORD dwCompFileSize, CFile *pMcfFile, PCHAR OutputFile )
|
||||
{
|
||||
int iStatus;
|
||||
int rc = 1;
|
||||
char szVerbose[128];
|
||||
IOFILEBLOCK FileIOBlock;
|
||||
PCHAR pScratchPad;
|
||||
|
||||
if( (pScratchPad = (PCHAR) new char[CMP_BUFFER_SIZE]) == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
FileIOBlock.InFile = pMcfFile;
|
||||
FileIOBlock.OutFile = new CFile;
|
||||
|
||||
// SETUP STRUCTURE USED BY ProcessReadBuffer() and ProcessWriteBuffer()
|
||||
FileIOBlock.mode = UNCOMPRESSING;
|
||||
FileIOBlock.dwCompressSize = dwCompFileSize;
|
||||
FileIOBlock.pDC = pDC;
|
||||
FileIOBlock.nCnt = 0;
|
||||
FileIOBlock.nPrevNdx = 0;
|
||||
FileIOBlock.dwCrc = ~((DWORD)0); // Pre-condition CRC
|
||||
|
||||
pDC->TextOut( 10,2, " " );
|
||||
|
||||
if( FileIOBlock.OutFile->Open(OutputFile, CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive | CFile::typeBinary) )
|
||||
{
|
||||
// ONLY UNCOMPRESS IF FILE IS NOT A ZERO LENGTH FILE
|
||||
if( FileIOBlock.dwCompressSize )
|
||||
{
|
||||
iStatus = explode( ProcessInBuffer, ProcessOutBuffer, pScratchPad, &FileIOBlock );
|
||||
}
|
||||
else
|
||||
{
|
||||
// SINCE THIS IS A ZERO LENGTH FILE, THERE IS NOTHING TO UNCOMPRESS
|
||||
// SET STATUS TO NO ERROR
|
||||
iStatus = 0;
|
||||
}
|
||||
|
||||
if( iStatus )
|
||||
{
|
||||
wsprintf( szVerbose, "Error occurred while exploding - %d ", iStatus );
|
||||
MessageBox( hWnd, szVerbose, "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
FileIOBlock.dwCrc = ~FileIOBlock.dwCrc;
|
||||
*pdwCrc = FileIOBlock.dwCrc;
|
||||
|
||||
if( FileIOBlock.dwCompressSize != 0 )
|
||||
{
|
||||
wsprintf( szVerbose, "Error uncompressing file: %s", OutputFile );
|
||||
MessageBox( hWnd, szVerbose, "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
FileIOBlock.OutFile->Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox( hWnd, "Error opening files for uncompression", "Error", MB_OK );
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
delete FileIOBlock.OutFile;
|
||||
delete pScratchPad;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: AddFileToMcfFile()
|
||||
*
|
||||
* Purpose: To add a compressed file with header to a .MCF file.
|
||||
* The file header is written followed by the compressed
|
||||
* file data
|
||||
*
|
||||
* Parameters: pFileHeader -> File header for the compressed file
|
||||
* pszInput -> Filename of the compressed file's data
|
||||
* pszOutput -> Filename of .MCF file
|
||||
* CompressedFileSize -> Size of the compressed file
|
||||
* NewMcfFile -> Flag used to create a new .MCF file
|
||||
* TRUE - A new .MCF file will be created
|
||||
* FALSE - The .MCF file will appended to
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int AddFileToMcfFile( PCMP_FILEHEADER pFileHeader, PCHAR pszInput,
|
||||
PCHAR pszOutput, DWORD CompressedFileSize,
|
||||
BOOL NewMcfFile )
|
||||
{
|
||||
PCHAR buf;
|
||||
UINT read;
|
||||
CFile InFile;
|
||||
CFile OutFile;
|
||||
|
||||
// ALLOCATE I/O BUFFER
|
||||
if( (buf = new char[APPENDBUFSIZE]) == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
TRY
|
||||
{
|
||||
// OPEN THE FILES
|
||||
InFile.Open( pszInput, CFile::modeRead | CFile::shareExclusive | CFile::typeBinary);
|
||||
|
||||
// IF NEW FILE, THEN CREATE MULTIPLE COMPRESSED FILES FILE
|
||||
if( NewMcfFile )
|
||||
{
|
||||
// CREATE NEW .MCF FILE
|
||||
OutFile.Open( pszOutput, CFile::modeCreate | CFile::modeWrite | CFile::modeWrite | CFile::shareExclusive | CFile::typeBinary);
|
||||
|
||||
// WRITE .MCF FILE HEADER
|
||||
OutFile.Write( MCF_FILEHEADER, 4 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// OPEN OLD .MCF FILE
|
||||
OutFile.Open( pszOutput, CFile::modeWrite | CFile::shareExclusive | CFile::typeBinary);
|
||||
|
||||
// GO TO END OF FILE
|
||||
OutFile.SeekToEnd();
|
||||
}
|
||||
|
||||
// WRITE THE COMPRESSED FILE'S FILEHEADER
|
||||
OutFile.Write( pFileHeader, sizeof(CMP_FILEHEADER) );
|
||||
|
||||
do
|
||||
{
|
||||
// READ FROM COMPRESSED FILE
|
||||
read = InFile.Read( buf, APPENDBUFSIZE );
|
||||
|
||||
// WRITE DATA TO .MCF FILE
|
||||
OutFile.Write( buf, read );
|
||||
|
||||
// IF ERROR OCCURRED
|
||||
if( CompressedFileSize < (DWORD) read )
|
||||
{
|
||||
delete buf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
CompressedFileSize -= (DWORD) read;
|
||||
}
|
||||
while( CompressedFileSize > 0 );
|
||||
}
|
||||
CATCH( CFileException, theException )
|
||||
{
|
||||
// IF ERROR OCCURRED WHILE APPENDING FILE
|
||||
if( theException->m_cause != CFileException::none )
|
||||
{
|
||||
delete buf;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
END_CATCH
|
||||
|
||||
delete buf;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: CompressFileToMCF()
|
||||
*
|
||||
* Purpose: To compress a file then add it to a .MCF file
|
||||
*
|
||||
*
|
||||
* Parameters: HWnd -> Handle to window
|
||||
* pDC -> Pointer to a device context
|
||||
* pszMcfFile -> Filename of .MCF file
|
||||
* pszFileToCompress -> Filename of file with full path
|
||||
* pszFilenameOnly -> Filename of file without any path
|
||||
* This is the filename that is stored
|
||||
* in the compressed file's file header
|
||||
* NewMcfFile -> Flag used to create a new .MCF file
|
||||
* TRUE - A new .MCF file will be created
|
||||
* FALSE - The .MCF file will appended to
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int CompressFileToMCF( HWND hWnd, CDC *pDC,
|
||||
PCHAR pszMcfFile, PCHAR pszFileToCompress,
|
||||
PCHAR pszFilenameOnly, BOOL NewMcfFile )
|
||||
{
|
||||
ASSERT( hWnd );
|
||||
ASSERT_VALID( pDC );
|
||||
|
||||
CMP_FILEHEADER FileHeader;
|
||||
|
||||
memset( &FileHeader, 0, sizeof(FileHeader) );
|
||||
|
||||
// ATTEMPT TO COMPRESS THE FILE
|
||||
if( !CompressFile( hWnd, pDC, &FileHeader.dwCrc,
|
||||
&FileHeader.dwCompressSize, pszFileToCompress,
|
||||
TEMPFILENAME ) )
|
||||
{
|
||||
remove( TEMPFILENAME );
|
||||
MessageBox( hWnd, "Compress File Failed", "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy( FileHeader.filename, pszFilenameOnly );
|
||||
|
||||
if( !AddFileToMcfFile( &FileHeader, TEMPFILENAME, pszMcfFile,
|
||||
FileHeader.dwCompressSize, NewMcfFile ) )
|
||||
{
|
||||
remove( TEMPFILENAME );
|
||||
MessageBox( hWnd, "Compress File Failed", "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
|
||||
remove( TEMPFILENAME );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function: UncompressFileToMCF()
|
||||
*
|
||||
* Purpose: To uncompress a .MCF file
|
||||
*
|
||||
*
|
||||
* Parameters: HWnd -> Handle to window
|
||||
* pDC -> Pointer to a device context
|
||||
* pszMcfFilename -> Filename of .MCF file
|
||||
*
|
||||
* Returns: 1 -> Successful completion
|
||||
* 0 -> Error occurred
|
||||
*
|
||||
*********************************************************************/
|
||||
int UncompressMcfFile( HWND hWnd, CDC *pDC, PCHAR pszMcfFilename )
|
||||
{
|
||||
ASSERT( hWnd );
|
||||
ASSERT_VALID( pDC );
|
||||
|
||||
CMP_FILEHEADER FileHeader;
|
||||
char szSaveDir[80];
|
||||
char McfFileheader[5];
|
||||
char szOutMsg[128];
|
||||
char szOutputFilename[100];
|
||||
UINT nNumFiles = 0;
|
||||
PCHAR pszTemp;
|
||||
DWORD dwCrc; // CRC OF FILE BEFORE COMPRESSION
|
||||
UINT read;
|
||||
CFile McfFile;
|
||||
|
||||
// MAKE A COPY OF BUFFER SO THAT IT CAN BE MODIFIED
|
||||
strcpy( szSaveDir, pszMcfFilename );
|
||||
|
||||
// SET BUFFER WITH NAME OF FILE WITHOUT A PATH OR EXTENSION
|
||||
if( !(pszTemp = (PCHAR) strrchr( szSaveDir, '\\' )) )
|
||||
{
|
||||
MessageBox( hWnd, "Error getting directory name", "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// POINT TO FIRST CHAR AFTER BACKSLASH
|
||||
*(++pszTemp) = '\0';
|
||||
|
||||
TRY
|
||||
{
|
||||
// OPEN THE FILES
|
||||
McfFile.Open( pszMcfFilename, CFile::modeRead | CFile::shareExclusive | CFile::typeBinary);
|
||||
|
||||
memset( McfFileheader, 0, sizeof(McfFileheader) );
|
||||
|
||||
// MAKE SURE FILE IS A MULTIPLE COMPRESSED FILE
|
||||
if( (McfFile.Read( McfFileheader, 4 ) != 4) ||
|
||||
(strcmp( McfFileheader, MCF_FILEHEADER ) != 0) )
|
||||
{
|
||||
MessageBox( hWnd, "Invalid file format", "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
// READ COMPRESSED FILE FILEHEADER
|
||||
read = McfFile.Read( &FileHeader, sizeof(FileHeader) );
|
||||
|
||||
// IF SUCCESSFULLY READ COMPRESSED FILE FILEHEADER
|
||||
if( read == sizeof(FileHeader) )
|
||||
{
|
||||
// CREATE OUTPUT FILENAME
|
||||
strcpy( szOutputFilename, szSaveDir );
|
||||
strcat( szOutputFilename, FileHeader.filename );
|
||||
|
||||
wsprintf( szOutMsg, "Uncompressing file: %s ", FileHeader.filename );
|
||||
pDC->TextOut( 10,60, szOutMsg );
|
||||
|
||||
// ATTEMPT TO EXPAND THE FILE
|
||||
if( !ExpandFile( hWnd, pDC, &dwCrc, FileHeader.dwCompressSize,
|
||||
&McfFile, szOutputFilename ) )
|
||||
{
|
||||
wsprintf( szOutMsg, "Error Uncompressing file: %s",
|
||||
szOutputFilename );
|
||||
MessageBox( hWnd, szOutMsg, "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CHECK THE CRC OF THE FILE
|
||||
if( dwCrc != FileHeader.dwCrc )
|
||||
{
|
||||
wsprintf( szOutMsg, "There is an error in the CRC of %s",
|
||||
szOutputFilename );
|
||||
MessageBox( hWnd, szOutMsg, "Error", MB_OK );
|
||||
}
|
||||
|
||||
nNumFiles++;
|
||||
}
|
||||
}
|
||||
while( read == sizeof(FileHeader) );
|
||||
|
||||
if( read != 0 )
|
||||
{
|
||||
MessageBox( hWnd, "Invalid file format", "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf( szOutMsg, "Uncompressed %u file(s)", nNumFiles );
|
||||
MessageBox( hWnd, szOutMsg, "MultFile", MB_OK );
|
||||
}
|
||||
}
|
||||
CATCH( CFileException, theException )
|
||||
{
|
||||
if( theException->m_cause != CFileException::none )
|
||||
{
|
||||
MessageBox( hWnd, "File Error", "Error", MB_OK );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
END_CATCH
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
int CompressFileToMCF( HWND hWnd, CDC *pDC,
|
||||
LPSTR lpszMcfFile, LPSTR lpszFileToCompress,
|
||||
LPSTR lpszFilenameOnly, BOOL NewMcfFile );
|
||||
int UncompressMcfFile( HWND hWnd, CDC *pDC, LPSTR lpszMcfFile );
|
||||
@@ -0,0 +1,44 @@
|
||||
/***************************************************************
|
||||
PKWARE Data Compression Library (R) for Win32
|
||||
Copyright 1991,1992,1994,1995 PKWARE Inc. All Rights Reserved.
|
||||
PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.
|
||||
***************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned int implode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param,
|
||||
unsigned int *type,
|
||||
unsigned int *dsize);
|
||||
|
||||
|
||||
unsigned int explode(
|
||||
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
|
||||
void (*write_buf)(char *buf, unsigned int *size, void *param),
|
||||
char *work_buf,
|
||||
void *param);
|
||||
|
||||
unsigned long crc32(char *buffer, unsigned int *size, unsigned long *old_crc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // End of 'extern "C"' declaration
|
||||
#endif
|
||||
|
||||
|
||||
#define CMP_BUFFER_SIZE 36312
|
||||
#define EXP_BUFFER_SIZE 12596
|
||||
|
||||
#define CMP_BINARY 0
|
||||
#define CMP_ASCII 1
|
||||
|
||||
#define CMP_NO_ERROR 0
|
||||
#define CMP_INVALID_DICTSIZE 1
|
||||
#define CMP_INVALID_MODE 2
|
||||
#define CMP_BAD_DATA 3
|
||||
#define CMP_ABORT 4
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,421 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
// mainfrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <stdio.h>
|
||||
#include "multfile.h"
|
||||
|
||||
#include "mainfrm.h"
|
||||
#include "dcl.h"
|
||||
#include "multfdlg.h"
|
||||
#include "implode.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
extern UINT DataType; // GLOBAL FOR DATA TYPE FOR COMPRESSION
|
||||
extern UINT DictSize; // GLOBAL FOR DICTIONARY SIZE FOR COMPRESSION
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
|
||||
//{{AFX_MSG_MAP(CMainFrame)
|
||||
ON_WM_CREATE()
|
||||
ON_WM_QUERYENDSESSION()
|
||||
ON_WM_CLOSE()
|
||||
ON_COMMAND(IDM_COMPRESS_FILES, OnCompressFiles)
|
||||
ON_COMMAND(IDM_UNCOMPRESS_FILES, OnUncompressFiles)
|
||||
ON_UPDATE_COMMAND_UI(IDM_COMPRESS_FILES, OnUpdateCompressFiles)
|
||||
ON_UPDATE_COMMAND_UI(IDM_UNCOMPRESS_FILES, OnUpdateUncompressFiles)
|
||||
ON_COMMAND(IDM_CMP_ASCII, OnCmpAscii)
|
||||
ON_COMMAND(IDM_CMP_BINARY, OnCmpBinary)
|
||||
ON_COMMAND(IDM_DICT_SIZE_1024, OnDictSize1024)
|
||||
ON_COMMAND(IDM_DICT_SIZE_2048, OnDictSize2048)
|
||||
ON_COMMAND(IDM_DICT_SIZE_4096, OnDictSize4096)
|
||||
ON_UPDATE_COMMAND_UI(IDM_CMP_ASCII, OnUpdateCmpAscii)
|
||||
ON_UPDATE_COMMAND_UI(IDM_CMP_BINARY, OnUpdateCmpBinary)
|
||||
ON_UPDATE_COMMAND_UI(IDM_DICT_SIZE_1024, OnUpdateDictSize1024)
|
||||
ON_UPDATE_COMMAND_UI(IDM_DICT_SIZE_2048, OnUpdateDictSize2048)
|
||||
ON_UPDATE_COMMAND_UI(IDM_DICT_SIZE_4096, OnUpdateDictSize4096)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// arrays of IDs used to initialize control bars
|
||||
|
||||
// toolbar buttons - IDs are command buttons
|
||||
static UINT BASED_CODE buttons[] =
|
||||
{
|
||||
// same order as in the bitmap 'toolbar.bmp'
|
||||
ID_FILE_NEW,
|
||||
ID_FILE_OPEN,
|
||||
ID_FILE_SAVE,
|
||||
ID_SEPARATOR,
|
||||
ID_EDIT_CUT,
|
||||
ID_EDIT_COPY,
|
||||
ID_EDIT_PASTE,
|
||||
ID_SEPARATOR,
|
||||
ID_FILE_PRINT,
|
||||
ID_APP_ABOUT,
|
||||
};
|
||||
|
||||
static UINT BASED_CODE indicators[] =
|
||||
{
|
||||
ID_SEPARATOR, // status line indicator
|
||||
ID_INDICATOR_CAPS,
|
||||
ID_INDICATOR_NUM,
|
||||
ID_INDICATOR_SCRL,
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame()
|
||||
{
|
||||
// TODO: add member initialization code here
|
||||
}
|
||||
|
||||
CMainFrame::~CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
{
|
||||
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
if (!m_wndStatusBar.Create(this) ||
|
||||
!m_wndStatusBar.SetIndicators(indicators,
|
||||
sizeof(indicators)/sizeof(UINT)))
|
||||
{
|
||||
TRACE("Failed to create status bar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMainFrame::AssertValid() const
|
||||
{
|
||||
CFrameWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFrameWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
|
||||
void CMainFrame::OnCompressFiles()
|
||||
{
|
||||
int rc;
|
||||
HWND hWnd;
|
||||
|
||||
// GET HANDLE TO WINDOW AND INSTANCE HANDLE
|
||||
hWnd = CWnd::GetSafeHwnd();
|
||||
|
||||
// TURN OFF HELP MESSAGE SCREEN AND CLEAR SCREEN
|
||||
SendMessageToDescendants( WM_TURN_OFF_HELP );
|
||||
|
||||
// CREATE FILE DIALOG THAT CAN USE CAN SELECT MULTIPLE FILES
|
||||
CMultiSelFileDialog *FileDlg = new CMultiSelFileDialog( this );
|
||||
|
||||
// IF USER PRESSED OK BUTTON
|
||||
if( (rc = FileDlg->DoModal()) == IDOK )
|
||||
{
|
||||
// CREATE SAVE AS FILE DIALOG
|
||||
CFileDialog SaveFileDlg( FALSE, "MCF", "*.MCF",
|
||||
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR,
|
||||
"Mult. Compressed Files (*.MCF) |*.MCF ||", this );
|
||||
|
||||
// GET FILENAME OF FILE TO PUT COMPRESSED FILES IN
|
||||
if( (SaveFileDlg.DoModal()) == IDOK )
|
||||
{
|
||||
BOOL GotFilenameOk,
|
||||
bError = FALSE,
|
||||
CreateMcfFile;
|
||||
UINT nNumCmpFiles = 0;
|
||||
char szFilename[13]; // BUFFER FOR FILENAME ONLY
|
||||
char szFullPathname[128]; // BUFFER FOR FULL PATH FOR FILE
|
||||
char szOutBuff[64]; // TEMP OUTPUT BUFFER
|
||||
|
||||
// SET FLAG TO PREVENT EXITING IN THE MIDDLE OF THE COMPRESSION
|
||||
((CMultfileApp *) AfxGetApp())->OkToExit = FALSE;
|
||||
|
||||
// GET DC AND SET THE TEXT BACKGROUND COLOR TO WINDOW BACKGROUND COLOR
|
||||
CClientDC dc(this);
|
||||
COLORREF bkGroundColor = dc.GetPixel( 0, 0 );
|
||||
dc.SetBkColor( bkGroundColor );
|
||||
|
||||
wsprintf( szOutBuff, "Compressing to: %s ",
|
||||
(LPSTR) (const char *) SaveFileDlg.GetPathName() );
|
||||
dc.TextOut( 10,20, szOutBuff );
|
||||
|
||||
// SET CREATE .MCF FILE FLAG TO TRUE, SO THAT THE FIRST TIME
|
||||
// CompressFileToMCF IS CALLED THE .MCF WILL BE CREATED INSTEAD
|
||||
// OF APPENDED TO
|
||||
CreateMcfFile = TRUE;
|
||||
|
||||
// GET THE FIRST FILENAME IN THE LIST
|
||||
GotFilenameOk = FileDlg->GetFirstFilename( szFullPathname,
|
||||
sizeof(szFullPathname),
|
||||
szFilename );
|
||||
// WHILE GOT A FILENAME FROM THE LIST
|
||||
while( GotFilenameOk )
|
||||
{
|
||||
// COMPRESS THE FILE AND ADD IT TO THE .MCF FILE
|
||||
if( !CompressFileToMCF( hWnd, &dc,
|
||||
(LPSTR) (const char *) SaveFileDlg.GetPathName(),
|
||||
szFullPathname, szFilename, CreateMcfFile ) )
|
||||
{
|
||||
// ERROR OCCURRED SO DELETE THE .MCF FILE
|
||||
remove( (const char *) SaveFileDlg.GetPathName() );
|
||||
bError = TRUE;
|
||||
break;
|
||||
}
|
||||
// INCREMENT TOTAL
|
||||
nNumCmpFiles++;
|
||||
|
||||
// RESET .MCF FILE FLAG SO THAT .MCF FILE WILL NOT BE CREATED
|
||||
CreateMcfFile = FALSE;
|
||||
|
||||
// GET THE FIRST FILENAME IN THE LIST
|
||||
GotFilenameOk = FileDlg->GetNextFilename( szFullPathname,
|
||||
sizeof(szFullPathname),
|
||||
szFilename );
|
||||
}
|
||||
|
||||
// IF THERE WAS NOT ERROR, THEN DISPLAY MESSAGE
|
||||
if( !bError )
|
||||
{
|
||||
wsprintf( szOutBuff, "Compressed %u file(s)", nNumCmpFiles );
|
||||
MessageBox( szOutBuff );
|
||||
}
|
||||
|
||||
// DONE WITH COMPRESION SO ALLOW THE USER TO EXIT
|
||||
((CMultfileApp *) AfxGetApp())->OkToExit = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// CLEAN-UP
|
||||
delete FileDlg;
|
||||
|
||||
// TURN ON HELP MESSAGE AND CLEAR SCREEN
|
||||
SendMessageToDescendants( WM_TURN_ON_HELP );
|
||||
}
|
||||
|
||||
void CMainFrame::OnUncompressFiles()
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
hWnd = CWnd::GetSafeHwnd();
|
||||
|
||||
// TURN OFF HELP MESSAGE AND CLEAR SCREEN
|
||||
SendMessageToDescendants( WM_TURN_OFF_HELP );
|
||||
|
||||
// OPENFILENAME
|
||||
CFileDialog OpenFileDlg( TRUE, "MCF", "*.MCF",
|
||||
OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||
"Mult. Compressed Files (*.MCF) |*.MCF ||", this );
|
||||
|
||||
// GET FILENAME OF FILE TO PUT COMPRESSED FILES IN
|
||||
if( (OpenFileDlg.DoModal()) == IDOK )
|
||||
{
|
||||
char szOutBuff[64]; // TEMP OUTPUT BUFFER
|
||||
|
||||
// SET FLAG TO PREVENT EXITING IN THE MIDDLE OF THE UNCOMPRESSION
|
||||
((CMultfileApp *) AfxGetApp())->OkToExit = FALSE;
|
||||
|
||||
// GET DC AND SET THE TEXT BACKGROUND COLOR TO WINDOW BACKGROUND COLOR
|
||||
CClientDC dc(this);
|
||||
COLORREF bkGroundColor = dc.GetPixel( 0, 0 );
|
||||
dc.SetBkColor( bkGroundColor );
|
||||
|
||||
wsprintf( szOutBuff, "Uncompressing: %s ",
|
||||
(LPSTR) (const char *) OpenFileDlg.GetPathName() );
|
||||
dc.TextOut( 10,20, szOutBuff );
|
||||
|
||||
// UNCOMPRESS THE FILE
|
||||
UncompressMcfFile( hWnd, &dc, (LPSTR) (const char *) OpenFileDlg.GetPathName() );
|
||||
|
||||
// DONE WITH UNCOMPRESION SO ALLOW THE USER TO EXIT
|
||||
((CMultfileApp *) AfxGetApp())->OkToExit = TRUE;
|
||||
}
|
||||
|
||||
// TURN ON HELP MESSAGE AND CLEAR SCREEN
|
||||
SendMessageToDescendants( WM_TURN_ON_HELP );
|
||||
}
|
||||
|
||||
BOOL CMainFrame::OnQueryEndSession()
|
||||
{
|
||||
if (!CFrameWnd::OnQueryEndSession())
|
||||
return FALSE;
|
||||
|
||||
// RETURN FALSE IF CANNOT EXIT RIGHT NOW
|
||||
if( !((CMultfileApp *) AfxGetApp())->OkToExit )
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CMainFrame::OnClose()
|
||||
{
|
||||
// RETURN IF CANNOT EXIT RIGHT NOW
|
||||
if( !((CMultfileApp *) AfxGetApp())->OkToExit )
|
||||
return;
|
||||
|
||||
CFrameWnd::OnClose();
|
||||
}
|
||||
|
||||
void CMainFrame::OnUpdateCompressFiles(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->Enable( ((CMultfileApp *) AfxGetApp())->OkToExit );
|
||||
}
|
||||
|
||||
void CMainFrame::OnUpdateUncompressFiles(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->Enable( ((CMultfileApp *) AfxGetApp())->OkToExit );
|
||||
}
|
||||
|
||||
|
||||
void CMainFrame::OnCmpAscii()
|
||||
{
|
||||
DataType = CMP_ASCII;
|
||||
}
|
||||
|
||||
void CMainFrame::OnCmpBinary()
|
||||
{
|
||||
DataType = CMP_BINARY;
|
||||
}
|
||||
|
||||
void CMainFrame::OnDictSize1024()
|
||||
{
|
||||
DictSize = 1024;
|
||||
}
|
||||
|
||||
void CMainFrame::OnDictSize2048()
|
||||
{
|
||||
DictSize = 2048;
|
||||
}
|
||||
|
||||
void CMainFrame::OnDictSize4096()
|
||||
{
|
||||
DictSize = 4096;
|
||||
}
|
||||
|
||||
void CMainFrame::OnUpdateCmpAscii(CCmdUI* pCmdUI)
|
||||
{
|
||||
// IF PROGRAM IS COMPRESSING OR UNCOMPRESSING RIGHT NOW
|
||||
if( !((CMultfileApp *) AfxGetApp())->OkToExit )
|
||||
{
|
||||
pCmdUI->Enable( FALSE );
|
||||
return;
|
||||
}
|
||||
|
||||
if( DataType == CMP_ASCII )
|
||||
{
|
||||
pCmdUI->SetCheck( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
pCmdUI->SetCheck( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void CMainFrame::OnUpdateCmpBinary(CCmdUI* pCmdUI)
|
||||
{
|
||||
// IF PROGRAM IS COMPRESSING OR UNCOMPRESSING RIGHT NOW
|
||||
if( !((CMultfileApp *) AfxGetApp())->OkToExit )
|
||||
{
|
||||
pCmdUI->Enable( FALSE );
|
||||
return;
|
||||
}
|
||||
|
||||
if( DataType == CMP_BINARY )
|
||||
{
|
||||
pCmdUI->SetCheck( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
pCmdUI->SetCheck( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void CMainFrame::OnUpdateDictSize1024(CCmdUI* pCmdUI)
|
||||
{
|
||||
// IF PROGRAM IS COMPRESSING OR UNCOMPRESSING RIGHT NOW
|
||||
if( !((CMultfileApp *) AfxGetApp())->OkToExit )
|
||||
{
|
||||
pCmdUI->Enable( FALSE );
|
||||
return;
|
||||
}
|
||||
|
||||
if( DictSize == 1024 )
|
||||
{
|
||||
pCmdUI->SetCheck( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
pCmdUI->SetCheck( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void CMainFrame::OnUpdateDictSize2048(CCmdUI* pCmdUI)
|
||||
{
|
||||
// IF PROGRAM IS COMPRESSING OR UNCOMPRESSING RIGHT NOW
|
||||
if( !((CMultfileApp *) AfxGetApp())->OkToExit )
|
||||
{
|
||||
pCmdUI->Enable( FALSE );
|
||||
return;
|
||||
}
|
||||
|
||||
if( DictSize == 2048 )
|
||||
{
|
||||
pCmdUI->SetCheck( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
pCmdUI->SetCheck( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void CMainFrame::OnUpdateDictSize4096(CCmdUI* pCmdUI)
|
||||
{
|
||||
// IF PROGRAM IS COMPRESSING OR UNCOMPRESSING RIGHT NOW
|
||||
if( !((CMultfileApp *) AfxGetApp())->OkToExit )
|
||||
{
|
||||
pCmdUI->Enable( FALSE );
|
||||
return;
|
||||
}
|
||||
|
||||
if( DictSize == 4096 )
|
||||
{
|
||||
pCmdUI->SetCheck( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
pCmdUI->SetCheck( 0 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
// mainfrm.h : interface of the CMainFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CMainFrame : public CFrameWnd
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CMainFrame();
|
||||
DECLARE_DYNCREATE(CMainFrame)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMainFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected: // control bar embedded members
|
||||
CStatusBar m_wndStatusBar;
|
||||
CToolBar m_wndToolBar;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMainFrame)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg void OnCompressFiles();
|
||||
afx_msg void OnUncompressFiles();
|
||||
afx_msg BOOL OnQueryEndSession();
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnUpdateCompressFiles(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateUncompressFiles(CCmdUI* pCmdUI);
|
||||
afx_msg void OnCmpAscii();
|
||||
afx_msg void OnCmpBinary();
|
||||
afx_msg void OnDictSize1024();
|
||||
afx_msg void OnDictSize2048();
|
||||
afx_msg void OnDictSize4096();
|
||||
afx_msg void OnUpdateCmpAscii(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateCmpBinary(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateDictSize1024(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateDictSize2048(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateDictSize4096(CCmdUI* pCmdUI);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "multfdlg.h"
|
||||
|
||||
#define FILELIST_BUFFSIZE 4096 // AMOUNT OF MEMORY TO ALLOCATE FOR FILE LIST
|
||||
|
||||
|
||||
CMultiSelFileDialog::CMultiSelFileDialog( CWnd *pParentWnd )
|
||||
:CFileDialog( TRUE, NULL, "*.*",
|
||||
OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_NOCHANGEDIR,
|
||||
"All Files (*.*) |*.* ||", pParentWnd )
|
||||
{
|
||||
// ALLOCATE MEMORY FOR FILE LIST
|
||||
pszFileList = (PCHAR) new char[FILELIST_BUFFSIZE];
|
||||
|
||||
// SET ALLOCATED BUFFER AS FILENAME BUFER IN OPENFILENAME STRUCT
|
||||
// AND REPLACE IT IN THE OPENFILENAME STRUCT
|
||||
pszOldPtr = m_ofn.lpstrFile;
|
||||
m_ofn.lpstrFile = pszFileList;
|
||||
m_ofn.nMaxFile = FILELIST_BUFFSIZE;
|
||||
|
||||
// DO SOME INITIALIZATION
|
||||
memset( pszFileList, 0, FILELIST_BUFFSIZE );
|
||||
strcpy( pszFileList, "*.*" );
|
||||
memset( szPath, 0, sizeof(szPath) );
|
||||
nPathLen = 0;
|
||||
Done = TRUE;
|
||||
}
|
||||
|
||||
|
||||
CMultiSelFileDialog::~CMultiSelFileDialog()
|
||||
{
|
||||
// REPLACE OLD POINTER AND FREE MEMORY
|
||||
m_ofn.lpstrFile = pszOldPtr;
|
||||
delete pszFileList;
|
||||
}
|
||||
|
||||
|
||||
BOOL CMultiSelFileDialog::GetFirstFilename( PCHAR pszFullPathBuff,
|
||||
UINT nPathBuffSize,
|
||||
PCHAR pszFilenameBuff )
|
||||
{
|
||||
PCHAR pszToken;
|
||||
|
||||
nPathLen = 0;
|
||||
Done = FALSE;
|
||||
|
||||
// GET THE FIRST TOKEN WHICH SHOULD BE THE PATH
|
||||
if( strchr( pszFileList, ' ' ) == NULL )
|
||||
{
|
||||
// COULD NOT FIND TOKEN SO MUST BE PATH AND FILENAME
|
||||
|
||||
Done = TRUE;
|
||||
|
||||
memset( szPath, 0, sizeof(szPath) );
|
||||
nPathLen = 0;
|
||||
|
||||
// MAKE SURE THE FILENAME + PATH WILL FIT
|
||||
if( strlen( pszFileList ) > nPathBuffSize )
|
||||
{
|
||||
*pszFullPathBuff = '\0';
|
||||
*pszFilenameBuff = '\0';
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// CREATE FILENAME ONLY
|
||||
strcpy( pszFilenameBuff, GetFileName() );
|
||||
strcat( pszFilenameBuff, "." );
|
||||
strcat( pszFilenameBuff, GetFileExt() );
|
||||
|
||||
// COPY PATH AND FILENAME TO BUFFER
|
||||
strcpy( pszFullPathBuff, pszFileList );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// GET THE FIRST TOKEN WHICH SHOULD BE THE PATH
|
||||
if( (pszToken = strtok( pszFileList, " " )) == NULL )
|
||||
{
|
||||
Done = TRUE;
|
||||
*pszFullPathBuff = '\0';
|
||||
*pszFilenameBuff = '\0';
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memset( szPath, 0, sizeof(szPath) );
|
||||
strcpy( szPath, pszToken );
|
||||
strcat( szPath, "\\" );
|
||||
|
||||
nPathLen = strlen( szPath );
|
||||
|
||||
return GetNextFilename( pszFullPathBuff, nPathBuffSize, pszFilenameBuff );
|
||||
}
|
||||
|
||||
|
||||
// pszFilenameBuff MUST BE AT LEAST 13 BYTES
|
||||
BOOL CMultiSelFileDialog::GetNextFilename( PCHAR pszFullPathBuff,
|
||||
UINT nPathBuffSize,
|
||||
PCHAR pszFilenameBuff )
|
||||
{
|
||||
PCHAR pszToken;
|
||||
|
||||
if( Done )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// GET THE NEXT TOKEN WHICH SHOULD BE A FILENAME
|
||||
if( (pszToken = strtok( NULL, " " )) == NULL )
|
||||
{
|
||||
Done = TRUE;
|
||||
*pszFullPathBuff = '\0';
|
||||
*pszFilenameBuff = '\0';
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// MAKE SURE THE FILENAME + PATH WILL FIT
|
||||
if( (strlen( pszToken ) + nPathLen) > nPathBuffSize )
|
||||
{
|
||||
Done = TRUE;
|
||||
*pszFullPathBuff = '\0';
|
||||
*pszFilenameBuff = '\0';
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// COPY PATH AND FILENAME TO BUFFER
|
||||
strcpy( pszFullPathBuff, szPath );
|
||||
strcat( pszFullPathBuff, pszToken );
|
||||
|
||||
PCHAR pszNameOnly = strrchr( pszFullPathBuff, '\\' );
|
||||
|
||||
if( (pszNameOnly == NULL) || (strlen(pszNameOnly) > 13) )
|
||||
{
|
||||
Done = TRUE;
|
||||
*pszFullPathBuff = '\0';
|
||||
*pszFilenameBuff = '\0';
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
strcpy( pszFilenameBuff, ++pszNameOnly );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
#include <afxdlgs.h>
|
||||
|
||||
class CMultiSelFileDialog : public CFileDialog
|
||||
{
|
||||
private:
|
||||
PCHAR pszFileList;
|
||||
PCHAR pszOldPtr;
|
||||
int nPathLen;
|
||||
char szPath[80];
|
||||
BOOL Done;
|
||||
|
||||
public:
|
||||
CMultiSelFileDialog( CWnd *pParentWnd );
|
||||
~CMultiSelFileDialog();
|
||||
BOOL GetFirstFilename( PCHAR pszFullPathBuff,
|
||||
UINT nPathBuffSize,
|
||||
PCHAR pszFilenameBuff );
|
||||
BOOL GetNextFilename( PCHAR pszFullPathBuff,
|
||||
UINT nPathBuffSize,
|
||||
PCHAR pszFilenameBuff );
|
||||
};
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
// multfdoc.cpp : implementation of the CMultfileDoc class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "multfile.h"
|
||||
|
||||
#include "multfdoc.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMultfileDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMultfileDoc, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMultfileDoc, CDocument)
|
||||
//{{AFX_MSG_MAP(CMultfileDoc)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMultfileDoc construction/destruction
|
||||
|
||||
CMultfileDoc::CMultfileDoc()
|
||||
{
|
||||
// TODO: add one-time construction code here
|
||||
}
|
||||
|
||||
CMultfileDoc::~CMultfileDoc()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CMultfileDoc::OnNewDocument()
|
||||
{
|
||||
if (!CDocument::OnNewDocument())
|
||||
return FALSE;
|
||||
|
||||
// TODO: add reinitialization code here
|
||||
// (SDI documents will reuse this document)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMultfileDoc serialization
|
||||
|
||||
void CMultfileDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
// TODO: add storing code here
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: add loading code here
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMultfileDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMultfileDoc::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void CMultfileDoc::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMultfileDoc commands
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
// multfdoc.h : interface of the CMultfileDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CMultfileDoc : public CDocument
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CMultfileDoc();
|
||||
DECLARE_DYNCREATE(CMultfileDoc)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMultfileDoc();
|
||||
virtual void Serialize(CArchive& ar); // overridden for document i/o
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual BOOL OnNewDocument();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMultfileDoc)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
// multfile.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "multfile.h"
|
||||
|
||||
#include "mainfrm.h"
|
||||
#include "multfdoc.h"
|
||||
#include "multfvw.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMultfileApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMultfileApp, CWinApp)
|
||||
//{{AFX_MSG_MAP(CMultfileApp)
|
||||
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard file based document commands
|
||||
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
|
||||
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMultfileApp construction
|
||||
|
||||
CMultfileApp::CMultfileApp()
|
||||
{
|
||||
// TODO: add construction code here,
|
||||
// Place all significant initialization in InitInstance
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CMultfileApp object
|
||||
|
||||
CMultfileApp NEAR theApp;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMultfileApp initialization
|
||||
|
||||
BOOL CMultfileApp::InitInstance()
|
||||
{
|
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need.
|
||||
|
||||
OkToExit = TRUE;
|
||||
|
||||
SetDialogBkColor(); // Set dialog background color to gray
|
||||
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views.
|
||||
|
||||
CSingleDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CSingleDocTemplate(
|
||||
IDR_MAINFRAME,
|
||||
RUNTIME_CLASS(CMultfileDoc),
|
||||
RUNTIME_CLASS(CMainFrame), // main SDI frame window
|
||||
RUNTIME_CLASS(CMultfileView));
|
||||
AddDocTemplate(pDocTemplate);
|
||||
|
||||
// create a new (empty) document
|
||||
OnFileNew();
|
||||
|
||||
if (m_lpCmdLine[0] != '\0')
|
||||
{
|
||||
// TODO: add command line processing here
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
class CAboutDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
CAboutDlg();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CAboutDlg)
|
||||
enum { IDD = IDD_ABOUTBOX };
|
||||
//}}AFX_DATA
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//{{AFX_MSG(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CAboutDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CAboutDlg)
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// App command to run the dialog
|
||||
void CMultfileApp::OnAppAbout()
|
||||
{
|
||||
CAboutDlg aboutDlg;
|
||||
aboutDlg.DoModal();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMultfileApp commands
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
*** Important information for use with the ***
|
||||
*** PKWARE Data Compression Library (R) for Win32 ***
|
||||
*** Copyright 1995 by PKWARE Inc. All Rights Reserved. ***
|
||||
*** PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off. ***
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
// multfile.h : main header file for the MULTFILE application
|
||||
//
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
#define WM_TURN_OFF_HELP WM_USER+1
|
||||
#define WM_TURN_ON_HELP WM_USER+2
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMultfileApp:
|
||||
// See multfile.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CMultfileApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CMultfileApp();
|
||||
|
||||
BOOL OkToExit;
|
||||
|
||||
|
||||
// Overrides
|
||||
virtual BOOL InitInstance();
|
||||
|
||||
// Implementation
|
||||
|
||||
//{{AFX_MSG(CMultfileApp)
|
||||
afx_msg void OnAppAbout();
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user