60 |
|
{ } |
61 |
|
{************************************************************************} |
62 |
|
unit FB25ClientAPI; |
63 |
+ |
{$IFDEF MSWINDOWS} |
64 |
+ |
{$DEFINE WINDOWS} |
65 |
+ |
{$ENDIF} |
66 |
|
|
67 |
|
{$IFDEF FPC} |
68 |
|
{$mode delphi} |
168 |
|
|
169 |
|
public |
170 |
|
{Helper Functions} |
171 |
< |
function DecodeInteger(bufptr: PChar; len: short): integer; override; |
172 |
< |
procedure SQLEncodeDate(aDate: TDateTime; bufptr: PChar); override; |
173 |
< |
function SQLDecodeDate(bufptr: PChar): TDateTime; override; |
174 |
< |
procedure SQLEncodeTime(aTime: TDateTime; bufptr: PChar); override; |
175 |
< |
function SQLDecodeTime(bufptr: PChar): TDateTime; override; |
176 |
< |
procedure SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PChar); override; |
177 |
< |
function SQLDecodeDateTime(bufptr: PChar): TDateTime; override; |
171 |
> |
function DecodeInteger(bufptr: PByte; len: short): integer; override; |
172 |
> |
procedure SQLEncodeDate(aDate: TDateTime; bufptr: PByte); override; |
173 |
> |
function SQLDecodeDate(bufptr: PByte): TDateTime; override; |
174 |
> |
procedure SQLEncodeTime(aTime: TDateTime; bufptr: PByte); override; |
175 |
> |
function SQLDecodeTime(bufptr: PByte): TDateTime; override; |
176 |
> |
procedure SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PByte); override; |
177 |
> |
function SQLDecodeDateTime(bufptr: PByte): TDateTime; override; |
178 |
|
|
179 |
|
public |
180 |
|
{IFirebirdAPI} |
181 |
|
|
182 |
|
{Database connections} |
183 |
|
function AllocateDPB: IDPB; |
184 |
< |
function OpenDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment; |
185 |
< |
function CreateDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload; |
186 |
< |
function CreateDatabase(sql: string; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload; |
184 |
> |
function OpenDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment; |
185 |
> |
function CreateDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload; |
186 |
> |
function CreateDatabase(sql: AnsiString; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload; |
187 |
|
|
188 |
|
{Start Transaction against multiple databases} |
189 |
|
function AllocateTPB: ITPB; |
195 |
|
{Service Manager} |
196 |
|
function AllocateSPB: ISPB; |
197 |
|
function HasServiceAPI: boolean; |
198 |
< |
function GetServiceManager(ServerName: string; Protocol: TProtocol; SPB: ISPB): IServiceManager; |
198 |
> |
function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload; |
199 |
> |
function GetServiceManager(ServerName: AnsiString; Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; overload; |
200 |
|
|
201 |
|
{Information} |
202 |
|
function GetStatus: IStatus; override; |
203 |
|
function HasRollbackRetaining: boolean; |
204 |
|
function IsEmbeddedServer: boolean; override; |
205 |
< |
function GetImplementationVersion: string; |
205 |
> |
function GetImplementationVersion: AnsiString; |
206 |
|
|
207 |
|
{Firebird 3 API} |
208 |
|
function HasMasterIntf: boolean; |
210 |
|
|
211 |
|
end; |
212 |
|
|
213 |
< |
const |
213 |
> |
var |
214 |
|
Firebird25ClientAPI: TFB25ClientAPI = nil; |
215 |
|
|
216 |
|
implementation |
217 |
|
|
218 |
< |
uses FBMessages, dynlibs, FB25Attachment, FB25Transaction, FB25Services, FBParamBlock, |
218 |
> |
uses FBMessages, |
219 |
> |
{$IFDEF WINDOWS}Windows, {$ENDIF} |
220 |
> |
{$IFDEF FPC} Dynlibs, {$ENDIF} |
221 |
> |
FB25Attachment, FB25Transaction, FB25Services, FBParamBlock, |
222 |
|
IBUtils; |
223 |
|
|
224 |
|
{ Stubs for 6.0 only functions } |
232 |
|
|
233 |
|
function isc_service_attach_stub(status_vector : PISC_STATUS; |
234 |
|
isc_arg2 : UShort; |
235 |
< |
isc_arg3 : PChar; |
235 |
> |
isc_arg3 : PAnsiChar; |
236 |
|
service_handle : PISC_SVC_HANDLE; |
237 |
|
isc_arg5 : UShort; |
238 |
< |
isc_arg6 : PChar): |
238 |
> |
isc_arg6 : PAnsiChar): |
239 |
|
ISC_STATUS; {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} |
240 |
|
begin |
241 |
|
Result := 0; |
254 |
|
service_handle : PISC_SVC_HANDLE; |
255 |
|
recv_handle : PISC_SVC_HANDLE; |
256 |
|
isc_arg4 : UShort; |
257 |
< |
isc_arg5 : PChar; |
257 |
> |
isc_arg5 : PAnsiChar; |
258 |
|
isc_arg6 : UShort; |
259 |
< |
isc_arg7 : PChar; |
259 |
> |
isc_arg7 : PAnsiChar; |
260 |
|
isc_arg8 : UShort; |
261 |
< |
isc_arg9 : PChar): |
261 |
> |
isc_arg9 : PAnsiChar): |
262 |
|
ISC_STATUS; {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} |
263 |
|
begin |
264 |
|
Result := 0; |
269 |
|
service_handle : PISC_SVC_HANDLE; |
270 |
|
recv_handle : PISC_SVC_HANDLE; |
271 |
|
isc_arg4 : UShort; |
272 |
< |
isc_arg5 : PChar): |
272 |
> |
isc_arg5 : PAnsiChar): |
273 |
|
ISC_STATUS; {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} |
274 |
|
begin |
275 |
|
Result := 0; |
448 |
|
Result := TDPB.Create; |
449 |
|
end; |
450 |
|
|
451 |
< |
function TFB25ClientAPI.OpenDatabase(DatabaseName: string; DPB: IDPB; |
451 |
> |
function TFB25ClientAPI.OpenDatabase(DatabaseName: AnsiString; DPB: IDPB; |
452 |
|
RaiseExceptionOnConnectError: boolean): IAttachment; |
453 |
|
begin |
454 |
|
Result := TFB25Attachment.Create(DatabaseName,DPB,RaiseExceptionOnConnectError); |
456 |
|
Result := nil; |
457 |
|
end; |
458 |
|
|
459 |
< |
function TFB25ClientAPI.CreateDatabase(DatabaseName: string; DPB: IDPB; |
459 |
> |
function TFB25ClientAPI.CreateDatabase(DatabaseName: AnsiString; DPB: IDPB; |
460 |
|
RaiseExceptionOnError: boolean): IAttachment; |
461 |
|
begin |
462 |
|
Result := TFB25Attachment.CreateDatabase(DatabaseName, DPB, RaiseExceptionOnError ); |
464 |
|
Result := nil; |
465 |
|
end; |
466 |
|
|
467 |
< |
function TFB25ClientAPI.CreateDatabase(sql: string; aSQLDialect: integer; |
467 |
> |
function TFB25ClientAPI.CreateDatabase(sql: AnsiString; aSQLDialect: integer; |
468 |
|
RaiseExceptionOnError: boolean): IAttachment; |
469 |
|
begin |
470 |
|
Result := TFB25Attachment.CreateDatabase(sql,aSQLDialect, RaiseExceptionOnError ); |
482 |
|
Result := TTPB.Create; |
483 |
|
end; |
484 |
|
|
485 |
< |
function TFB25ClientAPI.GetServiceManager(ServerName: string; |
485 |
> |
function TFB25ClientAPI.GetServiceManager(ServerName: AnsiString; |
486 |
|
Protocol: TProtocol; SPB: ISPB): IServiceManager; |
487 |
|
begin |
488 |
|
if HasServiceAPI then |
491 |
|
Result := nil; |
492 |
|
end; |
493 |
|
|
494 |
+ |
function TFB25ClientAPI.GetServiceManager(ServerName: AnsiString; |
495 |
+ |
Port: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager; |
496 |
+ |
begin |
497 |
+ |
if HasServiceAPI then |
498 |
+ |
Result := TFB25ServiceManager.Create(ServerName,Protocol,SPB,Port) |
499 |
+ |
else |
500 |
+ |
Result := nil; |
501 |
+ |
end; |
502 |
+ |
|
503 |
|
function TFB25ClientAPI.StartTransaction(Attachments: array of IAttachment; |
504 |
|
TPB: array of byte; DefaultCompletion: TTransactionCompletion): ITransaction; |
505 |
|
begin |
543 |
|
Result := nil; |
544 |
|
end; |
545 |
|
|
546 |
< |
function TFB25ClientAPI.GetImplementationVersion: string; |
546 |
> |
function TFB25ClientAPI.GetImplementationVersion: AnsiString; |
547 |
|
begin |
548 |
|
Result := FBClientInterfaceVersion; |
549 |
|
end; |
550 |
|
|
551 |
< |
function TFB25ClientAPI.DecodeInteger(bufptr: PChar; len: short): integer; |
551 |
> |
function TFB25ClientAPI.DecodeInteger(bufptr: PByte; len: short): integer; |
552 |
|
begin |
553 |
|
Result := isc_portable_integer(bufptr,len); |
554 |
|
end; |
555 |
|
|
556 |
< |
procedure TFB25ClientAPI.SQLEncodeDate(aDate: TDateTime; bufptr: PChar); |
556 |
> |
procedure TFB25ClientAPI.SQLEncodeDate(aDate: TDateTime; bufptr: PByte); |
557 |
|
var |
558 |
|
tm_date: TCTimeStructure; |
559 |
|
Yr, Mn, Dy: Word; |
570 |
|
isc_encode_sql_date(@tm_date, PISC_DATE(bufptr)); |
571 |
|
end; |
572 |
|
|
573 |
< |
function TFB25ClientAPI.SQLDecodeDate(bufptr: PChar): TDateTime; |
573 |
> |
function TFB25ClientAPI.SQLDecodeDate(bufptr: PByte): TDateTime; |
574 |
|
var |
575 |
|
tm_date: TCTimeStructure; |
576 |
|
begin |
585 |
|
end; |
586 |
|
end; |
587 |
|
|
588 |
< |
procedure TFB25ClientAPI.SQLEncodeTime(aTime: TDateTime; bufptr: PChar); |
588 |
> |
procedure TFB25ClientAPI.SQLEncodeTime(aTime: TDateTime; bufptr: PByte); |
589 |
|
var |
590 |
|
tm_date: TCTimeStructure; |
591 |
|
Hr, Mt, S, Ms: Word; |
605 |
|
Inc(PISC_TIME(bufptr)^,Ms*10); |
606 |
|
end; |
607 |
|
|
608 |
< |
function TFB25ClientAPI.SQLDecodeTime(bufptr: PChar): TDateTime; |
608 |
> |
function TFB25ClientAPI.SQLDecodeTime(bufptr: PByte): TDateTime; |
609 |
|
var |
610 |
|
tm_date: TCTimeStructure; |
611 |
|
msecs: Word; |
622 |
|
end; |
623 |
|
end; |
624 |
|
|
625 |
< |
procedure TFB25ClientAPI.SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PChar); |
625 |
> |
procedure TFB25ClientAPI.SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PByte); |
626 |
|
var |
627 |
|
tm_date: TCTimeStructure; |
628 |
|
Yr, Mn, Dy, Hr, Mt, S, Ms: Word; |
642 |
|
Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,Ms*10); |
643 |
|
end; |
644 |
|
|
645 |
< |
function TFB25ClientAPI.SQLDecodeDateTime(bufptr: PChar): TDateTime; |
645 |
> |
function TFB25ClientAPI.SQLDecodeDateTime(bufptr: PByte): TDateTime; |
646 |
|
var |
647 |
|
tm_date: TCTimeStructure; |
648 |
|
msecs: Word; |
667 |
|
|
668 |
|
end. |
669 |
|
|
670 |
+ |
|