Symbian3/SDK/Source/GUID-4CC4D912-810B-4542-AFCD-58CEE8E0128C.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-4CC4D912-810B-4542-AFCD-58CEE8E0128C" xml:lang="en"><title>Open
C libz Example</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>The example demonstrates how to use the libz library to compress a file
and decompress it. The library can compress and decompress any kind of file
(txt, doc, xls, xml, mpeg, ppt, mp3 etc). </p>
<section id="GUID-026FD8D6-6C4A-5958-B289-775D4AE1E756-GENID-1-10-1-11-1-1-5-1-3-1-11-1-11-1-2-2"><title>Download</title> <p>Click
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>
<section id="GUID-7E7C4564-B10E-41F9-8A9D-D8A6C5E9C51C-GENID-1-10-1-11-1-1-5-1-3-1-11-1-11-1-2-3"><title>Design and
Implementation</title> <p>The following sections provide more information
about the steps that the example performs. </p> <p><b>Capabilities</b> </p>Program
capabilities are defined in <filepath>openclibz.mmp</filepath>: <codeph>CAPABILITY
None</codeph><p><b>Implementation details of EXE</b> </p>This example is a
console based application. This application can be launched from the icon
(openclibz) in installed folder and also from eshell.  When we launch it through
icon it prompts the user to enter the mode to process. The strategy parameter
is used to select the compression algorithm. For compressing a file, it reads
the file and then compresses it using the API of the libz library and then
stores the compressed content in a (.gz) file. If you want to decompress,
type d.  For decompressing a file, it opens the compressed (.gz) file using
libz API's  and then reads the content and decompresses it . To check what
happens to the content of the string after compression then type s. Enter
the string you want and see the data in compressed format .   This option
is to demonstrate compression of string using libz API's.<p>To run this application
through eshell: </p><p><codeblock xml:space="preserve"> Usage :  openclibz [-d] [-f] [-h] [-r] [-1 to -9] [files...]
   -d : decompress
   -f : compress with Z_FILTERED
   -h : compress with Huffman encoding
   -r : compress with run-length encoding
   -1 to -9 : compression level
   files : absolute path of files
</codeblock></p><p><b>Some usage tips</b></p><p>Once you choose compression
process, enter the file name. You should provide absolute path of the file
you want to compress.  <filepath>(drive letter):\[(folder name)\]filename</filepath>.
  To get : on phone you have to press 1 few times.  To get on phone you have
to press 1 few times.  To get on emulator is bit tricky. If you are lucky
then pressing 1 will get it for you, otherwise change the mode. using "\ BUTTON"
(Just above the enter button in the keyboard) and then try pressing 1.  To
press enter on phone we are supposed to press 0 four times. </p><p><b>Cross
platform usage</b></p><p>We can compress the file on any platform and uncompress
it on any other platform.  For example Unix's gzip files can be compressed
using the example application and decompressed using Unix's gunzip.   Compression
can be done in a single step, if the buffers are large enough; or compression
can be done by repeated calls of the compression function. In the second scenario,
application must provide more input and consume the output (providing more
output space) before each call. </p></section>
<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
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
libc library </p></section>
<section id="GUID-67A72761-1D92-46D1-B1C9-7455978BDE4E-GENID-1-10-1-11-1-1-5-1-3-1-11-1-11-1-2-5"><title>Building and
Using</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian
build process</xref> describes how to build this example application. </p> To
build the example application, go to the openclibz\group directory and build
the application.  The definition for the whole application can be found in
the bld.inf file in the group subdirectory of the applications main directory. </section>
</conbody></concept>