home *** CD-ROM | disk | FTP | other *** search
- #define NAME "StripXpkStuff"
- #define DISTRIBUTION "(Freeware) "
- #define REVISION "0"
-
- /* NOTE: This program depends on certain things, which may change. It is
- only valid as long as the xpkmaster internal structures do not change.
- It is only for tests and no standard use tool!!! Never distribute a binary
- version of it or use its routines in other programs! */
-
- /* Programmheader
-
- Name: StripXpkStuff
- Author: SDI
- Distribution: Freeware
- Description: strips xpk-headers from XPKF files (for tests only)
- Compileropts: -
- Linkeropts: -
-
- 1.0 21.02.98 : first Version
- */
-
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <exec/memory.h>
- #include "SDI_defines.h"
- #include "/xpkmaster/xpkmaster.h"
-
- #define PARAM "FROM/A,TO/A"
-
- struct Args {
- STRPTR from;
- STRPTR to;
- };
-
- void main(void)
- {
- struct Args args;
- struct RDArgs *rda;
-
- args.to = 0;
-
- if((rda = ReadArgs(PARAM, (LONG *) &args, 0)))
- {
- ULONG fh;
-
- if(!args.to)
- args.to = args.from;
-
- if((fh = Open(args.from, MODE_OLDFILE)))
- {
- ULONG size;
-
- if(Read(fh, &size, 4) == 4)
- {
- if(size == 0x58504B46)
- {
- if(Read(fh, &size, 4) == 4)
- {
- STRPTR mem;
- if((mem = (STRPTR) AllocMem(size, MEMF_ANY)))
- {
- if(Read(fh, mem, size) == size)
- {
- Close(fh);
- if((fh = Open(args.to, MODE_NEWFILE)))
- {
- struct XpkStreamHeader *sh;
-
- sh = (struct XpkStreamHeader *) (mem-8);
-
- if(!(sh->xsh_Flags & XPKSTREAMF_EXTHEADER))
- {
- if(sh->xsh_Flags & XPKSTREAMF_LONGHEADERS)
- {
- struct XpkChunkHdrLong *ch;
-
- ch = (struct XpkChunkHdrLong *)
- (mem+sizeof(struct XpkStreamHeader)-8);
- while(ch->xchl_Type != XPKCHUNK_END)
- {
- Write(fh, ((STRPTR) ch) + sizeof(struct XpkChunkHdrLong),
- ch->xchl_CLen);
- ch = (struct XpkChunkHdrLong *) (((STRPTR) ch) +
- sizeof(struct XpkChunkHdrLong) + ROUNDLONG(ch->xchl_CLen));
- }
- }
- else
- {
- struct XpkChunkHdrWord *ch;
-
- ch = (struct XpkChunkHdrWord *)
- (mem+sizeof(struct XpkStreamHeader)-8);
- while(ch->xchw_Type != XPKCHUNK_END)
- {
- Write(fh, ((STRPTR) ch) + sizeof(struct XpkChunkHdrWord),
- ch->xchw_CLen);
- ch = (struct XpkChunkHdrWord *) (((STRPTR) ch) +
- sizeof(struct XpkChunkHdrWord) + ROUNDLONG(ch->xchw_CLen));
- }
- }
- }
- }
- }
- FreeMem(mem, size);
- }
- }
- }
- }
- if(fh)
- Close(fh);
- }
- FreeArgs(rda);
- }
- }
-
-