00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "OpenCLibzheader.h"
00019
00020
00021
00022
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 int main (int argc, char *argv[])
00046 {
00047 char outmode[20];
00048 char name[20+1];
00049 int uncompr = 0;
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