home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 2 / MECOMP-CD-II.iso / amiga / datatypes / mididt / source / libinit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-04  |  4.0 KB  |  136 lines

  1. /*
  2. ** $PROJECT: midi.datatype
  3. **
  4. ** $VER: libinit.c 40.0 (11.09.97)
  5. **
  6. ** Copyright 1997 by Martin Gierich.
  7. **
  8. ** Library initializers and functions to be called by StartUp.c
  9. **
  10. ** Based on Datatype in 100% C created by Andreas R. Kleinert.
  11. ** Adapted by Martin Gierich.
  12. ** All Rights Reserved !
  13. **
  14. ** $HISTORY:
  15. ** 11.09.97 : 40.00 : Initial BETA release
  16. **
  17. ** $TABSIZE: 8
  18. */
  19.  
  20.  
  21. #define __USE_SYSBASE
  22.  
  23. #include <exec/types.h>
  24. #include <exec/libraries.h>
  25. #include <exec/resident.h>
  26. #include <exec/initializers.h>
  27.  
  28. #include <proto/exec.h>
  29. #include <proto/intuition.h>
  30. #include <proto/datatypes.h>
  31.  
  32. #include "register.h"
  33.  
  34. Class *initClass ( struct ClassBase *cb );
  35.  
  36.  
  37. extern struct ClassBase *ClassBase;
  38.  
  39. struct ExecBase      *SysBase        = NULL;
  40. struct DosLibrary    *DOSBase        = NULL;
  41. struct IntuitionBase *IntuitionBase  = NULL;
  42. struct GfxBase       *GfxBase        = NULL;
  43. struct Library       *UtilityBase    = NULL;
  44. struct Library       *IFFParseBase   = NULL;
  45. struct Library       *GadToolsBase   = NULL;
  46. struct Library       *DataTypesBase  = NULL;
  47.  
  48.  
  49. #define VERSION  40
  50. #define REVISION 0
  51.  
  52. char __aligned ExLibName [] = "midi.datatype";
  53. char __aligned ExLibID   [] = "midi.datatype 40.0 (11.9.97)";
  54. char __aligned Copyright [] = "Copyright 1997 Martin Gierich";
  55.  
  56. extern ULONG InitTab[];
  57.  
  58. extern APTR EndResident; /* below */
  59.  
  60. struct Resident __aligned ROMTag =
  61. {
  62.  RTC_MATCHWORD,
  63.  &ROMTag,
  64.  &EndResident,
  65.  RTF_AUTOINIT,
  66.  VERSION,
  67.  NT_LIBRARY,
  68.  0,
  69.  &ExLibName[0],
  70.  &ExLibID[0],
  71.  &InitTab[0]
  72. };
  73.  
  74. APTR EndResident;
  75.  
  76. struct MyDataInit                      /* do not change */
  77. {
  78.  UWORD ln_Type_Init;      UWORD ln_Type_Offset;      UWORD ln_Type_Content;
  79.  UBYTE ln_Name_Init;      UBYTE ln_Name_Offset;      ULONG ln_Name_Content;
  80.  UWORD lib_Flags_Init;    UWORD lib_Flags_Offset;    UWORD lib_Flags_Content;
  81.  UWORD lib_Version_Init;  UWORD lib_Version_Offset;  UWORD lib_Version_Content;
  82.  UWORD lib_Revision_Init; UWORD lib_Revision_Offset; UWORD lib_Revision_Content;
  83.  UBYTE lib_IdString_Init; UBYTE lib_IdString_Offset; ULONG lib_IdString_Content;
  84.  ULONG ENDMARK;
  85. } DataTab =
  86. {
  87.  INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  88.  0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &ExLibName[0],
  89.  INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  90.  INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  91.  INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  92.  0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &ExLibID[0],
  93.  (ULONG) 0
  94. };
  95.  
  96.  /* Libraries not shareable between Processes or libraries messing
  97.     with RamLib (deadlock and crash) may not be opened here - open/close
  98.     these later locally and or maybe close them fromout L_CloseLibs()
  99.     when expunging !
  100.  */
  101.  
  102. ULONG __saveds __stdargs L_OpenLibs(void)
  103. {
  104.  SysBase = (*((struct ExecBase **) 4));
  105.  
  106.  if( !(DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 39)) ) return(FALSE);
  107.  if( !(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 39)) ) return(FALSE);
  108.  if( !(GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 39)) ) return(FALSE);
  109.  if( !(UtilityBase = OpenLibrary("utility.library", 39)) ) return(FALSE);
  110.  if( !(IFFParseBase = OpenLibrary("iffparse.library", 37)) ) return(FALSE);
  111.  if( !(GadToolsBase = OpenLibrary("gadtools.library", 39)) ) return(FALSE);
  112.  if( !(DataTypesBase = OpenLibrary("datatypes.library", 39)) ) return(FALSE);
  113.  if(ClassBase->cb_Class = initClass(ClassBase)) return(TRUE);
  114.  
  115.  return(FALSE);
  116. }
  117.  
  118. void __saveds __stdargs L_CloseLibs(void)
  119. {
  120.  if(ClassBase->cb_Class) FreeClass(ClassBase->cb_Class);
  121.  
  122.  if(DataTypesBase)  CloseLibrary(DataTypesBase);
  123.  if(GadToolsBase)   CloseLibrary(GadToolsBase);
  124.  if(IFFParseBase)   CloseLibrary(IFFParseBase);
  125.  if(UtilityBase)    CloseLibrary(UtilityBase);
  126.  if(GfxBase)        CloseLibrary((struct Library *)GfxBase);
  127.  if(IntuitionBase)  CloseLibrary((struct Library *)IntuitionBase);
  128.  if(DOSBase)        CloseLibrary((struct Library *)DOSBase);
  129. }
  130.  
  131.  
  132. Class * __saveds __asm ObtainMidiEngine ( register __a6 struct ClassBase *cb)
  133. {
  134.  return (cb->cb_Class);
  135. }
  136.