examples/PIPS/openclibz/src/openclibz.c

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010   this list of conditions and the following disclaimer in the documentation
00011   and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013   may be used to endorse or promote products derived from this software
00014   without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description:  
00028 */
00029 
00030 
00031 //#include <staticlibinit_gcce.h>
00032 
00033 #include "OpenCLibzheader.h"
00034 
00035 
00036 
00037 
00048 // This aplication works with eshell as well ....so i have taken care of argumets 
00049 /* ===========================================================================
00050  * Usage:  OpenCLibz [-d] [-f] [-h] [-r] [-1 to -9] [files...]
00051  *   -d : decompress
00052  *   -f : compress with Z_FILTERED
00053  *   -h : compress with Z_HUFFMAN_ONLY
00054  *   -r : compress with Z_RLE
00055  *   -1 to -9 : compression level
00056  *   files : absolute path
00057 */
00058 //If user runs through the icon then he will be asked to enter the options.
00059 //
00060 int main (int argc, char *argv[])
00061         {
00062     char outmode[20];
00063     char  name[20+1]; // name of the file
00064     int uncompr = 0;//mode parameters to choose 
00065         
00066     strcpy(outmode, "wb6 ");
00067     
00068     argc--, argv++;
00069 
00070     while (argc > 0) 
00071     {
00072       if (strcmp(*argv, "-d") == 0)
00073         uncompr = 1;
00074       else if (strcmp(*argv, "-f") == 0)
00075         outmode[3] = 'f';
00076       else if (strcmp(*argv, "-h") == 0)
00077         outmode[3] = 'h';
00078       else if (strcmp(*argv, "-r") == 0)
00079         outmode[3] = 'R';
00080       else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
00081                (*argv)[2] == 0)
00082         outmode[2] = (*argv)[1];
00083       else
00084         break;
00085       argc--, argv++;
00086     }
00087     if (outmode[3] == ' ')
00088         outmode[3] = 0;
00089     if (argc == 0) 
00090     {
00091       char choice;
00092       printf("enter the mode to process \n \n");
00093       printf("  h for Huffman only compression \n");            
00094       printf("  f for filtered data compression\n");
00095       printf("  R for run-length encoding compression\n");
00096       printf("  d for decompress \n ");
00097       printf(" s to  compress a string\n\n " );      
00098       
00099       choice = getchar();
00100       
00101       if(choice == 'd')
00102       uncompr = 1;
00103       else 
00104       outmode[3] = choice;
00105       if(choice == 's')
00106       {
00107                 StringCompress();
00108       }
00109       else if (uncompr) 
00110       {
00111             printf("enter the filename to compress....for example if log.txt.gz is there in c drive then type  \n");    
00112                 
00113                 printf(" c:\\log.txt.gz  \n\n\n");
00114                 
00115                 scanf("%20s", name);               
00116         
00117                 FileUnCompress(name);
00118       }
00119       else
00120       {  
00121                 printf("enter the filename to compress....for example if log.txt is there in c drive then type  \n");
00122                 
00123                 printf(" c:\\log.txt  \n\n\n");
00124                 
00125                 scanf("%20s",name);             
00126                                 
00127                 FileCompress(name, outmode);
00128       }
00129     } 
00130     else
00131     {
00132         do 
00133         {
00134             if (uncompr) 
00135             {
00136                 FileUnCompress(*argv);
00137             } else {
00138                 FileCompress(*argv, outmode);
00139             }
00140         } while (argv++, --argc);
00141     }
00142 
00143          getchar();
00144          getchar();
00145          fclose(stdin);
00146          fclose(stdout);
00147          fclose(stderr);
00148 
00149 
00150     return 0;
00151 
00152         }
00153 
00154 
00155 /*  End of File */

Generated by  doxygen 1.6.2