From dbaf64ce1bb212580f51e7d8b874a71b47a3f912 Mon Sep 17 00:00:00 2001 From: geby Date: Fri, 7 Jan 2022 13:56:47 +0000 Subject: [PATCH] =?UTF-8?q?Delphi=20Posix=20(Android)=20fixes=20by=20Radek?= =?UTF-8?q?=20=C4=8Cervinka?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@240 7c85be65-684b-0410-a082-b2ed4fbef004 --- ssl_openssl11_lib.pas | 22 +++++++++++++--------- ssposix.inc | 12 +++++++++--- synacode.pas | 6 +++--- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ssl_openssl11_lib.pas b/ssl_openssl11_lib.pas index 92e7d90..be9ce81 100644 --- a/ssl_openssl11_lib.pas +++ b/ssl_openssl11_lib.pas @@ -88,7 +88,11 @@ uses BaseUnix, {$ENDIF UNIX} {$ELSE} - Libc, + {$IFDEF POSIX} + {$ELSE} + Libc, + {$ENDIF} + {$ENDIF} SysUtils; {$ELSE} @@ -225,8 +229,8 @@ const TLSEXT_NAMETYPE_host_name = 0; TLS1_VERSION = $0301; - TLS1_1_VERSION = $0302; - TLS1_2_VERSION = $0303; + TLS1_1_VERSION = $0302; + TLS1_2_VERSION = $0303; TLS1_3_VERSION = $0304; var @@ -577,12 +581,12 @@ begin end; function SslMethodTLS:PSSL_METHOD; -begin - if InitSSLInterface and Assigned(_SslMethodTLS) then - Result := _SslMethodTLS - else - Result := nil; -end; +begin + if InitSSLInterface and Assigned(_SslMethodTLS) then + Result := _SslMethodTLS + else + Result := nil; +end; function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer; begin diff --git a/ssposix.inc b/ssposix.inc index 8332c57..94342db 100644 --- a/ssposix.inc +++ b/ssposix.inc @@ -102,7 +102,7 @@ const FIONBIO = $8004667E; //OSX FIONBIO = Posix.StrOpts.FIONBIO; FIOASYNC = $8004667D; //OSX FIOASYNC = Posix.StrOpts.FIOASYNC; // not defined in XE2 {$ELSE} - // LINUX + // LINUX & ANDROID FIONREAD = $541B; FIONBIO = $5421; FIOASYNC = $5452; @@ -238,7 +238,11 @@ const AF_UNSPEC = Posix.SysSocket.AF_UNSPEC;// 0; { unspecified } AF_INET = Posix.SysSocket.AF_INET; // 2; { internetwork: UDP, TCP, etc. } AF_INET6 = Posix.SysSocket.AF_INET6; // !! 30 { Internetwork Version 6 } +{$IFDEF ANDROID} + AF_MAX = 24; +{$ELSE} AF_MAX = Posix.SysSocket.AF_MAX; // !! - variable by OS +{$ENDIF} { Protocol families, same as address families for now. } PF_UNSPEC = AF_UNSPEC; @@ -756,15 +760,17 @@ var if (IP = cAnyHost) or (IP = c6AnyHost) then begin Hints.ai_flags := AI_PASSIVE; - Result := GetAddrInfo(nil, PAnsiChar(aPort)), Hints, Addr); + Result := GetAddrInfo(nil, PAnsiChar(aPort), Hints, Addr); end else if (IP = cLocalhost) or (IP = c6Localhost) then begin - Result := GetAddrInfo(nil, PAnsiChar(aPort)), Hints, Addr); + Result := GetAddrInfo(nil, PAnsiChar(aPort), Hints, Addr); end else begin + //for Android see code in System.Net.Socket TIPAddress.LookupName + // Result := getaddrinfo(M.AsUTF8(TURI.UnicodeToIDNA(aIP)).ToPointer, nil, Hints, Addr); Result := GetAddrInfo(PAnsiChar(aIP), PAnsiChar(aPort), Hints, Addr); end; end; diff --git a/synacode.pas b/synacode.pas index 52c9dfe..16da2a8 100644 --- a/synacode.pas +++ b/synacode.pas @@ -388,8 +388,8 @@ type Hash: array[0..4] of Integer; HashByte: array[0..19] of byte; end; - - TMDTransform = procedure(var Buf: array of LongInt; const Data: array of LongInt); + // longint on 64bit POSIX is 8 byte + TMDTransform = procedure(var Buf: array of Integer; const Data: array of Integer); {==============================================================================} @@ -1013,7 +1013,7 @@ begin Move(Data[1], BufAnsiChar[Index], partLen); {$ENDIF} ArrByteToLong(BufAnsiChar, BufLong); - Transform(State, Buflong); + Transform(State, Buflong); //Transform params are LongInt I := partLen; while I + 63 < InputLen do begin