home *** CD-ROM | disk | FTP | other *** search
- #define NAME "testFHUnpack"
- #define DISTRIBUTION "(Freeware) "
- #define REVISION "1"
- #define SDI_ENDCODE_NOCTRLC
-
- /* Programmheader
-
- Name: testFHUnpack
- Author: SDI
- Distribution: Freeware
- Description: easy file to file unpacker using FH's
- Compileropts: -
- Linkeropts: -l xpkmaster amiga
-
- 1.0 02.04.97 : first version
- 1.1 28.11.97 : moved chunk-hook into include file
- */
-
- /* NOTE: You may pass option OFFSET, when packed data does not start at
- really file start */
-
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/xpkmaster.h>
- #include "SDI_defines.h"
- #include "chunkhook.c"
-
- struct Library *XpkBase = 0;
- ULONG DosVersion = 37;
- struct RDArgs *rda = 0;
- ULONG fhin = 0;
- ULONG fhout = 0;
-
- #define PARAM "FROM/A,TO/A,OFFSET/K/N"
-
- void main(void)
- {
- ULONG err;
-
- struct {
- STRPTR from;
- STRPTR to;
- ULONG *offset;
- } args = {0, 0, 0};
-
- if(!(rda = ReadArgs(PARAM, (LONG *) &args, 0)) ||
- !(XpkBase = OpenLibrary(XPKNAME, 4)) ||
- !(fhin = Open(args.from, MODE_OLDFILE)) ||
- !(fhout = Open(args.to, MODE_NEWFILE)) ||
- (args.offset && Seek(fhin, *args.offset, OFFSET_BEGINNING) == -1))
- End(RETURN_FAIL);
-
- if((err = XpkUnpackTags(XPK_InFH, fhin, XPK_OutFH, fhout,
- XPK_ChunkHook, &chunkhook, TAG_DONE)))
- {
- XpkPrintFault(err, "Can't XpkUnpack");
- End(RETURN_FAIL);
- }
-
- End(RETURN_OK);
- }
-
- void end(void)
- {
- if(fhout) Close(fhout);
- if(fhin) Close(fhin);
- if(XpkBase) CloseLibrary(XpkBase);
- if(rda) FreeArgs(rda);
- }
-
-