home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / edu / DITOdev.lha / DITOdev / Extensions / Source / Italiano / LibInit.c < prev    next >
C/C++ Source or Header  |  1996-12-17  |  3KB  |  113 lines

  1. /*
  2. **      $VER: LibInit.c 1.0 (14.8.96)
  3. **
  4. **      Library initializers and functions to be called by StartUp.c
  5. **
  6. **      (C) Copyright 1996 Andreas R. Kleinert
  7. **      All Rights Reserved.
  8. **
  9. **      Modified by Dirk Holtwick for DITO, 1996
  10. */
  11.  
  12. /// HEADER
  13. #include <exec/types.h>
  14. #include <exec/memory.h>
  15. #include <exec/libraries.h>
  16. #include <exec/execbase.h>
  17. #include <exec/resident.h>
  18. #include <exec/initializers.h>
  19.  
  20. #include <proto/exec.h>
  21.  
  22. #include "defs.h"
  23. #include "base.h"
  24.  
  25. ULONG __saveds __stdargs L_OpenLibs(void);
  26. void  __saveds __stdargs L_CloseLibs(void);
  27.  
  28. extern struct DitoExtBase *DitoExtBase;
  29.  
  30. extern ULONG DITO_OpenExtension(void);
  31. extern void DITO_CloseExtension(void);
  32.  
  33. struct ExecBase      *SysBase       = NULL;
  34. struct DosLibrary    *DOSBase       = NULL;
  35. struct IntuitionBase *IntuitionBase = NULL;
  36. struct GfxBase       *GfxBase       = NULL;
  37.  
  38. char __aligned ExLibName   [] = LIBNAME;
  39. char __aligned ExLibID     [] = LIBID;
  40. char __aligned AKCopyright [] = COPYRIGHT;
  41.  
  42. extern ULONG InitTab[];
  43.  
  44. extern APTR EndResident; /* below */
  45.  
  46. struct Resident ROMTag =
  47. {
  48.  RTC_MATCHWORD,
  49.  &ROMTag,
  50.  &EndResident,
  51.  RTF_AUTOINIT,
  52.  VERSION,
  53.  NT_LIBRARY,
  54.  REVISION,
  55.  &ExLibName[0],
  56.  &ExLibID[0],
  57.  &InitTab[0]
  58. };
  59.  
  60. APTR EndResident;
  61.  
  62. struct MyDataInit
  63. {
  64.  UWORD ainit1; UWORD binit1; UWORD ln_type;
  65.  UBYTE ainit2; UBYTE binit2; ULONG ln_name2;
  66.  UWORD ainit3; UWORD binit3; UWORD lib_flags;
  67.  UWORD ainit4; UWORD binit4; UWORD lib_version;
  68.  UWORD ainit5; UWORD binit5; UWORD lib_revision;
  69.  UBYTE ainit6; UBYTE binit6; ULONG lib_idstring2;
  70.  ULONG end;
  71. } DataTab =
  72. {
  73.  INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  74.  0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &ExLibName[0],
  75.  INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  76.  INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  77.  INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  78.  0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &ExLibID[0],
  79.  (ULONG) 0
  80. };
  81. ///
  82.  
  83. /// L_OpenLibs()
  84. ULONG __saveds __stdargs L_OpenLibs(void)
  85. {
  86.  SysBase = (*((struct ExecBase **) 4));
  87.  
  88.  DOSBase = (APTR) OpenLibrary("dos.library", 37);
  89.  if(!DOSBase) return(FALSE);
  90.  
  91.  IntuitionBase = (APTR) OpenLibrary("intuition.library", 37);
  92.  if(!IntuitionBase) return(FALSE);
  93.  
  94.  GfxBase = (APTR) OpenLibrary("graphics.library", 37);
  95.  if(!GfxBase) return(FALSE);
  96.  
  97.  DitoExtBase->exb_DOSBase       = DOSBase;
  98.  DitoExtBase->exb_IntuitionBase = IntuitionBase;
  99.  DitoExtBase->exb_GfxBase       = GfxBase;
  100.  
  101.  return(DITO_OpenExtension());
  102. }
  103. ///
  104. /// L_CloseLibs()
  105. void __saveds __stdargs L_CloseLibs(void)
  106. {
  107.  DITO_CloseExtension();
  108.  if(GfxBase)               CloseLibrary((APTR) GfxBase);
  109.  if(IntuitionBase)         CloseLibrary((APTR) IntuitionBase);
  110.  if(DOSBase)               CloseLibrary((APTR) DOSBase);
  111. }
  112. ///
  113.