00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "OpenCLibzheader.h"
00034
00035
00036
00037
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 int main (int argc, char *argv[])
00061 {
00062 char outmode[20];
00063 char name[20+1];
00064 int uncompr = 0;
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