00001 {*********************************************************}
00002 { }
00003 { Zeos Database Objects }
00004 { Compatibility Classes and Functions }
00005 { }
00006 { Originally written by Sergey Seroukhov }
00007 { }
00008 {*********************************************************}
00009
00010 {@********************************************************}
00011 { Copyright (c) 1999-2006 Zeos Development Group }
00012 { }
00013 { License Agreement: }
00014 { }
00015 { This library is distributed in the hope that it will be }
00016 { useful, but WITHOUT ANY WARRANTY; without even the }
00017 { implied warranty of MERCHANTABILITY or FITNESS FOR }
00018 { A PARTICULAR PURPOSE. See the GNU Lesser General }
00019 { Public License for more details. }
00020 { }
00021 { The source code of the ZEOS Libraries and packages are }
00022 { distributed under the Library GNU General Public }
00023 { License (see the file COPYING / COPYING.ZEOS) }
00024 { with the following modification: }
00025 { As a special exception, the copyright holders of this }
00026 { library give you permission to link this library with }
00027 { independent modules to produce an executable, }
00028 { regardless of the license terms of these independent }
00029 { modules, and to copy and distribute the resulting }
00030 { executable under terms of your choice, provided that }
00031 { you also meet, for each linked independent module, }
00032 { the terms and conditions of the license of that module. }
00033 { An independent module is a module which is not derived }
00034 { from or based on this library. If you modify this }
00035 { library, you may extend this exception to your version }
00036 { of the library, but you are not obligated to do so. }
00037 { If you do not wish to do so, delete this exception }
00038 { statement from your version. }
00039 { }
00040 { }
00041 { The project web site is located on: }
00042 { http:
00043 { http:
00044 { svn:
00045 { }
00046 { http:
00047 { http:
00048 { }
00049 { }
00050 { }
00051 { Zeos Development Group. }
00052 {********************************************************@}
00053
00054 unit ZCompatibility;
00055
00056 interface
00057
00058 {$I ZCore.inc}
00059
00060 uses
00061 {$IFNDEF VER130BELOW}
00062 Variants,
00063 {$ENDIF}
00064 {$IFDEF UNIX}
00065 {$IFDEF FPC}
00066 dl,
00067 {$ELSE}
00068 libc,
00069 {$ENDIF}
00070 {$ENDIF}
00071 Classes, SysUtils;
00072
00073 type
00074
00075 {$IFDEF VER130BELOW}
00076 TIntegerDynArray = array of Integer;
00077 TCardinalDynArray = array of Cardinal;
00078 TWordDynArray = array of Word;
00079 TSmallIntDynArray = array of SmallInt;
00080
00081 TShortIntDynArray = array of ShortInt;
00082 TInt64DynArray = array of Int64;
00083 TLongWordDynArray = array of LongWord;
00084 TSingleDynArray = array of Single;
00085 TDoubleDynArray = array of Double;
00086 TBooleanDynArray = array of Boolean;
00087 TStringDynArray = array of string;
00088 TWideStringDynArray = array of WideString;
00089 TVariantDynArray = array of Variant;
00090 {$ENDIF}
00091
00092 TByteDynArray = array of Byte;
00093 TObjectDynArray = array of TObject;
00094
00095 {$IFDEF VER130BELOW}
00096 IntegerArray = array[0..$effffff] of Integer;
00097 PIntegerArray = ^IntegerArray;
00098
00099 PPointer = ^Pointer;
00100 PByte = ^Byte;
00101 PBoolean = ^Boolean;
00102 PShortInt = ^ShortInt;
00103 PSmallInt = ^SmallInt;
00104 PInteger = ^Integer;
00105 PLongInt = ^LongInt;
00106 PSingle = ^Single;
00107 PDouble = ^Double;
00108 PWordBool = ^WordBool;
00109 PCardinal = ^Cardinal;
00110 PInt64 = ^Int64;
00111 PPChar = ^PChar;
00112 PPAnsiChar = ^PAnsiChar;
00113 PLongWord = ^LongWord;
00114 {$ENDIF}
00115 PWord = ^Word;
00116
00117
00118 {$IFDEF VER130BELOW}
00119 type
00120 TLoginEvent = procedure(Sender: TObject; Username, Password: string) of object;
00121 {$ENDIF}
00122
00123 {$IFDEF VER130BELOW}
00124 type
00125 TDBScreenCursor = (dcrDefault, dcrHourGlass, dcrSQLWait, dcrOther);
00126
00127 IDBScreen = interface
00128 ['{29A1C508-6ADC-44CD-88DE-4F51B25D5995}']
00129 function GetCursor: TDBScreenCursor;
00130 procedure SetCursor(Cursor: TDBScreenCursor);
00131
00132 property Cursor: TDBScreenCursor read GetCursor write SetCursor;
00133 end;
00134
00135 var
00136 LoginDialogProc: function (const ADatabaseName: string; var AUserName,
00137 APassword: string): Boolean;
00138 DBScreen: IDBScreen;
00139
00140 function StrToFloatDef(const Str: string; Def: Extended): Extended;
00141 function AnsiDequotedStr(const S: string; AQuote: Char): string;
00142 function BoolToStr(Value: Boolean): string;
00143 function VarIsStr(const V: Variant): Boolean;
00144 {$ENDIF}
00145
00146 {$IFNDEF FPC}
00147 const
00148 LineEnding = #13#10;
00149 {$ENDIF}
00150
00151 {$IFDEF UNIX}
00152 {$IFDEF FPC}
00153 const
00154 RTLD_GLOBAL = $101;
00155
00156 type
00157 HMODULE = LongWord;
00158
00159 function LoadLibrary(ModuleName: PChar): HMODULE;
00160 function FreeLibrary(Module: HMODULE): LongBool;
00161 function GetProcAddress(Module: HMODULE; Proc: PChar): Pointer;
00162
00163
00164 {$ENDIF}
00165 {$ENDIF}
00166
00167 implementation
00168
00169 {$IFDEF VER130BELOW}
00170
00171 function StrToFloatDef(const Str: string; Def: Extended): Extended;
00172 begin
00173 try
00174 if Str <> '' then
00175 Result := StrToFloat(Str)
00176 else Result := Def;
00177 except
00178 Result := Def;
00179 end;
00180 end;
00181
00182 {$ENDIF}
00183
00184 {$IFDEF VER130BELOW}
00185
00186 function AnsiDequotedStr(const S: string; AQuote: Char): string;
00187 var
00188 LText: PChar;
00189 begin
00190 LText := PChar(S);
00191 Result := AnsiExtractQuotedStr(LText, AQuote);
00192 if Result = '' then
00193 Result := S;
00194 end;
00195
00196 function BoolToStr(Value: Boolean): string;
00197 begin
00198 if Value = True then
00199 Result := 'True'
00200 else Result := 'False';
00201 end;
00202
00203 function VarIsStr(const V: Variant): Boolean;
00204 begin
00205 Result := ((TVarData(V).VType and varTypeMask) = varOleStr) or
00206 ((TVarData(V).VType and varTypeMask) = varString);
00207 end;
00208 {$ENDIF}
00209
00210 {$IFDEF UNIX}
00211 {$IFDEF FPC}
00212 function LoadLibrary(ModuleName: PChar): HMODULE;
00213 begin
00214 Result := HMODULE(dlopen(Modulename, RTLD_GLOBAL));
00215 end;
00216
00217 function FreeLibrary(Module: HMODULE): LongBool;
00218 begin
00219 Result := longbool(dlclose(pointer(Module)));
00220 end;
00221
00222 function GetProcAddress(Module: HMODULE; Proc: PChar): Pointer;
00223 begin
00224 Result := dlsym(pointer(Module), Proc);
00225 end;
00226
00227 {function GetModuleFileName(Module: HMODULE; Buffer: PChar; BufLen: Integer): Integer;
00228 begin
00229 Result := 0;
00230 end;
00231
00232 function GetModuleHandle(Location: Pchar): HMODULE;
00233 begin
00234 Result := 0;
00235 end;
00236 }
00237 {$ENDIF}
00238 {$ENDIF}
00239
00240 end.
00241