Hi,
As a bit of fun and a "nice to have" I'm trying to use the zlib1.dll to compress and decompress strings on the fly. I'm sure it'll come in useful someday.
Code:
/*
Compress a string into compString
then decopmress it into thirdString
using the zlib1.dll
*/
char* returnString = "hello world";
char* compString;
char* thirdString;
int rv;
Action()
{
if ((compString = (char*) malloc(100 * sizeof(char))) == NULL) {
lr_error_message ("Insufficient memory available");
return -1;
}
strcpy(compString, "");
if ((thirdString = (char*) malloc(100 * sizeof(char))) == NULL) {
lr_error_message ("Insufficient memory available");
return -1;
}
strcpy(thirdString, "");
rv = lr_load_dll("zlib1.dll");
if(0 == rv)
lr_error_message("dll was loaded: return code %d", rv);
else
lr_error_message("dll was not loaded: return code %d", rv);
lr_error_message("returnString is %s", returnString);
lr_error_message("compString is %s", compString);
rv = deflate(returnString, compString);
lr_error_message("returnstring is %s and compString is %s: The dll return code was %d",returnString, compString, rv);
//inflate(compString, thirdString);
lr_error_message("thirdstring is %s", thirdString);
return 0;
}
The structure may be a bit strange as I'm using a tool called Loadrunner which has a C complier built in.
When I run I get:
Starting action Action.
Action.c(33): Error: dll was loaded: return code 0
Action.c(37): Error: returnString is hello world
Action.c(38): Error: compString is
Action.c(42): Error: returnstring is hello world and compString is : The dll return code was -2
Action.c(45): Error: thirdstring is
Ending action Action.
I really don't know what I'm doing here and I can't get much vanilla "C" from the zlib docs.
Any tips, tricks or clues gratefully received.
jerry