home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / varie / xad / developer / sources / clients / superduper3.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-25  |  3.5 KB  |  135 lines

  1. #ifndef XADMASTER_SUPERDUPER3_C
  2. #define XADMASTER_SUPERDUPER3_C
  3.  
  4. /* Programmheader
  5.  
  6.     Name:        SuperDuper3.c
  7.     Main:        xadmaster
  8.     Versionstring:    $VER: SuperDuper3.c 1.3 (29.08.1999)
  9.     Author:        SDI
  10.     Distribution:    Freeware
  11.     Description:    SuperDuper3 disk image client
  12.  
  13.  1.0   07.09.98 : first version
  14.  1.1   20.06.99 : removed exec.library calls
  15.  1.2   29.06.99 : now uses master free stuff
  16.  1.3   29.08.99 : now uses xdi_DataPos
  17. */
  18.  
  19. #include <proto/xadmaster.h>
  20. #include "SDI_compiler.h"
  21. #include "xadXPK.c"
  22.  
  23. #ifndef XADMASTERFILE
  24. #define SuperDuper3_Client    FirstClient
  25. #define NEXTCLIENT        0
  26. UBYTE version[] = "$VER: SuperDuper3 1.3 (29.08.1999)";
  27. #endif
  28. #define SUPERDUPER3_VERSION    1
  29. #define SUPERDUPER3_REVISION    3
  30.  
  31. ASM(BOOL) SuperDuper3_RecogData(REG(d0, ULONG size), REG(a0, STRPTR data),
  32. REG(a6, struct xadMasterBase *xadMasterBase))
  33. {
  34.   if(((ULONG *) data)[0] == 0x464F524D &&
  35.   (((ULONG *) data)[2] == 0x53444444 ||
  36.   ((ULONG *) data)[2] == 0x53444844))
  37.     return 1;
  38.   else
  39.     return 0;
  40. }
  41.  
  42. ASM(LONG) SuperDuper3_GetInfo(REG(a0, struct xadArchiveInfo *ai),
  43. REG(a6, struct xadMasterBase *xadMasterBase))
  44. {
  45.   LONG err;
  46.   ULONG dat[9], num = 0;
  47.   struct xadDiskInfo *xdi;
  48.  
  49.   if(!(xdi = (struct xadDiskInfo *) xadAllocObjectA(XADOBJ_DISKINFO, 0)))
  50.     return XADERR_NOMEMORY;
  51.   ai->xai_DiskInfo = xdi;
  52.  
  53.   if((err = xadHookAccess(XADAC_READ, 12, dat, ai)))
  54.     return err;
  55.  
  56.   xdi->xdi_EntryNumber = 1;
  57.   xdi->xdi_SectorSize = 512;
  58.   xdi->xdi_Cylinders = 80;
  59.   xdi->xdi_Heads = 2;
  60.   xdi->xdi_Flags = XADDIF_GUESSLOWCYL|XADDIF_GUESSHIGHCYL|XADDIF_SEEKDATAPOS;
  61. /*xdi->xdi_LowCyl = 0; */
  62.   xdi->xdi_DataPos = 12;
  63.   xdi->xdi_TrackSectors = dat[2] == 0x53444844 ? 22 : 11;
  64.   xdi->xdi_CylSectors = 2 * xdi->xdi_TrackSectors;
  65.   xdi->xdi_TotalSectors = 80 * xdi->xdi_CylSectors;
  66.  
  67.   while(ai->xai_InPos < ai->xai_InSize)
  68.   {
  69.     if((err = xadHookAccess(XADAC_READ, 36, dat, ai)))
  70.       return err;
  71.     if((err = xadHookAccess(XADAC_INPUTSEEK, dat[1]-28, 0, ai)))
  72.       return err;
  73.     ++num;
  74.     if(dat[0] == 0x58504B46 && (dat[8] & (1<<25)))
  75.     { /* check for password flag in every entry */
  76.       ai->xai_Flags |= XADAIF_CRYPTED;
  77.       xdi->xdi_Flags |= XADDIF_CRYPTED;
  78.     }
  79.   }
  80.  
  81.   if(num > 80)
  82.     return XADERR_ILLEGALDATA;
  83.  
  84.   xdi->xdi_HighCyl = num-1;
  85.  
  86.   return 0;
  87. }
  88.  
  89. ASM(LONG) SuperDuper3_UnArchive(REG(a0, struct xadArchiveInfo *ai),
  90. REG(a6, struct xadMasterBase *xadMasterBase))
  91. {
  92.   LONG i, err = 0;
  93.   struct {
  94.     STRPTR a;
  95.     ULONG  s;
  96.   } dat;
  97.  
  98.   /* skip entries */
  99.   for(i = ai->xai_CurDisk->xdi_LowCyl; !err && i < ai->xai_LowCyl; ++i)
  100.   {
  101.     if(!(err = xadHookAccess(XADAC_READ, 8, &dat, ai)))
  102.       err = xadHookAccess(XADAC_INPUTSEEK, dat.s, 0, ai);
  103.   }
  104.  
  105.   for(; !err && i <= ai->xai_HighCyl; ++i)
  106.   {
  107.     if(!(err = xadHookAccess(XADAC_READ, 8, &dat, ai)))
  108.     {
  109.       if(dat.a == (STRPTR) 0x58504B46)
  110.       {
  111.         if(!(err = xadHookAccess(XADAC_INPUTSEEK, -8, 0, ai)))
  112.         {
  113.           if(!(err = xpkDecrunch(&dat.a, &dat.s, ai, xadMasterBase)))
  114.           {
  115.             err = xadHookAccess(XADAC_WRITE, dat.s, dat.a, ai);
  116.             xadFreeObjectA(dat.a, 0);
  117.           }
  118.         }
  119.       }
  120.       else /* normal BODY chunk */
  121.         err = xadHookAccess(XADAC_COPY, dat.s, 0, ai);
  122.     }
  123.   }
  124.  
  125.   return err;
  126. }
  127.  
  128. const struct xadClient SuperDuper3_Client = {
  129. NEXTCLIENT, XADCLIENT_VERSION, 7, SUPERDUPER3_VERSION, SUPERDUPER3_REVISION,
  130. 12, XADCF_DISKARCHIVER|XADCF_FREEDISKINFO, XADCID_SUPERDUPER3, "SuperDuper3",
  131. (BOOL (*)()) SuperDuper3_RecogData, (LONG (*)()) SuperDuper3_GetInfo,
  132. (LONG (*)()) SuperDuper3_UnArchive, 0};
  133.  
  134. #endif /* XADASTER_SUPERDUPER3_C */
  135.