home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / reference / amiga_mail_vol2 / iii-29 / dillo_lib.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  2KB  |  65 lines

  1. /*
  2. **  dillo_lib.c
  3. **
  4. **  Contains the __UserLibInit() and __UserLibCleanup() routines for
  5. **  the armadillo.library example shared library.
  6. **
  7. **  © Copyright 1993, Commodore-Amiga Inc. All Rights Reserved.
  8. **  Written by John Wiederhirn
  9. **
  10. */
  11.  
  12. #include    <exec/types.h>
  13. #include    <clib/exec_protos.h>
  14. #include    <pragmas/exec_pragmas.h>
  15.  
  16. /* These prototypes are just to keep the compiler happy since we don't
  17. ** want them in the distributable proto file.
  18. */
  19.  
  20. int __saveds __UserLibInit(void);
  21. void __saveds __UserLibCleanup(void);
  22.  
  23. /* Following global item (UtilityBase) is created so our library can make
  24. ** utility.library calls.  Technically putting it in the near section is a waste
  25. ** of memory, but for this example, it serves its purpose.  Note also that we
  26. ** don't actually MAKE any Utility calls, but we COULD.
  27. */
  28.  
  29. struct Library *UtilityBase = NULL;
  30. struct Library *SysBase = NULL;
  31.  
  32. /*
  33. */
  34.  
  35. int __saveds
  36. __UserLibInit( void )
  37. {
  38.     int retval = 1;
  39.  
  40.     SysBase = (*((void **)4));
  41.  
  42.     /* Here we attempt to open Utility library.  Not a particularly good
  43.     ** example, but it gets the point across.  If exec.library could not
  44.     ** be opened (say for a second it couldn't), then __UserLibInit would
  45.     ** return 1 indicating failure (where a return of 0 means success).
  46.     */
  47.  
  48.     if (UtilityBase = OpenLibrary( "utility.library", 0L ))
  49.         retval = 0;
  50.  
  51.     return( retval );
  52. }
  53.  
  54.  
  55. /* About as basic a routine as you can get, this routine cleans up the library
  56. ** by providing a matching CloseLibrary of the Utility library base we opened
  57. ** in the __UserLibInit() routine.
  58. */
  59.  
  60. void __saveds
  61. __UserLibCleanup( void )
  62. {
  63.     CloseLibrary( UtilityBase );
  64. }
  65.