home *** CD-ROM | disk | FTP | other *** search
- #include "CompUtils:Compress.cc.h.Type6"
- #include <stdlib.h>
- #include <stdio.h>
-
- #define IBUFF (10*1024)
- #define OBUFF (25*1024)
-
- #define INFILE "RAM:$.infile"
- #define OUTFILE "RAM:$.outfile"
-
- main()
- {
- FILE *in, *out;
-
- /* Set up I/O buffers */
- Compress_6_SrcBufferPtr = malloc(IBUFF);
- Compress_6_DestBufferPtr = malloc(OBUFF);
- Compress_6_SrcLength = IBUFF;
- Compress_6_DestLength = OBUFF;
-
- /* Claim workspace */
- if (Compress_6_GlobalLength)
- Compress_6_GlobalPtr = malloc(Compress_6_GlobalLength);
-
- /* NB - this program assumes no errors occur */
-
- /* Set up reason code and output flags */
- Compress_6_ReasonCode = 0;
- Compress_6_Flags = OUTPUT_LINEAR; /* All other flags are off */
-
- /* Open source file */
- in = fopen(INFILE, "rb");
- if (in==NULL)
- {
- printf("Can't open input file '%s'\n",INFILE);
- exit(1);
- }
- /* Open destination file */
- out = fopen(OUTFILE, "wb");
- if (out==NULL)
- {
- fclose(in);
- printf("Can't open output file '%s'\n",OUTFILE);
- exit(1);
- }
-
- /* Get sample length and sample period */
- fseek(in, 0, SEEK_END);
- fgetpos(in, &Compress_6_SampleLength);
- Compress_6_SampleLength--;
- fseek(in, 0, SEEK_SET);
- fread(&Compress_6_SamplePeriod, 1, 1, in);
-
- puts("Starting...\n");
-
- while (Compress_6() != 0)
- {
- /* A non-zero reason code, so some action must be taken */
- printf("Reason code: %d\n",Compress_6_ReasonCode);
- switch (Compress_6_ReasonCode)
- {
- case SRC_EMPTY:
- /* Refill the source buffer */
- fread(Compress_6_SrcBufferPtr, 1, Compress_6_SrcLength, in);
- break;
- case DEST_FULL:
- /* Output the destination buffer */
- fwrite(Compress_6_DestBufferPtr, 1, Compress_6_BytesWritten, out);
- break;
- case SCAN_DONE:
- /* Claim the phase 2 workspace */
- if (Compress_6_Phase2Length)
- Compress_6_Phase2Ptr = malloc(Compress_6_Phase2Length);
- puts("Scanning phase done");
-
- /* Fall through into NEXT_PASS */
- case NEXT_PASS:
- /* Start again from the beginning */
- fseek(in, 1, SEEK_SET);
- puts("Next pass");
- break;
- case CLAIM_WORK:
- /* Claim phase 1 workspace */
- if (Compress_6_Phase1Length)
- Compress_6_Phase1Ptr = malloc(Compress_6_Phase1Length);
- break;
- default:
- fclose(in);
- fclose(out);
- printf("Unexpected reason code (%d)\n",Compress_6_ReasonCode);
- exit(1);
-
- }
- }
-
- /* Tidy up and exit */
- fclose(in);
- fclose(out);
- }
-