#define NAME		"testFileUnpack"
#define DISTRIBUTION	"(Freeware) "
#define REVISION	"1"
#define SDI_ENDCODE_NOCTRLC

/* Programmheader

	Name:		testFileUnpack
	Author:		SDI
	Distribution:	Freeware
	Description:	easy file to file unpacker
	Compileropts:	-
	Linkeropts:	-l xpkmaster amiga

 1.0   24.03.97 : first version
 1.1   28.11.97 : moved chunk-hook into include file
*/

#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;

#define PARAM "FROM/A,TO/A"

void main(void)
{
  UBYTE errbuf[XPKERRMSGSIZE+1];
  struct {
    STRPTR from;
    STRPTR to;
  } args = {0,0};

  if(!(rda = ReadArgs(PARAM, (LONG *) &args, 0)) ||
  !(XpkBase = OpenLibrary(XPKNAME, 3)))
    End(RETURN_FAIL);

  if(XpkUnpackTags(XPK_InName, args.from, XPK_OutName, args.to,
  XPK_GetError, errbuf, XPK_ChunkHook, &chunkhook, TAG_DONE))
  {
    STRPTR a = errbuf;
    VPrintf("Can't XpkUnpack: %s\n", &a);
    End(RETURN_FAIL);
  }

  End(RETURN_OK);
}

void end(void)
{
  if(XpkBase)	CloseLibrary(XpkBase);
  if(rda)	FreeArgs(rda);
}

