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,
{$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

View File

@ -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;

View File

@ -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