home *** CD-ROM | disk | FTP | other *** search
- #include "exec/types.h"
- #include "exec/memory.h"
- #include "libraries/dosextens.h"
- #include "libraries/dos.h"
- #include "stdio.h"
-
- main(argc,argv)
- int argc ;
- char *argv[] ;
- {
- struct FileHandle *fi, *fo ;
- int result, inlength ;
- char header[4] ;
- struct FileLock *lock ;
- struct FileInfoBlock *block ;
-
- if (argc < 3)
- { puts (" Usage: Comp [input file] [output file]\n") ;
- exit(NULL) ;
- }
-
- lock = (struct FileLock *)Lock(argv[1], ACCESS_READ) ;
- block = (struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock), 0) ;
- Examine (lock, block) ;
- inlength = block->fib_Size ;
- UnLock (lock) ;
- FreeMem (block, sizeof(struct FileInfoBlock)) ;
-
- if ((fi = (struct FileHandle *)Open(argv[1], MODE_OLDFILE)) == 0)
- {
- puts ("Can't open input file\n") ;
- exit (NULL) ;
- }
-
- Read(fi, header, 4) ;
- if ((header[0] == 'P') && (header[1] == 'R') && (header[2] == 'E')) ;
- else Seek (fi, -4, 0) ;
-
- Read(fi, header, 2) ;
-
- if ((header[0] == 'L') && (header[1] == 'H'))
- {
- puts ("File already compressed\n");
- Close (fi) ;
- exit(NULL) ;
- }
-
- if ((fo = (struct FileHandle *)Open(argv[2], MODE_NEWFILE)) == 0)
- {
- puts ("Can't open output file\n") ;
- Close (fi) ;
- exit (NULL) ;
- }
-
- result = compress (fi, fo) ;
-
- Close (fi) ;
- Close (fo) ;
- if (result == 1) puts ("Decompression failed\n") ;
- else if (result == 2) puts ("Out of memory\n") ;
- exit(NULL) ;
- }
-
-
-
-
-
-