home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 10
/
Sonderheft_12.iso
/
best-of-tools
/
packer
/
xpk3.11
/
xpk_source
/
xpkmaster
/
test
/
testmemexamine.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-12-06
|
2KB
|
84 lines
#define NAME "testMemExamine"
#define REVISION "1"
#define ENDCODE_NOCTRLC
/* Programmheader
Name: testMemExamine
Author: SDI
Distribution: PD
Description: tests Xpk Examine function
Compileropts: -
Linkeropts: -l xpkmaster
1.1 06.12.96 : fixed for new includes, added new WriteXpkFib
*/
#include <pragma/exec_lib.h>
#include <pragma/dos_lib.h>
#include <pragma/xpkmaster_lib.h>
#include <exec/memory.h>
#include "WriteXpkFib.c"
#include "SDI_defines.h"
struct Library *XpkBase = 0;
ULONG DosVersion = 37;
STRPTR buf = 0;
BPTR fh = 0;
struct RDArgs *rda = 0;
struct FileInfoBlock *fib = 0;
struct XpkFib *xfib = 0;
#define PARAM "FILENAME/A"
void main(void)
{
UBYTE errbuf[XPKERRMSGSIZE+1];
STRPTR filename;
if(!(rda = ReadArgs(PARAM, (LONG *) &filename, 0)) ||
!(xfib = (struct XpkFib *) AllocMem(sizeof(struct XpkFib), MEMF_ANY|MEMF_CLEAR)) ||
!(XpkBase = OpenLibrary(XPKNAME, 0)))
End(RETURN_FAIL);
if(XpkExamineTags(xfib, XPK_InName, filename, XPK_GetError, errbuf,
TAG_DONE))
{
STRPTR a = errbuf;
VPrintf("Can't XpkExamine: %s\n", &a);
End(RETURN_FAIL);
}
WriteXpkFib(xfib);
if(!(fh = Open(filename, MODE_OLDFILE)) ||
!(fib = (struct FileInfoBlock *) AllocDosObject(DOS_FIB, 0)) ||
!(ExamineFH(fh, fib)) ||
!(buf = (STRPTR) AllocMem(fib->fib_Size, MEMF_ANY)) ||
Read(fh, buf, fib->fib_Size) != fib->fib_Size)
End(RETURN_FAIL);
if(XpkExamineTags(xfib, XPK_InBuf, buf, XPK_InLen, fib->fib_Size,
XPK_GetError, errbuf, TAG_DONE))
{
STRPTR a = errbuf;
VPrintf("Can't XpkExamine: %s\n", &a);
End(RETURN_FAIL);
}
WriteXpkFib(xfib);
End(RETURN_OK);
}
void end(void)
{
if(fh) Close(fh);
if(xfib) FreeMem(xfib, sizeof(struct XpkFib));
if(buf) FreeMem(buf, fib->fib_Size);
if(XpkBase) CloseLibrary(XpkBase);
if(fib) FreeDosObject(DOS_FIB, fib);
if(rda) FreeArgs(rda);
}