{ $Id: PDOCompatibility.pas 23 2007-01-19 22:06:28Z jmarino $ 

############################################################################################

	Pascal Data Objects Library
	Copyright © 2006 John Marino, http://www.synsport.com
	Project site: http://pdo.sourceforge.net

	Note: This file contains code fragments from Zeoslib
	Copyright © 1999-2004 Sergey Seroukhov

############################################################################################

	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License as published by the Free Software Foundation; either
	version 2.1 of the License, or (at your option) any later version.

	This library 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.  See the GNU
	Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with this library; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

############################################################################################}


unit PDOCompatibility;

interface

{$I directives.inc}

uses
  Variants,
{$IFDEF UNIX}
  {$IFDEF FPC}
    dl,
  {$ELSE}
    libc,
  {$ENDIF FPC}
{$ENDIF UNIX}


  Classes, SysUtils;

type
  TByteDynArray = array of Byte;



{$IFDEF UNIX}
  {$IFDEF FPC}
const
  RTLD_GLOBAL = $101;

type
  FPCHMODULE = LongWord;

function LoadLibrary(ModuleName: PChar): FPCHMODULE;
function FreeLibrary(Module: FPCHMODULE): LongBool;
function GetProcAddress(Module: FPCHMODULE; Proc: PChar): Pointer;
function GetModuleHandle(Location: Pchar): FPCHMODULE;
  {$ENDIF FPC}
{$ENDIF UNIX}

implementation


{$IFDEF UNIX}
  {$IFDEF FPC}
function LoadLibrary(ModuleName: PChar): FPCHMODULE;
begin
  Result := FPCHMODULE(dlopen(Modulename, RTLD_GLOBAL));
end;

function FreeLibrary(Module: FPCHMODULE): LongBool;
begin
  Result := longbool(dlclose(pointer(Module)));
end;

function GetProcAddress(Module: FPCHMODULE; Proc: PChar): Pointer;
begin
  Result := dlsym(pointer(Module), Proc);
end;

function GetModuleHandle(Location: Pchar): FPCHMODULE;
begin
  Result := 0;
end;

  {$ENDIF FPC}
{$ENDIF UNIX}

end.

