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 315 by tony, Thu Feb 25 11:56:36 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 166 | Line 163 | type
163      isc_array_put_slice: Tisc_array_put_slice;
164      isc_prepare_transaction: Tisc_prepare_transaction;
165      isc_version: Tisc_Version;
166 +    isc_interprete: Tisc_interprete;
167  
168    public
169      {Helper Functions}
# Line 176 | Line 174 | type
174      function SQLDecodeTime(bufptr: PByte): TDateTime;  override;
175      procedure SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PByte); override;
176      function SQLDecodeDateTime(bufptr: PByte): TDateTime; override;
177 <
177 >    function FormatStatus(Status: TFBStatus): AnsiString; override;
178    public
179      {IFirebirdAPI}
180  
# Line 203 | Line 201 | type
201      function GetStatus: IStatus; override;
202      function HasRollbackRetaining: boolean;
203      function IsEmbeddedServer: boolean; override;
204 <    function GetImplementationVersion: AnsiString;
204 >    function GetClientMajor: integer; override;
205 >    function GetClientMinor: integer; override;
206  
207      {Firebird 3 API}
208      function HasMasterIntf: boolean;
# Line 216 | Line 215 | implementation
215   uses FBMessages,
216      {$IFDEF WINDOWS}Windows, {$ENDIF}
217      {$IFDEF FPC} Dynlibs, {$ENDIF}
218 <  FB25Attachment, FB25Transaction, FB25Services, FBParamBlock,
219 <  IBUtils;
218 >  FB25Attachment, FB25Transaction, FB25Services,
219 >  IBUtils, FBAttachment, FBTransaction, FBServices;
220  
221   { Stubs for 6.0 only functions }
222   function isc_rollback_retaining_stub(status_vector   : PISC_STATUS;
# Line 386 | Line 385 | begin
385    isc_array_put_slice := GetProcAddr('isc_array_put_slice'); {do not localize}
386    isc_prepare_transaction  := GetProcAddr('isc_prepare_transaction'); {do not localize}
387    isc_version  := GetProcAddr('isc_version'); {do not localize}
388 +  isc_interprete := GetProcAddr('isc_interprete'); {do not localize}
389  
390    FIBServiceAPIPresent := true;
391    isc_rollback_retaining := GetProcAddress(FFBLibrary.IBLibrary, 'isc_rollback_retaining'); {do not localize}
# Line 538 | Line 538 | begin
538   {$ENDIF}
539   end;
540  
541 + function TFB25ClientAPI.GetClientMajor: integer;
542 + begin
543 +  Result := 2;
544 + end;
545 +
546 + function TFB25ClientAPI.GetClientMinor: integer;
547 + begin
548 +  Result := 5;
549 + end;
550 +
551   function TFB25ClientAPI.HasMasterIntf: boolean;
552   begin
553    Result := false;
# Line 548 | Line 558 | begin
558    Result := nil;
559   end;
560  
551 function TFB25ClientAPI.GetImplementationVersion: AnsiString;
552 begin
553  Result := FBClientInterfaceVersion;
554 end;
555
561   function TFB25ClientAPI.DecodeInteger(bufptr: PByte; len: short): integer;
562   begin
563    Result := isc_portable_integer(bufptr,len);
# Line 593 | Line 598 | end;
598   procedure TFB25ClientAPI.SQLEncodeTime(aTime: TDateTime; bufptr: PByte);
599   var
600    tm_date: TCTimeStructure;
601 <  Hr, Mt, S, Ms: Word;
601 >  Hr, Mt, S: Word;
602 >  DMs: cardinal; {DMs = decimilliseconds}
603   begin
604 <  DecodeTime(aTime, Hr, Mt, S, Ms);
604 >  FBDecodeTime(aTime, Hr, Mt, S, DMs);
605    with tm_date do begin
606      tm_sec := S;
607      tm_min := Mt;
# Line 605 | Line 611 | begin
611      tm_year := 0;
612    end;
613    isc_encode_sql_time(@tm_date, PISC_TIME(bufptr));
614 <  if Ms > 0 then
615 <    Inc(PISC_TIME(bufptr)^,Ms*10);
614 >  if DMs > 0 then
615 >    Inc(PISC_TIME(bufptr)^,DMs);
616   end;
617  
618   function TFB25ClientAPI.SQLDecodeTime(bufptr: PByte): TDateTime;
619   var
620    tm_date: TCTimeStructure;
621 <  msecs: Word;
621 >  DMs: cardinal; {DMs = decimilliseconds}
622   begin
623    isc_decode_sql_time(PISC_TIME(bufptr), @tm_date);
624    try
625 <    msecs :=  (PISC_TIME(bufptr)^ mod 10000) div 10;
626 <    result := EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
627 <                         Word(tm_date.tm_sec), msecs)
625 >    DMs :=  PISC_TIME(bufptr)^ mod 10000;
626 >    result := FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
627 >                         Word(tm_date.tm_sec), DMs)
628    except
629      on E: EConvertError do begin
630        IBError(ibxeInvalidDataConversion, [nil]);
# Line 630 | Line 636 | procedure TFB25ClientAPI.SQLEncodeDateTi
636   var
637    tm_date: TCTimeStructure;
638    Yr, Mn, Dy, Hr, Mt, S, Ms: Word;
639 +  DMs: cardinal;
640   begin
641    DecodeDate(aDateTime, Yr, Mn, Dy);
642 <  DecodeTime(aDateTime, Hr, Mt, S, Ms);
642 >  FBDecodeTime(aDateTime, Hr, Mt, S, DMs);
643    with tm_date do begin
644      tm_sec := S;
645      tm_min := Mt;
# Line 642 | Line 649 | begin
649      tm_year := Yr - 1900;
650    end;
651    isc_encode_date(@tm_date, PISC_QUAD(bufptr));
652 <  if Ms > 0 then
653 <    Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,Ms*10);
652 >  if DMs > 0 then
653 >    Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,DMs);
654   end;
655  
656   function TFB25ClientAPI.SQLDecodeDateTime(bufptr: PByte): TDateTime;
657   var
658    tm_date: TCTimeStructure;
659 <  msecs: Word;
659 >  Dmsecs: Word;
660   begin
661    isc_decode_date(PISC_QUAD(bufptr), @tm_date);
662    try
663      result := EncodeDate(Word(tm_date.tm_year + 1900), Word(tm_date.tm_mon + 1),
664                          Word(tm_date.tm_mday));
665 <    msecs := (PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000) div 10;
665 >    Dmsecs := PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000;
666      if result >= 0 then
667 <      result := result + EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
668 <                                    Word(tm_date.tm_sec), msecs)
667 >      result := result + FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
668 >                                    Word(tm_date.tm_sec), Dmsecs)
669      else
670 <      result := result - EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
671 <                                    Word(tm_date.tm_sec), msecs)
670 >      result := result - FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min),
671 >                                    Word(tm_date.tm_sec), Dmsecs)
672    except
673      on E: EConvertError do begin
674        IBError(ibxeInvalidDataConversion, [nil]);
# Line 669 | Line 676 | begin
676    end;
677   end;
678  
679 + function TFB25ClientAPI.FormatStatus(Status: TFBStatus): AnsiString;
680 + var psb: PStatusVector;
681 +    local_buffer: array[0..IBHugeLocalBufferLength - 1] of AnsiChar;
682 + begin
683 +  psb := Status.StatusVector;
684 +  Result := '';
685 +  while isc_interprete(@local_buffer,@psb) > 0 do
686 +  begin
687 +    if (Result <> '') and (Result[Length(Result)] <> LF) then
688 +      Result := Result + LineEnding + '-';
689 +    Result := Result + strpas(local_buffer);
690 +  end;
691 + end;
692 +
693   end.
694  
695  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines