home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / exec / openlibrary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  2.6 KB  |  115 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: openlibrary.c,v 1.7 1997/01/01 03:46:13 ldp Exp $
  4.     $Log: openlibrary.c,v $
  5.     Revision 1.7  1997/01/01 03:46:13  ldp
  6.     Committed Amiga native (support) code
  7.  
  8.     Changed clib to proto
  9.  
  10.     Revision 1.6  1996/12/10 13:51:49  aros
  11.     Moved all #include's in the first column so makedepend can see it.
  12.  
  13.     Revision 1.5  1996/10/24 15:50:53  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.4  1996/08/13 13:56:05  digulla
  17.     Replaced AROS_LA by AROS_LHA
  18.     Replaced some AROS_LH*I by AROS_LH*
  19.     Sorted and added includes
  20.  
  21.     Revision 1.3  1996/08/01 17:41:15  digulla
  22.     Added standard header for all files
  23.  
  24.     Desc:
  25.     Lang: english
  26. */
  27. #include <exec/execbase.h>
  28. #include <exec/lists.h>
  29. #include <exec/libraries.h>
  30. #include <aros/libcall.h>
  31. #include <proto/exec.h>
  32.  
  33. /*****************************************************************************
  34.  
  35.     NAME */
  36.  
  37.     AROS_LH2(struct Library *, OpenLibrary,
  38.  
  39. /*  SYNOPSIS */
  40.     AROS_LHA(UBYTE *, libName, A1),
  41.     AROS_LHA(ULONG,   version, D0),
  42.  
  43. /*  LOCATION */
  44.     struct ExecBase *, SysBase, 92, Exec)
  45.  
  46. /*  FUNCTION
  47.     Opens a library given by name and revision. If the library
  48.     doesn't exist in memory it is tried to load it from disk.
  49.     It this fails too, NULL is returned.
  50.  
  51.     INPUTS
  52.     libName - Pointer to the library's name.
  53.     version - the library's version number.
  54.  
  55.     RESULT
  56.     Pointer to library structure or NULL.
  57.  
  58.     NOTES
  59.  
  60.     EXAMPLE
  61.  
  62.     BUGS
  63.  
  64.     SEE ALSO
  65.     CloseLibrary().
  66.  
  67.     INTERNALS
  68.  
  69.     HISTORY
  70.     21-10-95    digulla automatically created from
  71.                 include:clib/exec_protos.h
  72.  
  73. *****************************************************************************/
  74. {
  75.     AROS_LIBFUNC_INIT
  76.  
  77.     AROS_LIBBASE_EXT_DECL(struct ExecBase *,SysBase)
  78.     struct Library * library;
  79.  
  80.     /* Arbitrate for the library list */
  81.     Forbid();
  82.  
  83.     /* Look for the library in our list */
  84.     library = (struct Library *) FindName (&SysBase->LibList, libName);
  85.  
  86.     /* Something found ? */
  87.     if(library!=NULL)
  88.     {
  89.     /* Check version */
  90.     if(library->lib_Version>=version)
  91.     {
  92.         /* Call Open vector */
  93.         library=AROS_LVO_CALL1(struct Library *,
  94.         AROS_LCA(ULONG,version,D0),
  95.         struct Library *,library,1,lib
  96.         );
  97.     }else
  98.         library=NULL;
  99.     }
  100.     /*
  101.     else
  102.     {
  103.     Under normal circumstances you'd expect the library loading here -
  104.     but this is only exec which doesn't know anything about the
  105.     filesystem level. Therefore dos.library has to SetFunction() this vector
  106.     for the additional functionality.
  107.     }
  108.     */
  109.  
  110.     /* All done. */
  111.     Permit();
  112.     return library;
  113.     AROS_LIBFUNC_EXIT
  114. } /* OpenLibrary */
  115.