Browse Source

fixed for Delphi/Linux

DmBel 2 years ago
parent
commit
0c7bbb9ae9
12 changed files with 108 additions and 100 deletions
  1. 15 7
      SynHttpSrv.pas
  2. 30 30
      blcksock.pas
  3. 6 6
      ssfpc.inc
  4. 0 1
      ssl_openssl_lib.pas
  5. 2 2
      sslinux.inc
  6. 9 6
      ssposix.inc
  7. 1 2
      synachar.pas
  8. 7 7
      synacrypt.pas
  9. 4 5
      synaicnv.pas
  10. 23 23
      synaser.pas
  11. 8 8
      synautil.pas
  12. 3 3
      synsock.pas

+ 15 - 7
SynHttpSrv.pas

@@ -1068,20 +1068,26 @@ end;
 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 @@ begin
  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 @@ begin
  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 @@ var
 
  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 @@ var
     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 @@ var
    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;

+ 30 - 30
blcksock.pas

@@ -323,9 +323,9 @@ type
     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 @@ type
     {$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 @@ type
     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 @@ type
      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 @@ type
 
     {: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 @@ type
     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 @@ type
 
     {: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 @@ type
     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 @@ begin
   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 @@ var
   x: integer;
   buf: TMemory;
 {$IFNDEF MSWINDOWS}
-{$IFNDEF ULTIBO}  
+{$IFNDEF ULTIBO}
   timeval: TTimeval;
 {$ENDIF}
 {$ENDIF}
@@ -1850,7 +1850,7 @@ begin
         ExceptCheck;
       end;
   end;
-  Value.free;
+  FreeAndNil(Value);
 end;
 
 procedure TBlockSocket.DelayedOption(const Value: TSynaOption);
@@ -1999,7 +1999,7 @@ begin
   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 @@ begin
   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 @@ end;
 
 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 @@ var
   CorCRLF: Boolean;
   t: string;
   tl: integer;
-  ti: LongWord;
+  ti: FixedUInt;
 begin
   ResetLastError;
   Result := '';
@@ -2611,7 +2611,7 @@ begin
   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 @@ begin
     ResolveNameToIP(Name, l);
     Result := l[0];
   finally
-    l.Free;
+    FreeAndNil(l);
   end;
 end;
 
@@ -3731,7 +3731,7 @@ begin
     SockCheck(synsock.Connect(FSocket, FRemoteSin));
     if FLastError = 0 then
       GetSins;
-  end;    
+  end;
   FBuffer := '';
   DoStatus(HR_Connect, IP + ':' + Port);
 end;
@@ -3751,7 +3751,7 @@ end;
 destructor TUDPBlockSocket.Destroy;
 begin
   if Assigned(FSocksControlSock) then
-    FSocksControlSock.Free;
+    FreeAndNil(FSocksControlSock);
   inherited;
 end;
 
@@ -3983,7 +3983,7 @@ end;
 destructor TTCPBlockSocket.Destroy;
 begin
   inherited Destroy;
-  FSSL.Free;
+  FreeAndNil(FSSL);
 end;
 
 function TTCPBlockSocket.GetErrorDescEx: string;

+ 6 - 6
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;

+ 0 - 1
ssl_openssl_lib.pas

@@ -97,7 +97,6 @@ uses
   BaseUnix,
    {$ENDIF UNIX}
   {$ELSE}
-   Libc,
   {$ENDIF}
   SysUtils;
 {$ELSE}

+ 2 - 2
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;

+ 9 - 6
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;

+ 1 - 2
synachar.pas

@@ -79,7 +79,6 @@ interface
 uses
 {$IFNDEF MSWINDOWS}
   {$IFNDEF FPC}
-  Libc,
   {$ENDIF}
 {$ELSE}
   Windows,
@@ -1503,7 +1502,7 @@ end;
 
 function GetCurCP: TMimeChar;
 begin
-  {$IFNDEF FPC}
+  {$IFNDEF LINUX}
   Result := GetCPFromID(nl_langinfo(_NL_CTYPE_CODESET_NAME));
   {$ELSE}
   //How to get system codepage without LIBC?

+ 7 - 7
synacrypt.pas

@@ -160,8 +160,8 @@ type
   {:@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 @@ const
 
 {==============================================================================}
 type
-  PDWord = ^LongWord;
+  PDWord = ^FixedUInt;
 
 procedure hperm_op(var a, t: integer; n, m: integer);
 begin
@@ -1968,7 +1968,7 @@ end;
 
 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 @@ end;
 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 @@ end;
 
 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 @@ end;
 
 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;

+ 4 - 5
synaicnv.pas

@@ -72,7 +72,6 @@ uses
   synafpc,
 {$IFNDEF MSWINDOWS}
   {$IFNDEF FPC}
-  Libc,
   {$ENDIF}
   SysUtils;
 {$ELSE}
@@ -294,10 +293,10 @@ begin
       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;

+ 23 - 23
synaser.pas

@@ -313,9 +313,9 @@ type
     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 @@ type
     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 @@ begin
   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 @@ var
 {$ENDIF}
 {$IFDEF ULTIBO}
 var
-  ResultCode: LongWord;
+  ResultCode: FixedUInt;
 {$ENDIF}
 begin
   // Is this TBlockSerial Instance already busy?
@@ -1092,7 +1092,7 @@ var
 {$ENDIF}
 {$IFDEF ULTIBO}
 var
-  ResultCode: LongWord;
+  ResultCode: FixedUInt;
 {$ENDIF}  
 begin
   Result := 0;
@@ -1109,7 +1109,7 @@ begin
   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 @@ begin
   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 @@ var
   CorCRLF: Boolean;
   t: ansistring;
   tl: integer;
-  ti: LongWord;
+  ti: FixedUInt;
 begin
   Result := '';
   if PreTestFailing then   {HGJ}
@@ -1571,9 +1571,9 @@ end;
 {$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 @@ end;
 {$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 @@ end;
 {$ELSE}
 procedure TBlockSerial.SetCommState;
 var
-  ResultCode: LongWord;
+  ResultCode: FixedUInt;
   Properties: TSerialProperties;
 begin
   FillChar(Properties, SizeOf(TSerialProperties), 0);
@@ -1867,7 +1867,7 @@ end;
 {$ELSE}
 procedure TBlockSerial.GetCommState;
 var
-  ResultCode: LongWord;
+  ResultCode: FixedUInt;
   Properties: TSerialProperties;
 begin
   ResultCode := SerialDeviceGetProperties(FSerialDevice, @Properties);
@@ -2131,7 +2131,7 @@ end;
 {$ELSE}
 function TBlockSerial.CanRead(Timeout: integer): boolean;
 var
-  Count: LongWord;
+  Count: FixedUInt;
 begin
   Result := WaitingData > 0;
   if not Result then
@@ -2194,7 +2194,7 @@ end;
 {$ELSE}
 function TBlockSerial.CanWrite(Timeout: integer): boolean;
 var
-  Count: LongWord;
+  Count: FixedUInt;
 begin
   Result := SendingData < FSendBuffer;
   if not Result then
@@ -2214,7 +2214,7 @@ end;
 {$ELSE}
 function TBlockSerial.CanWrite(Timeout: integer): boolean;
 var
-  t: LongWord;
+  t: FixedUInt;
 begin
   Result := SendingData = 0;
   if not Result then
@@ -2743,7 +2743,7 @@ type
     Devices: String;
   end;
   
-function SerialDeviceCallback(Serial:PSerialDevice;Data:Pointer):LongWord;
+function SerialDeviceCallback(Serial:PSerialDevice;Data:Pointer):FixedUInt;
 var 
   SerialCallbackData: PSerialCallbackData;
 begin

+ 8 - 8
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 @@ end;
 {==============================================================================}
 
 {$IFNDEF MSWINDOWS}
-function GetTick: LongWord;
+function GetTick: FixedUInt;
 var
   Stamp: TTimeStamp;
 begin
@@ -913,7 +913,7 @@ begin
   Result := Stamp.Time;
 end;
 {$ELSE}
-function GetTick: LongWord;
+function GetTick: FixedUInt;
 var
   tick, freq: TLargeInteger;
 {$IFDEF VER100}
@@ -927,7 +927,7 @@ begin
     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 @@ end;
 
 {==============================================================================}
 
-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 @@ begin
   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

+ 3 - 3
synsock.pas

@@ -85,9 +85,9 @@ unit synsock;
     {$ENDIF}
   {$ENDIF}
 {$ENDIF}
-{$IFDEF POSIX}
-   {$I ssposix.inc} //experimental!
-{$ENDIF}
+//{$IFDEF POSIX}
+//   {$I ssposix.inc} //experimental!
+//{$ENDIF}
 
 end.