home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / iffconverter / opencloselibs.c < prev    next >
C/C++ Source or Header  |  1997-01-07  |  4KB  |  134 lines

  1. /*
  2. **     $VER: OpenCloseLibs.c V0.01 (13-06-95)
  3. **
  4. **     Author:  Gerben Venekamp
  5. **     Updates: 13-06-95  Version 0.01    Initial module
  6. **
  7. **
  8. **  OpenCloseLibs.c contains the basic routines to open and close libraries.
  9. **
  10. */
  11.  
  12. #include <intuition/intuition.h>
  13. #include <proto/exec.h>
  14. #include <proto/intuition.h>
  15.  
  16. #include "IFFConverter.h"
  17.  
  18.  
  19. // Define Variables
  20. struct IntuitionBase *IntuitionBase = NULL;
  21. struct DosLibrary    *DOSBase       = NULL;
  22. struct Library       *GadToolsBase  = NULL;
  23. struct Library       *AslBase       = NULL;
  24. struct Library       *IFFParseBase  = NULL;
  25. struct GfxBase       *GfxBase       = NULL;
  26. struct Library       *DiskfontBase  = NULL;
  27. struct Library       *IconBase      = NULL;
  28.  
  29.  
  30. // Define protos
  31. void OpenLibraries(void);
  32. void CloseLibraries(void);
  33.  
  34.  
  35. /*
  36. **  OpenLibraries()
  37. **
  38. **     Open a hole bunch of libraries, just for you.
  39. **     Libraries attempted to open are:
  40. **        · Intuition
  41. **        · Dos
  42. **        · Gadtools
  43. **        · Asl
  44. **        · IFFParse
  45. **        · Graphics
  46. **        · Diskfont
  47. **        · Icon
  48. **
  49. **  pre:  None.
  50. **  post: None.
  51. **
  52. */
  53. void OpenLibraries()
  54. {
  55. // Try to open intuition.library
  56.    if(!(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", Lib_Version)))
  57.    {   // Couldn't open intuirion.library Lib_Version. Try to open ANY version.
  58.       if(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0L))
  59.       {
  60.          struct IntuiText AR_ErrorMessage = {
  61.             0, 1, JAM2, 20, 8, NULL,
  62.             (UBYTE *)"I Need intuition.library V" Lib_VersionQ "+", NULL
  63.          };
  64.          struct IntuiText AR_NegText = {
  65.             0, 1, JAM2, 6, 4, NULL,
  66.             (UBYTE *)"Right", NULL
  67.          };
  68.          
  69.          AutoRequest(NULL, &AR_ErrorMessage, NULL, &AR_NegText, 0, 0, 60, 30);
  70.       }
  71.       ErrorHandler( IFFerror_NoIntuition, NULL );
  72.    }
  73.  
  74. // Try to open dos.library   
  75.    if(!(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", Lib_Version)))
  76.       ErrorHandler( IFFerror_NoLibrary, "dos", Lib_Version );
  77.  
  78. // Try to open gadtools.library
  79.    if(!(GadToolsBase = OpenLibrary("gadtools.library", Lib_Version)))
  80.       ErrorHandler( IFFerror_NoLibrary, "gadtools", Lib_Version);
  81.  
  82. // Try to open asl.library
  83.    if(!(AslBase = OpenLibrary("asl.library", Lib_Version)))
  84.       ErrorHandler( IFFerror_NoLibrary, "asl", Lib_Version );
  85.  
  86. // Try to open iffparse.library
  87.    if(!(IFFParseBase = OpenLibrary("iffparse.library", Lib_Version)))
  88.       ErrorHandler( IFFerror_NoLibrary, "iffparse", Lib_Version );
  89.  
  90. // Try to open graphics.library
  91.    if(!(GfxBase = (struct GfxBase*)OpenLibrary("graphics.library", Lib_Version)))
  92.       ErrorHandler( IFFerror_NoLibrary, "graphics", Lib_Version );
  93.  
  94. // Try to open diskfont.library
  95.    if(!(DiskfontBase = OpenLibrary("diskfont.library", Lib_Version)))
  96.       ErrorHandler( IFFerror_NoLibrary, "diskfont", Lib_Version );
  97.  
  98. // Try to open icon.library
  99.    if(!(IconBase = OpenLibrary("icon.library", Lib_Version)))
  100.       ErrorHandler( IFFerror_NoLibrary, "icon", Lib_Version );
  101.    
  102. }
  103.  
  104.  
  105. /*
  106. **  CloseLibraries()
  107. **
  108. **     Here we close all the libraries that we've opend.
  109. **     The nomenies are:
  110. **        · Intuition
  111. **        · Dos
  112. **        · Gadtools
  113. **        · Asl
  114. **        · IFFParse
  115. **        · Graphics
  116. **        · Diskfont
  117. **        · Icon
  118. **
  119. **  pre:  None.
  120. **  post: None.
  121. **
  122. */
  123. void CloseLibraries()
  124. {
  125.    if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
  126.    if(DOSBase)       CloseLibrary((struct Library *)DOSBase);
  127.    if(GadToolsBase)  CloseLibrary((struct Library *)GadToolsBase);
  128.    if(AslBase)       CloseLibrary((struct Library *)AslBase);
  129.    if(IFFParseBase)  CloseLibrary((struct Library *)IFFParseBase);
  130.    if(GfxBase)       CloseLibrary((struct Library *)GfxBase);
  131.    if(DiskfontBase)  CloseLibrary((struct Library *)DiskfontBase);
  132.    if(IconBase )     CloseLibrary((struct Library *)IconBase);
  133. }
  134.