home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / library / src / openlibrary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  2.1 KB  |  98 lines

  1. /*
  2.     (C) 1995 AROS - The Amiga Replacement OS
  3.     $Id: openlibrary.c 1.1 1995/11/14 22:18:52 digulla Exp digulla $
  4.     $Log: openlibrary.c $
  5.  * Revision 1.1  1995/11/14  22:18:52  digulla
  6.  * Initial revision
  7.  *
  8.     Desc:
  9.     Lang: english
  10. */
  11. #include "exec_intern.h"
  12. #include <exec/execbase.h>
  13. #include <exec/lists.h>
  14. #include <aros/libcall.h>
  15.  
  16. /*****************************************************************************
  17.  
  18.     NAME */
  19.     #include <exec/libraries.h>
  20.     #include <clib/exec_protos.h>
  21.  
  22.     __AROS_LH2(struct Library *, OpenLibrary,
  23.  
  24. /*  SYNOPSIS */
  25.     __AROS_LA(UBYTE *, libName, A1),
  26.     __AROS_LA(ULONG,   version, D0),
  27.  
  28. /*  LOCATION */
  29.     struct ExecBase *, SysBase, 92, Exec)
  30.  
  31. /*  FUNCTION
  32.     Opens a library given by name and revision. If the library
  33.     doesn't exist in memory it is tried to load it from disk.
  34.     It this fails too, NULL is returned.
  35.  
  36.     INPUTS
  37.     libName - Pointer to the library's name.
  38.     version - the library's version number.
  39.  
  40.     RESULT
  41.     Pointer to library structure or NULL.
  42.  
  43.     NOTES
  44.  
  45.     EXAMPLE
  46.  
  47.     BUGS
  48.  
  49.     SEE ALSO
  50.     CloseLibrary().
  51.  
  52.     INTERNALS
  53.  
  54.     HISTORY
  55.     21-10-95    digulla automatically created from
  56.                 include:clib/exec_protos.h
  57.  
  58. *****************************************************************************/
  59. {
  60.     __AROS_FUNC_INIT
  61.  
  62.     __AROS_BASE_EXT_DECL(struct ExecBase *,SysBase)
  63.     struct Library * library;
  64.  
  65.     /* Arbitrate for the library list */
  66.     Forbid();
  67.  
  68.     /* Look for the library in our list */
  69.     library = (struct Library *) FindName (&SysBase->LibList, libName);
  70.  
  71.     /* Something found ? */
  72.     if(library!=NULL)
  73.     {
  74.     /* Check version */
  75.     if(library->lib_Version>=version)
  76.     {
  77.         /* Call Open vector */
  78.         library=__AROS_LC1(struct Library *, open,
  79.         __AROS_LCA(ULONG, version, D0),
  80.         struct Library *, library, 1, UserLib);
  81.     }
  82.     }
  83.     /*
  84.     else
  85.     {
  86.     Under normal circumstances you'd expect the library loading here -
  87.     but this is only exec which doesn't know anything about the
  88.     filesystem level. Therefore dos.library has to SetFunction() this vector
  89.     for the additional functionality.
  90.     }
  91.     */
  92.  
  93.     /* All done. */
  94.     Permit();
  95.     return library;
  96.     __AROS_FUNC_EXIT
  97. } /* OpenLibrary */
  98.