examples/PIPS/openclibz/src/openclibz.c

Go to the documentation of this file.
00001 /*
00002 * ==============================================================================
00003 *  Name        : OpenCLibz.c
00004 *  Part of     : OpenCLibz
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2007 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 //#include <staticlibinit_gcce.h>
00017 
00018 #include "OpenCLibzheader.h"
00019 
00020 
00021 
00022 
00033 // This aplication works with eshell as well ....so i have taken care of argumets 
00034 /* ===========================================================================
00035  * Usage:  OpenCLibz [-d] [-f] [-h] [-r] [-1 to -9] [files...]
00036  *   -d : decompress
00037  *   -f : compress with Z_FILTERED
00038  *   -h : compress with Z_HUFFMAN_ONLY
00039  *   -r : compress with Z_RLE
00040  *   -1 to -9 : compression level
00041  *   files : absolute path
00042 */
00043 //If user runs through the icon then he will be asked to enter the options.
00044 //
00045 int main (int argc, char *argv[])
00046         {
00047     char outmode[20];
00048     char  name[20+1]; // name of the file
00049     int uncompr = 0;//mode parameters to choose 
00050         
00051     strcpy(outmode, "wb6 ");
00052     
00053     argc--, argv++;
00054 
00055     while (argc > 0) 
00056     {
00057       if (strcmp(*argv, "-d") == 0)
00058         uncompr = 1;
00059       else if (strcmp(*argv, "-f") == 0)
00060         outmode[3] = 'f';
00061       else if (strcmp(*argv, "-h") == 0)
00062         outmode[3] = 'h';
00063       else if (strcmp(*argv, "-r") == 0)
00064         outmode[3] = 'R';
00065       else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
00066                (*argv)[2] == 0)
00067         outmode[2] = (*argv)[1];
00068       else
00069         break;
00070       argc--, argv++;
00071     }
00072     if (outmode[3] == ' ')
00073         outmode[3] = 0;
00074     if (argc == 0) 
00075     {
00076       char choice;
00077       printf("enter the mode to process \n \n");
00078       printf("  h for Huffman only compression \n");            
00079       printf("  f for filtered data compression\n");
00080       printf("  R for run-length encoding compression\n");
00081       printf("  d for decompress \n ");
00082       printf(" s to  compress a string\n\n " );      
00083       
00084       choice = getchar();
00085       
00086       if(choice == 'd')
00087       uncompr = 1;
00088       else 
00089       outmode[3] = choice;
00090       if(choice == 's')
00091       {
00092                 StringCompress();
00093       }
00094       else if (uncompr) 
00095       {
00096             printf("enter the filename to compress....for example if log.txt.gz is there in c drive then type  \n");    
00097                 
00098                 printf(" c:\\log.txt.gz  \n\n\n");
00099                 
00100                 scanf("%20s", name);               
00101         
00102                 FileUnCompress(name);
00103       }
00104       else
00105       {  
00106                 printf("enter the filename to compress....for example if log.txt is there in c drive then type  \n");
00107                 
00108                 printf(" c:\\log.txt  \n\n\n");
00109                 
00110                 scanf("%20s",name);             
00111                                 
00112                 FileCompress(name, outmode);
00113       }
00114     } 
00115     else
00116     {
00117         do 
00118         {
00119             if (uncompr) 
00120             {
00121                 FileUnCompress(*argv);
00122             } else {
00123                 FileCompress(*argv, outmode);
00124             }
00125         } while (argv++, --argc);
00126     }
00127 
00128          getchar();
00129          getchar();
00130          fclose(stdin);
00131          fclose(stdout);
00132          fclose(stderr);
00133 
00134 
00135     return 0;
00136 
00137         }
00138 
00139 
00140 /*  End of File */

Generated by  doxygen 1.6.2