home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / util / macsnd_dt-1.7.lha / MacSND_dt / Source / dtc_function.c < prev    next >
C/C++ Source or Header  |  1994-09-03  |  2KB  |  75 lines

  1. /*
  2. **    MacSND DataType
  3. **
  4. **    Written by Olaf `Olsen' Barthel <olsen@sourcery.han.de>
  5. **        Public domain
  6. **
  7. ** :ts=4
  8. */
  9.  
  10. #include "Global.h"
  11.  
  12.     // We want to use the hook data
  13.  
  14. #undef SysBase
  15. #define SysBase    Hook -> dthc_SysBase
  16.  
  17. #undef DOSBase
  18. #define DOSBase    Hook -> dthc_DOSBase
  19.  
  20.     /* DTHook(register __a0 struct DTHookContext *Hook):
  21.      *
  22.      *    Examine a file and return if we know its format.
  23.      */
  24.  
  25. BOOL __asm __saveds
  26. DTHook(register __a0 struct DTHookContext *Hook)
  27. {
  28.         // Did we get everything we needed?
  29.  
  30.     if(Hook -> dthc_Lock && Hook -> dthc_FIB && Hook -> dthc_FileHandle)
  31.     {
  32.             // Examine the file
  33.  
  34.         if(Examine(Hook -> dthc_Lock,Hook -> dthc_FIB))
  35.         {
  36.                 // Is this really a file?
  37.  
  38.             if(Hook -> dthc_FIB -> fib_DirEntryType < 0)
  39.             {
  40.                     // Seek back to the beginning
  41.  
  42.                 if(Seek(Hook -> dthc_FileHandle,0,OFFSET_BEGINNING) != -1)
  43.                 {
  44.                     struct SoundDataHeader    Header;
  45.                     LONG                    Error;
  46.  
  47.                         // Try to read the MacBinary header
  48.  
  49.                     if(ReadMacBinaryHeader(Hook -> dthc_FileHandle,&Error,(struct ExecBase *)SysBase,(struct DosLibrary *)DOSBase))
  50.                     {
  51.                             // Look for a "snd " resource
  52.  
  53.                         if(ScanResource(Hook -> dthc_FileHandle,&Header,&Error,(struct ExecBase *)SysBase,(struct DosLibrary *)DOSBase))
  54.                             return(TRUE);
  55.                     }
  56.  
  57.                         // Seek back to the beginning
  58.  
  59.                     if(Seek(Hook -> dthc_FileHandle,0,OFFSET_BEGINNING) != -1)
  60.                     {
  61.                             // Look for a "snd " resource
  62.  
  63.                         if(ScanResource(Hook -> dthc_FileHandle,&Header,&Error,(struct ExecBase *)SysBase,(struct DosLibrary *)DOSBase))
  64.                             return(TRUE);
  65.                     }
  66.                 }
  67.             }
  68.         }
  69.     }
  70.  
  71.         // No success
  72.  
  73.     return(FALSE);
  74. }
  75.