home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / reference / amiga_mail_vol2 / iv-101 / dt.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  3KB  |  73 lines

  1. ; /* Compiled with SAS/C 6.56.  Run from CLI only.
  2. sc DATA=NEAR NMINC STRMERGE NOSTKCHK IGNORE=73 dt.c
  3. slink from lib:c.o dt.o TO dt LIBRARY lib:sc.lib lib:amiga.lib
  4. quit ; */
  5.  
  6. #include <exec/types.h>
  7. #include <datatypes/datatypesclass.h>  /* This includes other files we need */
  8. #include <stdio.h>
  9.  
  10. #include <clib/exec_protos.h>          /* Prototypes for system functions */
  11. #include <clib/intuition_protos.h>
  12. #include <clib/datatypes_protos.h>
  13.  
  14. #ifdef LATTICE                         /* Disable SAS/C CTRL-C handling */
  15. int CXBRK(void)    { return(0); }
  16. int chkabort(void) { return(0); }
  17. #endif
  18.  
  19.  
  20.  
  21.  
  22. struct Library *IntuitionBase=NULL;    /* System library bases */
  23. struct Library *DataTypesBase=NULL;
  24.  
  25. VOID main(int argc, char **argv)
  26. {
  27. APTR dtobject=NULL;        /* Pointer to a datatypes object */
  28. struct dtTrigger mydtt;    /* A trigger structure for the DTM_TRIGGER method */
  29. ULONG dores;               /* Variable for return values    */
  30.  
  31. if (IntuitionBase=OpenLibrary("intuition.library",39L))
  32.    {
  33.    if(DataTypesBase=OpenLibrary("datatypes.library",39L) )
  34.       {
  35.       if(argc > 1 ) /* CLI only, at least one argument please. */
  36.          {
  37.          /* Attempt to make an 8svx sound object from the file name the user */
  38.          /* specified in the command line.  For a list of possible error     */
  39.          /* returns, see the Autodocs for NewDTObjectA().  The group ID tag  */
  40.          /* will allow only sound datatype files to be accepted for the call.*/
  41.          if (dtobject = NewDTObject(argv[1], DTA_GroupID, GID_SOUND,
  42.                                              TAG_END) )
  43.             {
  44.             mydtt.MethodID     = DTM_TRIGGER; /* Fill in the dtTrigger struct */
  45.             mydtt.dtt_GInfo    = NULL;
  46.             mydtt.dtt_Function = STM_PLAY;
  47.             mydtt.dtt_Data     = NULL;
  48.  
  49.             /* The return value of the DTM_TRIGGER method used with the 8svx */
  50.             /* sound datatype is undefined in V39.  This is likely to change */
  51.             /* in future versions of the Amiga operating system.             */
  52.             dores = DoDTMethodA(dtobject, NULL, NULL, &mydtt);
  53.  
  54.             /* Let the 8svx sound finish playing.  Currently (V39) there is  */
  55.             /* no programmatic way to find out when it is finished playing.  */
  56.             Wait(SIGBREAKF_CTRL_C);
  57.  
  58.             DisposeDTObject(dtobject);
  59.             }
  60.          else printf("Couldn't create new object or not a sound data file\n");
  61.  
  62.          }
  63.       else printf("Give a file name too.\n");
  64.  
  65.       CloseLibrary(DataTypesBase);
  66.       }
  67.    else printf("Can't open datatypes library\n");
  68.  
  69.    CloseLibrary(IntuitionBase);
  70.    }
  71. else printf("Can't open V39 Intuition\n");
  72. }
  73.