|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-4CC4D912-810B-4542-AFCD-58CEE8E0128C" xml:lang="en"><title>Open |
|
13 C libz Example</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>The example demonstrates how to use the libz library to compress a file |
|
15 and decompress it. The library can compress and decompress any kind of file |
|
16 (txt, doc, xls, xml, mpeg, ppt, mp3 etc). </p> |
|
17 <section id="GUID-026FD8D6-6C4A-5958-B289-775D4AE1E756-GENID-1-8-1-11-1-1-5-1-3-1-11-1-12-1-2-2"><title>Download</title> <p>Click |
|
18 on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4e9f70e8-96f8-45be-90fc-00c9071cf562.zip" scope="external"> openclibz.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4e9f70e8-96f8-45be-90fc-00c9071cf562.html" scope="peer">browse</xref> to view the example code. </p> </section> |
|
19 <section id="GUID-7E7C4564-B10E-41F9-8A9D-D8A6C5E9C51C-GENID-1-8-1-11-1-1-5-1-3-1-11-1-12-1-2-3"><title>Design and |
|
20 Implementation</title> <p>The following sections provide more information |
|
21 about the steps that the example performs. </p> <p><b>Capabilities</b> </p>Program |
|
22 capabilities are defined in <filepath>openclibz.mmp</filepath>: <codeph>CAPABILITY |
|
23 None</codeph><p><b>Implementation details of EXE</b> </p>This example is a |
|
24 console based application. This application can be launched from the icon |
|
25 (openclibz) in installed folder and also from eshell. When we launch it through |
|
26 icon it prompts the user to enter the mode to process. The strategy parameter |
|
27 is used to select the compression algorithm. For compressing a file, it reads |
|
28 the file and then compresses it using the API of the libz library and then |
|
29 stores the compressed content in a (.gz) file. If you want to decompress, |
|
30 type d. For decompressing a file, it opens the compressed (.gz) file using |
|
31 libz API's and then reads the content and decompresses it . To check what |
|
32 happens to the content of the string after compression then type s. Enter |
|
33 the string you want and see the data in compressed format . This option |
|
34 is to demonstrate compression of string using libz API's.<p>To run this application |
|
35 through eshell: </p><p><codeblock xml:space="preserve"> Usage : openclibz [-d] [-f] [-h] [-r] [-1 to -9] [files...] |
|
36 -d : decompress |
|
37 -f : compress with Z_FILTERED |
|
38 -h : compress with Huffman encoding |
|
39 -r : compress with run-length encoding |
|
40 -1 to -9 : compression level |
|
41 files : absolute path of files |
|
42 </codeblock></p><p><b>Some usage tips</b></p><p>Once you choose compression |
|
43 process, enter the file name. You should provide absolute path of the file |
|
44 you want to compress. <filepath>(drive letter):\[(folder name)\]filename</filepath>. |
|
45 To get : on phone you have to press 1 few times. To get on phone you have |
|
46 to press 1 few times. To get on emulator is bit tricky. If you are lucky |
|
47 then pressing 1 will get it for you, otherwise change the mode. using "\ BUTTON" |
|
48 (Just above the enter button in the keyboard) and then try pressing 1. To |
|
49 press enter on phone we are supposed to press 0 four times. </p><p><b>Cross |
|
50 platform usage</b></p><p>We can compress the file on any platform and uncompress |
|
51 it on any other platform. For example Unix's gzip files can be compressed |
|
52 using the example application and decompressed using Unix's gunzip. Compression |
|
53 can be done in a single step, if the buffers are large enough; or compression |
|
54 can be done by repeated calls of the compression function. In the second scenario, |
|
55 application must provide more input and consume the output (providing more |
|
56 output space) before each call. </p></section> |
|
57 <section id="GUID-D72E3F44-9925-456B-9B1D-FBCBAC2548DA"><b>APIs Used</b><p><codeph>compress</codeph>, <codeph>uncompress</codeph>, <codeph>gzopen</codeph>, <codeph>gzclose</codeph>, <codeph>gzread</codeph>, <codeph>gzwrite</codeph>, <codeph>gzerror</codeph> from |
|
58 libz library</p><p> <codeph>fopen</codeph>, <codeph>fclose</codeph>, <codeph>fread</codeph>, <codeph>fwrite</codeph>, <codeph>mmap</codeph>, <codeph>munmap</codeph>, <codeph>fstat</codeph>, <codeph>unlink</codeph>, <codeph>printf</codeph>, <codeph>scanf</codeph> from |
|
59 libc library </p></section> |
|
60 <section id="GUID-67A72761-1D92-46D1-B1C9-7455978BDE4E-GENID-1-8-1-11-1-1-5-1-3-1-11-1-12-1-2-5"><title>Building and |
|
61 Using</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian |
|
62 build process</xref> describes how to build this example application. </p> To |
|
63 build the example application, go to the openclibz\group directory and build |
|
64 the application. The definition for the whole application can be found in |
|
65 the bld.inf file in the group subdirectory of the applications main directory. </section> |
|
66 </conbody></concept> |