home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 432b.lha / EzLib / src / openlibs.c < prev    next >
C/C++ Source or Header  |  1990-11-10  |  2KB  |  74 lines

  1. /*    This file contains the routines for opening and closing libraries.
  2.  * Notice that all the library bases are defined here.    You can access
  3.  * them in your code if you wish, but they are defined here.
  4.  *
  5.  *    Oh, it *is* important that they be initialized to zero.
  6.  */
  7.  
  8. #include "ezlib.h"
  9.  
  10. struct GfxBase         *GfxBase         = NULL;
  11. struct IntuitionBase *IntuitionBase  = NULL;
  12. struct Library         *DiskfontBase   = NULL;
  13. struct ArpBase         *ArpBase         = NULL;
  14. struct Library         *TranslatorBase = NULL;
  15. struct RxsLib         *RexxSysBase    = NULL;
  16. void *OpenLibrary();
  17.  
  18. openlibs( which_ones )
  19.  register int which_ones;
  20. {
  21.  register int errs = NULL;
  22.  
  23.  if (which_ones & GFX)
  24.    if ( (GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L)) == NULL)
  25.     {  MSG("No Graphics.library.\n"); errs = 1; }
  26.  
  27.  if (which_ones & INTUI)
  28.    if ( (IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0L)) == NULL)
  29.     {  MSG("No Intuition.library.\n"); errs = 1; }
  30.  
  31.  if (which_ones & ARP)
  32.    if ( (ArpBase = (struct ArpBase *)OpenLibrary("arp.library", 34)) == NULL)
  33.     { MSG("No Arp.library in your LIBS directory.\n");errs = 1; }
  34.  
  35.  if (which_ones & DISKFONT)
  36.    if ( (DiskfontBase = (struct Library *)OpenLibrary("diskfont.library", 0L)) == NULL)
  37.     { MSG("No Diskfont.library in your LIBS: directory.\n"); errs = 1; }
  38.  
  39.  if (which_ones & TRANSLATOR)
  40.    if ( (TranslatorBase = (struct Library *)OpenLibrary("translator.library", 0L)) == NULL)
  41.     { MSG("No Translator.library in your LIBS: directory.\n"); errs = 1; }
  42.  
  43.  if (which_ones & REXX)
  44.    if ( (RexxSysBase = (struct RxsLib *)OpenLibrary("rexxsyslib.library", 0L)) == NULL)
  45.     { MSG("No rexxsyslib.library in your LIBS: directory.\n"); errs = 1; }
  46.  
  47.  if ( errs )
  48.    { closelibs(); return NULL; }
  49.  
  50.  return 1;
  51. }
  52.  
  53. closelibs()
  54. {
  55.  if (DiskfontBase > 100)
  56.   { CloseLibrary(DiskfontBase); DiskfontBase = NULL; }
  57.  
  58.  if (ArpBase > 100)
  59.   { CloseLibrary(ArpBase); ArpBase = NULL; }
  60.  
  61.  if (IntuitionBase > 100)
  62.   { CloseLibrary(IntuitionBase); IntuitionBase = NULL; }
  63.  
  64.  if (GfxBase > 100)
  65.   { CloseLibrary(GfxBase); GfxBase = NULL; }
  66.  
  67.  if (TranslatorBase > 100)
  68.   { CloseLibrary(TranslatorBase); TranslatorBase = NULL; }
  69.  
  70.  if (RexxSysBase > 100)
  71.   { CloseLibrary(RexxSysBase); RexxSysBase = NULL; }
  72. }
  73.  
  74.