home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Amiga
/
Workbench
/
Archivers
/
xpk_Source.lha
/
xpk_Source
/
shell
/
xType.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-02-08
|
2KB
|
88 lines
#define NAME "xType"
#define DISTRIBUTION "(Freeware) "
#define REVISION "1"
/* Programmheader
Name: xType
Author: SDI (before 1.1 Urban Dominik Mⁿller)
Distribution: Freeware
Description: Unpack file to stdout
Compileropts: -
Linkeropts: -l xpkmaster
1.0 : first public release
1.1 29.11.96 : fixed for new includes
*/
#include "SDI_defines.h"
#define SDI_TO_ANSI
#include "SDI_ASM_STD_protos.h"
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/xpkmaster.h>
#ifdef __MAXON__
#define __asm
#endif
struct Library *XpkBase = 0;
UBYTE errbuf[XPKERRMSGSIZE + 1], *outbuf;
LONG outbuflen;
void end(STRPTR text)
{
if(text) printf("%s\n", text);
if(XpkBase) CloseLibrary(XpkBase);
exit(text ? 10 : 0);
}
void main(int argc, char **argv)
{
struct XpkFib *xfh;
STRPTR ptr, last, eol;
LONG i, len;
if(!(XpkBase = OpenLibrary(XPKNAME, 0)))
end("Cannot open " XPKNAME);
if(argc < 2 || argv[1][0] == '?')
end("Usage: xType filename");
for(i = 1; i < argc; i++)
{
if(XpkOpenTags(&xfh, XPK_InName, argv[i], XPK_PassThru, TRUE, TAG_DONE))
end(errbuf);
if(!(outbuf = (STRPTR) AllocMem(outbuflen = xfh->xf_NLen + XPK_MARGIN, 0)))
end("Out of memory");
while((len = XpkRead(xfh, outbuf, XPKLEN_ONECHUNK)) > 0)
{
ptr = outbuf;
last = ptr + len;
*last = '\n';
do
{
if(SetSignal (0L, 0L) & SIGBREAKF_CTRL_C)
{
XpkClose(xfh);
end("***Break");
}
if(!(eol = strchr(ptr, '\n')))
eol = last - 1;
Write(Output(), ptr, 1 + eol - ptr);
ptr = eol + 1;
} while(ptr < last);
}
if(XpkClose(xfh) || len)
end(errbuf);
FreeMem(outbuf, outbuflen);
outbuf = NULL;
}
end(NULL);
}