home *** CD-ROM | disk | FTP | other *** search
- /*
- ** expfile.c
- ** contains: expfile()
- */
-
- #include <stdio.h>
- #include "gfuncts.h"
-
-
- #ifdef AZTEC
- #define READOPENSTR "r"
- #define WRITEOPENSTR "w"
- #else
- #define READOPENSTR "rb"
- #define WRITEOPENSTR "wb"
- #endif
-
- /*
- ** int
- ** expfile(char *inputname,char *outputname)
- **
- ** ARGUMENT(s)
- ** inputname - Null terminated string for source path & filename.
- ** outputname - Null terminated string for destination path & filename.
- **
- **
- ** DESCRIPTION
- ** "Un-compresses" a file previously compressed with compfile().
- **
- ** RETURNS
- ** 0 = successful or CANTOPENFILE
- **
- ** AUTHOR
- ** "" Mon 09-Jan-1989 15:27:26
- ** Copyright (C)1989-1990 Greenleaf Software Inc. All Rights Reserved.
- **
- ** MODIFICATIONS
- **
- */
- int GF_CONV expfile(inputname,outputname)
- char *inputname,*outputname;
- {
- FILE *inhandle;
- FILE *outhandle;
- unsigned short runcount;
- int inputchar,prevchar;
-
- if((inhandle=fopen(inputname,READOPENSTR))==(FILE *)0)
- return(CANTOPENFILE);
- if((outhandle=fopen(outputname,WRITEOPENSTR))==(FILE *)0) {
- fclose(inhandle);
- return(CANTOPENFILE);
- }
- runcount=0;
- while((inputchar=fgetc(inhandle))!=-1) {
- if(inputchar!=COMPMARK) {
- fputc(inputchar,outhandle);
- prevchar=inputchar;
- } else {
- runcount=fgetc(inhandle);
- if(!runcount)
- fputc(COMPMARK,outhandle);
- else {
- while(--runcount)
- fputc(prevchar,outhandle);
- }
- }
- }
- fclose(inhandle);
- fclose(outhandle);
- return(0);
- }
-