|
Nokia N97 SDK Example Applications Guide |
00001 00002 /* 00003 * ============================================================================== 00004 * Name : OpenCLibzheader.h 00005 * Part of : OpenCLibz 00006 * Interface : 00007 * Description : 00008 * Version : 00009 * 00010 * Copyright (c) 2007 Nokia Corporation. 00011 * This material, including documentation and any related 00012 * computer programs, is protected by copyright controlled by 00013 * Nokia Corporation. 00014 * ============================================================================== 00015 */ 00016 00017 /** @file OpenCLibzheader.h 00018 */ 00019 /* INCLUDE FILES */ 00020 00021 #include <zlib.h> 00022 #include <stdio.h> 00023 #include <string.h> 00024 #include <stdlib.h> 00025 #include<unistd.h> 00026 00027 /* INCLUDE FILES REQUIRED ONLY FOR MEMORY MAPPING */ 00028 #ifdef USE_MMAP 00029 # include <sys/types.h> 00030 # include <sys/mman.h> 00031 # include <sys/stat.h> 00032 #endif 00033 00034 00035 00036 #ifndef GZ_SUFFIX 00037 # define GZ_SUFFIX ".gz" //extension of the compressed file 00038 #endif 00039 00040 #define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) 00041 00042 #define BUFLEN 16384 00043 #define MAX_NAME_LEN 1024 00044 00045 00046 00047 /** 00048 * Compresses the string 00049 * This function compresses the string entered by the user and shows the 00050 * compressed string and then decompressess it 00051 * Actually This function will show the content on the screen and demonstarte 00052 * how strings can be compressed 00053 * 00054 */ 00055 void StringCompress(); 00056 /** 00057 * In case of any error display the error message 00058 * 00059 * @param msg will be displayed to the user 00060 * 00061 * @return No return code ,application will terminate after displaying the error message. 00062 */ 00063 void Error OF((const char *msg)); 00064 /** 00065 * Compresses the input file 00066 * First tries to compress using GzCompressMmap ,But if it fails it 00067 * tries normal technique 00068 * 00069 * @param in is the name of input file . 00070 * @param out is the name of output file. 00071 * @return a Symbian OS error code. 00072 */ 00073 void GzCompress OF((FILE *in, gzFile out)); 00074 /** 00075 * GzCompressMmap function compresses the file using mmap technique 00076 * Compression can be done in a single step using mmap but it requires 00077 * enough large buffers. 00078 * I have implemented my code such that, EvenIn case of mmap failure (because of 00079 * shortage of buffer space) It compresses using normal technique. 00080 * 00081 * @param in the name of input file. 00082 * @param out is the name of output file. 00083 */ 00084 #ifdef USE_MMAP 00085 int GzCompressMmap OF((FILE *in, gzFile out)); 00086 #endif 00087 /** 00088 * UnCompresses the file using libz api's 00089 * 00090 * @param in is the name of input file . 00091 * @param out is the name of output file. 00092 * 00093 */ 00094 void GzUnCompress OF((gzFile in, FILE *out)); 00095 /** 00096 * Compresses the File 00097 * It creates the output filename . 00098 * It checkes for the existence of input file. 00099 * And then it calls GzCompress . 00100 * 00101 * @param file is the name of the file to be compressed 00102 * @param mode is for the technique used for opening the file. 00103 * 00104 */ 00105 void FileCompress OF((char *file, char *mode)); 00106 /** 00107 * It generates the output filename . 00108 * It checks for the existence of the file and then calls GzUnCompress. 00109 * 00110 * @param file is the name of the compressed (.gz) file . 00111 * 00112 */ 00113 void FileUnCompress OF((char *file));
|
© Nokia 2009 |