home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / c / CLib37x.lha / c_lib / source / lib_source / LibInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-25  |  3.1 KB  |  115 lines

  1. /*
  2. **      $VER: LibInit.c 37.5 (24.1.97)
  3. **
  4. **      Library initializers and functions to be called by StartUp.c
  5. **
  6. **      (C) Copyright 1996-97 Andreas R. Kleinert
  7. **      All Rights Reserved.
  8. */
  9.  
  10. #define __USE_SYSBASE         // ignored by Maxon
  11.  
  12. #include <exec/types.h>
  13. #include <exec/memory.h>
  14. #include <exec/libraries.h>
  15. #include <exec/execbase.h>
  16. #include <exec/resident.h>
  17. #include <exec/initializers.h>
  18.  
  19. #ifdef __MAXON__
  20. #include <clib/exec_protos.h>
  21. #else
  22. #include <proto/exec.h>
  23. #endif
  24. #include "compiler.h"
  25.  
  26. #include "/include/example/examplebase.h"
  27.  
  28. ULONG __saveds __stdargs L_OpenLibs(void);
  29. void  __saveds __stdargs L_CloseLibs(void);
  30.  
  31. extern struct ExampleBase *ExampleBase;
  32.  
  33.  
  34. struct ExecBase      *SysBase       = NULL;
  35. struct IntuitionBase *IntuitionBase = NULL;
  36. struct GfxBase       *GfxBase       = NULL;
  37.  
  38. #define VERSION  37
  39. #define REVISION 3
  40.  
  41. char __aligned ExLibName [] = "example.library";
  42. char __aligned ExLibID   [] = "example 37.3 (1.1.97)";
  43. char __aligned Copyright [] = "(C)opyright 1996-97 by Andreas R. Kleinert. All rights reserved.";
  44.  
  45. extern ULONG InitTab[];
  46.  
  47. extern APTR EndResident; /* below */
  48.  
  49. struct Resident __aligned ROMTag =     /* do not change */
  50. {
  51.  RTC_MATCHWORD,
  52.  &ROMTag,
  53.  &EndResident,
  54.  RTF_AUTOINIT,
  55.  VERSION,
  56.  NT_LIBRARY,
  57.  0,
  58.  &ExLibName[0],
  59.  &ExLibID[0],
  60.  &InitTab[0]
  61. };
  62.  
  63. APTR EndResident;
  64.  
  65. struct MyDataInit                      /* do not change */
  66. {
  67.  UWORD ln_Type_Init;      UWORD ln_Type_Offset;      UWORD ln_Type_Content;
  68.  UBYTE ln_Name_Init;      UBYTE ln_Name_Offset;      ULONG ln_Name_Content;
  69.  UWORD lib_Flags_Init;    UWORD lib_Flags_Offset;    UWORD lib_Flags_Content;
  70.  UWORD lib_Version_Init;  UWORD lib_Version_Offset;  UWORD lib_Version_Content;
  71.  UWORD lib_Revision_Init; UWORD lib_Revision_Offset; UWORD lib_Revision_Content;
  72.  UBYTE lib_IdString_Init; UBYTE lib_IdString_Offset; ULONG lib_IdString_Content;
  73.  ULONG ENDMARK;
  74. } DataTab =
  75. {
  76.  INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  77.  0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &ExLibName[0],
  78.  INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  79.  INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  80.  INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  81.  0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &ExLibID[0],
  82.  (ULONG) 0
  83. };
  84.  
  85.  /* Libraries not shareable between Processes or libraries messing
  86.     with RamLib (deadlock and crash) may not be opened here - open/close
  87.     these later locally and or maybe close them fromout L_CloseLibs()
  88.     when expunging !
  89.  */
  90.  
  91. ULONG __saveds __stdargs L_OpenLibs(void)
  92. {
  93.  SysBase = (*((struct ExecBase **) 4));
  94.  
  95.  IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 37);
  96.  if(!IntuitionBase) return(FALSE);
  97.  
  98.  GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 37);
  99.  if(!GfxBase) return(FALSE);
  100.  
  101.  
  102.  ExampleBase->exb_SysBase       = SysBase;
  103.  
  104.  ExampleBase->exb_IntuitionBase = IntuitionBase;
  105.  ExampleBase->exb_GfxBase       = GfxBase;
  106.  
  107.  return(TRUE);
  108. }
  109.  
  110. void __saveds __stdargs L_CloseLibs(void)
  111. {
  112.  if(GfxBase)       CloseLibrary((struct Library *) GfxBase);
  113.  if(IntuitionBase) CloseLibrary((struct Library *) IntuitionBase);
  114. }
  115.