dynlibs.inc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. Implement OS-dependent part of dynamic library loading.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$ifdef readinterface}
  13. { ---------------------------------------------------------------------
  14. Interface declarations
  15. ---------------------------------------------------------------------}
  16. Type
  17. TLibHandle = Pointer;
  18. Const
  19. NilHandle = Nil;
  20. {$else}
  21. { ---------------------------------------------------------------------
  22. Implementation section
  23. ---------------------------------------------------------------------}
  24. uses dl;
  25. Function LoadLibrary(Name : AnsiString) : TLibHandle;
  26. begin
  27. Result:=dlopen(Pchar(Name),RTLD_LAZY);
  28. end;
  29. Function GetProcedureAddress(Lib : TLibHandle; ProcName : AnsiString) : Pointer;
  30. begin
  31. Result:=dlsym(lib,pchar(ProcName));
  32. end;
  33. Function UnloadLibrary(Lib : TLibHandle) : Boolean;
  34. begin
  35. Result:=dlClose(Lib)=0;
  36. end;
  37. {$endif}
  38. {
  39. $Log$
  40. Revision 1.2 2002-09-07 16:01:27 peter
  41. * old logs removed and tabs fixed
  42. }