ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/journaling/fbintf/client/2.5/FB25ClientAPI.pas
(Generate patch)

Comparing ibx/trunk/fbintf/client/2.5/FB25ClientAPI.pas (file contents):
Revision 266 by tony, Wed Dec 26 18:34:32 2018 UTC vs.
Revision 352 by tony, Thu Oct 21 12:17:43 2021 UTC

# Line 74 | Line 74 | interface
74   uses
75    Classes, SysUtils, FBClientAPI, IBHeader, IBExternals, IB;
76  
77 const
78  FBClientInterfaceVersion = '2.5';
79
77   type
78  
79    { TFB25Status }
# Line 114 | Line 111 | type
111      BLOB_put: TBLOB_put;
112      isc_wait_for_event: Tisc_wait_for_event;
113      isc_vax_integer: Tisc_vax_integer;
117    isc_portable_integer: Tisc_portable_integer;
114      isc_blob_info: Tisc_blob_info;
115      isc_blob_lookup_desc: Tisc_blob_lookup_desc;
116      isc_open_blob2: Tisc_open_blob2;
# Line 166 | Line 162 | type
162      isc_array_put_slice: Tisc_array_put_slice;
163      isc_prepare_transaction: Tisc_prepare_transaction;
164      isc_version: Tisc_Version;
165 +    isc_interprete: Tisc_interprete;
166  
167    public
168      {Helper Functions}
172    function DecodeInteger(bufptr: PByte; len: short): integer; override;
169      procedure SQLEncodeDate(aDate: TDateTime; bufptr: PByte); override;
170      function SQLDecodeDate(bufptr: PByte): TDateTime; override;
171      procedure SQLEncodeTime(aTime: TDateTime; bufptr: PByte); override;
172      function SQLDecodeTime(bufptr: PByte): TDateTime;  override;
173      procedure SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PByte); override;
174      function SQLDecodeDateTime(bufptr: PByte): TDateTime; override;
175 <
175 >    function FormatStatus(Status: TFBStatus): AnsiString; override;
176    public
177      {IFirebirdAPI}
178  
# Line 203 | Line 199 | type
199      function GetStatus: IStatus; override;
200      function HasRollbackRetaining: boolean;
201      function IsEmbeddedServer: boolean; override;
202 <    function GetImplementationVersion: AnsiString;
202 >    function GetClientMajor: integer; override;
203 >    function GetClientMinor: integer; override;
204  
205      {Firebird 3 API}
206      function HasMasterIntf: boolean;
# Line 216 | Line 213 | implementation
213   uses FBMessages,
214      {$IFDEF WINDOWS}Windows, {$ENDIF}
215      {$IFDEF FPC} Dynlibs, {$ENDIF}
216 <  FB25Attachment, FB25Transaction, FB25Services, FBParamBlock,
217 <  IBUtils;
216 >  FB25Attachment, FB25Transaction, FB25Services,
217 >  IBUtils, FBAttachment, FBTransaction, FBServices;
218  
219   { Stubs for 6.0 only functions }
220   function isc_rollback_retaining_stub(status_vector   : PISC_STATUS;
# Line 345 | Line 342 | begin
342    BLOB_put := GetProcAddr('BLOB_put'); {do not localize}
343    isc_wait_for_event := GetProcAddr('isc_wait_for_event'); {do not localize}
344    isc_vax_integer := GetProcAddr('isc_vax_integer'); {do not localize}
348  isc_portable_integer := GetProcAddr('isc_portable_integer'); {do not localize}
345    isc_blob_info := GetProcAddr('isc_blob_info'); {do not localize}
346    isc_blob_lookup_desc := GetProcAddr('isc_blob_lookup_desc');  {do not localize}
347    isc_open_blob2 := GetProcAddr('isc_open_blob2'); {do not localize}
# Line 386 | Line 382 | begin
382    isc_array_put_slice := GetProcAddr('isc_array_put_slice'); {do not localize}
383    isc_prepare_transaction  := GetProcAddr('isc_prepare_transaction'); {do not localize}
384    isc_version  := GetProcAddr('isc_version'); {do not localize}
385 +  isc_interprete := GetProcAddr('isc_interprete'); {do not localize}
386  
387    FIBServiceAPIPresent := true;
388    isc_rollback_retaining := GetProcAddress(FFBLibrary.IBLibrary, 'isc_rollback_retaining'); {do not localize}
# Line 538 | Line 535 | begin
535   {$ENDIF}
536   end;
537  
538 < function TFB25ClientAPI.HasMasterIntf: boolean;
538 > function TFB25ClientAPI.GetClientMajor: integer;
539   begin
540 <  Result := false;
540 >  Result := 2;
541   end;
542  
543 < function TFB25ClientAPI.GetIMaster: TObject;
543 > function TFB25ClientAPI.GetClientMinor: integer;
544   begin
545 <  Result := nil;
545 >  Result := 5;
546   end;
547  
548 < function TFB25ClientAPI.GetImplementationVersion: AnsiString;
548 > function TFB25ClientAPI.HasMasterIntf: boolean;
549   begin
550 <  Result := FBClientInterfaceVersion;
550 >  Result := false;
551   end;
552  
553 < function TFB25ClientAPI.DecodeInteger(bufptr: PByte; len: short): integer;
553 > function TFB25ClientAPI.GetIMaster: TObject;
554   begin
555 <  Result := isc_portable_integer(bufptr,len);
555 >  Result := nil;
556   end;
557  
558   procedure TFB25ClientAPI.SQLEncodeDate(aDate: TDateTime; bufptr: PByte);
# Line 593 | Line 590 | end;
590   procedure TFB25ClientAPI.SQLEncodeTime(aTime: TDateTime; bufptr: PByte);
591   var
592    tm_date: TCTimeStructure;
593 <  Hr, Mt, S, Ms: Word;
593 >  Hr, Mt, S: Word;
594 >  DMs: cardinal; {DMs = decimilliseconds}
595   begin
596 <  DecodeTime(aTime, Hr, Mt, S, Ms);
596 >  FBDecodeTime(aTime, Hr, Mt, S, DMs);
597    with tm_date do begin
598      tm_sec := S;
599      tm_min := Mt;
# Line 605 | Line 603 | begin
603      tm_year := 0;
604    end;
605    isc_encode_sql_time(@tm_date, PISC_TIME(bufptr));
606 <  if Ms > 0 then
607 <    Inc(PISC_TIME(bufptr)^,Ms*10);
606 >  if DMs > 0 then
607 >    Inc(PISC_TIME(bufptr)^,DMs);
608   end;
609  
610   function TFB25ClientAPI.SQLDecodeTime(bufptr: PByte): TDateTime;
611   var
612    tm_date: TCTimeStructure;
613 <  msecs: Word;
613 >  DMs: cardinal; {DMs = decimilliseconds}
614   begin
615    isc_decode_sql_time(PISC_TIME(bufptr), @tm_date);
616    try
617 <    msecs :=  (PISC_TIME(bufptr)^ mod 10000) div 10;
618 <    result := EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
619 <                         Word(tm_date.tm_sec), msecs)
617 >    DMs :=  PISC_TIME(bufptr)^ mod 10000;
618 >    result := FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
619 >                         Word(tm_date.tm_sec), DMs)
620    except
621      on E: EConvertError do begin
622        IBError(ibxeInvalidDataConversion, [nil]);
# Line 630 | Line 628 | procedure TFB25ClientAPI.SQLEncodeDateTi
628   var
629    tm_date: TCTimeStructure;
630    Yr, Mn, Dy, Hr, Mt, S, Ms: Word;
631 +  DMs: cardinal;
632   begin
633    DecodeDate(aDateTime, Yr, Mn, Dy);
634 <  DecodeTime(aDateTime, Hr, Mt, S, Ms);
634 >  FBDecodeTime(aDateTime, Hr, Mt, S, DMs);
635    with tm_date do begin
636      tm_sec := S;
637      tm_min := Mt;
# Line 642 | Line 641 | begin
641      tm_year := Yr - 1900;
642    end;
643    isc_encode_date(@tm_date, PISC_QUAD(bufptr));
644 <  if Ms > 0 then
645 <    Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,Ms*10);
644 >  if DMs > 0 then
645 >    Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,DMs);
646   end;
647  
648   function TFB25ClientAPI.SQLDecodeDateTime(bufptr: PByte): TDateTime;
649   var
650    tm_date: TCTimeStructure;
651 <  msecs: Word;
651 >  Dmsecs: Word;
652   begin
653    isc_decode_date(PISC_QUAD(bufptr), @tm_date);
654    try
655      result := EncodeDate(Word(tm_date.tm_year + 1900), Word(tm_date.tm_mon + 1),
656                          Word(tm_date.tm_mday));
657 <    msecs := (PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000) div 10;
657 >    Dmsecs := PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000;
658      if result >= 0 then
659 <      result := result + EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
660 <                                    Word(tm_date.tm_sec), msecs)
659 >      result := result + FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
660 >                                    Word(tm_date.tm_sec), Dmsecs)
661      else
662 <      result := result - EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
663 <                                    Word(tm_date.tm_sec), msecs)
662 >      result := result - FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
663 >                                    Word(tm_date.tm_sec), Dmsecs)
664    except
665      on E: EConvertError do begin
666        IBError(ibxeInvalidDataConversion, [nil]);
# Line 669 | Line 668 | begin
668    end;
669   end;
670  
671 + function TFB25ClientAPI.FormatStatus(Status: TFBStatus): AnsiString;
672 + var psb: PStatusVector;
673 +    local_buffer: array[0..IBHugeLocalBufferLength - 1] of AnsiChar;
674 + begin
675 +  psb := Status.StatusVector;
676 +  Result := '';
677 +  while isc_interprete(@local_buffer,@psb) > 0 do
678 +  begin
679 +    if (Result <> '') and (Result[Length(Result)] <> LF) then
680 +      Result := Result + LineEnding + '-';
681 +    Result := Result + strpas(local_buffer);
682 +  end;
683 + end;
684 +
685   end.
686  
687  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines