|
Nokia N97 SDK Example Applications Guide |
Definition in file openclibzheader.h.
#include <zlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
Go to the source code of this file.
Defines |
|
| #define | GZ_SUFFIX ".gz" |
| #define | SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) |
| #define | BUFLEN 16384 |
| #define | MAX_NAME_LEN 1024 |
Functions |
|
| void | StringCompress () |
| void Error | OF ((const char *msg)) |
| void GzCompress | OF ((FILE *in, gzFile out)) |
| void GzUnCompress | OF ((gzFile in, FILE *out)) |
| void FileCompress | OF ((char *file, char *mode)) |
| void FileUnCompress | OF ((char *file)) |
|
|
Compresses the string This function compresses the string entered by the user and shows the compressed string and then decompressess it Actually This function will show the content on the screen and demonstarte how strings can be compressed Definition at line 174 of file compress.c. References Error(). Referenced by main(). 00175 { 00176 Byte *compr, *uncompr; 00177 uLong len,comprLen,uncomprLen; 00178 char *hello; 00179 00180 hello = (char *)malloc(100*sizeof(char)); 00181 00182 printf("enter the string(maximum 100 characters) to compress....\n"); 00183 00184 00185 00186 scanf("%s",hello); //accepts the string from the user 00187 len = (uLong)strlen(hello)+1; 00188 comprLen = 10 * len; 00189 uncomprLen = comprLen; 00190 00191 //memory allocation 00192 compr = (Byte*)calloc((uInt)comprLen, 1); 00193 uncompr = (Byte*)calloc((uInt)uncomprLen, 1); 00194 00195 00196 00197 //compress is one of the api of libz library used to compress data 00198 00199 compress(compr, &comprLen, (const Bytef*)hello, len); 00200 00201 strcpy((char*)uncompr, "garbage"); //initialization 00202 00203 printf("compressed string is : %s\n\n", (char *)compr); 00204 00205 //uncompress is one of the api of libz library used to uncompress data 00206 00207 uncompress(uncompr, &uncomprLen, compr, comprLen); 00208 00209 00210 printf("press enter to uncompress it\n"); 00211 00212 getchar(); 00213 getchar(); 00214 00215 if (strcmp((char*)uncompr, hello)) 00216 { 00217 Error("bad uncompress\n"); 00218 free(compr); 00219 free(uncompr); 00220 } 00221 else 00222 { 00223 printf("uncompressed string is : %s\n", (char *)uncompr); 00224 free(compr); 00225 free(uncompr); 00226 } 00227 00228 }
|
|
|
In case of any error display the error message
|
|
|
Compresses the input file First tries to compress using GzCompressMmap ,But if it fails it tries normal technique
|
|
|
UnCompresses the file using libz api's
|
|
|
Compresses the File It creates the output filename . It checkes for the existence of input file. And then it calls GzCompress .
|
|
|
It generates the output filename . It checks for the existence of the file and then calls GzUnCompress.
|
|
© Nokia 2009 |