1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- {
- This file is part of the Free Pascal run time library.
- Copyright (c) 1999-2004 by the Free Pascal development team
- Implement OS-dependent part of dynamic library loading.
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- uses libc;
- Function SysLoadLibraryA(const Name : RawByteString) : TLibHandle;
- begin
- Result:=dlopen(PAnsiChar(Name),RTLD_LAZY);
- end;
- Function SysLoadLibraryU(const Name: UnicodeString) : TLibHandle;
- begin
- Result:=SysLoadLibraryA(ToSingleByteFileSystemEncodedFileName(Name));
- end;
- Function SysGetProcedureAddress(Lib : TLibHandle; const ProcName : AnsiString) : Pointer;
- begin
- Result:=dlsym(lib,pchar(ProcName));
- end;
- Function SysUnloadLibrary(Lib : TLibHandle) : Boolean;
- begin
- Result:=dlClose(Lib)=0;
- end;
- Function SysGetLoadErrorStr: string;
- begin
- Result:='';
- end;
- const
- SysDynLibsManager: TDynLibsManager = (
- LoadLibraryU: @SysLoadLibraryU;
- LoadLibraryA: @SysLoadLibraryA;
- GetProcAddress: @SysGetProcedureAddress;
- GetProcAddressOrdinal: Nil;
- UnloadLibrary: @SysUnloadLibrary;
- GetLoadErrorStr: @SysGetLoadErrorStr;
- );
- procedure InitDynLibs;
- begin
- SetDynLibsManager(SysDynLibsManager);
- end;
|