home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Cruncher / XPK416SR.LHA / xpk_Source / test / testFilePack.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-06  |  2.0 KB  |  91 lines

  1. #define NAME        "testFilePack"
  2. #define DISTRIBUTION    "(Freeware) "
  3. #define REVISION    "0"
  4. #define ENDCODE_NOCTRLC
  5.  
  6. /* Programmheader
  7.  
  8.     Name:        testFilePack
  9.     Author:        SDI
  10.     Distribution:    Freeware
  11.     Description:    easy file to file packer
  12.     Compileropts:    -
  13.     Linkeropts:    -l xpkmaster amiga
  14.  
  15.  1.0   06.01.97 : wrote to find the read bit error
  16. */
  17.  
  18. #include <proto/exec.h>
  19. #include <proto/dos.h>
  20. #include <proto/xpkmaster.h>
  21. #include <exec/memory.h>
  22. #include "SDI_defines.h"
  23.  
  24. #ifdef __MAXON__
  25.   #define __asm
  26.   #define __saveds
  27. #endif
  28.  
  29. struct Library        *XpkBase        = 0;
  30. ULONG            DosVersion        = 37;
  31. struct RDArgs        *rda            = 0;
  32.  
  33. #define PARAM "FROM/A,TO/A,METHOD"
  34.  
  35. LONG __asm __saveds chunkfunc(register __a1 struct XpkProgress *prog)
  36. {
  37.   switch(prog->xp_Type)
  38.   {
  39.   case XPKPROG_START: PutStr("Start: "); break;
  40.   case XPKPROG_MID: PutStr("\rMid  : "); break;
  41.   case XPKPROG_END: PutStr("\rEnd  : "); break;
  42.   }
  43.  
  44.   if(prog->xp_Type != XPKPROG_END)
  45.     Printf("%4s: %-8s (%3ld%% done, %2ld%% CF, %6ld cps) %s",
  46.       prog->xp_PackerName, prog->xp_Activity, prog->xp_Done,
  47.       prog->xp_CF, prog->xp_Speed, prog->xp_FileName);
  48.   else
  49.     Printf("%4s: %-8s (%3ldK, %2ld%% CF, %6ld cps) %s\033[K\n",
  50.       prog->xp_PackerName, prog->xp_Activity, prog->xp_ULen >> 10,
  51.       prog->xp_CF, prog->xp_Speed, prog->xp_FileName);
  52.  
  53.   Flush(Output());
  54.   return (LONG) SetSignal(0, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C;
  55. }
  56.  
  57. struct Hook chunkhook = { {0}, (ULONG (*)()) chunkfunc};
  58.  
  59. void main(void)
  60. {
  61.   UBYTE errbuf[XPKERRMSGSIZE+1];
  62.   struct {
  63.     STRPTR from;
  64.     STRPTR to;
  65.     STRPTR method;
  66.   } args = {0,0,"USER"};
  67.  
  68.   if(!(rda = ReadArgs(PARAM, (LONG *) &args, 0)) ||
  69.   !(XpkBase = OpenLibrary(XPKNAME, 3)))
  70.     End(RETURN_FAIL);
  71.  
  72.   if(XpkPackTags(XPK_InName, args.from, XPK_OutName, args.to,
  73.   XPK_PackMethod, args.method, XPK_GetError,
  74.   errbuf, XPK_ChunkHook, &chunkhook, TAG_DONE))
  75.   {
  76.     STRPTR a = errbuf;
  77.     VPrintf("Can't XpkPack: %s\n", &a);
  78.     End(RETURN_FAIL);
  79.   }
  80.  
  81.   End(RETURN_OK);
  82. }
  83.  
  84.  
  85. void end(void)
  86. {
  87.   if(XpkBase)    CloseLibrary(XpkBase);
  88.   if(rda)    FreeArgs(rda);
  89. }
  90.  
  91.