Delphi Posix (Android) fixes by Radek Červinka

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@240 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2022-01-07 13:56:47 +00:00
parent 101520e02e
commit dbaf64ce1b
3 changed files with 25 additions and 15 deletions

View File

@ -88,7 +88,11 @@ uses
BaseUnix, BaseUnix,
{$ENDIF UNIX} {$ENDIF UNIX}
{$ELSE} {$ELSE}
Libc, {$IFDEF POSIX}
{$ELSE}
Libc,
{$ENDIF}
{$ENDIF} {$ENDIF}
SysUtils; SysUtils;
{$ELSE} {$ELSE}
@ -225,8 +229,8 @@ const
TLSEXT_NAMETYPE_host_name = 0; TLSEXT_NAMETYPE_host_name = 0;
TLS1_VERSION = $0301; TLS1_VERSION = $0301;
TLS1_1_VERSION = $0302; TLS1_1_VERSION = $0302;
TLS1_2_VERSION = $0303; TLS1_2_VERSION = $0303;
TLS1_3_VERSION = $0304; TLS1_3_VERSION = $0304;
var var
@ -577,12 +581,12 @@ begin
end; end;
function SslMethodTLS:PSSL_METHOD; function SslMethodTLS:PSSL_METHOD;
begin begin
if InitSSLInterface and Assigned(_SslMethodTLS) then if InitSSLInterface and Assigned(_SslMethodTLS) then
Result := _SslMethodTLS Result := _SslMethodTLS
else else
Result := nil; Result := nil;
end; end;
function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer; function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer;
begin begin

View File

@ -102,7 +102,7 @@ const
FIONBIO = $8004667E; //OSX FIONBIO = Posix.StrOpts.FIONBIO; FIONBIO = $8004667E; //OSX FIONBIO = Posix.StrOpts.FIONBIO;
FIOASYNC = $8004667D; //OSX FIOASYNC = Posix.StrOpts.FIOASYNC; // not defined in XE2 FIOASYNC = $8004667D; //OSX FIOASYNC = Posix.StrOpts.FIOASYNC; // not defined in XE2
{$ELSE} {$ELSE}
// LINUX // LINUX & ANDROID
FIONREAD = $541B; FIONREAD = $541B;
FIONBIO = $5421; FIONBIO = $5421;
FIOASYNC = $5452; FIOASYNC = $5452;
@ -238,7 +238,11 @@ const
AF_UNSPEC = Posix.SysSocket.AF_UNSPEC;// 0; { unspecified } AF_UNSPEC = Posix.SysSocket.AF_UNSPEC;// 0; { unspecified }
AF_INET = Posix.SysSocket.AF_INET; // 2; { internetwork: UDP, TCP, etc. } AF_INET = Posix.SysSocket.AF_INET; // 2; { internetwork: UDP, TCP, etc. }
AF_INET6 = Posix.SysSocket.AF_INET6; // !! 30 { Internetwork Version 6 } 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 AF_MAX = Posix.SysSocket.AF_MAX; // !! - variable by OS
{$ENDIF}
{ Protocol families, same as address families for now. } { Protocol families, same as address families for now. }
PF_UNSPEC = AF_UNSPEC; PF_UNSPEC = AF_UNSPEC;
@ -756,15 +760,17 @@ var
if (IP = cAnyHost) or (IP = c6AnyHost) then if (IP = cAnyHost) or (IP = c6AnyHost) then
begin begin
Hints.ai_flags := AI_PASSIVE; Hints.ai_flags := AI_PASSIVE;
Result := GetAddrInfo(nil, PAnsiChar(aPort)), Hints, Addr); Result := GetAddrInfo(nil, PAnsiChar(aPort), Hints, Addr);
end end
else else
if (IP = cLocalhost) or (IP = c6Localhost) then if (IP = cLocalhost) or (IP = c6Localhost) then
begin begin
Result := GetAddrInfo(nil, PAnsiChar(aPort)), Hints, Addr); Result := GetAddrInfo(nil, PAnsiChar(aPort), Hints, Addr);
end end
else else
begin 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); Result := GetAddrInfo(PAnsiChar(aIP), PAnsiChar(aPort), Hints, Addr);
end; end;
end; end;

View File

@ -388,8 +388,8 @@ type
Hash: array[0..4] of Integer; Hash: array[0..4] of Integer;
HashByte: array[0..19] of byte; HashByte: array[0..19] of byte;
end; end;
// longint on 64bit POSIX is 8 byte
TMDTransform = procedure(var Buf: array of LongInt; const Data: array of LongInt); TMDTransform = procedure(var Buf: array of Integer; const Data: array of Integer);
{==============================================================================} {==============================================================================}
@ -1013,7 +1013,7 @@ begin
Move(Data[1], BufAnsiChar[Index], partLen); Move(Data[1], BufAnsiChar[Index], partLen);
{$ENDIF} {$ENDIF}
ArrByteToLong(BufAnsiChar, BufLong); ArrByteToLong(BufAnsiChar, BufLong);
Transform(State, Buflong); Transform(State, Buflong); //Transform params are LongInt
I := partLen; I := partLen;
while I + 63 < InputLen do while I + 63 < InputLen do
begin begin