📄 jvuibase.pas
字号:
{******************************************************************************}
{ UNIFIED INTERBASE (UIB) }
{ }
{ Project JEDI Code Library (JCL) }
{ }
{ The contents of this file are subject to the Mozilla Public License Version }
{ 1.1 (the "License"); you may not use this file except in compliance with the }
{ License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, }
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
{ the specific language governing rights and limitations under the License. }
{ }
{ The Initial Developer of the Original Code is documented in the accompanying }
{ help file JCL.chm. Portions created by these individuals are Copyright (C) }
{ 2003 of these individuals. }
{ }
{ Interbase & FireBird Borland Compliant API Conversion. }
{ Interbase 6.x, 7.0, 7.1 }
{ FireBird 1.x }
{ Yaffil }
{ To use a specific version of Interbase or FireBird you must Define compiler }
{ Options in "JvUIB.inc" }
{ }
{ Unit owner: Henri Gourvest }
{ Last modified: September 21, 2003 }
{ }
{******************************************************************************}
{$I jvcl.inc}
{$I JvUIB.inc}
{$ALIGN ON}
{$MINENUMSIZE 4}
{$IFDEF USE_IBASE_H}
(*$HPPEMIT '#include<ibase.h>'*)
{$ENDIF USE_IBASE_H}
unit JvUIBase;
interface
uses
{$IFDEF USEJVCL}
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
{$ENDIF USEJVCL}
{$IFDEF MSWINDOWS}
Windows,
{$ENDIF MSWINDOWS}
{$IFDEF LINUX}
{$IFDEF FPC}
DL,
{$ELSE}
libc,
{$ENDIF FPC}
{$ENDIF LINUX}
SysUtils, SyncObjs;
(* Basic data types *)
type
{$IFNDEF COMPILER6_UP}
{$IFNDEF FPC}
PPointer = ^Pointer;
PPChar = ^PChar;
PWord = ^Word;
PCardinal = ^Cardinal;
PSmallInt = ^Smallint;
PInteger = ^Integer;
PDouble = ^Double;
PSingle = ^Single;
PInt64 = ^Int64;
{$ENDIF !FPC}
{$ELSE}
{$IFDEF BCB}
PPointer = ^Pointer;
{$ENDIF BCB}
{$ENDIF !COMPILER6_UP}
UCHAR = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Char;
{$IFNDEF FPC}{$NODEFINE UCHAR}{$ENDIF}
USHORT = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Word;
{$IFNDEF FPC}{$NODEFINE USHORT}{$ENDIF}
ULONG = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Cardinal;
{$IFNDEF FPC}{$NODEFINE ULONG}{$ENDIF}
SCHAR = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Char;
{$IFNDEF FPC}{$NODEFINE SCHAR}{$ENDIF}
SSHORT = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Smallint;
{$IFNDEF FPC}{$NODEFINE SSHORT}{$ENDIF}
SLONG = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Integer;
{$IFNDEF FPC}{$NODEFINE SLONG}{$ENDIF}
SQUAD = record
high: SLONG;
low: ULONG;
end;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM SQUAD}{$ENDIF}
PGDSQuad = ^TGDSQuad;
GDS_QUAD = record
gds_quad_high: SLONG;
gds_quad_low: ULONG;
end;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM GDS_QUAD}{$ENDIF}
TGDSQuad = GDS_QUAD;
// *************************************************
// TMN: some misc data types from all over the place
//**************************************************
// Originally vary_length = SShort but if you need the correct length you
// need to use isc_portable_integer that convert it to word so i simply convert
// it directly to Word, Very strange.
PVary = ^TVary;
vary = record
vary_length: USHORT;
vary_string: array [0..0] of Char;
end;
TVary = vary;
{$IFDEF FB15_UP}
PLString = ^TLString;
lstring = record
lstr_length: ULONG;
lstr_allocated: ULONG;
lstr_address: ^UCHAR;
end;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM lstring}{$ENDIF}
TLString = lstring;
{$ENDIF FB15_UP}
//typedef unsigned char BOOLEAN; (Delphi Compatible)
{$IFNDEF FPC}
TEXT = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Char; (* To be expunged over time *)
{$IFDEF USE_IBASE_H}{$EXTERNALSYM TEXT}{$ENDIF}
{$ENDIF !FPC}
STEXT = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Char; (* Signed text - very rare *)
{$IFDEF USE_IBASE_H}{$EXTERNALSYM STEXT}{$ENDIF}
UTEXT = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Char; (* Unsigned text - common *)
{$IFDEF USE_IBASE_H}{$EXTERNALSYM UTEXT}{$ENDIF}
//typedef unsigned char BYTE; /* Unsigned byte - common */(Delphi Compatible)
SBYTE = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Byte; (* Signed byte - rare usage *)
{$IFNDEF FPC}{$NODEFINE SBYTE}{$ENDIF}
STATUS = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Longint;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM STATUS}{$ENDIF}
IPTR = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Longint;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM IPTR}{$ENDIF}
U_IPTR = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Cardinal;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM U_IPTR}{$ENDIF}
RCRD_OFFSET = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Cardinal;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM RCRD_OFFSET}{$ENDIF}
FLD_LENGTH = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Word;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM FLD_LENGTH}{$ENDIF}
//typedef void (*FPTR_VOID) ();
//typedef void (*FPTR_VOID_PTR) (void *);
//typedef int (*FPTR_INT) ();
//typedef int (*FPTR_INT_VOID_PTR) (void *);
const
(* Number of elements in an arry *)
{$IFDEF FB15_UP}
{ TODO -oHG : TRANSLATE }
//#define FB_NELEM(x) ((int)(sizeof(x) / sizeof(x[0])))
//#define FB_ALIGN(n,b) ((n+b-1)&~(b-1))
FB_API_VER = 15;
{$ENDIF FB15_UP}
GDS_TRUE = 1;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM GDS_TRUE}{$ENDIF}
GDS_FALSE = 0;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM GDS_FALSE}{$ENDIF}
//{$IFNDEF __cplusplus}
// GDS__TRUE = GDS_TRUE;
// {$IFDEF USE_IBASE_H} {$EXTERNALSYM GDS__TRUE} {$ENDIF}
// GDS__FALSE = GDS_FALSE;
// {$IFDEF USE_IBASE_H} {$EXTERNALSYM GDS__FALSE} {$ENDIF}
//{$ENDIF}
type
(* We can remove these three #defines if we change gdsold.h and gen/codes.h *)
GDS_LONG = SLONG;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM GDS_LONG}{$ENDIF}
GDS_ULONG = ULONG;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM GDS_ULONG}{$ENDIF}
GDS_STATUS = Longint;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM GDS_STATUS}{$ENDIF}
const
ISC_TRUE = 1;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_TRUE}{$ENDIF}
ISC_FALSE = 0;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_FALSE}{$ENDIF}
//{$IFNDEF __cplusplus}
// ISC__TRUE = ISC_TRUE;
// {$IFDEF USE_IBASE_H} {$EXTERNALSYM ISC__TRUE} {$ENDIF}
// ISC__FALSE = ISC_FALSE;
// {$IFDEF USE_IBASE_H} {$EXTERNALSYM ISC__FALSE} {$ENDIF}
//{$ENDIF}
//#if (defined __osf__ && defined __alpha)
//#define ISC_LONG int
//#define ISC_ULONG unsigned int
//#else
type
ISC_LONG = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Integer;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_LONG}{$ENDIF}
ISCLong = ISC_LONG;
PISCLong = ^ISCLong;
ISC_ULONG = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Cardinal;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_ULONG}{$ENDIF}
ISCULong = ISC_ULONG;
PISCULong = ^ISCULong;
//#endif
{$IFDEF IB7_UP}
ISC_BOOLEAN = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Smallint;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_BOOLEAN}{$ENDIF}
ISCBoolean = ISC_BOOLEAN;
PISCBoolean = ^ISCBoolean;
{$ENDIF IB7_UP}
ISC_SHORT = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Smallint;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_SHORT}{$ENDIF}
ISCShort = ISC_SHORT;
PISCShort = ^ISCShort;
ISC_USHORT = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Word;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_USHORT}{$ENDIF}
ISCUShort = ISC_USHORT;
PISCUShort = ^ISCUShort;
ISC_STATUS = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Longint;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_STATUS}{$ENDIF}
ISCStatus = ISC_STATUS;
PISCStatus = ^ISCStatus;
PPISCStatus = ^PISCStatus;
ISC_UCHAR = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Char;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_UCHAR}{$ENDIF}
ISCUChar = ISC_UCHAR;
PISCUChar = ^ISCUChar;
const
DSQL_close = 1;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM DSQL_close}{$ENDIF}
DSQL_drop = 2;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM DSQL_drop}{$ENDIF}
{$IFDEF IB65ORYF867}
DSQL_cancel = 4;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM DSQL_cancel}{$ENDIF}
{$ENDIF IB65ORYF867}
{$IFDEF IB7_UP}
METADATALENGTH = 68;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM METADATALENGTH}{$ENDIF}
{$ELSE}
METADATALENGTH = 32;
{$ENDIF IB7_UP}
(******************************************************************
* Define type, export and other stuff based on c/c++ and Windows *
******************************************************************)
//#define ISC_EXPORT GDS_EXPORT
//#define ISC_FAR
//#if (defined(_MSC_VER) && defined(_WIN32)) || \
// (defined(__BORLANDC__) && defined(__WIN32__))
//# define ISC_FAR
//# define ISC_EXPORT_VARARG __cdecl
type
ISC_INT64 = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Int64;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_INT64}{$ENDIF}
ISCInt64 = ISC_INT64;
ISC_UINT64 = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Int64;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_UINT64}{$ENDIF}
ISCUInt64 = ISC_UINT64;
{$DEFINE ISC_INT64_DEFINED}
//#else /* Not Windows*/
//# define ISC_EXPORT_VARARG
//#endif /* Windows/NT */
(*******************************************************************
* 64 bit Integers *
*******************************************************************)
{$IFDEF ISC_INT64_DEFINED}
{$UNDEF ISC_INT64_DEFINED}
{$ELSE}
ISC_INT64 = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Int64;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_INT64}{$ENDIF}
ISC_UINT64 = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Int64;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_UINT64}{$ENDIF}
{$ENDIF ISC_INT64_DEFINED}
(*******************************************************************
* Time & Date Support *
*******************************************************************)
ISC_DATE = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Longint;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_DATE}{$ENDIF}
ISCDate = ISC_DATE;
PISCDate = ^ISCDate;
ISC_TIME = {$IFDEF TYPE_IDENTITY} type {$ENDIF} Cardinal;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_TIME}{$ENDIF}
ISCTime = ISC_TIME;
PISCTime = ^ISCTime;
PISCTimeStamp = ^TISCTimeStamp;
ISC_TIMESTAMP = record
timestamp_date: ISC_DATE;
timestamp_time: ISC_TIME;
end;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_TIMESTAMP}{$ENDIF}
TISCTimeStamp = ISC_TIMESTAMP;
{$DEFINE ISC_TIMESTAMP_DEFINED}
const
ISC_TIME_SECONDS_PRECISION = 10000;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_TIME_SECONDS_PRECISION}{$ENDIF}
ISC_TIME_SECONDS_PRECISION_SCALE = -4;
{$IFDEF USE_IBASE_H}{$EXTERNALSYM ISC_TIME_SECONDS_PRECISION_SCALE}{$ENDIF}
(*******************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -