home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / datatypes / macpict2-dtc / desc_macpict2.c next >
C/C++ Source or Header  |  1980-01-02  |  2KB  |  67 lines

  1. ;/*
  2. SC resopt desc_MacPICT2.c nodebug opt optsize link nostrt nostkext nostkchk
  3. quit 
  4. */
  5. /* Execute this file to compile with SAS C 
  6.  * Ex. "1.Ram:>execute desc_MacPICT2.c"
  7.  *
  8.  * Otherwise it must be compiled with no stack checking. 
  9.  * It must not be linked with any startup code so that DTHook is
  10.  * the entry point for the executable.
  11.  *
  12.  */
  13.  
  14. #include <exec/types.h>
  15. #include <exec/memory.h>
  16. #include <dos/dos.h>
  17. #include <dos/dosextens.h>
  18. #include <datatypes/datatypes.h>
  19. #include <datatypes/pictureclass.h>
  20.  
  21. #include <clib/exec_protos.h>
  22. #include <clib/dos_protos.h>
  23. #include <clib/utility_protos.h>
  24.  
  25. #include <pragmas/exec_pragmas.h>
  26. #include <pragmas/dos_pragmas.h>
  27. #include <pragmas/utility_pragmas.h>
  28.  
  29. #define SysBase          dthc->dthc_SysBase
  30. #define DOSBase          dthc->dthc_DOSBase
  31. #define UtilityBase      dthc->dthc_UtilityBase
  32.  
  33. #define HEADER_SIZE 0x200
  34. #define    PICT_picVersion    0x0011
  35. #define PICT_MacPICT2 0x02ff
  36. #define BUFSIZE 0x80
  37. #define MAXCHECK 0x3e /* BUFSIZE/2 - 2 */
  38.  
  39. BOOL __asm DTHook (register __a0 struct DTHookContext * dthc)
  40. {
  41.   BOOL retval = FALSE;
  42.   ULONG n;
  43.   UWORD *buffer;
  44.   BPTR fh;
  45.  
  46.   /* Make sure we have a filehandle */
  47.   if (fh = dthc->dthc_FileHandle) {
  48.  
  49.     /* Allocate a buffer */
  50.     if(buffer = AllocVec(BUFSIZE, MEMF_PUBLIC)) {
  51.  
  52.       Seek(fh, HEADER_SIZE, OFFSET_BEGINNING);
  53.       if(Read(fh, buffer, BUFSIZE) == BUFSIZE) {
  54.         n = 5;
  55.         while((n < MAXCHECK) && (buffer[n]==0)) n++;
  56.         if((buffer[n]==PICT_picVersion) && (buffer[n+1]==PICT_MacPICT2))
  57.           retval = TRUE;
  58.       }
  59.       /* Do not steal memory */
  60.       FreeVec(buffer);        
  61.     }
  62.   }
  63.   return retval;
  64. }
  65.  
  66.  
  67.