mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-21 08:39:32 +01:00
* Changed library names to include version number, make uniform dynamic loader interface
git-svn-id: trunk@22162 -
This commit is contained in:
parent
396a9cafa8
commit
6926b50f2c
@ -19,9 +19,21 @@ uses Dynlibs,ctypes;
|
|||||||
{$IFDEF Unix}
|
{$IFDEF Unix}
|
||||||
{$DEFINE extdecl:=cdecl}
|
{$DEFINE extdecl:=cdecl}
|
||||||
const
|
const
|
||||||
gdslib = 'libgds.'+sharedsuffix;
|
gdslib = 'libgds.'+sharedsuffix; // Needs completion ?
|
||||||
fbclib = 'libfbclient.'+sharedsuffix;
|
libfc = 'libfbclient.'+sharedsuffix;
|
||||||
fbembedlib = 'libfbembed.'+sharedsuffix;
|
libem = 'libfbembed.'+sharedsuffix;
|
||||||
|
v2 = {$ifndef darwin}'.2'{$endif};
|
||||||
|
v21 = {$ifndef darwin}'.2.1'{$endif};
|
||||||
|
v25 = {$ifndef darwin}'.2.5'{$endif};
|
||||||
|
fbclib2 = libfc+v2;
|
||||||
|
fbembedlib2 = libem+v2;
|
||||||
|
fbclib21 = libfc+v21;
|
||||||
|
fbembedlib21 = libem+v21;
|
||||||
|
fbclib25 = libfc+v25;
|
||||||
|
fbembedlib25 = libem+v25;
|
||||||
|
// Set default here
|
||||||
|
fbclib = fbclib25;
|
||||||
|
fbembedlib = fbembedlib25;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF Windows}
|
{$IFDEF Windows}
|
||||||
{$DEFINE extdecl:=stdcall}
|
{$DEFINE extdecl:=stdcall}
|
||||||
@ -2655,15 +2667,19 @@ function InitialiseIBase60 : integer;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
If UseEmbeddedFirebird then
|
if (RefCount<>0) then
|
||||||
|
// pretend to load whatever is already loaded, so we do not get a library name conflict.
|
||||||
|
Inc(RefCount)
|
||||||
|
else If UseEmbeddedFirebird then
|
||||||
begin
|
begin
|
||||||
If (TryInitialiseIBase60(fbembedlib)=0) then
|
If (TryInitialiseIBase60(fbembedlib)=0) and (TryInitialiseIBase60(libem)=0) then
|
||||||
Raise EInOutError.CreateFmt(SErrEmbeddedFailed,[fbembedlib]);
|
Raise EInOutError.CreateFmt(SErrEmbeddedFailed,[fbembedlib]);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
If (TryInitialiseIBase60(fbclib)=0) and
|
If (TryInitialiseIBase60(fbclib)=0) and
|
||||||
(TryInitialiseIBase60(gdslib)=0) and
|
(TryInitialiseIBase60(gdslib)=0) and
|
||||||
|
(TryInitialiseIBase60(libfc)=0) and
|
||||||
(TryInitialiseIBase60(fbembedlib)=0) then
|
(TryInitialiseIBase60(fbembedlib)=0) then
|
||||||
Raise EInOutError.CreateFmt(SErrDefaultsFailed,[fbclib,gdslib,fbembedlib]);
|
Raise EInOutError.CreateFmt(SErrDefaultsFailed,[fbclib,gdslib,fbembedlib]);
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -1596,7 +1596,8 @@ uses
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
{$IFDEF LinkDynamically}
|
{$IFDEF LinkDynamically}
|
||||||
Function InitialiseMysql(Const LibraryName : String; argc:cint = -1; argv:PPchar = nil; groups:PPchar = nil) : Integer;
|
Function InitialiseMysql(Const LibraryName : String) : Integer;
|
||||||
|
Function InitialiseMysql(Const LibraryName : String; argc: cint; argv:PPchar = Nil; groups:PPchar = nil) : Integer;
|
||||||
Function InitialiseMysql(argc:cint = -1; argv:PPchar = nil; groups:PPchar = nil) : Integer;
|
Function InitialiseMysql(argc:cint = -1; argv:PPchar = nil; groups:PPchar = nil) : Integer;
|
||||||
Procedure ReleaseMysql;
|
Procedure ReleaseMysql;
|
||||||
|
|
||||||
@ -1745,12 +1746,22 @@ Function InitialiseMysql(argc: cint; argv: PPchar; groups: PPchar) : Integer;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
If (TryInitialiseMysql(mysqlvlib,argc,argv,groups) = 0) and
|
if (RefCount<>0) then
|
||||||
(TryInitialiseMysql(mysqllib,argc,argv,groups) = 0) then
|
// pretend to load whatever is already loaded, so we do not get a library name conflict.
|
||||||
|
Inc(RefCount)
|
||||||
|
else
|
||||||
|
If (TryInitialiseMysql(mysqllib,argc,argv,groups)=0)
|
||||||
|
and (TryInitialiseMysql(mysqlvlib,argc,argv,groups)=0) then
|
||||||
Raise EInOutError.CreateFmt(SErrDefaultsFailed,[mysqlvlib,mysqllib]);
|
Raise EInOutError.CreateFmt(SErrDefaultsFailed,[mysqlvlib,mysqllib]);
|
||||||
Result := RefCount;
|
Result := RefCount;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function InitialiseMysql(Const LibraryName: String) : Integer;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=InitialiseMySQL(LibraryName,-1,Nil,Nil);
|
||||||
|
end;
|
||||||
|
|
||||||
Function InitialiseMysql(Const LibraryName: String; argc: cint; argv: PPchar; groups:PPchar) : Integer;
|
Function InitialiseMysql(Const LibraryName: String; argc: cint; argv: PPchar; groups:PPchar) : Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|||||||
@ -16,11 +16,18 @@ uses
|
|||||||
|
|
||||||
{$IFDEF Unix}
|
{$IFDEF Unix}
|
||||||
const
|
const
|
||||||
pqlib = 'libpq.'+sharedsuffix;
|
{$ifdef darwin}
|
||||||
|
pqlib = 'libpq.'+sharedsuffix; // No version number.
|
||||||
|
{$else}
|
||||||
|
pqlib5 = 'libpq.'+sharedsuffix+'.5'; // 8.2 and higher
|
||||||
|
pqlib4 = 'libpq.'+sharedsuffix+'.4'; // 8.0, 8.1
|
||||||
|
pqlib3 = 'libpq.'+sharedsuffix+'.3'; // 7.3, 7.4
|
||||||
|
pqlib = pqlib5;
|
||||||
|
{$endif}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF Win32}
|
{$IFDEF Win32}
|
||||||
const
|
const
|
||||||
pqlib = 'libpq.dll';
|
pqlib = 'libpq.dll'; // Not sure if it has a version number ?
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
|
||||||
@ -210,7 +217,8 @@ var
|
|||||||
{ Get encoding id from environment variable PGCLIENTENCODING }
|
{ Get encoding id from environment variable PGCLIENTENCODING }
|
||||||
PQenv2encoding: function :longint;cdecl;
|
PQenv2encoding: function :longint;cdecl;
|
||||||
|
|
||||||
Procedure InitialisePostgres3(libpath:string=pqlib);
|
Function InitialisePostgres3(Const libpath : shortstring) : integer;
|
||||||
|
Procedure InitialisePostgres3;
|
||||||
Procedure ReleasePostgres3;
|
Procedure ReleasePostgres3;
|
||||||
|
|
||||||
function PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME : pchar) : ppgconn;
|
function PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME : pchar) : ppgconn;
|
||||||
@ -227,10 +235,22 @@ var
|
|||||||
RefCount : integer;
|
RefCount : integer;
|
||||||
LoadedLibrary : String;
|
LoadedLibrary : String;
|
||||||
|
|
||||||
Procedure InitialisePostgres3(libpath:string=pqlib);
|
procedure InitialisePostgres3;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if (RefCount<>0) then
|
||||||
|
// pretend to load whatever is already loaded, so we do not get a library name conflict.
|
||||||
|
inc(Refcount)
|
||||||
|
else
|
||||||
|
InitialisePostgres3(pqlib)
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function InitialisePostgres3(Const libpath : shortstring) : Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inc(RefCount);
|
inc(RefCount);
|
||||||
|
Result:=Refcount;
|
||||||
if RefCount = 1 then
|
if RefCount = 1 then
|
||||||
begin
|
begin
|
||||||
Postgres3LibraryHandle := loadlibrary(libpath);
|
Postgres3LibraryHandle := loadlibrary(libpath);
|
||||||
@ -344,7 +364,7 @@ begin
|
|||||||
pointer(PQmblen) := GetProcedureAddress(Postgres3LibraryHandle,'PQmblen');
|
pointer(PQmblen) := GetProcedureAddress(Postgres3LibraryHandle,'PQmblen');
|
||||||
pointer(PQenv2encoding) := GetProcedureAddress(Postgres3LibraryHandle,'PQenv2encoding');
|
pointer(PQenv2encoding) := GetProcedureAddress(Postgres3LibraryHandle,'PQenv2encoding');
|
||||||
|
|
||||||
InitialiseDllist;
|
InitialiseDllist(libpath);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (libpath<>pqlib) and (LoadedLibrary<>libpath) then
|
if (libpath<>pqlib) and (LoadedLibrary<>libpath) then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user