|
Nokia N97 SDK Example Applications Guide |
Definition in file compress.c.
#include "OpenCLibzheader.h"
#include <limits.h>
Go to the source code of this file.
Functions |
|
| void | GzCompress (FILE *in, gzFile out) |
| void | FileCompress (char *file, char *mode) |
| void | StringCompress () |
|
|
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 }
|
|
© Nokia 2009 |