From 0c7bbb9ae9909a82d70df654c4a5b32867b3b190 Mon Sep 17 00:00:00 2001 From: DmBel Date: Tue, 22 Nov 2022 09:36:00 +0300 Subject: [PATCH] fixed for Delphi/Linux --- SynHttpSrv.pas | 22 +++++++++++------ blcksock.pas | 60 ++++++++++++++++++++++----------------------- ssfpc.inc | 12 ++++----- ssl_openssl_lib.pas | 1 - sslinux.inc | 4 +-- ssposix.inc | 15 +++++++----- synachar.pas | 3 +-- synacrypt.pas | 14 +++++------ synaicnv.pas | 9 +++---- synaser.pas | 46 +++++++++++++++++----------------- synautil.pas | 16 ++++++------ synsock.pas | 6 ++--- 12 files changed, 108 insertions(+), 100 deletions(-) diff --git a/SynHttpSrv.pas b/SynHttpSrv.pas index 428e2b4..c33bd69 100644 --- a/SynHttpSrv.pas +++ b/SynHttpSrv.pas @@ -1068,20 +1068,26 @@ procedure TryDecodeUtf8(var Url: string); procedure TryDecodeUtf8(var Url: string); var S: string; begin - S:=UTF8ToString(Url); // returns empty, if not valid Utf8... + S:=UTF8ToString(RawByteString(Url)); // returns empty, if not valid Utf8... if (S<>'') then Url:=S; end; {$endif} -function ValHex(const S: string; var Value: integer): boolean; +function ValHex(const S: AnsiString; var Value: integer): boolean; var code: integer; begin - Val('$' + S, Value, Code); + Val('$' + string(S), Value, Code); Result := Code = 0; end; +function AnsiCopy(const s: ansistring; StartIndex, Lenght: integer): ansistring; +begin + SetLength(Result, Lenght); + Move(s[StartIndex], Result[1], Lenght); +end; + function ConvertUrlChars(Url: string): string; var p, len, code: integer; @@ -1102,7 +1108,7 @@ function ConvertUrlChars(Url: string): string; while (p <= len) do begin if (buff[p] = '%') then - if ValHex(Copy(string(buff), p + 1, 2), code) then + if ValHex(AnsiCopy(buff, p + 1, 2), code) then begin Delete(buff, p + 1, 2); Dec(len, 2); @@ -2156,6 +2162,7 @@ procedure RegisterInternalContentTypes; RegisterContentType('.bmp', 'image/bmp'); RegisterContentType('.htc', 'text/x-component'); RegisterContentType('.js', 'text/javascript'); + RegisterContentType('.pdf', 'application/pdf'); end; function GetContentTypeByExt(const Ext: string): string; @@ -2822,7 +2829,8 @@ procedure TSynHttpServer.ReadRequest(Connection: TSynTcpSrvConnection; Request, function PreparePostStream: boolean; var - i, Size: integer; + i: integer; + Size: int64; begin Result := False; if (Request.TransferEncoding <> '') and (not SameText(Request.TransferEncoding, 'identity')) then @@ -2845,7 +2853,7 @@ procedure TSynHttpServer.ReadRequest(Connection: TSynTcpSrvConnection; Request, i := Pos(';', S); {do not localize} if i > 0 then S := Copy(S, 1, i - 1); - Size := StrToIntDef('$' + Trim(S), 0); {do not localize} + Size := StrToInt64Def('$' + Trim(S), 0); {do not localize} if Size = 0 then Break; Connection.Socket.RecvStreamSize(Request.PostStream, cDefLineTimeout, Size); @@ -2864,7 +2872,7 @@ procedure TSynHttpServer.ReadRequest(Connection: TSynTcpSrvConnection; Request, Request.PostStream.Position := 0; if Request.ContentLength > '0' then begin - Size := StrToIntDef(Request.ContentLength, 0); + Size := StrToInt64Def(Request.ContentLength, 0); Connection.Socket.RecvStreamSize(Request.PostStream, cDefLineTimeout, Size); Request.PostStream.Position := 0; end; diff --git a/blcksock.pas b/blcksock.pas index 75013d7..4bd4950 100644 --- a/blcksock.pas +++ b/blcksock.pas @@ -323,9 +323,9 @@ TBlockSocket = class(TObject) FNonBlockMode: Boolean; FMaxLineLength: Integer; FMaxSendBandwidth: Integer; - FNextSend: LongWord; + FNextSend: FixedUInt; FMaxRecvBandwidth: Integer; - FNextRecv: LongWord; + FNextRecv: FixedUInt; FConvertLineEnd: Boolean; FLastCR: Boolean; FLastLF: Boolean; @@ -339,9 +339,9 @@ TBlockSocket = class(TObject) {$IFNDEF CIL} FFDSet: TFDSet; {$ENDIF} - FRecvCounter: Integer; - FSendCounter: Integer; - FSendMaxChunk: Integer; + FRecvCounter: int64; + FSendCounter: int64; + FSendMaxChunk: int64; FStopFlag: Boolean; FNonblockSendTimeout: Integer; FHeartbeatRate: integer; @@ -377,7 +377,7 @@ TBlockSocket = class(TObject) procedure DoMonitor(Writing: Boolean; const Buffer: TMemory; Len: Integer); procedure DoCreateSocket; procedure DoHeartbeat; - procedure LimitBandwidth(Length: Integer; MaxB: integer; var Next: LongWord); + procedure LimitBandwidth(Length: Integer; MaxB: integer; var Next: FixedUInt); procedure SetBandwidth(Value: Integer); function TestStopFlag: Boolean; procedure InternalSendStream(const Stream: TStream; WithSize, Indy: boolean); virtual; @@ -575,7 +575,7 @@ TBlockSocket = class(TObject) occured.)} procedure RecvStreamRaw(const Stream: TStream; Timeout: Integer); virtual; {:Read requested count of bytes from socket to stream.} - procedure RecvStreamSize(const Stream: TStream; Timeout: Integer; Size: Integer); + procedure RecvStreamSize(const Stream: TStream; Timeout: Integer; Size: int64); {:Receive data to stream. It using @link(RecvBlock) method.} procedure RecvStream(const Stream: TStream; Timeout: Integer); virtual; @@ -798,11 +798,11 @@ TBlockSocket = class(TObject) {:Return count of received bytes on this socket from begin of current connection.} - property RecvCounter: Integer read FRecvCounter; + property RecvCounter: int64 read FRecvCounter; {:Return count of sended bytes on this socket from begin of current connection.} - property SendCounter: Integer read FSendCounter; + property SendCounter: int64 read FSendCounter; published {:Return descriptive string for given error code. This is class function. You may call it without created object!} @@ -861,7 +861,7 @@ TBlockSocket = class(TObject) property InterPacketTimeout: Boolean read FInterPacketTimeout Write FInterPacketTimeout; {:All sended datas was splitted by this value.} - property SendMaxChunk: Integer read FSendMaxChunk Write FSendMaxChunk; + property SendMaxChunk: int64 read FSendMaxChunk Write FSendMaxChunk; {:By setting this property to @true you can stop any communication. You can use this property for soft abort of communication.} @@ -1147,7 +1147,7 @@ TDgramBlockSocket = class(TSocksBlockSocket) {:Silently redirected to @link(TBlockSocket.RecvBufferFrom).} function RecvBuffer(Buffer: TMemory; Length: Integer): Integer; override; - + {:Specify if connect should called on the underlying socket.} property UseConnect: Boolean read FUseConnect Write FUseConnect; end; @@ -1509,9 +1509,9 @@ TIPHeader = record TTL: Byte; Protocol: Byte; CheckSum: Word; - SourceIp: LongWord; - DestIp: LongWord; - Options: LongWord; + SourceIp: FixedUInt; + DestIp: FixedUInt; + Options: FixedUInt; end; {:@abstract(Parent class of application protocol implementations.) @@ -1649,9 +1649,9 @@ destructor TBlockSocket.Destroy; for n := FDelayedOptions.Count - 1 downto 0 do begin p := TSynaOption(FDelayedOptions[n]); - p.Free; + FreeAndNil(p); end; - FDelayedOptions.Free; + FreeAndNil(FDelayedOptions); inherited Destroy; end; @@ -1673,7 +1673,7 @@ procedure TBlockSocket.SetDelayedOption(const Value: TSynaOption); x: integer; buf: TMemory; {$IFNDEF MSWINDOWS} -{$IFNDEF ULTIBO} +{$IFNDEF ULTIBO} timeval: TTimeval; {$ENDIF} {$ENDIF} @@ -1850,7 +1850,7 @@ procedure TBlockSocket.SetDelayedOption(const Value: TSynaOption); ExceptCheck; end; end; - Value.free; + FreeAndNil(Value); end; procedure TBlockSocket.DelayedOption(const Value: TSynaOption); @@ -1999,7 +1999,7 @@ procedure TBlockSocket.AbortSocket; for n := FDelayedOptions.Count - 1 downto 0 do begin p := TSynaOption(FDelayedOptions[n]); - p.Free; + FreeAndNil(p); end; FDelayedOptions.Clear; FFamily := FFamilySave; @@ -2104,10 +2104,10 @@ procedure TBlockSocket.SetBandwidth(Value: Integer); MaxRecvBandwidth := Value; end; -procedure TBlockSocket.LimitBandwidth(Length: Integer; MaxB: integer; var Next: LongWord); +procedure TBlockSocket.LimitBandwidth(Length: Integer; MaxB: integer; var Next: FixedUInt); var - x: LongWord; - y: LongWord; + x: FixedUInt; + y: FixedUInt; n: integer; begin if FStopFlag then @@ -2255,7 +2255,7 @@ procedure TBlockSocket.SendBlock(const Data: string); procedure TBlockSocket.InternalSendStream(const Stream: TStream; WithSize, Indy: boolean); var - l: integer; + l: int64; yr: integer; s: string; b: boolean; @@ -2347,7 +2347,7 @@ function TBlockSocket.RecvBufferEx(Buffer: TMemory; Len: Integer; var s: TSynaBytes; rl, l: integer; - ti: LongWord; + ti: FixedUInt; {$IFDEF CIL} n: integer; b: TMemory; @@ -2520,7 +2520,7 @@ function TBlockSocket.RecvTerminated(Timeout: Integer; const Terminator: string) CorCRLF: Boolean; t: string; tl: integer; - ti: LongWord; + ti: FixedUInt; begin ResetLastError; Result := ''; @@ -2611,7 +2611,7 @@ procedure TBlockSocket.RecvStreamRaw(const Stream: TStream; Timeout: Integer); until FLastError <> 0; end; -procedure TBlockSocket.RecvStreamSize(const Stream: TStream; Timeout: Integer; Size: Integer); +procedure TBlockSocket.RecvStreamSize(const Stream: TStream; Timeout: Integer; Size: int64); var s: TSynaBytes; n: integer; @@ -2835,7 +2835,7 @@ function TBlockSocket.ResolveName(const Name: string): string; ResolveNameToIP(Name, l); Result := l[0]; finally - l.Free; + FreeAndNil(l); end; end; @@ -3731,7 +3731,7 @@ procedure TDgramBlockSocket.Connect(const IP, Port: string); SockCheck(synsock.Connect(FSocket, FRemoteSin)); if FLastError = 0 then GetSins; - end; + end; FBuffer := ''; DoStatus(HR_Connect, IP + ':' + Port); end; @@ -3751,7 +3751,7 @@ function TDgramBlockSocket.SendBuffer(const Buffer: TMemory; Length: Integer): I destructor TUDPBlockSocket.Destroy; begin if Assigned(FSocksControlSock) then - FSocksControlSock.Free; + FreeAndNil(FSocksControlSock); inherited; end; @@ -3983,7 +3983,7 @@ constructor TTCPBlockSocket.Create; destructor TTCPBlockSocket.Destroy; begin inherited Destroy; - FSSL.Free; + FreeAndNil(FSSL); end; function TTCPBlockSocket.GetErrorDescEx: string; diff --git a/ssfpc.inc b/ssfpc.inc index e8f14fb..7498550 100644 --- a/ssfpc.inc +++ b/ssfpc.inc @@ -368,9 +368,9 @@ type sin_addr: TInAddr; sin_zero: array[0..7] of Char); AF_INET6: (sin6_port: word; - sin6_flowinfo: longword; + sin6_flowinfo: FixedUInt; sin6_addr: TInAddr6; - sin6_scope_id: longword); + sin6_scope_id: FixedUInt); ); end; @@ -390,11 +390,11 @@ function SizeOfVarSin(sin: TVarSin): integer; function SendTo(s: TSocket; Buf: TMemory; len, flags: Integer; addrto: TVarSin): Integer; function RecvFrom(s: TSocket; Buf: TMemory; len, flags: Integer; var from: TVarSin): Integer; function ntohs(netshort: word): word; - function ntohl(netlong: longword): longword; + function ntohl(netlong: FixedUInt): FixedUInt; function Listen(s: TSocket; backlog: Integer): Integer; function IoctlSocket(s: TSocket; cmd: DWORD; var arg: integer): Integer; function htons(hostshort: word): word; - function htonl(hostlong: longword): longword; + function htonl(hostlong: FixedUInt): FixedUInt; function GetSockName(s: TSocket; var name: TVarSin): Integer; function GetPeerName(s: TSocket; var name: TVarSin): Integer; function Connect(s: TSocket; const name: TVarSin): Integer; @@ -617,7 +617,7 @@ begin Result := sockets.ntohs(NetShort); end; -function ntohl(netlong: longword): longword; +function ntohl(netlong: FixedUInt): FixedUInt; begin Result := sockets.ntohl(NetLong); end; @@ -640,7 +640,7 @@ begin Result := sockets.htons(Hostshort); end; -function htonl(hostlong: longword): longword; +function htonl(hostlong: FixedUInt): FixedUInt; begin Result := sockets.htonl(HostLong); end; diff --git a/ssl_openssl_lib.pas b/ssl_openssl_lib.pas index e6696b5..215dc95 100644 --- a/ssl_openssl_lib.pas +++ b/ssl_openssl_lib.pas @@ -97,7 +97,6 @@ interface BaseUnix, {$ENDIF UNIX} {$ELSE} - Libc, {$ENDIF} SysUtils; {$ELSE} diff --git a/sslinux.inc b/sslinux.inc index 00d7e9d..4920cd3 100644 --- a/sslinux.inc +++ b/sslinux.inc @@ -102,7 +102,7 @@ const type DWORD = Integer; - __fd_mask = LongWord; + __fd_mask = FixedUInt; const __FD_SETSIZE = 1024; __NFDBITS = 8 * sizeof(__fd_mask); @@ -731,7 +731,7 @@ end; function __FDMASK(Socket: TSocket): __fd_mask; begin - Result := LongWord(1) shl (Socket mod __NFDBITS); + Result := FixedUInt(1) shl (Socket mod __NFDBITS); end; function FD_ISSET(Socket: TSocket; var fdset: TFDSet): Boolean; diff --git a/ssposix.inc b/ssposix.inc index b275380..2072a96 100644 --- a/ssposix.inc +++ b/ssposix.inc @@ -48,6 +48,8 @@ {$IFDEF POSIX} {for delphi XE2+} +{$WARN SYMBOL_PLATFORM OFF} + //{$DEFINE FORCEOLDAPI} {Note about define FORCEOLDAPI: If you activate this compiler directive, then is allways used old socket API @@ -76,6 +78,7 @@ function InitSocketInterface(stack: string): Boolean; function DestroySocketInterface: Boolean; const + WSABASEERR = 10000; DLLStackName = ''; WinsockLevel = $0202; @@ -370,9 +373,9 @@ type sin_addr: TInAddr; sin_zero: array[0..7] of Byte); AF_INET6: (sin6_port: word; - sin6_flowinfo: longword; + sin6_flowinfo: FixedUInt; sin6_addr: TInAddr6; - sin6_scope_id: longword); + sin6_scope_id: FixedUInt); ); end; @@ -392,11 +395,11 @@ function SizeOfVarSin(sin: TVarSin): integer; function SendTo(s: TSocket; Buf: TMemory; len, flags: Integer; addrto: TVarSin): Integer; function RecvFrom(s: TSocket; Buf: TMemory; len, flags: Integer; var from: TVarSin): Integer; function ntohs(netshort: word): word; - function ntohl(netlong: longword): longword; + function ntohl(netlong: FixedUInt): FixedUInt; function Listen(s: TSocket; backlog: Integer): Integer; function IoctlSocket(s: TSocket; cmd: Integer; var arg: integer): Integer; function htons(hostshort: word): word; - function htonl(hostlong: longword): longword; + function htonl(hostlong: FixedUInt): FixedUInt; function GetSockName(s: TSocket; var name: TVarSin): Integer; function GetPeerName(s: TSocket; var name: TVarSin): Integer; function Connect(s: TSocket; const name: TVarSin): Integer; @@ -639,7 +642,7 @@ begin Result := Posix.ArpaInet.ntohs(NetShort); end; -function ntohl(netlong: longword): longword; +function ntohl(netlong: FixedUInt): FixedUInt; begin Result := Posix.ArpaInet.ntohl(NetLong); end; @@ -662,7 +665,7 @@ begin Result := Posix.ArpaInet.htons(Hostshort); end; -function htonl(hostlong: longword): longword; +function htonl(hostlong: FixedUInt): FixedUInt; begin Result := Posix.ArpaInet.htonl(HostLong); end; diff --git a/synachar.pas b/synachar.pas index f35b6f1..e86bc43 100644 --- a/synachar.pas +++ b/synachar.pas @@ -79,7 +79,6 @@ interface uses {$IFNDEF MSWINDOWS} {$IFNDEF FPC} - Libc, {$ENDIF} {$ELSE} Windows, @@ -1503,7 +1502,7 @@ function CharsetConversionTrans(Value: AnsiString; CharFrom: TMimeChar; function GetCurCP: TMimeChar; begin - {$IFNDEF FPC} + {$IFNDEF LINUX} Result := GetCPFromID(nl_langinfo(_NL_CTYPE_CODESET_NAME)); {$ELSE} //How to get system codepage without LIBC? diff --git a/synacrypt.pas b/synacrypt.pas index 4eb3849..e6dfad6 100644 --- a/synacrypt.pas +++ b/synacrypt.pas @@ -160,8 +160,8 @@ TSyna3Des= class(TSynaCustomDes) {:@abstract(Implementation of AES encryption)} TSynaAes= class(TSynaBlockcipher) protected - numrounds: longword; - rk, drk: array[0..MAXROUNDS,0..7] of longword; + numrounds: FixedUInt; + rk, drk: array[0..MAXROUNDS,0..7] of FixedUInt; procedure InitKey(Key: AnsiString); override; function GetSize: byte; override; public @@ -1354,7 +1354,7 @@ implementation {==============================================================================} type - PDWord = ^LongWord; + PDWord = ^FixedUInt; procedure hperm_op(var a, t: integer; n, m: integer); begin @@ -1968,7 +1968,7 @@ function TSyna3Des.DecryptECB(const InData: AnsiString): AnsiString; procedure InvMixColumn(a: PByteArray; BC: byte); var - j: longword; + j: FixedUInt; begin for j:= 0 to (BC-1) do PDWord(@(a^[j*4]))^:= PDWord(@U1[a^[j*4+0]])^ @@ -1987,7 +1987,7 @@ function TSynaAes.GetSize: byte; procedure TSynaAes.InitKey(Key: AnsiString); var Size: integer; - KC, ROUNDS, j, r, t, rconpointer: longword; + KC, ROUNDS, j, r, t, rconpointer: FixedUInt; tk: array[0..MAXKC-1,0..3] of byte; //n: integer; begin @@ -2080,7 +2080,7 @@ procedure TSynaAes.InitKey(Key: AnsiString); function TSynaAes.EncryptECB(const InData: AnsiString): AnsiString; var - r: longword; + r: FixedUInt; tempb: array[0..MAXBC-1,0..3] of byte; a: array[0..MAXBC,0..3] of byte; p: pointer; @@ -2141,7 +2141,7 @@ function TSynaAes.EncryptECB(const InData: AnsiString): AnsiString; function TSynaAes.DecryptECB(const InData: AnsiString): AnsiString; var - r: longword; + r: FixedUInt; tempb: array[0..MAXBC-1,0..3] of byte; a: array[0..MAXBC,0..3] of byte; p: pointer; diff --git a/synaicnv.pas b/synaicnv.pas index cbe0bfc..da4dbeb 100644 --- a/synaicnv.pas +++ b/synaicnv.pas @@ -72,7 +72,6 @@ interface synafpc, {$IFNDEF MSWINDOWS} {$IFNDEF FPC} - Libc, {$ENDIF} SysUtils; {$ELSE} @@ -294,10 +293,10 @@ function InitIconvInterface: Boolean; if (IconvLibHandle <> 0) then begin {$IFNDEF CIL} - _iconv_open := GetProcAddress(IconvLibHandle, PAnsiChar(AnsiString('libiconv_open'))); - _iconv := GetProcAddress(IconvLibHandle, PAnsiChar(AnsiString('libiconv'))); - _iconv_close := GetProcAddress(IconvLibHandle, PAnsiChar(AnsiString('libiconv_close'))); - _iconvctl := GetProcAddress(IconvLibHandle, PAnsiChar(AnsiString('libiconvctl'))); + _iconv_open := GetProcAddress(IconvLibHandle, PChar('libiconv_open')); + _iconv := GetProcAddress(IconvLibHandle, PChar('libiconv')); + _iconv_close := GetProcAddress(IconvLibHandle, PChar('libiconv_close')); + _iconvctl := GetProcAddress(IconvLibHandle, PChar('libiconvctl')); {$ENDIF} Result := True; Iconvloaded := True; diff --git a/synaser.pas b/synaser.pas index 0ce9c63..f7b0581 100644 --- a/synaser.pas +++ b/synaser.pas @@ -313,9 +313,9 @@ TBlockSerial = class(TObject) FMaxLineLength: Integer; FLinuxLock: Boolean; FMaxSendBandwidth: Integer; - FNextSend: LongWord; + FNextSend: FixedUInt; FMaxRecvBandwidth: Integer; - FNextRecv: LongWord; + FNextRecv: FixedUInt; FConvertLineEnd: Boolean; FATResult: Boolean; FAtTimeout: integer; @@ -352,7 +352,7 @@ TBlockSerial = class(TObject) function LockfileName: String; virtual; procedure CreateLockfile(PidNr: integer); virtual; {$ENDIF} - procedure LimitBandwidth(Length: Integer; MaxB: integer; var Next: LongWord); virtual; + procedure LimitBandwidth(Length: Integer; MaxB: integer; var Next: FixedUInt); virtual; procedure SetBandwidth(Value: Integer); virtual; public {: data Control Block with communication parameters. Usable only when you @@ -891,10 +891,10 @@ procedure TBlockSerial.SetBandwidth(Value: Integer); MaxRecvBandwidth := Value; end; -procedure TBlockSerial.LimitBandwidth(Length: Integer; MaxB: integer; var Next: LongWord); +procedure TBlockSerial.LimitBandwidth(Length: Integer; MaxB: integer; var Next: FixedUInt); var - x: LongWord; - y: LongWord; + x: FixedUInt; + y: FixedUInt; begin if MaxB > 0 then begin @@ -952,7 +952,7 @@ procedure TBlockSerial.Connect(comport: string); {$ENDIF} {$IFDEF ULTIBO} var - ResultCode: LongWord; + ResultCode: FixedUInt; {$ENDIF} begin // Is this TBlockSerial Instance already busy? @@ -1092,7 +1092,7 @@ function TBlockSerial.SendBuffer(buffer: pointer; length: integer): integer; {$ENDIF} {$IFDEF ULTIBO} var - ResultCode: LongWord; + ResultCode: FixedUInt; {$ENDIF} begin Result := 0; @@ -1109,7 +1109,7 @@ function TBlockSerial.SendBuffer(buffer: pointer; length: integer): integer; result := FileWrite(Fhandle, Buffer^, Length); serialcheck(result); {$ELSE} - ResultCode := SerialDeviceWrite(FSerialDevice, buffer, length, SERIAL_WRITE_NONE, LongWord(Result)); + ResultCode := SerialDeviceWrite(FSerialDevice, buffer, length, SERIAL_WRITE_NONE, FixedUInt(Result)); SetLastError(ResultCode); if ResultCode <> ERROR_SUCCESS then SerialCheck(sErr) @@ -1227,13 +1227,13 @@ function TBlockSerial.RecvBuffer(buffer: pointer; length: integer): integer; serialcheck(result); {$ELSE} var - ResultCode: LongWord; + ResultCode: FixedUInt; begin Result := 0; if PreTestFailing then {HGJ} Exit; {HGJ} LimitBandwidth(Length, FMaxRecvBandwidth, FNextRecv); - ResultCode := SerialDeviceRead(FSerialDevice, buffer, length, SERIAL_READ_NONE, LongWord(Result)); + ResultCode := SerialDeviceRead(FSerialDevice, buffer, length, SERIAL_READ_NONE, FixedUInt(Result)); SetLastError(ResultCode); if ResultCode <> ERROR_SUCCESS then SerialCheck(sErr) @@ -1279,7 +1279,7 @@ function TBlockSerial.RecvBufferEx(buffer: pointer; length: integer; timeout: in var s: AnsiString; rl, l: integer; - ti: LongWord; + ti: FixedUInt; begin Result := 0; if PreTestFailing then {HGJ} @@ -1404,7 +1404,7 @@ function TBlockSerial.RecvTerminated(Timeout: Integer; const Terminator: AnsiStr CorCRLF: Boolean; t: ansistring; tl: integer; - ti: LongWord; + ti: FixedUInt; begin Result := ''; if PreTestFailing then {HGJ} @@ -1571,9 +1571,9 @@ function TBlockSerial.WaitingData: integer; {$ELSE} function TBlockSerial.WaitingData: integer; var - ResultCode: LongWord; + ResultCode: FixedUInt; begin - ResultCode := SerialDeviceRead(FSerialDevice, @ResultCode, SizeOf(ResultCode), SERIAL_READ_PEEK_BUFFER, LongWord(Result)); + ResultCode := SerialDeviceRead(FSerialDevice, @ResultCode, SizeOf(ResultCode), SERIAL_READ_PEEK_BUFFER, FixedUInt(Result)); SetLastError(ResultCode); if ResultCode <> ERROR_SUCCESS then begin @@ -1624,9 +1624,9 @@ function TBlockSerial.SendingData: integer; {$ELSE} function TBlockSerial.SendingData: integer; var - ResultCode: LongWord; + ResultCode: FixedUInt; begin - ResultCode := SerialDeviceWrite(FSerialDevice, @ResultCode, SizeOf(ResultCode), SERIAL_WRITE_PEEK_BUFFER, LongWord(Result)); + ResultCode := SerialDeviceWrite(FSerialDevice, @ResultCode, SizeOf(ResultCode), SERIAL_WRITE_PEEK_BUFFER, FixedUInt(Result)); SetLastError(ResultCode); if ResultCode <> ERROR_SUCCESS then begin @@ -1792,7 +1792,7 @@ procedure TBlockSerial.SetCommState; {$ELSE} procedure TBlockSerial.SetCommState; var - ResultCode: LongWord; + ResultCode: FixedUInt; Properties: TSerialProperties; begin FillChar(Properties, SizeOf(TSerialProperties), 0); @@ -1867,7 +1867,7 @@ procedure TBlockSerial.GetCommState; {$ELSE} procedure TBlockSerial.GetCommState; var - ResultCode: LongWord; + ResultCode: FixedUInt; Properties: TSerialProperties; begin ResultCode := SerialDeviceGetProperties(FSerialDevice, @Properties); @@ -2131,7 +2131,7 @@ function TBlockSerial.CanRead(Timeout: integer): boolean; {$ELSE} function TBlockSerial.CanRead(Timeout: integer): boolean; var - Count: LongWord; + Count: FixedUInt; begin Result := WaitingData > 0; if not Result then @@ -2194,7 +2194,7 @@ function TBlockSerial.CanWrite(Timeout: integer): boolean; {$ELSE} function TBlockSerial.CanWrite(Timeout: integer): boolean; var - Count: LongWord; + Count: FixedUInt; begin Result := SendingData < FSendBuffer; if not Result then @@ -2214,7 +2214,7 @@ function TBlockSerial.CanWrite(Timeout: integer): boolean; {$ELSE} function TBlockSerial.CanWrite(Timeout: integer): boolean; var - t: LongWord; + t: FixedUInt; begin Result := SendingData = 0; if not Result then @@ -2743,7 +2743,7 @@ TSerialCallbackData = record Devices: String; end; -function SerialDeviceCallback(Serial:PSerialDevice;Data:Pointer):LongWord; +function SerialDeviceCallback(Serial:PSerialDevice;Data:Pointer):FixedUInt; var SerialCallbackData: PSerialCallbackData; begin diff --git a/synautil.pas b/synautil.pas index ee7ceb7..f8f34dc 100644 --- a/synautil.pas +++ b/synautil.pas @@ -176,11 +176,11 @@ function SetUTTime(Newdt: TDateTime): Boolean; {:Return current value of system timer with precizion 1 millisecond. Good for measure time difference.} -function GetTick: LongWord; +function GetTick: FixedUInt; {:Return difference between two timestamps. It working fine only for differences smaller then maxint. (difference must be smaller then 24 days.)} -function TickDelta(TickOld, TickNew: LongWord): LongWord; +function TickDelta(TickOld, TickNew: FixedUInt): FixedUInt; {:Return two characters, which ordinal values represents the value in byte format. (High-endian)} @@ -905,7 +905,7 @@ function SetUTTime(Newdt: TDateTime): Boolean; {==============================================================================} {$IFNDEF MSWINDOWS} -function GetTick: LongWord; +function GetTick: FixedUInt; var Stamp: TTimeStamp; begin @@ -913,7 +913,7 @@ function GetTick: LongWord; Result := Stamp.Time; end; {$ELSE} -function GetTick: LongWord; +function GetTick: FixedUInt; var tick, freq: TLargeInteger; {$IFDEF VER100} @@ -927,7 +927,7 @@ function GetTick: LongWord; x.QuadPart := (tick.QuadPart / freq.QuadPart) * 1000; Result := x.LowPart; {$ELSE} - Result := Trunc((tick / freq) * 1000) and High(LongWord) + Result := Trunc((tick / freq) * 1000) and High(FixedUInt) {$ENDIF} end else @@ -937,7 +937,7 @@ function GetTick: LongWord; {==============================================================================} -function TickDelta(TickOld, TickNew: LongWord): LongWord; +function TickDelta(TickOld, TickNew: FixedUInt): FixedUInt; begin //if DWord is signed type (older Deplhi), // then it not work properly on differencies larger then maxint! @@ -946,8 +946,8 @@ function TickDelta(TickOld, TickNew: LongWord): LongWord; begin if TickNew < TickOld then begin - TickNew := TickNew + LongWord(MaxInt) + 1; - TickOld := TickOld + LongWord(MaxInt) + 1; + TickNew := TickNew + FixedUInt(MaxInt) + 1; + TickOld := TickOld + FixedUInt(MaxInt) + 1; end; Result := TickNew - TickOld; if TickNew < TickOld then diff --git a/synsock.pas b/synsock.pas index d6979a8..f73bbbc 100644 --- a/synsock.pas +++ b/synsock.pas @@ -85,9 +85,9 @@ {$ENDIF} {$ENDIF} {$ENDIF} -{$IFDEF POSIX} - {$I ssposix.inc} //experimental! -{$ENDIF} +//{$IFDEF POSIX} +// {$I ssposix.inc} //experimental! +//{$ENDIF} end.