Changes for Delphi 2009 compatibility.
git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@95 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
parent
e0b3eeb0c2
commit
c7c54cd9df
85
blcksock.pas
85
blcksock.pas
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 009.004.002 |
|
| Project : Ararat Synapse | 009.005.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Library base |
|
| Content: Library base |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -174,10 +174,10 @@ type
|
|||||||
{:Procedural type for OnStatus event. Sender is calling TBlockSocket object,
|
{:Procedural type for OnStatus event. Sender is calling TBlockSocket object,
|
||||||
Reason is one of set Status events and value is optional data.}
|
Reason is one of set Status events and value is optional data.}
|
||||||
THookSocketStatus = procedure(Sender: TObject; Reason: THookSocketReason;
|
THookSocketStatus = procedure(Sender: TObject; Reason: THookSocketReason;
|
||||||
const Value: string) of object;
|
const Value: String) of object;
|
||||||
|
|
||||||
{:This procedural type is used for DataFilter hooks.}
|
{:This procedural type is used for DataFilter hooks.}
|
||||||
THookDataFilter = procedure(Sender: TObject; var Value: string) of object;
|
THookDataFilter = procedure(Sender: TObject; var Value: AnsiString) of object;
|
||||||
|
|
||||||
{:This procedural type is used for hook OnCreateSocket. By this hook you can
|
{:This procedural type is used for hook OnCreateSocket. By this hook you can
|
||||||
insert your code after initialisation of socket. (you can set special socket
|
insert your code after initialisation of socket. (you can set special socket
|
||||||
@ -267,7 +267,7 @@ type
|
|||||||
FLocalSin: TVarSin;
|
FLocalSin: TVarSin;
|
||||||
FRemoteSin: TVarSin;
|
FRemoteSin: TVarSin;
|
||||||
FTag: integer;
|
FTag: integer;
|
||||||
FBuffer: string;
|
FBuffer: AnsiString;
|
||||||
FRaiseExcept: Boolean;
|
FRaiseExcept: Boolean;
|
||||||
FNonBlockMode: Boolean;
|
FNonBlockMode: Boolean;
|
||||||
FMaxLineLength: Integer;
|
FMaxLineLength: Integer;
|
||||||
@ -440,7 +440,7 @@ type
|
|||||||
|
|
||||||
{:Similar to @link(RecvBufferEx), but readed data is stored in binary
|
{:Similar to @link(RecvBufferEx), but readed data is stored in binary
|
||||||
string, not in memory buffer.}
|
string, not in memory buffer.}
|
||||||
function RecvBufferStr(Length: Integer; Timeout: Integer): AnsiString; virtual;
|
function RecvBufferStr(Len: Integer; Timeout: Integer): AnsiString; virtual;
|
||||||
|
|
||||||
{:Note: This is high-level receive function. It using internal
|
{:Note: This is high-level receive function. It using internal
|
||||||
@link(LineBuffer) and you can combine this function freely with other
|
@link(LineBuffer) and you can combine this function freely with other
|
||||||
@ -698,7 +698,7 @@ type
|
|||||||
{:Buffer used by all high-level receiving functions. This buffer is used for
|
{:Buffer used by all high-level receiving functions. This buffer is used for
|
||||||
optimized reading of data from socket. In normal cases you not need access
|
optimized reading of data from socket. In normal cases you not need access
|
||||||
to this buffer directly!}
|
to this buffer directly!}
|
||||||
property LineBuffer: string read FBuffer write FBuffer;
|
property LineBuffer: AnsiString read FBuffer write FBuffer;
|
||||||
|
|
||||||
{:Size of Winsock receive buffer. If it is not supported by socket provider,
|
{:Size of Winsock receive buffer. If it is not supported by socket provider,
|
||||||
it return as size one kilobyte.}
|
it return as size one kilobyte.}
|
||||||
@ -844,8 +844,8 @@ type
|
|||||||
FSocksRemotePort: string;
|
FSocksRemotePort: string;
|
||||||
FBypassFlag: Boolean;
|
FBypassFlag: Boolean;
|
||||||
FSocksType: TSocksType;
|
FSocksType: TSocksType;
|
||||||
function SocksCode(IP, Port: string): string;
|
function SocksCode(IP, Port: string): Ansistring;
|
||||||
function SocksDecode(Value: string): integer;
|
function SocksDecode(Value: Ansistring): integer;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
|
|
||||||
@ -1154,13 +1154,13 @@ type
|
|||||||
FCiphers: string;
|
FCiphers: string;
|
||||||
FCertificateFile: string;
|
FCertificateFile: string;
|
||||||
FPrivateKeyFile: string;
|
FPrivateKeyFile: string;
|
||||||
FCertificate: string;
|
FCertificate: Ansistring;
|
||||||
FPrivateKey: string;
|
FPrivateKey: Ansistring;
|
||||||
FPFX: string;
|
FPFX: Ansistring;
|
||||||
FPFXfile: string;
|
FPFXfile: string;
|
||||||
FCertCA: string;
|
FCertCA: Ansistring;
|
||||||
FCertCAFile: string;
|
FCertCAFile: string;
|
||||||
FTrustCertificate: string;
|
FTrustCertificate: Ansistring;
|
||||||
FTrustCertificateFile: string;
|
FTrustCertificateFile: string;
|
||||||
FVerifyCert: Boolean;
|
FVerifyCert: Boolean;
|
||||||
FUsername: string;
|
FUsername: string;
|
||||||
@ -1295,15 +1295,15 @@ type
|
|||||||
|
|
||||||
{:Used for loading certificate from binary string. See to plugin documentation
|
{:Used for loading certificate from binary string. See to plugin documentation
|
||||||
if this method is supported and how!}
|
if this method is supported and how!}
|
||||||
property Certificate: string read FCertificate write FCertificate;
|
property Certificate: Ansistring read FCertificate write FCertificate;
|
||||||
|
|
||||||
{:Used for loading private key from binary string. See to plugin documentation
|
{:Used for loading private key from binary string. See to plugin documentation
|
||||||
if this method is supported and how!}
|
if this method is supported and how!}
|
||||||
property PrivateKey: string read FPrivateKey write FPrivateKey;
|
property PrivateKey: Ansistring read FPrivateKey write FPrivateKey;
|
||||||
|
|
||||||
{:Used for loading PFX from binary string. See to plugin documentation
|
{:Used for loading PFX from binary string. See to plugin documentation
|
||||||
if this method is supported and how!}
|
if this method is supported and how!}
|
||||||
property PFX: string read FPFX write FPFX;
|
property PFX: Ansistring read FPFX write FPFX;
|
||||||
|
|
||||||
{:Used for loading PFX from disk file. See to plugin documentation
|
{:Used for loading PFX from disk file. See to plugin documentation
|
||||||
if this method is supported and how!}
|
if this method is supported and how!}
|
||||||
@ -1315,11 +1315,11 @@ type
|
|||||||
|
|
||||||
{:Used for loading trusted certificates from binary string. See to plugin documentation
|
{:Used for loading trusted certificates from binary string. See to plugin documentation
|
||||||
if this method is supported and how!}
|
if this method is supported and how!}
|
||||||
property TrustCertificate: string read FTrustCertificate write FTrustCertificate;
|
property TrustCertificate: Ansistring read FTrustCertificate write FTrustCertificate;
|
||||||
|
|
||||||
{:Used for loading CA certificates from binary string. See to plugin documentation
|
{:Used for loading CA certificates from binary string. See to plugin documentation
|
||||||
if this method is supported and how!}
|
if this method is supported and how!}
|
||||||
property CertCA: string read FCertCA write FCertCA;
|
property CertCA: Ansistring read FCertCA write FCertCA;
|
||||||
|
|
||||||
{:Used for loading CA certificates from disk file. See to plugin documentation
|
{:Used for loading CA certificates from disk file. See to plugin documentation
|
||||||
if this method is supported and how!}
|
if this method is supported and how!}
|
||||||
@ -1677,7 +1677,7 @@ begin
|
|||||||
f := FFamily;
|
f := FFamily;
|
||||||
FLastError := synsock.SetVarSin(sin, ip, port, FamilyToAF(f),
|
FLastError := synsock.SetVarSin(sin, ip, port, FamilyToAF(f),
|
||||||
GetSocketprotocol, GetSocketType, FPreferIP4);
|
GetSocketprotocol, GetSocketType, FPreferIP4);
|
||||||
DoStatus(HR_ResolvingEnd, IP + ':' + Port);
|
DoStatus(HR_ResolvingEnd, GetSinIP(sin) + ':' + IntTostr(GetSinPort(sin)));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBlockSocket.GetSinIP(Sin: TVarSin): string;
|
function TBlockSocket.GetSinIP(Sin: TVarSin): string;
|
||||||
@ -1956,11 +1956,10 @@ procedure TBlockSocket.SendString(Data: AnsiString);
|
|||||||
var
|
var
|
||||||
buf: TMemory;
|
buf: TMemory;
|
||||||
begin
|
begin
|
||||||
// SendBuffer(PChar(Data), Length(Data));
|
|
||||||
{$IFDEF CIL}
|
{$IFDEF CIL}
|
||||||
buf := BytesOf(Data);
|
buf := BytesOf(Data);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
buf := pchar(data);
|
buf := Pointer(data);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
SendBuffer(buf, Length(Data));
|
SendBuffer(buf, Length(Data));
|
||||||
end;
|
end;
|
||||||
@ -2019,7 +2018,7 @@ begin
|
|||||||
end
|
end
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Setlength(s, FSendMaxChunk);
|
Setlength(s, FSendMaxChunk);
|
||||||
yr := Stream.read(Pchar(s)^, FSendMaxChunk);
|
yr := Stream.read(Pointer(s)^, FSendMaxChunk);
|
||||||
if yr > 0 then
|
if yr > 0 then
|
||||||
begin
|
begin
|
||||||
SetLength(s, yr);
|
SetLength(s, yr);
|
||||||
@ -2124,7 +2123,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBlockSocket.RecvBufferStr(Length: Integer; Timeout: Integer): AnsiString;
|
function TBlockSocket.RecvBufferStr(Len: Integer; Timeout: Integer): AnsiString;
|
||||||
var
|
var
|
||||||
x: integer;
|
x: integer;
|
||||||
{$IFDEF CIL}
|
{$IFDEF CIL}
|
||||||
@ -2132,11 +2131,11 @@ var
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
if Length > 0 then
|
if Len > 0 then
|
||||||
begin
|
begin
|
||||||
{$IFDEF CIL}
|
{$IFDEF CIL}
|
||||||
Setlength(Buf, Length);
|
Setlength(Buf, Len);
|
||||||
x := RecvBufferEx(buf, Length , Timeout);
|
x := RecvBufferEx(buf, Len , Timeout);
|
||||||
if FLastError = 0 then
|
if FLastError = 0 then
|
||||||
begin
|
begin
|
||||||
SetLength(Buf, x);
|
SetLength(Buf, x);
|
||||||
@ -2145,8 +2144,8 @@ begin
|
|||||||
else
|
else
|
||||||
Result := '';
|
Result := '';
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Setlength(Result, Length);
|
Setlength(Result, Len);
|
||||||
x := RecvBufferEx(PChar(Result), Length , Timeout);
|
x := RecvBufferEx(Pointer(Result), Len , Timeout);
|
||||||
if FLastError = 0 then
|
if FLastError = 0 then
|
||||||
SetLength(Result, x)
|
SetLength(Result, x)
|
||||||
else
|
else
|
||||||
@ -2378,7 +2377,7 @@ begin
|
|||||||
s := RecvBufferStr(FSendMaxChunk, Timeout);
|
s := RecvBufferStr(FSendMaxChunk, Timeout);
|
||||||
if FLastError <> 0 then
|
if FLastError <> 0 then
|
||||||
Exit;
|
Exit;
|
||||||
Stream.Write(Pchar(s)^, FSendMaxChunk);
|
WriteStrToStream(Stream, s);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
n := Size mod FSendMaxChunk;
|
n := Size mod FSendMaxChunk;
|
||||||
@ -2394,7 +2393,7 @@ begin
|
|||||||
s := RecvBufferStr(n, Timeout);
|
s := RecvBufferStr(n, Timeout);
|
||||||
if FLastError <> 0 then
|
if FLastError <> 0 then
|
||||||
Exit;
|
Exit;
|
||||||
Stream.Write(Pchar(s)^, n);
|
WriteStrToStream(Stream, s);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2929,7 +2928,7 @@ end;
|
|||||||
|
|
||||||
procedure TBlockSocket.DoReadFilter(Buffer: TMemory; var Len: Integer);
|
procedure TBlockSocket.DoReadFilter(Buffer: TMemory; var Len: Integer);
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
begin
|
begin
|
||||||
if assigned(OnReadFilter) then
|
if assigned(OnReadFilter) then
|
||||||
if Len > 0 then
|
if Len > 0 then
|
||||||
@ -3252,7 +3251,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSocksBlockSocket.SocksCode(IP, Port: string): string;
|
function TSocksBlockSocket.SocksCode(IP, Port: string): Ansistring;
|
||||||
var
|
var
|
||||||
ip6: TIp6Bytes;
|
ip6: TIp6Bytes;
|
||||||
n: integer;
|
n: integer;
|
||||||
@ -3294,7 +3293,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSocksBlockSocket.SocksDecode(Value: string): integer;
|
function TSocksBlockSocket.SocksDecode(Value: Ansistring): integer;
|
||||||
var
|
var
|
||||||
Atyp: Byte;
|
Atyp: Byte;
|
||||||
y, n: integer;
|
y, n: integer;
|
||||||
@ -3435,7 +3434,7 @@ function TUDPBlockSocket.SendBufferTo(Buffer: TMemory; Length: Integer): Integer
|
|||||||
var
|
var
|
||||||
SIp: string;
|
SIp: string;
|
||||||
SPort: integer;
|
SPort: integer;
|
||||||
Buf: string;
|
Buf: Ansistring;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
FUsingSocks := False;
|
FUsingSocks := False;
|
||||||
@ -3450,9 +3449,9 @@ begin
|
|||||||
SPort := GetRemoteSinPort;
|
SPort := GetRemoteSinPort;
|
||||||
SetRemoteSin(FSocksRemoteIP, FSocksRemotePort);
|
SetRemoteSin(FSocksRemoteIP, FSocksRemotePort);
|
||||||
SetLength(Buf,Length);
|
SetLength(Buf,Length);
|
||||||
Move(Buffer^, PChar(Buf)^, Length);
|
Move(Buffer^, Pointer(Buf)^, Length);
|
||||||
Buf := #0 + #0 + #0 + SocksCode(Sip, IntToStr(SPort)) + Buf;
|
Buf := #0 + #0 + #0 + SocksCode(Sip, IntToStr(SPort)) + Buf;
|
||||||
Result := inherited SendBufferTo(PChar(Buf), System.Length(buf));
|
Result := inherited SendBufferTo(Pointer(Buf), System.Length(buf));
|
||||||
SetRemoteSin(Sip, IntToStr(SPort));
|
SetRemoteSin(Sip, IntToStr(SPort));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end
|
end
|
||||||
@ -3463,7 +3462,7 @@ end;
|
|||||||
|
|
||||||
function TUDPBlockSocket.RecvBufferFrom(Buffer: TMemory; Length: Integer): Integer;
|
function TUDPBlockSocket.RecvBufferFrom(Buffer: TMemory; Length: Integer): Integer;
|
||||||
var
|
var
|
||||||
Buf: string;
|
Buf: Ansistring;
|
||||||
x: integer;
|
x: integer;
|
||||||
begin
|
begin
|
||||||
Result := inherited RecvBufferFrom(Buffer, Length);
|
Result := inherited RecvBufferFrom(Buffer, Length);
|
||||||
@ -3471,11 +3470,11 @@ begin
|
|||||||
begin
|
begin
|
||||||
{$IFNDEF CIL}
|
{$IFNDEF CIL}
|
||||||
SetLength(Buf, Result);
|
SetLength(Buf, Result);
|
||||||
Move(Buffer^, PChar(Buf)^, Result);
|
Move(Buffer^, Pointer(Buf)^, Result);
|
||||||
x := SocksDecode(Buf);
|
x := SocksDecode(Buf);
|
||||||
Result := Result - x + 1;
|
Result := Result - x + 1;
|
||||||
Buf := Copy(Buf, x, Result);
|
Buf := Copy(Buf, x, Result);
|
||||||
Move(PChar(Buf)^, Buffer^, Result);
|
Move(Pointer(Buf)^, Buffer^, Result);
|
||||||
SetRemoteSin(FSocksResponseIP, FSocksResponsePort);
|
SetRemoteSin(FSocksResponseIP, FSocksResponsePort);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
@ -3496,14 +3495,14 @@ begin
|
|||||||
Multicast6.ipv6mr_multiaddr.u6_addr8[n] := Ip6[n];
|
Multicast6.ipv6mr_multiaddr.u6_addr8[n] := Ip6[n];
|
||||||
Multicast6.ipv6mr_interface := 0;
|
Multicast6.ipv6mr_interface := 0;
|
||||||
SockCheck(synsock.SetSockOpt(FSocket, IPPROTO_IPV6, IPV6_JOIN_GROUP,
|
SockCheck(synsock.SetSockOpt(FSocket, IPPROTO_IPV6, IPV6_JOIN_GROUP,
|
||||||
pchar(@Multicast6), SizeOf(Multicast6)));
|
PAnsiChar(@Multicast6), SizeOf(Multicast6)));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Multicast.imr_multiaddr.S_addr := swapbytes(strtoip(MCastIP));
|
Multicast.imr_multiaddr.S_addr := swapbytes(strtoip(MCastIP));
|
||||||
Multicast.imr_interface.S_addr := INADDR_ANY;
|
Multicast.imr_interface.S_addr := INADDR_ANY;
|
||||||
SockCheck(synsock.SetSockOpt(FSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
SockCheck(synsock.SetSockOpt(FSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
||||||
pchar(@Multicast), SizeOf(Multicast)));
|
PAnsiChar(@Multicast), SizeOf(Multicast)));
|
||||||
end;
|
end;
|
||||||
ExceptCheck;
|
ExceptCheck;
|
||||||
end;
|
end;
|
||||||
@ -3522,14 +3521,14 @@ begin
|
|||||||
Multicast6.ipv6mr_multiaddr.u6_addr8[n] := Ip6[n];
|
Multicast6.ipv6mr_multiaddr.u6_addr8[n] := Ip6[n];
|
||||||
Multicast6.ipv6mr_interface := 0;
|
Multicast6.ipv6mr_interface := 0;
|
||||||
SockCheck(synsock.SetSockOpt(FSocket, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
|
SockCheck(synsock.SetSockOpt(FSocket, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
|
||||||
pchar(@Multicast6), SizeOf(Multicast6)));
|
PAnsiChar(@Multicast6), SizeOf(Multicast6)));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Multicast.imr_multiaddr.S_addr := swapbytes(strtoip(MCastIP));
|
Multicast.imr_multiaddr.S_addr := swapbytes(strtoip(MCastIP));
|
||||||
Multicast.imr_interface.S_addr := INADDR_ANY;
|
Multicast.imr_interface.S_addr := INADDR_ANY;
|
||||||
SockCheck(synsock.SetSockOpt(FSocket, IPPROTO_IP, IP_DROP_MEMBERSHIP,
|
SockCheck(synsock.SetSockOpt(FSocket, IPPROTO_IP, IP_DROP_MEMBERSHIP,
|
||||||
pchar(@Multicast), SizeOf(Multicast)));
|
PAnsiChar(@Multicast), SizeOf(Multicast)));
|
||||||
end;
|
end;
|
||||||
ExceptCheck;
|
ExceptCheck;
|
||||||
end;
|
end;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 003.012.001 |
|
| Project : Ararat Synapse | 003.012.002 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: HTTP client |
|
| Content: HTTP client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -33,7 +33,7 @@
|
|||||||
| DAMAGE. |
|
| DAMAGE. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
||||||
| Portions created by Lukas Gebauer are Copyright (c) 1999-2007. |
|
| Portions created by Lukas Gebauer are Copyright (c) 1999-2008. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -679,7 +679,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
FDownloadSize := Size;
|
FDownloadSize := Size;
|
||||||
FSock.RecvStreamSize(FDocument, FTimeout, Size);
|
FSock.RecvStreamSize(FDocument, FTimeout, Size);
|
||||||
FDocument.Seek(0, soFromEnd);
|
FDocument.Position := FDocument.Size;
|
||||||
Result := FSock.LastError = 0;
|
Result := FSock.LastError = 0;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.000.004 |
|
| Project : Ararat Synapse | 001.001.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: SSL support by OpenSSL |
|
| Content: SSL support by OpenSSL |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2005, Lukas Gebauer |
|
| Copyright (c)1999-2008, Lukas Gebauer |
|
||||||
| All rights reserved. |
|
| All rights reserved. |
|
||||||
| |
|
| |
|
||||||
| Redistribution and use in source and binary forms, with or without |
|
| Redistribution and use in source and binary forms, with or without |
|
||||||
@ -33,7 +33,7 @@
|
|||||||
| DAMAGE. |
|
| DAMAGE. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
||||||
| Portions created by Lukas Gebauer are Copyright (c)2005. |
|
| Portions created by Lukas Gebauer are Copyright (c)2005-2008. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -105,7 +105,7 @@ type
|
|||||||
function Init(server:Boolean): Boolean;
|
function Init(server:Boolean): Boolean;
|
||||||
function DeInit: Boolean;
|
function DeInit: Boolean;
|
||||||
function Prepare(server:Boolean): Boolean;
|
function Prepare(server:Boolean): Boolean;
|
||||||
function LoadPFX(pfxdata: string): Boolean;
|
function LoadPFX(pfxdata: ansistring): Boolean;
|
||||||
function CreateSelfSignedCert(Host: string): Boolean; override;
|
function CreateSelfSignedCert(Host: string): Boolean; override;
|
||||||
public
|
public
|
||||||
{:See @inherited}
|
{:See @inherited}
|
||||||
@ -156,9 +156,9 @@ implementation
|
|||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
|
|
||||||
{$IFNDEF CIL}
|
{$IFNDEF CIL}
|
||||||
function PasswordCallback(buf:PChar; size:Integer; rwflag:Integer; userdata: Pointer):Integer; cdecl;
|
function PasswordCallback(buf:PAnsiChar; size:Integer; rwflag:Integer; userdata: Pointer):Integer; cdecl;
|
||||||
var
|
var
|
||||||
Password: String;
|
Password: AnsiString;
|
||||||
begin
|
begin
|
||||||
Password := '';
|
Password := '';
|
||||||
if TCustomSSL(userdata) is TCustomSSL then
|
if TCustomSSL(userdata) is TCustomSSL then
|
||||||
@ -166,7 +166,7 @@ begin
|
|||||||
if Length(Password) > (Size - 1) then
|
if Length(Password) > (Size - 1) then
|
||||||
SetLength(Password, Size - 1);
|
SetLength(Password, Size - 1);
|
||||||
Result := Length(Password);
|
Result := Length(Password);
|
||||||
StrLCopy(buf, PChar(Password + #0), Result + 1);
|
StrLCopy(buf, PAnsiChar(Password + #0), Result + 1);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
@ -197,10 +197,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TSSLOpenSSL.SSLCheck: Boolean;
|
function TSSLOpenSSL.SSLCheck: Boolean;
|
||||||
{$IFDEF CIL}
|
|
||||||
var
|
var
|
||||||
|
{$IFDEF CIL}
|
||||||
sb: StringBuilder;
|
sb: StringBuilder;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
s : AnsiString;
|
||||||
begin
|
begin
|
||||||
Result := true;
|
Result := true;
|
||||||
FLastErrorDesc := '';
|
FLastErrorDesc := '';
|
||||||
@ -214,8 +215,9 @@ begin
|
|||||||
ErrErrorString(FLastError, sb, 256);
|
ErrErrorString(FLastError, sb, 256);
|
||||||
FLastErrorDesc := Trim(sb.ToString);
|
FLastErrorDesc := Trim(sb.ToString);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
FLastErrorDesc := StringOfChar(#0, 256);
|
s := StringOfChar(#0, 256);
|
||||||
ErrErrorString(FLastError, FLastErrorDesc, Length(FLastErrorDesc));
|
ErrErrorString(FLastError, s, Length(s));
|
||||||
|
FLastErrorDesc := s;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -307,7 +309,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSSLOpenSSL.LoadPFX(pfxdata: string): Boolean;
|
function TSSLOpenSSL.LoadPFX(pfxdata: Ansistring): Boolean;
|
||||||
var
|
var
|
||||||
cert, pkey, ca: SslPtr;
|
cert, pkey, ca: SslPtr;
|
||||||
b: PBIO;
|
b: PBIO;
|
||||||
@ -392,6 +394,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TSSLOpenSSL.Init(server:Boolean): Boolean;
|
function TSSLOpenSSL.Init(server:Boolean): Boolean;
|
||||||
|
var
|
||||||
|
s: AnsiString;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
FLastErrorDesc := '';
|
FLastErrorDesc := '';
|
||||||
@ -416,7 +420,8 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
SslCtxSetCipherList(Fctx, FCiphers);
|
s := FCiphers;
|
||||||
|
SslCtxSetCipherList(Fctx, s);
|
||||||
if FVerifyCert then
|
if FVerifyCert then
|
||||||
SslCtxSetVerify(FCtx, SSL_VERIFY_PEER, nil)
|
SslCtxSetVerify(FCtx, SSL_VERIFY_PEER, nil)
|
||||||
else
|
else
|
||||||
@ -632,7 +637,7 @@ end;
|
|||||||
function TSSLOpenSSL.GetPeerSubject: string;
|
function TSSLOpenSSL.GetPeerSubject: string;
|
||||||
var
|
var
|
||||||
cert: PX509;
|
cert: PX509;
|
||||||
s: string;
|
s: ansistring;
|
||||||
{$IFDEF CIL}
|
{$IFDEF CIL}
|
||||||
sb: StringBuilder;
|
sb: StringBuilder;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -660,7 +665,7 @@ end;
|
|||||||
|
|
||||||
function TSSLOpenSSL.GetPeerName: string;
|
function TSSLOpenSSL.GetPeerName: string;
|
||||||
var
|
var
|
||||||
s: string;
|
s: ansistring;
|
||||||
begin
|
begin
|
||||||
s := GetPeerSubject;
|
s := GetPeerSubject;
|
||||||
s := SeparateRight(s, '/CN=');
|
s := SeparateRight(s, '/CN=');
|
||||||
@ -670,7 +675,7 @@ end;
|
|||||||
function TSSLOpenSSL.GetPeerIssuer: string;
|
function TSSLOpenSSL.GetPeerIssuer: string;
|
||||||
var
|
var
|
||||||
cert: PX509;
|
cert: PX509;
|
||||||
s: string;
|
s: ansistring;
|
||||||
{$IFDEF CIL}
|
{$IFDEF CIL}
|
||||||
sb: StringBuilder;
|
sb: StringBuilder;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 003.004.001 |
|
| Project : Ararat Synapse | 003.005.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: SSL support by OpenSSL |
|
| Content: SSL support by OpenSSL |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2005, Lukas Gebauer |
|
| Copyright (c)1999-2008, Lukas Gebauer |
|
||||||
| All rights reserved. |
|
| All rights reserved. |
|
||||||
| |
|
| |
|
||||||
| Redistribution and use in source and binary forms, with or without |
|
| Redistribution and use in source and binary forms, with or without |
|
||||||
@ -33,7 +33,7 @@
|
|||||||
| DAMAGE. |
|
| DAMAGE. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
||||||
| Portions created by Lukas Gebauer are Copyright (c)2002-2005. |
|
| Portions created by Lukas Gebauer are Copyright (c)2002-2008. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -652,7 +652,7 @@ var
|
|||||||
function SslLibraryInit:Integer;
|
function SslLibraryInit:Integer;
|
||||||
procedure SslLoadErrorStrings;
|
procedure SslLoadErrorStrings;
|
||||||
// function SslCtxSetCipherList(arg0: PSSL_CTX; str: PChar):Integer;
|
// function SslCtxSetCipherList(arg0: PSSL_CTX; str: PChar):Integer;
|
||||||
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: String):Integer;
|
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: AnsiString):Integer;
|
||||||
function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX;
|
function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX;
|
||||||
procedure SslCtxFree(arg0: PSSL_CTX);
|
procedure SslCtxFree(arg0: PSSL_CTX);
|
||||||
function SslSetFd(s: PSSL; fd: Integer):Integer;
|
function SslSetFd(s: PSSL; fd: Integer):Integer;
|
||||||
@ -661,19 +661,19 @@ var
|
|||||||
function SslMethodTLSV1:PSSL_METHOD;
|
function SslMethodTLSV1:PSSL_METHOD;
|
||||||
function SslMethodV23:PSSL_METHOD;
|
function SslMethodV23:PSSL_METHOD;
|
||||||
function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer;
|
function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer;
|
||||||
function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: String; len: integer):Integer;
|
function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: AnsiString; len: integer):Integer;
|
||||||
// function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer;
|
// function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer;
|
||||||
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;
|
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: AnsiString; _type: Integer):Integer;
|
||||||
function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):Integer;
|
function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):Integer;
|
||||||
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: integer; d: String):Integer;
|
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: integer; d: AnsiString):Integer;
|
||||||
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;
|
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: AnsiString; _type: Integer):Integer;
|
||||||
// function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PChar):Integer;
|
// function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PChar):Integer;
|
||||||
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: String):Integer;
|
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: AnsiString):Integer;
|
||||||
function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):Integer;
|
function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):Integer;
|
||||||
procedure SslCtxSetDefaultPasswdCb(ctx: PSSL_CTX; cb: PPasswdCb);
|
procedure SslCtxSetDefaultPasswdCb(ctx: PSSL_CTX; cb: PPasswdCb);
|
||||||
procedure SslCtxSetDefaultPasswdCbUserdata(ctx: PSSL_CTX; u: SslPtr);
|
procedure SslCtxSetDefaultPasswdCbUserdata(ctx: PSSL_CTX; u: SslPtr);
|
||||||
// function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):Integer;
|
// function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):Integer;
|
||||||
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: String; const CApath: String):Integer;
|
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: AnsiString; const CApath: AnsiString):Integer;
|
||||||
function SslNew(ctx: PSSL_CTX):PSSL;
|
function SslNew(ctx: PSSL_CTX):PSSL;
|
||||||
procedure SslFree(ssl: PSSL);
|
procedure SslFree(ssl: PSSL);
|
||||||
function SslAccept(ssl: PSSL):Integer;
|
function SslAccept(ssl: PSSL):Integer;
|
||||||
@ -683,29 +683,29 @@ var
|
|||||||
function SslPeek(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
|
function SslPeek(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
|
||||||
function SslWrite(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
|
function SslWrite(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
|
||||||
function SslPending(ssl: PSSL):Integer;
|
function SslPending(ssl: PSSL):Integer;
|
||||||
function SslGetVersion(ssl: PSSL):String;
|
function SslGetVersion(ssl: PSSL):AnsiString;
|
||||||
function SslGetPeerCertificate(ssl: PSSL):PX509;
|
function SslGetPeerCertificate(ssl: PSSL):PX509;
|
||||||
procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: Integer; arg2: PFunction);
|
procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: Integer; arg2: PFunction);
|
||||||
function SSLGetCurrentCipher(s: PSSL):SslPtr;
|
function SSLGetCurrentCipher(s: PSSL):SslPtr;
|
||||||
function SSLCipherGetName(c: SslPtr): String;
|
function SSLCipherGetName(c: SslPtr): AnsiString;
|
||||||
function SSLCipherGetBits(c: SslPtr; var alg_bits: Integer):Integer;
|
function SSLCipherGetBits(c: SslPtr; var alg_bits: Integer):Integer;
|
||||||
function SSLGetVerifyResult(ssl: PSSL):Integer;
|
function SSLGetVerifyResult(ssl: PSSL):Integer;
|
||||||
|
|
||||||
// libeay.dll
|
// libeay.dll
|
||||||
function X509New: PX509;
|
function X509New: PX509;
|
||||||
procedure X509Free(x: PX509);
|
procedure X509Free(x: PX509);
|
||||||
function X509NameOneline(a: PX509_NAME; var buf: String; size: Integer):String;
|
function X509NameOneline(a: PX509_NAME; var buf: AnsiString; size: Integer):AnsiString;
|
||||||
function X509GetSubjectName(a: PX509):PX509_NAME;
|
function X509GetSubjectName(a: PX509):PX509_NAME;
|
||||||
function X509GetIssuerName(a: PX509):PX509_NAME;
|
function X509GetIssuerName(a: PX509):PX509_NAME;
|
||||||
function X509NameHash(x: PX509_NAME):Cardinal;
|
function X509NameHash(x: PX509_NAME):Cardinal;
|
||||||
// function SslX509Digest(data: PX509; _type: PEVP_MD; md: PChar; len: PInteger):Integer;
|
// function SslX509Digest(data: PX509; _type: PEVP_MD; md: PChar; len: PInteger):Integer;
|
||||||
function X509Digest(data: PX509; _type: PEVP_MD; md: String; var len: Integer):Integer;
|
function X509Digest(data: PX509; _type: PEVP_MD; md: AnsiString; var len: Integer):Integer;
|
||||||
function X509print(b: PBIO; a: PX509): integer;
|
function X509print(b: PBIO; a: PX509): integer;
|
||||||
function X509SetVersion(x: PX509; version: integer): integer;
|
function X509SetVersion(x: PX509; version: integer): integer;
|
||||||
function X509SetPubkey(x: PX509; pkey: EVP_PKEY): integer;
|
function X509SetPubkey(x: PX509; pkey: EVP_PKEY): integer;
|
||||||
function X509SetIssuerName(x: PX509; name: PX509_NAME): integer;
|
function X509SetIssuerName(x: PX509; name: PX509_NAME): integer;
|
||||||
function X509NameAddEntryByTxt(name: PX509_NAME; field: string; _type: integer;
|
function X509NameAddEntryByTxt(name: PX509_NAME; field: Ansistring; _type: integer;
|
||||||
bytes: string; len, loc, _set: integer): integer;
|
bytes: Ansistring; len, loc, _set: integer): integer;
|
||||||
function X509Sign(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer;
|
function X509Sign(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer;
|
||||||
function X509GmtimeAdj(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME;
|
function X509GmtimeAdj(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME;
|
||||||
function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): integer;
|
function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): integer;
|
||||||
@ -714,11 +714,11 @@ var
|
|||||||
function EvpPkeyNew: EVP_PKEY;
|
function EvpPkeyNew: EVP_PKEY;
|
||||||
procedure EvpPkeyFree(pk: EVP_PKEY);
|
procedure EvpPkeyFree(pk: EVP_PKEY);
|
||||||
function EvpPkeyAssign(pkey: EVP_PKEY; _type: integer; key: Prsa): integer;
|
function EvpPkeyAssign(pkey: EVP_PKEY; _type: integer; key: Prsa): integer;
|
||||||
function EvpGetDigestByName(Name: String): PEVP_MD;
|
function EvpGetDigestByName(Name: AnsiString): PEVP_MD;
|
||||||
procedure EVPcleanup;
|
procedure EVPcleanup;
|
||||||
// function ErrErrorString(e: integer; buf: PChar): PChar;
|
// function ErrErrorString(e: integer; buf: PChar): PChar;
|
||||||
function SSLeayversion(t: integer): string;
|
function SSLeayversion(t: integer): Ansistring;
|
||||||
procedure ErrErrorString(e: integer; var buf: string; len: integer);
|
procedure ErrErrorString(e: integer; var buf: Ansistring; len: integer);
|
||||||
function ErrGetError: integer;
|
function ErrGetError: integer;
|
||||||
procedure ErrClearError;
|
procedure ErrClearError;
|
||||||
procedure ErrFreeStrings;
|
procedure ErrFreeStrings;
|
||||||
@ -730,10 +730,10 @@ var
|
|||||||
procedure BioFreeAll(b: PBIO);
|
procedure BioFreeAll(b: PBIO);
|
||||||
function BioSMem: PBIO_METHOD;
|
function BioSMem: PBIO_METHOD;
|
||||||
function BioCtrlPending(b: PBIO): integer;
|
function BioCtrlPending(b: PBIO): integer;
|
||||||
function BioRead(b: PBIO; var Buf: String; Len: integer): integer;
|
function BioRead(b: PBIO; var Buf: AnsiString; Len: integer): integer;
|
||||||
function BioWrite(b: PBIO; Buf: String; Len: integer): integer;
|
function BioWrite(b: PBIO; Buf: AnsiString; Len: integer): integer;
|
||||||
function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr;
|
function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr;
|
||||||
function PKCS12parse(p12: SslPtr; pass: string; var pkey, cert, ca: SslPtr): integer;
|
function PKCS12parse(p12: SslPtr; pass: Ansistring; var pkey, cert, ca: SslPtr): integer;
|
||||||
procedure PKCS12free(p12: SslPtr);
|
procedure PKCS12free(p12: SslPtr);
|
||||||
function RsaGenerateKey(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA;
|
function RsaGenerateKey(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA;
|
||||||
function Asn1UtctimeNew: PASN1_UTCTIME;
|
function Asn1UtctimeNew: PASN1_UTCTIME;
|
||||||
@ -763,7 +763,7 @@ type
|
|||||||
TSslGetError = function(s: PSSL; ret_code: Integer):Integer; cdecl;
|
TSslGetError = function(s: PSSL; ret_code: Integer):Integer; cdecl;
|
||||||
TSslLibraryInit = function:Integer; cdecl;
|
TSslLibraryInit = function:Integer; cdecl;
|
||||||
TSslLoadErrorStrings = procedure; cdecl;
|
TSslLoadErrorStrings = procedure; cdecl;
|
||||||
TSslCtxSetCipherList = function(arg0: PSSL_CTX; str: PChar):Integer; cdecl;
|
TSslCtxSetCipherList = function(arg0: PSSL_CTX; str: PAnsiChar):Integer; cdecl;
|
||||||
TSslCtxNew = function(meth: PSSL_METHOD):PSSL_CTX; cdecl;
|
TSslCtxNew = function(meth: PSSL_METHOD):PSSL_CTX; cdecl;
|
||||||
TSslCtxFree = procedure(arg0: PSSL_CTX); cdecl;
|
TSslCtxFree = procedure(arg0: PSSL_CTX); cdecl;
|
||||||
TSslSetFd = function(s: PSSL; fd: Integer):Integer; cdecl;
|
TSslSetFd = function(s: PSSL; fd: Integer):Integer; cdecl;
|
||||||
@ -773,46 +773,46 @@ type
|
|||||||
TSslMethodV23 = function:PSSL_METHOD; cdecl;
|
TSslMethodV23 = function:PSSL_METHOD; cdecl;
|
||||||
TSslCtxUsePrivateKey = function(ctx: PSSL_CTX; pkey: sslptr):Integer; cdecl;
|
TSslCtxUsePrivateKey = function(ctx: PSSL_CTX; pkey: sslptr):Integer; cdecl;
|
||||||
TSslCtxUsePrivateKeyASN1 = function(pk: integer; ctx: PSSL_CTX; d: sslptr; len: integer):Integer; cdecl;
|
TSslCtxUsePrivateKeyASN1 = function(pk: integer; ctx: PSSL_CTX; d: sslptr; len: integer):Integer; cdecl;
|
||||||
TSslCtxUsePrivateKeyFile = function(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer; cdecl;
|
TSslCtxUsePrivateKeyFile = function(ctx: PSSL_CTX; const _file: PAnsiChar; _type: Integer):Integer; cdecl;
|
||||||
TSslCtxUseCertificate = function(ctx: PSSL_CTX; x: SslPtr):Integer; cdecl;
|
TSslCtxUseCertificate = function(ctx: PSSL_CTX; x: SslPtr):Integer; cdecl;
|
||||||
TSslCtxUseCertificateASN1 = function(ctx: PSSL_CTX; len: Integer; d: SslPtr):Integer; cdecl;
|
TSslCtxUseCertificateASN1 = function(ctx: PSSL_CTX; len: Integer; d: SslPtr):Integer; cdecl;
|
||||||
TSslCtxUseCertificateFile = function(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer; cdecl;
|
TSslCtxUseCertificateFile = function(ctx: PSSL_CTX; const _file: PAnsiChar; _type: Integer):Integer; cdecl;
|
||||||
TSslCtxUseCertificateChainFile = function(ctx: PSSL_CTX; const _file: PChar):Integer; cdecl;
|
TSslCtxUseCertificateChainFile = function(ctx: PSSL_CTX; const _file: PAnsiChar):Integer; cdecl;
|
||||||
TSslCtxCheckPrivateKeyFile = function(ctx: PSSL_CTX):Integer; cdecl;
|
TSslCtxCheckPrivateKeyFile = function(ctx: PSSL_CTX):Integer; cdecl;
|
||||||
TSslCtxSetDefaultPasswdCb = procedure(ctx: PSSL_CTX; cb: SslPtr); cdecl;
|
TSslCtxSetDefaultPasswdCb = procedure(ctx: PSSL_CTX; cb: SslPtr); cdecl;
|
||||||
TSslCtxSetDefaultPasswdCbUserdata = procedure(ctx: PSSL_CTX; u: SslPtr); cdecl;
|
TSslCtxSetDefaultPasswdCbUserdata = procedure(ctx: PSSL_CTX; u: SslPtr); cdecl;
|
||||||
TSslCtxLoadVerifyLocations = function(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):Integer; cdecl;
|
TSslCtxLoadVerifyLocations = function(ctx: PSSL_CTX; const CAfile: PAnsiChar; const CApath: PAnsiChar):Integer; cdecl;
|
||||||
TSslNew = function(ctx: PSSL_CTX):PSSL; cdecl;
|
TSslNew = function(ctx: PSSL_CTX):PSSL; cdecl;
|
||||||
TSslFree = procedure(ssl: PSSL); cdecl;
|
TSslFree = procedure(ssl: PSSL); cdecl;
|
||||||
TSslAccept = function(ssl: PSSL):Integer; cdecl;
|
TSslAccept = function(ssl: PSSL):Integer; cdecl;
|
||||||
TSslConnect = function(ssl: PSSL):Integer; cdecl;
|
TSslConnect = function(ssl: PSSL):Integer; cdecl;
|
||||||
TSslShutdown = function(ssl: PSSL):Integer; cdecl;
|
TSslShutdown = function(ssl: PSSL):Integer; cdecl;
|
||||||
TSslRead = function(ssl: PSSL; buf: PChar; num: Integer):Integer; cdecl;
|
TSslRead = function(ssl: PSSL; buf: PAnsiChar; num: Integer):Integer; cdecl;
|
||||||
TSslPeek = function(ssl: PSSL; buf: PChar; num: Integer):Integer; cdecl;
|
TSslPeek = function(ssl: PSSL; buf: PAnsiChar; num: Integer):Integer; cdecl;
|
||||||
TSslWrite = function(ssl: PSSL; const buf: PChar; num: Integer):Integer; cdecl;
|
TSslWrite = function(ssl: PSSL; const buf: PAnsiChar; num: Integer):Integer; cdecl;
|
||||||
TSslPending = function(ssl: PSSL):Integer; cdecl;
|
TSslPending = function(ssl: PSSL):Integer; cdecl;
|
||||||
TSslGetVersion = function(ssl: PSSL):PChar; cdecl;
|
TSslGetVersion = function(ssl: PSSL):PAnsiChar; cdecl;
|
||||||
TSslGetPeerCertificate = function(ssl: PSSL):PX509; cdecl;
|
TSslGetPeerCertificate = function(ssl: PSSL):PX509; cdecl;
|
||||||
TSslCtxSetVerify = procedure(ctx: PSSL_CTX; mode: Integer; arg2: SslPtr); cdecl;
|
TSslCtxSetVerify = procedure(ctx: PSSL_CTX; mode: Integer; arg2: SslPtr); cdecl;
|
||||||
TSSLGetCurrentCipher = function(s: PSSL):SslPtr; cdecl;
|
TSSLGetCurrentCipher = function(s: PSSL):SslPtr; cdecl;
|
||||||
TSSLCipherGetName = function(c: Sslptr):PChar; cdecl;
|
TSSLCipherGetName = function(c: Sslptr):PAnsiChar; cdecl;
|
||||||
TSSLCipherGetBits = function(c: SslPtr; alg_bits: PInteger):Integer; cdecl;
|
TSSLCipherGetBits = function(c: SslPtr; alg_bits: PInteger):Integer; cdecl;
|
||||||
TSSLGetVerifyResult = function(ssl: PSSL):Integer; cdecl;
|
TSSLGetVerifyResult = function(ssl: PSSL):Integer; cdecl;
|
||||||
|
|
||||||
// libeay.dll
|
// libeay.dll
|
||||||
TX509New = function: PX509; cdecl;
|
TX509New = function: PX509; cdecl;
|
||||||
TX509Free = procedure(x: PX509); cdecl;
|
TX509Free = procedure(x: PX509); cdecl;
|
||||||
TX509NameOneline = function(a: PX509_NAME; buf: PChar; size: Integer):PChar; cdecl;
|
TX509NameOneline = function(a: PX509_NAME; buf: PAnsiChar; size: Integer):PAnsiChar; cdecl;
|
||||||
TX509GetSubjectName = function(a: PX509):PX509_NAME; cdecl;
|
TX509GetSubjectName = function(a: PX509):PX509_NAME; cdecl;
|
||||||
TX509GetIssuerName = function(a: PX509):PX509_NAME; cdecl;
|
TX509GetIssuerName = function(a: PX509):PX509_NAME; cdecl;
|
||||||
TX509NameHash = function(x: PX509_NAME):Cardinal; cdecl;
|
TX509NameHash = function(x: PX509_NAME):Cardinal; cdecl;
|
||||||
TX509Digest = function(data: PX509; _type: PEVP_MD; md: PChar; len: PInteger):Integer; cdecl;
|
TX509Digest = function(data: PX509; _type: PEVP_MD; md: PAnsiChar; len: PInteger):Integer; cdecl;
|
||||||
TX509print = function(b: PBIO; a: PX509): integer; cdecl;
|
TX509print = function(b: PBIO; a: PX509): integer; cdecl;
|
||||||
TX509SetVersion = function(x: PX509; version: integer): integer; cdecl;
|
TX509SetVersion = function(x: PX509; version: integer): integer; cdecl;
|
||||||
TX509SetPubkey = function(x: PX509; pkey: EVP_PKEY): integer; cdecl;
|
TX509SetPubkey = function(x: PX509; pkey: EVP_PKEY): integer; cdecl;
|
||||||
TX509SetIssuerName = function(x: PX509; name: PX509_NAME): integer; cdecl;
|
TX509SetIssuerName = function(x: PX509; name: PX509_NAME): integer; cdecl;
|
||||||
TX509NameAddEntryByTxt = function(name: PX509_NAME; field: PChar; _type: integer;
|
TX509NameAddEntryByTxt = function(name: PX509_NAME; field: PAnsiChar; _type: integer;
|
||||||
bytes: PChar; len, loc, _set: integer): integer; cdecl;
|
bytes: PAnsiChar; len, loc, _set: integer): integer; cdecl;
|
||||||
TX509Sign = function(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer; cdecl;
|
TX509Sign = function(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer; cdecl;
|
||||||
TX509GmtimeAdj = function(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME; cdecl;
|
TX509GmtimeAdj = function(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME; cdecl;
|
||||||
TX509SetNotBefore = function(x: PX509; tm: PASN1_UTCTIME): integer; cdecl;
|
TX509SetNotBefore = function(x: PX509; tm: PASN1_UTCTIME): integer; cdecl;
|
||||||
@ -821,10 +821,10 @@ type
|
|||||||
TEvpPkeyNew = function: EVP_PKEY; cdecl;
|
TEvpPkeyNew = function: EVP_PKEY; cdecl;
|
||||||
TEvpPkeyFree = procedure(pk: EVP_PKEY); cdecl;
|
TEvpPkeyFree = procedure(pk: EVP_PKEY); cdecl;
|
||||||
TEvpPkeyAssign = function(pkey: EVP_PKEY; _type: integer; key: Prsa): integer; cdecl;
|
TEvpPkeyAssign = function(pkey: EVP_PKEY; _type: integer; key: Prsa): integer; cdecl;
|
||||||
TEvpGetDigestByName = function(Name: PChar): PEVP_MD; cdecl;
|
TEvpGetDigestByName = function(Name: PAnsiChar): PEVP_MD; cdecl;
|
||||||
TEVPcleanup = procedure; cdecl;
|
TEVPcleanup = procedure; cdecl;
|
||||||
TSSLeayversion = function(t: integer): PChar; cdecl;
|
TSSLeayversion = function(t: integer): PAnsiChar; cdecl;
|
||||||
TErrErrorString = procedure(e: integer; buf: PChar; len: integer); cdecl;
|
TErrErrorString = procedure(e: integer; buf: PAnsiChar; len: integer); cdecl;
|
||||||
TErrGetError = function: integer; cdecl;
|
TErrGetError = function: integer; cdecl;
|
||||||
TErrClearError = procedure; cdecl;
|
TErrClearError = procedure; cdecl;
|
||||||
TErrFreeStrings = procedure; cdecl;
|
TErrFreeStrings = procedure; cdecl;
|
||||||
@ -836,10 +836,10 @@ type
|
|||||||
TBioFreeAll = procedure(b: PBIO); cdecl;
|
TBioFreeAll = procedure(b: PBIO); cdecl;
|
||||||
TBioSMem = function: PBIO_METHOD; cdecl;
|
TBioSMem = function: PBIO_METHOD; cdecl;
|
||||||
TBioCtrlPending = function(b: PBIO): integer; cdecl;
|
TBioCtrlPending = function(b: PBIO): integer; cdecl;
|
||||||
TBioRead = function(b: PBIO; Buf: PChar; Len: integer): integer; cdecl;
|
TBioRead = function(b: PBIO; Buf: PAnsiChar; Len: integer): integer; cdecl;
|
||||||
TBioWrite = function(b: PBIO; Buf: PChar; Len: integer): integer; cdecl;
|
TBioWrite = function(b: PBIO; Buf: PAnsiChar; Len: integer): integer; cdecl;
|
||||||
Td2iPKCS12bio = function(b:PBIO; Pkcs12: SslPtr): SslPtr; cdecl;
|
Td2iPKCS12bio = function(b:PBIO; Pkcs12: SslPtr): SslPtr; cdecl;
|
||||||
TPKCS12parse = function(p12: SslPtr; pass: PChar; var pkey, cert, ca: SslPtr): integer; cdecl;
|
TPKCS12parse = function(p12: SslPtr; pass: PAnsiChar; var pkey, cert, ca: SslPtr): integer; cdecl;
|
||||||
TPKCS12free = procedure(p12: SslPtr); cdecl;
|
TPKCS12free = procedure(p12: SslPtr); cdecl;
|
||||||
TRsaGenerateKey = function(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA; cdecl;
|
TRsaGenerateKey = function(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA; cdecl;
|
||||||
TAsn1UtctimeNew = function: PASN1_UTCTIME; cdecl;
|
TAsn1UtctimeNew = function: PASN1_UTCTIME; cdecl;
|
||||||
@ -986,10 +986,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//function SslCtxSetCipherList(arg0: PSSL_CTX; str: PChar):Integer;
|
//function SslCtxSetCipherList(arg0: PSSL_CTX; str: PChar):Integer;
|
||||||
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: String):Integer;
|
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: AnsiString):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslCtxSetCipherList) then
|
if InitSSLInterface and Assigned(_SslCtxSetCipherList) then
|
||||||
Result := _SslCtxSetCipherList(arg0, PChar(str))
|
Result := _SslCtxSetCipherList(arg0, PAnsiChar(str))
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
@ -1056,7 +1056,7 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: String; len: integer):Integer;
|
function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: AnsiString; len: integer):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyASN1) then
|
if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyASN1) then
|
||||||
Result := _SslCtxUsePrivateKeyASN1(pk, ctx, Sslptr(d), len)
|
Result := _SslCtxUsePrivateKeyASN1(pk, ctx, Sslptr(d), len)
|
||||||
@ -1065,10 +1065,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer;
|
//function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer;
|
||||||
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;
|
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: AnsiString; _type: Integer):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyFile) then
|
if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyFile) then
|
||||||
Result := _SslCtxUsePrivateKeyFile(ctx, PChar(_file), _type)
|
Result := _SslCtxUsePrivateKeyFile(ctx, PAnsiChar(_file), _type)
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
@ -1081,7 +1081,7 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: integer; d: String):Integer;
|
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: integer; d: AnsiString):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslCtxUseCertificateASN1) then
|
if InitSSLInterface and Assigned(_SslCtxUseCertificateASN1) then
|
||||||
Result := _SslCtxUseCertificateASN1(ctx, len, SslPtr(d))
|
Result := _SslCtxUseCertificateASN1(ctx, len, SslPtr(d))
|
||||||
@ -1089,19 +1089,19 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;
|
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: AnsiString; _type: Integer):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslCtxUseCertificateFile) then
|
if InitSSLInterface and Assigned(_SslCtxUseCertificateFile) then
|
||||||
Result := _SslCtxUseCertificateFile(ctx, PChar(_file), _type)
|
Result := _SslCtxUseCertificateFile(ctx, PAnsiChar(_file), _type)
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PChar):Integer;
|
//function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PChar):Integer;
|
||||||
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: String):Integer;
|
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: AnsiString):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslCtxUseCertificateChainFile) then
|
if InitSSLInterface and Assigned(_SslCtxUseCertificateChainFile) then
|
||||||
Result := _SslCtxUseCertificateChainFile(ctx, PChar(_file))
|
Result := _SslCtxUseCertificateChainFile(ctx, PAnsiChar(_file))
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
@ -1127,7 +1127,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):Integer;
|
//function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):Integer;
|
||||||
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: String; const CApath: String):Integer;
|
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: AnsiString; const CApath: AnsiString):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslCtxLoadVerifyLocations) then
|
if InitSSLInterface and Assigned(_SslCtxLoadVerifyLocations) then
|
||||||
Result := _SslCtxLoadVerifyLocations(ctx, SslPtr(CAfile), SslPtr(CApath))
|
Result := _SslCtxLoadVerifyLocations(ctx, SslPtr(CAfile), SslPtr(CApath))
|
||||||
@ -1177,7 +1177,7 @@ end;
|
|||||||
function SslRead(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
|
function SslRead(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslRead) then
|
if InitSSLInterface and Assigned(_SslRead) then
|
||||||
Result := _SslRead(ssl, PChar(buf), num)
|
Result := _SslRead(ssl, PAnsiChar(buf), num)
|
||||||
else
|
else
|
||||||
Result := -1;
|
Result := -1;
|
||||||
end;
|
end;
|
||||||
@ -1186,7 +1186,7 @@ end;
|
|||||||
function SslPeek(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
|
function SslPeek(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslPeek) then
|
if InitSSLInterface and Assigned(_SslPeek) then
|
||||||
Result := _SslPeek(ssl, PChar(buf), num)
|
Result := _SslPeek(ssl, PAnsiChar(buf), num)
|
||||||
else
|
else
|
||||||
Result := -1;
|
Result := -1;
|
||||||
end;
|
end;
|
||||||
@ -1195,7 +1195,7 @@ end;
|
|||||||
function SslWrite(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
|
function SslWrite(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslWrite) then
|
if InitSSLInterface and Assigned(_SslWrite) then
|
||||||
Result := _SslWrite(ssl, PChar(buf), num)
|
Result := _SslWrite(ssl, PAnsiChar(buf), num)
|
||||||
else
|
else
|
||||||
Result := -1;
|
Result := -1;
|
||||||
end;
|
end;
|
||||||
@ -1209,7 +1209,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//function SslGetVersion(ssl: PSSL):PChar;
|
//function SslGetVersion(ssl: PSSL):PChar;
|
||||||
function SslGetVersion(ssl: PSSL):String;
|
function SslGetVersion(ssl: PSSL):AnsiString;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslGetVersion) then
|
if InitSSLInterface and Assigned(_SslGetVersion) then
|
||||||
Result := _SslGetVersion(ssl)
|
Result := _SslGetVersion(ssl)
|
||||||
@ -1244,7 +1244,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//function SSLCipherGetName(c: SslPtr):PChar;
|
//function SSLCipherGetName(c: SslPtr):PChar;
|
||||||
function SSLCipherGetName(c: SslPtr):String;
|
function SSLCipherGetName(c: SslPtr):AnsiString;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SSLCipherGetName) then
|
if InitSSLInterface and Assigned(_SSLCipherGetName) then
|
||||||
Result := _SSLCipherGetName(c)
|
Result := _SSLCipherGetName(c)
|
||||||
@ -1285,10 +1285,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//function SslX509NameOneline(a: PX509_NAME; buf: PChar; size: Integer):PChar;
|
//function SslX509NameOneline(a: PX509_NAME; buf: PChar; size: Integer):PChar;
|
||||||
function X509NameOneline(a: PX509_NAME; var buf: String; size: Integer):String;
|
function X509NameOneline(a: PX509_NAME; var buf: AnsiString; size: Integer):AnsiString;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_X509NameOneline) then
|
if InitSSLInterface and Assigned(_X509NameOneline) then
|
||||||
Result := _X509NameOneline(a, PChar(buf),size)
|
Result := _X509NameOneline(a, PAnsiChar(buf),size)
|
||||||
else
|
else
|
||||||
Result := '';
|
Result := '';
|
||||||
end;
|
end;
|
||||||
@ -1318,10 +1318,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//function SslX509Digest(data: PX509; _type: PEVP_MD; md: PChar; len: PInteger):Integer;
|
//function SslX509Digest(data: PX509; _type: PEVP_MD; md: PChar; len: PInteger):Integer;
|
||||||
function X509Digest(data: PX509; _type: PEVP_MD; md: String; var len: Integer):Integer;
|
function X509Digest(data: PX509; _type: PEVP_MD; md: AnsiString; var len: Integer):Integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_X509Digest) then
|
if InitSSLInterface and Assigned(_X509Digest) then
|
||||||
Result := _X509Digest(data, _type, PChar(md), @len)
|
Result := _X509Digest(data, _type, PAnsiChar(md), @len)
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
@ -1340,15 +1340,15 @@ begin
|
|||||||
_EvpPkeyFree(pk);
|
_EvpPkeyFree(pk);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SSLeayversion(t: integer): string;
|
function SSLeayversion(t: integer): Ansistring;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SSLeayversion) then
|
if InitSSLInterface and Assigned(_SSLeayversion) then
|
||||||
Result := PChar(_SSLeayversion(t))
|
Result := PAnsiChar(_SSLeayversion(t))
|
||||||
else
|
else
|
||||||
Result := '';
|
Result := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ErrErrorString(e: integer; var buf: string; len: integer);
|
procedure ErrErrorString(e: integer; var buf: Ansistring; len: integer);
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_ErrErrorString) then
|
if InitSSLInterface and Assigned(_ErrErrorString) then
|
||||||
_ErrErrorString(e, Pointer(buf), len);
|
_ErrErrorString(e, Pointer(buf), len);
|
||||||
@ -1436,19 +1436,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//function BioRead(b: PBIO; Buf: PChar; Len: integer): integer;
|
//function BioRead(b: PBIO; Buf: PChar; Len: integer): integer;
|
||||||
function BioRead(b: PBIO; var Buf: String; Len: integer): integer;
|
function BioRead(b: PBIO; var Buf: AnsiString; Len: integer): integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_BioRead) then
|
if InitSSLInterface and Assigned(_BioRead) then
|
||||||
Result := _BioRead(b, PChar(Buf), Len)
|
Result := _BioRead(b, PAnsiChar(Buf), Len)
|
||||||
else
|
else
|
||||||
Result := -2;
|
Result := -2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//function BioWrite(b: PBIO; Buf: PChar; Len: integer): integer;
|
//function BioWrite(b: PBIO; Buf: PChar; Len: integer): integer;
|
||||||
function BioWrite(b: PBIO; Buf: String; Len: integer): integer;
|
function BioWrite(b: PBIO; Buf: AnsiString; Len: integer): integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_BioWrite) then
|
if InitSSLInterface and Assigned(_BioWrite) then
|
||||||
Result := _BioWrite(b, PChar(Buf), Len)
|
Result := _BioWrite(b, PAnsiChar(Buf), Len)
|
||||||
else
|
else
|
||||||
Result := -2;
|
Result := -2;
|
||||||
end;
|
end;
|
||||||
@ -1469,7 +1469,7 @@ begin
|
|||||||
Result := nil;
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PKCS12parse(p12: SslPtr; pass: string; var pkey, cert, ca: SslPtr): integer;
|
function PKCS12parse(p12: SslPtr; pass: Ansistring; var pkey, cert, ca: SslPtr): integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_PKCS12parse) then
|
if InitSSLInterface and Assigned(_PKCS12parse) then
|
||||||
Result := _PKCS12parse(p12, SslPtr(pass), pkey, cert, ca)
|
Result := _PKCS12parse(p12, SslPtr(pass), pkey, cert, ca)
|
||||||
@ -1523,11 +1523,11 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function X509NameAddEntryByTxt(name: PX509_NAME; field: string; _type: integer;
|
function X509NameAddEntryByTxt(name: PX509_NAME; field: Ansistring; _type: integer;
|
||||||
bytes: string; len, loc, _set: integer): integer;
|
bytes: Ansistring; len, loc, _set: integer): integer;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_X509NameAddEntryByTxt) then
|
if InitSSLInterface and Assigned(_X509NameAddEntryByTxt) then
|
||||||
Result := _X509NameAddEntryByTxt(name, PChar(field), _type, PChar(Bytes), len, loc, _set)
|
Result := _X509NameAddEntryByTxt(name, PAnsiChar(field), _type, PAnsiChar(Bytes), len, loc, _set)
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
@ -1594,10 +1594,10 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function EvpGetDigestByName(Name: String): PEVP_MD;
|
function EvpGetDigestByName(Name: AnsiString): PEVP_MD;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_EvpGetDigestByName) then
|
if InitSSLInterface and Assigned(_EvpGetDigestByName) then
|
||||||
Result := _EvpGetDigestByName(PChar(Name))
|
Result := _EvpGetDigestByName(PAnsiChar(Name))
|
||||||
else
|
else
|
||||||
Result := nil;
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
236
sswin32.pas
236
sswin32.pas
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 002.000.002 |
|
| Project : Ararat Synapse | 002.002.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Socket Independent Platform Layer - Win32 definition include |
|
| Content: Socket Independent Platform Layer - Win32 definition include |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2003, Lukas Gebauer |
|
| Copyright (c)1999-2008, Lukas Gebauer |
|
||||||
| All rights reserved. |
|
| All rights reserved. |
|
||||||
| |
|
| |
|
||||||
| Redistribution and use in source and binary forms, with or without |
|
| Redistribution and use in source and binary forms, with or without |
|
||||||
@ -244,7 +244,7 @@ uses
|
|||||||
SyncObjs, SysUtils, Classes,
|
SyncObjs, SysUtils, Classes,
|
||||||
Windows;
|
Windows;
|
||||||
|
|
||||||
function InitSocketInterface(stack: string): Boolean;
|
function InitSocketInterface(stack: String): Boolean;
|
||||||
function DestroySocketInterface: Boolean;
|
function DestroySocketInterface: Boolean;
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -255,7 +255,6 @@ const
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
type
|
type
|
||||||
u_char = Char;
|
|
||||||
u_short = Word;
|
u_short = Word;
|
||||||
u_int = Integer;
|
u_int = Integer;
|
||||||
u_long = Longint;
|
u_long = Longint;
|
||||||
@ -331,9 +330,9 @@ type
|
|||||||
0: (sin_family: u_short;
|
0: (sin_family: u_short;
|
||||||
sin_port: u_short;
|
sin_port: u_short;
|
||||||
sin_addr: TInAddr;
|
sin_addr: TInAddr;
|
||||||
sin_zero: array[0..7] of Char);
|
sin_zero: array[0..7] of byte);
|
||||||
1: (sa_family: u_short;
|
1: (sa_family: u_short;
|
||||||
sa_data: array[0..13] of Char)
|
sa_data: array[0..13] of byte)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TIP_mreq = record
|
TIP_mreq = record
|
||||||
@ -368,35 +367,35 @@ type
|
|||||||
|
|
||||||
PHostEnt = ^THostEnt;
|
PHostEnt = ^THostEnt;
|
||||||
THostEnt = packed record
|
THostEnt = packed record
|
||||||
h_name: PChar;
|
h_name: PAnsiChar;
|
||||||
h_aliases: ^PChar;
|
h_aliases: ^PAnsiChar;
|
||||||
h_addrtype: Smallint;
|
h_addrtype: Smallint;
|
||||||
h_length: Smallint;
|
h_length: Smallint;
|
||||||
case integer of
|
case integer of
|
||||||
0: (h_addr_list: ^PChar);
|
0: (h_addr_list: ^PAnsiChar);
|
||||||
1: (h_addr: ^PInAddr);
|
1: (h_addr: ^PInAddr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PNetEnt = ^TNetEnt;
|
PNetEnt = ^TNetEnt;
|
||||||
TNetEnt = packed record
|
TNetEnt = packed record
|
||||||
n_name: PChar;
|
n_name: PAnsiChar;
|
||||||
n_aliases: ^PChar;
|
n_aliases: ^PAnsiChar;
|
||||||
n_addrtype: Smallint;
|
n_addrtype: Smallint;
|
||||||
n_net: u_long;
|
n_net: u_long;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PServEnt = ^TServEnt;
|
PServEnt = ^TServEnt;
|
||||||
TServEnt = packed record
|
TServEnt = packed record
|
||||||
s_name: PChar;
|
s_name: PAnsiChar;
|
||||||
s_aliases: ^PChar;
|
s_aliases: ^PAnsiChar;
|
||||||
s_port: Smallint;
|
s_port: Smallint;
|
||||||
s_proto: PChar;
|
s_proto: PAnsiChar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PProtoEnt = ^TProtoEnt;
|
PProtoEnt = ^TProtoEnt;
|
||||||
TProtoEnt = packed record
|
TProtoEnt = packed record
|
||||||
p_name: PChar;
|
p_name: PAnsiChar;
|
||||||
p_aliases: ^Pchar;
|
p_aliases: ^PAnsichar;
|
||||||
p_proto: Smallint;
|
p_proto: Smallint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -540,7 +539,7 @@ type
|
|||||||
ai_socktype: integer; // SOCK_xxx.
|
ai_socktype: integer; // SOCK_xxx.
|
||||||
ai_protocol: integer; // 0 or IPPROTO_xxx for IPv4 and IPv6.
|
ai_protocol: integer; // 0 or IPPROTO_xxx for IPv4 and IPv6.
|
||||||
ai_addrlen: u_int; // Length of ai_addr.
|
ai_addrlen: u_int; // Length of ai_addr.
|
||||||
ai_canonname: PChar; // Canonical name for nodename.
|
ai_canonname: PAnsiChar; // Canonical name for nodename.
|
||||||
ai_addr: PSockAddr; // Binary address.
|
ai_addr: PSockAddr; // Binary address.
|
||||||
ai_next: PAddrInfo; // Next structure in linked list.
|
ai_next: PAddrInfo; // Next structure in linked list.
|
||||||
end;
|
end;
|
||||||
@ -719,11 +718,11 @@ type
|
|||||||
TWSAData = packed record
|
TWSAData = packed record
|
||||||
wVersion: Word;
|
wVersion: Word;
|
||||||
wHighVersion: Word;
|
wHighVersion: Word;
|
||||||
szDescription: array[0..WSADESCRIPTION_LEN] of Char;
|
szDescription: array[0..WSADESCRIPTION_LEN] of AnsiChar;
|
||||||
szSystemStatus: array[0..WSASYS_STATUS_LEN] of Char;
|
szSystemStatus: array[0..WSASYS_STATUS_LEN] of AnsiChar;
|
||||||
iMaxSockets: Word;
|
iMaxSockets: Word;
|
||||||
iMaxUdpDg: Word;
|
iMaxUdpDg: Word;
|
||||||
lpVendorInfo: PChar;
|
lpVendorInfo: PAnsiChar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function IN6_IS_ADDR_UNSPECIFIED(const a: PInAddr6): boolean;
|
function IN6_IS_ADDR_UNSPECIFIED(const a: PInAddr6): boolean;
|
||||||
@ -751,26 +750,26 @@ type
|
|||||||
stdcall;
|
stdcall;
|
||||||
TWSAGetLastError = function: Integer;
|
TWSAGetLastError = function: Integer;
|
||||||
stdcall;
|
stdcall;
|
||||||
TGetServByName = function(name, proto: PChar): PServEnt;
|
TGetServByName = function(name, proto: PAnsiChar): PServEnt;
|
||||||
stdcall;
|
stdcall;
|
||||||
TGetServByPort = function(port: Integer; proto: PChar): PServEnt;
|
TGetServByPort = function(port: Integer; proto: PAnsiChar): PServEnt;
|
||||||
stdcall;
|
stdcall;
|
||||||
TGetProtoByName = function(name: PChar): PProtoEnt;
|
TGetProtoByName = function(name: PAnsiChar): PProtoEnt;
|
||||||
stdcall;
|
stdcall;
|
||||||
TGetProtoByNumber = function(proto: Integer): PProtoEnt;
|
TGetProtoByNumber = function(proto: Integer): PProtoEnt;
|
||||||
stdcall;
|
stdcall;
|
||||||
TGetHostByName = function(name: PChar): PHostEnt;
|
TGetHostByName = function(name: PAnsiChar): PHostEnt;
|
||||||
stdcall;
|
stdcall;
|
||||||
TGetHostByAddr = function(addr: Pointer; len, Struc: Integer): PHostEnt;
|
TGetHostByAddr = function(addr: Pointer; len, Struc: Integer): PHostEnt;
|
||||||
stdcall;
|
stdcall;
|
||||||
TGetHostName = function(name: PChar; len: Integer): Integer;
|
TGetHostName = function(name: PAnsiChar; len: Integer): Integer;
|
||||||
stdcall;
|
stdcall;
|
||||||
TShutdown = function(s: TSocket; how: Integer): Integer;
|
TShutdown = function(s: TSocket; how: Integer): Integer;
|
||||||
stdcall;
|
stdcall;
|
||||||
TSetSockOpt = function(s: TSocket; level, optname: Integer; optval: PChar;
|
TSetSockOpt = function(s: TSocket; level, optname: Integer; optval: PAnsiChar;
|
||||||
optlen: Integer): Integer;
|
optlen: Integer): Integer;
|
||||||
stdcall;
|
stdcall;
|
||||||
TGetSockOpt = function(s: TSocket; level, optname: Integer; optval: PChar;
|
TGetSockOpt = function(s: TSocket; level, optname: Integer; optval: PAnsiChar;
|
||||||
var optlen: Integer): Integer;
|
var optlen: Integer): Integer;
|
||||||
stdcall;
|
stdcall;
|
||||||
TSendTo = function(s: TSocket; const Buf; len, flags: Integer; addrto: PSockAddr;
|
TSendTo = function(s: TSocket; const Buf; len, flags: Integer; addrto: PSockAddr;
|
||||||
@ -791,9 +790,9 @@ type
|
|||||||
stdcall;
|
stdcall;
|
||||||
TIoctlSocket = function(s: TSocket; cmd: DWORD; var arg: Integer): Integer;
|
TIoctlSocket = function(s: TSocket; cmd: DWORD; var arg: Integer): Integer;
|
||||||
stdcall;
|
stdcall;
|
||||||
TInet_ntoa = function(inaddr: TInAddr): PChar;
|
TInet_ntoa = function(inaddr: TInAddr): PAnsiChar;
|
||||||
stdcall;
|
stdcall;
|
||||||
TInet_addr = function(cp: PChar): u_long;
|
TInet_addr = function(cp: PAnsiChar): u_long;
|
||||||
stdcall;
|
stdcall;
|
||||||
Thtons = function(hostshort: u_short): u_short;
|
Thtons = function(hostshort: u_short): u_short;
|
||||||
stdcall;
|
stdcall;
|
||||||
@ -817,13 +816,13 @@ type
|
|||||||
timeout: PTimeVal): Longint;
|
timeout: PTimeVal): Longint;
|
||||||
stdcall;
|
stdcall;
|
||||||
|
|
||||||
TGetAddrInfo = function(NodeName: PChar; ServName: PChar; Hints: PAddrInfo;
|
TGetAddrInfo = function(NodeName: PAnsiChar; ServName: PAnsiChar; Hints: PAddrInfo;
|
||||||
var Addrinfo: PAddrInfo): integer;
|
var Addrinfo: PAddrInfo): integer;
|
||||||
stdcall;
|
stdcall;
|
||||||
TFreeAddrInfo = procedure(ai: PAddrInfo);
|
TFreeAddrInfo = procedure(ai: PAddrInfo);
|
||||||
stdcall;
|
stdcall;
|
||||||
TGetNameInfo = function( addr: PSockAddr; namelen: Integer; host: PChar;
|
TGetNameInfo = function( addr: PSockAddr; namelen: Integer; host: PAnsiChar;
|
||||||
hostlen: DWORD; serv: PChar; servlen: DWORD; flags: integer): integer;
|
hostlen: DWORD; serv: PAnsiChar; servlen: DWORD; flags: integer): integer;
|
||||||
stdcall;
|
stdcall;
|
||||||
|
|
||||||
T__WSAFDIsSet = function (s: TSocket; var FDSet: TFDSet): Bool;
|
T__WSAFDIsSet = function (s: TSocket; var FDSet: TFDSet): Bool;
|
||||||
@ -891,7 +890,7 @@ type
|
|||||||
case sin_family: u_short of
|
case sin_family: u_short of
|
||||||
AF_INET: (sin_port: u_short;
|
AF_INET: (sin_port: u_short;
|
||||||
sin_addr: TInAddr;
|
sin_addr: TInAddr;
|
||||||
sin_zero: array[0..7] of Char);
|
sin_zero: array[0..7] of byte);
|
||||||
AF_INET6: (sin6_port: u_short;
|
AF_INET6: (sin6_port: u_short;
|
||||||
sin6_flowinfo: u_long;
|
sin6_flowinfo: u_long;
|
||||||
sin6_addr: TInAddr6;
|
sin6_addr: TInAddr6;
|
||||||
@ -905,7 +904,7 @@ function Bind(s: TSocket; const addr: TVarSin): Integer;
|
|||||||
function Connect(s: TSocket; const name: TVarSin): Integer;
|
function Connect(s: TSocket; const name: TVarSin): Integer;
|
||||||
function GetSockName(s: TSocket; var name: TVarSin): Integer;
|
function GetSockName(s: TSocket; var name: TVarSin): Integer;
|
||||||
function GetPeerName(s: TSocket; var name: TVarSin): Integer;
|
function GetPeerName(s: TSocket; var name: TVarSin): Integer;
|
||||||
function GetHostName: string;
|
function GetHostName: AnsiString;
|
||||||
function Send(s: TSocket; Buf: TMemory; len, flags: Integer): Integer;
|
function Send(s: TSocket; Buf: TMemory; len, flags: Integer): Integer;
|
||||||
function Recv(s: TSocket; Buf: TMemory; len, flags: Integer): Integer;
|
function Recv(s: TSocket; Buf: TMemory; len, flags: Integer): Integer;
|
||||||
function SendTo(s: TSocket; Buf: TMemory; len, flags: Integer; addrto: TVarSin): Integer;
|
function SendTo(s: TSocket; Buf: TMemory; len, flags: Integer; addrto: TVarSin): Integer;
|
||||||
@ -913,12 +912,12 @@ function RecvFrom(s: TSocket; Buf: TMemory; len, flags: Integer; var from: TVarS
|
|||||||
function Accept(s: TSocket; var addr: TVarSin): TSocket;
|
function Accept(s: TSocket; var addr: TVarSin): TSocket;
|
||||||
|
|
||||||
function IsNewApi(Family: integer): Boolean;
|
function IsNewApi(Family: integer): Boolean;
|
||||||
function SetVarSin(var Sin: TVarSin; IP, Port: string; Family, SockProtocol, SockType: integer; PreferIP4: Boolean): integer;
|
function SetVarSin(var Sin: TVarSin; IP, Port: AnsiString; Family, SockProtocol, SockType: integer; PreferIP4: Boolean): integer;
|
||||||
function GetSinIP(Sin: TVarSin): string;
|
function GetSinIP(Sin: TVarSin): AnsiString;
|
||||||
function GetSinPort(Sin: TVarSin): Integer;
|
function GetSinPort(Sin: TVarSin): Integer;
|
||||||
procedure ResolveNameToIP(Name: string; Family, SockProtocol, SockType: integer; const IPList: TStrings);
|
procedure ResolveNameToIP(Name: AnsiString; Family, SockProtocol, SockType: integer; const IPList: TStrings);
|
||||||
function ResolveIPToName(IP: string; Family, SockProtocol, SockType: integer): string;
|
function ResolveIPToName(IP: AnsiString; Family, SockProtocol, SockType: integer): AnsiString;
|
||||||
function ResolvePort(Port: string; Family, SockProtocol, SockType: integer): Word;
|
function ResolvePort(Port: AnsiString; Family, SockProtocol, SockType: integer): Word;
|
||||||
|
|
||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
implementation
|
implementation
|
||||||
@ -1058,14 +1057,14 @@ begin
|
|||||||
Result := ssGetPeerName(s, @name, Len);
|
Result := ssGetPeerName(s, @name, Len);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetHostName: string;
|
function GetHostName: AnsiString;
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
setlength(s, 255);
|
setlength(s, 255);
|
||||||
ssGetHostName(pchar(s), Length(s) - 1);
|
ssGetHostName(pAnsichar(s), Length(s) - 1);
|
||||||
Result := Pchar(s);
|
Result := PAnsichar(s);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Send(s: TSocket; Buf: TMemory; len, flags: Integer): Integer;
|
function Send(s: TSocket; Buf: TMemory; len, flags: Integer): Integer;
|
||||||
@ -1107,7 +1106,7 @@ begin
|
|||||||
Result := (Family = AF_INET6) and SockWship6Api;
|
Result := (Family = AF_INET6) and SockWship6Api;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SetVarSin(var Sin: TVarSin; IP, Port: string; Family, SockProtocol, SockType: integer; PreferIP4: Boolean): integer;
|
function SetVarSin(var Sin: TVarSin; IP, Port: AnsiString; Family, SockProtocol, SockType: integer; PreferIP4: Boolean): integer;
|
||||||
type
|
type
|
||||||
pu_long = ^u_long;
|
pu_long = ^u_long;
|
||||||
var
|
var
|
||||||
@ -1119,7 +1118,7 @@ var
|
|||||||
Sin1, Sin2: TVarSin;
|
Sin1, Sin2: TVarSin;
|
||||||
TwoPass: boolean;
|
TwoPass: boolean;
|
||||||
|
|
||||||
function GetAddr(const IP, port: string; Hints: TAddrInfo; var Sin: TVarSin): integer;
|
function GetAddr(const IP, port: AnsiString; Hints: TAddrInfo; var Sin: TVarSin): integer;
|
||||||
var
|
var
|
||||||
Addr: PAddrInfo;
|
Addr: PAddrInfo;
|
||||||
begin
|
begin
|
||||||
@ -1130,23 +1129,23 @@ var
|
|||||||
begin
|
begin
|
||||||
Hints.ai_socktype := 0;
|
Hints.ai_socktype := 0;
|
||||||
Hints.ai_protocol := 0;
|
Hints.ai_protocol := 0;
|
||||||
Result := synsock.GetAddrInfo(PChar(IP), nil, @Hints, Addr);
|
Result := synsock.GetAddrInfo(PAnsiChar(IP), nil, @Hints, Addr);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
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 := synsock.GetAddrInfo(nil, PChar(Port), @Hints, Addr);
|
Result := synsock.GetAddrInfo(nil, PAnsiChar(Port), @Hints, Addr);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (IP = cLocalhost) or (IP = c6Localhost) then
|
if (IP = cLocalhost) or (IP = c6Localhost) then
|
||||||
begin
|
begin
|
||||||
Result := synsock.GetAddrInfo(nil, PChar(Port), @Hints, Addr);
|
Result := synsock.GetAddrInfo(nil, PAnsiChar(Port), @Hints, Addr);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Result := synsock.GetAddrInfo(PChar(IP), PChar(Port), @Hints, Addr);
|
Result := synsock.GetAddrInfo(PAnsiChar(IP), PAnsiChar(Port), @Hints, Addr);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if Result = 0 then
|
if Result = 0 then
|
||||||
@ -1169,7 +1168,7 @@ begin
|
|||||||
ProtoEnt := synsock.GetProtoByNumber(SockProtocol);
|
ProtoEnt := synsock.GetProtoByNumber(SockProtocol);
|
||||||
ServEnt := nil;
|
ServEnt := nil;
|
||||||
if ProtoEnt <> nil then
|
if ProtoEnt <> nil then
|
||||||
ServEnt := synsock.GetServByName(PChar(Port), ProtoEnt^.p_name);
|
ServEnt := synsock.GetServByName(PAnsiChar(Port), ProtoEnt^.p_name);
|
||||||
if ServEnt = nil then
|
if ServEnt = nil then
|
||||||
Sin.sin_port := synsock.htons(StrToIntDef(Port, 0))
|
Sin.sin_port := synsock.htons(StrToIntDef(Port, 0))
|
||||||
else
|
else
|
||||||
@ -1178,10 +1177,10 @@ begin
|
|||||||
Sin.sin_addr.s_addr := u_long(INADDR_BROADCAST)
|
Sin.sin_addr.s_addr := u_long(INADDR_BROADCAST)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Sin.sin_addr.s_addr := synsock.inet_addr(PChar(IP));
|
Sin.sin_addr.s_addr := synsock.inet_addr(PAnsiChar(IP));
|
||||||
if Sin.sin_addr.s_addr = u_long(INADDR_NONE) then
|
if Sin.sin_addr.s_addr = u_long(INADDR_NONE) then
|
||||||
begin
|
begin
|
||||||
HostEnt := synsock.GetHostByName(PChar(IP));
|
HostEnt := synsock.GetHostByName(PAnsiChar(IP));
|
||||||
Result := synsock.WSAGetLastError;
|
Result := synsock.WSAGetLastError;
|
||||||
if HostEnt <> nil then
|
if HostEnt <> nil then
|
||||||
Sin.sin_addr.S_addr := u_long(Pu_long(HostEnt^.h_addr_list^)^);
|
Sin.sin_addr.S_addr := u_long(Pu_long(HostEnt^.h_addr_list^)^);
|
||||||
@ -1233,10 +1232,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetSinIP(Sin: TVarSin): string;
|
function GetSinIP(Sin: TVarSin): AnsiString;
|
||||||
var
|
var
|
||||||
p: PChar;
|
p: PAnsiChar;
|
||||||
host, serv: string;
|
host, serv: AnsiString;
|
||||||
hostlen, servlen: integer;
|
hostlen, servlen: integer;
|
||||||
r: integer;
|
r: integer;
|
||||||
begin
|
begin
|
||||||
@ -1253,10 +1252,10 @@ begin
|
|||||||
servlen := NI_MAXSERV;
|
servlen := NI_MAXSERV;
|
||||||
setlength(host, hostlen);
|
setlength(host, hostlen);
|
||||||
setlength(serv, servlen);
|
setlength(serv, servlen);
|
||||||
r := getnameinfo(@sin, SizeOfVarSin(sin), PChar(host), hostlen,
|
r := getnameinfo(@sin, SizeOfVarSin(sin), PAnsiChar(host), hostlen,
|
||||||
PChar(serv), servlen, NI_NUMERICHOST + NI_NUMERICSERV);
|
PAnsiChar(serv), servlen, NI_NUMERICHOST + NI_NUMERICSERV);
|
||||||
if r = 0 then
|
if r = 0 then
|
||||||
Result := PChar(host);
|
Result := PAnsiChar(host);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1268,7 +1267,7 @@ begin
|
|||||||
Result := synsock.ntohs(Sin.sin_port);
|
Result := synsock.ntohs(Sin.sin_port);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ResolveNameToIP(Name: string; Family, SockProtocol, SockType: integer; const IPList: TStrings);
|
procedure ResolveNameToIP(Name: AnsiString; Family, SockProtocol, SockType: integer; const IPList: TStrings);
|
||||||
type
|
type
|
||||||
TaPInAddr = array[0..250] of PInAddr;
|
TaPInAddr = array[0..250] of PInAddr;
|
||||||
PaPInAddr = ^TaPInAddr;
|
PaPInAddr = ^TaPInAddr;
|
||||||
@ -1277,24 +1276,24 @@ var
|
|||||||
Addr: PAddrInfo;
|
Addr: PAddrInfo;
|
||||||
AddrNext: PAddrInfo;
|
AddrNext: PAddrInfo;
|
||||||
r: integer;
|
r: integer;
|
||||||
host, serv: string;
|
host, serv: AnsiString;
|
||||||
hostlen, servlen: integer;
|
hostlen, servlen: integer;
|
||||||
RemoteHost: PHostEnt;
|
RemoteHost: PHostEnt;
|
||||||
IP: u_long;
|
IP: u_long;
|
||||||
PAdrPtr: PaPInAddr;
|
PAdrPtr: PaPInAddr;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
s: string;
|
s: AnsiString;
|
||||||
InAddr: TInAddr;
|
InAddr: TInAddr;
|
||||||
begin
|
begin
|
||||||
IPList.Clear;
|
IPList.Clear;
|
||||||
if not IsNewApi(Family) then
|
if not IsNewApi(Family) then
|
||||||
begin
|
begin
|
||||||
IP := synsock.inet_addr(PChar(Name));
|
IP := synsock.inet_addr(PAnsiChar(Name));
|
||||||
if IP = u_long(INADDR_NONE) then
|
if IP = u_long(INADDR_NONE) then
|
||||||
begin
|
begin
|
||||||
SynSockCS.Enter;
|
SynSockCS.Enter;
|
||||||
try
|
try
|
||||||
RemoteHost := synsock.GetHostByName(PChar(Name));
|
RemoteHost := synsock.GetHostByName(PAnsiChar(Name));
|
||||||
if RemoteHost <> nil then
|
if RemoteHost <> nil then
|
||||||
begin
|
begin
|
||||||
PAdrPtr := PAPInAddr(RemoteHost^.h_addr_list);
|
PAdrPtr := PAPInAddr(RemoteHost^.h_addr_list);
|
||||||
@ -1324,7 +1323,7 @@ begin
|
|||||||
Hints.ai_socktype := SockType;
|
Hints.ai_socktype := SockType;
|
||||||
Hints.ai_protocol := SockProtocol;
|
Hints.ai_protocol := SockProtocol;
|
||||||
Hints.ai_flags := 0;
|
Hints.ai_flags := 0;
|
||||||
r := synsock.GetAddrInfo(PChar(Name), nil, @Hints, Addr);
|
r := synsock.GetAddrInfo(PAnsiChar(Name), nil, @Hints, Addr);
|
||||||
if r = 0 then
|
if r = 0 then
|
||||||
begin
|
begin
|
||||||
AddrNext := Addr;
|
AddrNext := Addr;
|
||||||
@ -1338,11 +1337,11 @@ begin
|
|||||||
setlength(host, hostlen);
|
setlength(host, hostlen);
|
||||||
setlength(serv, servlen);
|
setlength(serv, servlen);
|
||||||
r := getnameinfo(AddrNext^.ai_addr, AddrNext^.ai_addrlen,
|
r := getnameinfo(AddrNext^.ai_addr, AddrNext^.ai_addrlen,
|
||||||
PChar(host), hostlen, PChar(serv), servlen,
|
PAnsiChar(host), hostlen, PAnsiChar(serv), servlen,
|
||||||
NI_NUMERICHOST + NI_NUMERICSERV);
|
NI_NUMERICHOST + NI_NUMERICSERV);
|
||||||
if r = 0 then
|
if r = 0 then
|
||||||
begin
|
begin
|
||||||
host := PChar(host);
|
host := PAnsiChar(host);
|
||||||
IPList.Add(host);
|
IPList.Add(host);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1358,7 +1357,7 @@ begin
|
|||||||
IPList.Add(cAnyHost);
|
IPList.Add(cAnyHost);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ResolvePort(Port: string; Family, SockProtocol, SockType: integer): Word;
|
function ResolvePort(Port: AnsiString; Family, SockProtocol, SockType: integer): Word;
|
||||||
var
|
var
|
||||||
ProtoEnt: PProtoEnt;
|
ProtoEnt: PProtoEnt;
|
||||||
ServEnt: PServEnt;
|
ServEnt: PServEnt;
|
||||||
@ -1374,7 +1373,7 @@ begin
|
|||||||
ProtoEnt := synsock.GetProtoByNumber(SockProtocol);
|
ProtoEnt := synsock.GetProtoByNumber(SockProtocol);
|
||||||
ServEnt := nil;
|
ServEnt := nil;
|
||||||
if ProtoEnt <> nil then
|
if ProtoEnt <> nil then
|
||||||
ServEnt := synsock.GetServByName(PChar(Port), ProtoEnt^.p_name);
|
ServEnt := synsock.GetServByName(PAnsiChar(Port), ProtoEnt^.p_name);
|
||||||
if ServEnt = nil then
|
if ServEnt = nil then
|
||||||
Result := StrToIntDef(Port, 0)
|
Result := StrToIntDef(Port, 0)
|
||||||
else
|
else
|
||||||
@ -1392,7 +1391,7 @@ begin
|
|||||||
Hints.ai_socktype := SockType;
|
Hints.ai_socktype := SockType;
|
||||||
Hints.ai_protocol := Sockprotocol;
|
Hints.ai_protocol := Sockprotocol;
|
||||||
Hints.ai_flags := AI_PASSIVE;
|
Hints.ai_flags := AI_PASSIVE;
|
||||||
r := synsock.GetAddrInfo(nil, PChar(Port), @Hints, Addr);
|
r := synsock.GetAddrInfo(nil, PAnsiChar(Port), @Hints, Addr);
|
||||||
if (r = 0) and Assigned(Addr) then
|
if (r = 0) and Assigned(Addr) then
|
||||||
begin
|
begin
|
||||||
if Addr^.ai_family = AF_INET then
|
if Addr^.ai_family = AF_INET then
|
||||||
@ -1407,12 +1406,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ResolveIPToName(IP: string; Family, SockProtocol, SockType: integer): string;
|
function ResolveIPToName(IP: AnsiString; Family, SockProtocol, SockType: integer): AnsiString;
|
||||||
var
|
var
|
||||||
Hints: TAddrInfo;
|
Hints: TAddrInfo;
|
||||||
Addr: PAddrInfo;
|
Addr: PAddrInfo;
|
||||||
r: integer;
|
r: integer;
|
||||||
host, serv: string;
|
host, serv: AnsiString;
|
||||||
hostlen, servlen: integer;
|
hostlen, servlen: integer;
|
||||||
RemoteHost: PHostEnt;
|
RemoteHost: PHostEnt;
|
||||||
IPn: u_long;
|
IPn: u_long;
|
||||||
@ -1420,7 +1419,7 @@ begin
|
|||||||
Result := IP;
|
Result := IP;
|
||||||
if not IsNewApi(Family) then
|
if not IsNewApi(Family) then
|
||||||
begin
|
begin
|
||||||
IPn := synsock.inet_addr(PChar(IP));
|
IPn := synsock.inet_addr(PAnsiChar(IP));
|
||||||
if IPn <> u_long(INADDR_NONE) then
|
if IPn <> u_long(INADDR_NONE) then
|
||||||
begin
|
begin
|
||||||
SynSockCS.Enter;
|
SynSockCS.Enter;
|
||||||
@ -1442,7 +1441,7 @@ begin
|
|||||||
Hints.ai_socktype := SockType;
|
Hints.ai_socktype := SockType;
|
||||||
Hints.ai_protocol := SockProtocol;
|
Hints.ai_protocol := SockProtocol;
|
||||||
Hints.ai_flags := 0;
|
Hints.ai_flags := 0;
|
||||||
r := synsock.GetAddrInfo(PChar(IP), nil, @Hints, Addr);
|
r := synsock.GetAddrInfo(PAnsiChar(IP), nil, @Hints, Addr);
|
||||||
if (r = 0) and Assigned(Addr)then
|
if (r = 0) and Assigned(Addr)then
|
||||||
begin
|
begin
|
||||||
hostlen := NI_MAXHOST;
|
hostlen := NI_MAXHOST;
|
||||||
@ -1450,10 +1449,10 @@ begin
|
|||||||
setlength(host, hostlen);
|
setlength(host, hostlen);
|
||||||
setlength(serv, servlen);
|
setlength(serv, servlen);
|
||||||
r := getnameinfo(Addr^.ai_addr, Addr^.ai_addrlen,
|
r := getnameinfo(Addr^.ai_addr, Addr^.ai_addrlen,
|
||||||
PChar(host), hostlen, PChar(serv), servlen,
|
PAnsiChar(host), hostlen, PAnsiChar(serv), servlen,
|
||||||
NI_NUMERICSERV);
|
NI_NUMERICSERV);
|
||||||
if r = 0 then
|
if r = 0 then
|
||||||
Result := PChar(host);
|
Result := PAnsiChar(host);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
if Assigned(Addr) then
|
if Assigned(Addr) then
|
||||||
@ -1464,7 +1463,7 @@ end;
|
|||||||
|
|
||||||
{=============================================================================}
|
{=============================================================================}
|
||||||
|
|
||||||
function InitSocketInterface(stack: string): Boolean;
|
function InitSocketInterface(stack: String): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
SockEnhancedApi := False;
|
SockEnhancedApi := False;
|
||||||
@ -1479,46 +1478,46 @@ begin
|
|||||||
LibHandle := LoadLibrary(PChar(Stack));
|
LibHandle := LoadLibrary(PChar(Stack));
|
||||||
if LibHandle <> 0 then
|
if LibHandle <> 0 then
|
||||||
begin
|
begin
|
||||||
WSAIoctl := GetProcAddress(LibHandle, PChar('WSAIoctl'));
|
WSAIoctl := GetProcAddress(LibHandle, PAnsiChar(AnsiString('WSAIoctl')));
|
||||||
__WSAFDIsSet := GetProcAddress(LibHandle, PChar('__WSAFDIsSet'));
|
__WSAFDIsSet := GetProcAddress(LibHandle, PAnsiChar(AnsiString('__WSAFDIsSet')));
|
||||||
CloseSocket := GetProcAddress(LibHandle, PChar('closesocket'));
|
CloseSocket := GetProcAddress(LibHandle, PAnsiChar(AnsiString('closesocket')));
|
||||||
IoctlSocket := GetProcAddress(LibHandle, PChar('ioctlsocket'));
|
IoctlSocket := GetProcAddress(LibHandle, PAnsiChar(AnsiString('ioctlsocket')));
|
||||||
WSAGetLastError := GetProcAddress(LibHandle, PChar('WSAGetLastError'));
|
WSAGetLastError := GetProcAddress(LibHandle, PAnsiChar(AnsiString('WSAGetLastError')));
|
||||||
WSAStartup := GetProcAddress(LibHandle, PChar('WSAStartup'));
|
WSAStartup := GetProcAddress(LibHandle, PAnsiChar(AnsiString('WSAStartup')));
|
||||||
WSACleanup := GetProcAddress(LibHandle, PChar('WSACleanup'));
|
WSACleanup := GetProcAddress(LibHandle, PAnsiChar(AnsiString('WSACleanup')));
|
||||||
ssAccept := GetProcAddress(LibHandle, PChar('accept'));
|
ssAccept := GetProcAddress(LibHandle, PAnsiChar(AnsiString('accept')));
|
||||||
ssBind := GetProcAddress(LibHandle, PChar('bind'));
|
ssBind := GetProcAddress(LibHandle, PAnsiChar(AnsiString('bind')));
|
||||||
ssConnect := GetProcAddress(LibHandle, PChar('connect'));
|
ssConnect := GetProcAddress(LibHandle, PAnsiChar(AnsiString('connect')));
|
||||||
ssGetPeerName := GetProcAddress(LibHandle, PChar('getpeername'));
|
ssGetPeerName := GetProcAddress(LibHandle, PAnsiChar(AnsiString('getpeername')));
|
||||||
ssGetSockName := GetProcAddress(LibHandle, PChar('getsockname'));
|
ssGetSockName := GetProcAddress(LibHandle, PAnsiChar(AnsiString('getsockname')));
|
||||||
GetSockOpt := GetProcAddress(LibHandle, PChar('getsockopt'));
|
GetSockOpt := GetProcAddress(LibHandle, PAnsiChar(AnsiString('getsockopt')));
|
||||||
Htonl := GetProcAddress(LibHandle, PChar('htonl'));
|
Htonl := GetProcAddress(LibHandle, PAnsiChar(AnsiString('htonl')));
|
||||||
Htons := GetProcAddress(LibHandle, PChar('htons'));
|
Htons := GetProcAddress(LibHandle, PAnsiChar(AnsiString('htons')));
|
||||||
Inet_Addr := GetProcAddress(LibHandle, PChar('inet_addr'));
|
Inet_Addr := GetProcAddress(LibHandle, PAnsiChar(AnsiString('inet_addr')));
|
||||||
Inet_Ntoa := GetProcAddress(LibHandle, PChar('inet_ntoa'));
|
Inet_Ntoa := GetProcAddress(LibHandle, PAnsiChar(AnsiString('inet_ntoa')));
|
||||||
Listen := GetProcAddress(LibHandle, PChar('listen'));
|
Listen := GetProcAddress(LibHandle, PAnsiChar(AnsiString('listen')));
|
||||||
Ntohl := GetProcAddress(LibHandle, PChar('ntohl'));
|
Ntohl := GetProcAddress(LibHandle, PAnsiChar(AnsiString('ntohl')));
|
||||||
Ntohs := GetProcAddress(LibHandle, PChar('ntohs'));
|
Ntohs := GetProcAddress(LibHandle, PAnsiChar(AnsiString('ntohs')));
|
||||||
ssRecv := GetProcAddress(LibHandle, PChar('recv'));
|
ssRecv := GetProcAddress(LibHandle, PAnsiChar(AnsiString('recv')));
|
||||||
ssRecvFrom := GetProcAddress(LibHandle, PChar('recvfrom'));
|
ssRecvFrom := GetProcAddress(LibHandle, PAnsiChar(AnsiString('recvfrom')));
|
||||||
Select := GetProcAddress(LibHandle, PChar('select'));
|
Select := GetProcAddress(LibHandle, PAnsiChar(AnsiString('select')));
|
||||||
ssSend := GetProcAddress(LibHandle, PChar('send'));
|
ssSend := GetProcAddress(LibHandle, PAnsiChar(AnsiString('send')));
|
||||||
ssSendTo := GetProcAddress(LibHandle, PChar('sendto'));
|
ssSendTo := GetProcAddress(LibHandle, PAnsiChar(AnsiString('sendto')));
|
||||||
SetSockOpt := GetProcAddress(LibHandle, PChar('setsockopt'));
|
SetSockOpt := GetProcAddress(LibHandle, PAnsiChar(AnsiString('setsockopt')));
|
||||||
ShutDown := GetProcAddress(LibHandle, PChar('shutdown'));
|
ShutDown := GetProcAddress(LibHandle, PAnsiChar(AnsiString('shutdown')));
|
||||||
Socket := GetProcAddress(LibHandle, PChar('socket'));
|
Socket := GetProcAddress(LibHandle, PAnsiChar(AnsiString('socket')));
|
||||||
GetHostByAddr := GetProcAddress(LibHandle, PChar('gethostbyaddr'));
|
GetHostByAddr := GetProcAddress(LibHandle, PAnsiChar(AnsiString('gethostbyaddr')));
|
||||||
GetHostByName := GetProcAddress(LibHandle, PChar('gethostbyname'));
|
GetHostByName := GetProcAddress(LibHandle, PAnsiChar(AnsiString('gethostbyname')));
|
||||||
GetProtoByName := GetProcAddress(LibHandle, PChar('getprotobyname'));
|
GetProtoByName := GetProcAddress(LibHandle, PAnsiChar(AnsiString('getprotobyname')));
|
||||||
GetProtoByNumber := GetProcAddress(LibHandle, PChar('getprotobynumber'));
|
GetProtoByNumber := GetProcAddress(LibHandle, PAnsiChar(AnsiString('getprotobynumber')));
|
||||||
GetServByName := GetProcAddress(LibHandle, PChar('getservbyname'));
|
GetServByName := GetProcAddress(LibHandle, PAnsiChar(AnsiString('getservbyname')));
|
||||||
GetServByPort := GetProcAddress(LibHandle, PChar('getservbyport'));
|
GetServByPort := GetProcAddress(LibHandle, PAnsiChar(AnsiString('getservbyport')));
|
||||||
ssGetHostName := GetProcAddress(LibHandle, PChar('gethostname'));
|
ssGetHostName := GetProcAddress(LibHandle, PAnsiChar(AnsiString('gethostname')));
|
||||||
|
|
||||||
{$IFNDEF FORCEOLDAPI}
|
{$IFNDEF FORCEOLDAPI}
|
||||||
GetAddrInfo := GetProcAddress(LibHandle, PChar('getaddrinfo'));
|
GetAddrInfo := GetProcAddress(LibHandle, PAnsiChar(AnsiString('getaddrinfo')));
|
||||||
FreeAddrInfo := GetProcAddress(LibHandle, PChar('freeaddrinfo'));
|
FreeAddrInfo := GetProcAddress(LibHandle, PAnsiChar(AnsiString('freeaddrinfo')));
|
||||||
GetNameInfo := GetProcAddress(LibHandle, PChar('getnameinfo'));
|
GetNameInfo := GetProcAddress(LibHandle, PAnsiChar(AnsiString('getnameinfo')));
|
||||||
SockEnhancedApi := Assigned(GetAddrInfo) and Assigned(FreeAddrInfo)
|
SockEnhancedApi := Assigned(GetAddrInfo) and Assigned(FreeAddrInfo)
|
||||||
and Assigned(GetNameInfo);
|
and Assigned(GetNameInfo);
|
||||||
if not SockEnhancedApi then
|
if not SockEnhancedApi then
|
||||||
@ -1526,9 +1525,9 @@ begin
|
|||||||
LibWship6Handle := LoadLibrary(PChar(DLLWship6));
|
LibWship6Handle := LoadLibrary(PChar(DLLWship6));
|
||||||
if LibWship6Handle <> 0 then
|
if LibWship6Handle <> 0 then
|
||||||
begin
|
begin
|
||||||
GetAddrInfo := GetProcAddress(LibWship6Handle, PChar('getaddrinfo'));
|
GetAddrInfo := GetProcAddress(LibWship6Handle, PAnsiChar(AnsiString('getaddrinfo')));
|
||||||
FreeAddrInfo := GetProcAddress(LibWship6Handle, PChar('freeaddrinfo'));
|
FreeAddrInfo := GetProcAddress(LibWship6Handle, PAnsiChar(AnsiString('freeaddrinfo')));
|
||||||
GetNameInfo := GetProcAddress(LibWship6Handle, PChar('getnameinfo'));
|
GetNameInfo := GetProcAddress(LibWship6Handle, PAnsiChar(AnsiString('getnameinfo')));
|
||||||
SockWship6Api := Assigned(GetAddrInfo) and Assigned(FreeAddrInfo)
|
SockWship6Api := Assigned(GetAddrInfo) and Assigned(FreeAddrInfo)
|
||||||
and Assigned(GetNameInfo);
|
and Assigned(GetNameInfo);
|
||||||
end;
|
end;
|
||||||
@ -1583,5 +1582,4 @@ begin
|
|||||||
SynSockCS.Free;
|
SynSockCS.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.000.000 |
|
| Project : Ararat Synapse | 001.001.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Socket debug tools |
|
| Content: Socket debug tools |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -61,14 +61,14 @@ type
|
|||||||
class procedure HookMonitor(Sender: TObject; Writing: Boolean; const Buffer: TMemory; Len: Integer);
|
class procedure HookMonitor(Sender: TObject; Writing: Boolean; const Buffer: TMemory; Len: Integer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure AppendToLog(const value: string);
|
procedure AppendToLog(const value: Ansistring);
|
||||||
|
|
||||||
var
|
var
|
||||||
LogFile: string;
|
LogFile: string;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure AppendToLog(const value: string);
|
procedure AppendToLog(const value: Ansistring);
|
||||||
var
|
var
|
||||||
st: TFileStream;
|
st: TFileStream;
|
||||||
s: string;
|
s: string;
|
||||||
@ -132,7 +132,7 @@ end;
|
|||||||
|
|
||||||
class procedure TSynaDebug.HookMonitor(Sender: TObject; Writing: Boolean; const Buffer: TMemory; Len: Integer);
|
class procedure TSynaDebug.HookMonitor(Sender: TObject; Writing: Boolean; const Buffer: TMemory; Len: Integer);
|
||||||
var
|
var
|
||||||
s, d: string;
|
s, d: Ansistring;
|
||||||
begin
|
begin
|
||||||
setlength(s, len);
|
setlength(s, len);
|
||||||
move(Buffer^, pointer(s)^, len);
|
move(Buffer^, pointer(s)^, len);
|
||||||
|
30
synaicnv.pas
30
synaicnv.pas
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.000.002 |
|
| Project : Ararat Synapse | 001.001.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: ICONV support for Win32, Linux and .NET |
|
| Content: ICONV support for Win32, Linux and .NET |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)2004, Lukas Gebauer |
|
| Copyright (c)2004-2008, Lukas Gebauer |
|
||||||
| All rights reserved. |
|
| All rights reserved. |
|
||||||
| |
|
| |
|
||||||
| Redistribution and use in source and binary forms, with or without |
|
| Redistribution and use in source and binary forms, with or without |
|
||||||
@ -33,7 +33,7 @@
|
|||||||
| DAMAGE. |
|
| DAMAGE. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
||||||
| Portions created by Lukas Gebauer are Copyright (c)2004. |
|
| Portions created by Lukas Gebauer are Copyright (c)2004-2008. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -92,9 +92,9 @@ type
|
|||||||
var
|
var
|
||||||
iconvLibHandle: TLibHandle = 0;
|
iconvLibHandle: TLibHandle = 0;
|
||||||
|
|
||||||
function SynaIconvOpen(const tocode, fromcode: string): iconv_t;
|
function SynaIconvOpen(const tocode, fromcode: Ansistring): iconv_t;
|
||||||
function SynaIconvOpenTranslit(const tocode, fromcode: string): iconv_t;
|
function SynaIconvOpenTranslit(const tocode, fromcode: Ansistring): iconv_t;
|
||||||
function SynaIconvOpenIgnore(const tocode, fromcode: string): iconv_t;
|
function SynaIconvOpenIgnore(const tocode, fromcode: Ansistring): iconv_t;
|
||||||
function SynaIconv(cd: iconv_t; inbuf: AnsiString; var outbuf: AnsiString): integer;
|
function SynaIconv(cd: iconv_t; inbuf: AnsiString; var outbuf: AnsiString): integer;
|
||||||
function SynaIconvClose(var cd: iconv_t): integer;
|
function SynaIconvClose(var cd: iconv_t): integer;
|
||||||
function SynaIconvCtl(cd: iconv_t; request: integer; argument: argptr): integer;
|
function SynaIconvCtl(cd: iconv_t; request: integer; argument: argptr): integer;
|
||||||
@ -139,7 +139,7 @@ uses SyncObjs;
|
|||||||
|
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
type
|
type
|
||||||
Ticonv_open = function(tocode: pchar; fromcode: pchar): iconv_t; cdecl;
|
Ticonv_open = function(tocode: pAnsichar; fromcode: pAnsichar): iconv_t; cdecl;
|
||||||
Ticonv = function(cd: iconv_t; var inbuf: pointer; var inbytesleft: size_t;
|
Ticonv = function(cd: iconv_t; var inbuf: pointer; var inbytesleft: size_t;
|
||||||
var outbuf: pointer; var outbytesleft: size_t): size_t; cdecl;
|
var outbuf: pointer; var outbytesleft: size_t): size_t; cdecl;
|
||||||
Ticonv_close = function(cd: iconv_t): integer; cdecl;
|
Ticonv_close = function(cd: iconv_t): integer; cdecl;
|
||||||
@ -156,7 +156,7 @@ var
|
|||||||
IconvCS: TCriticalSection;
|
IconvCS: TCriticalSection;
|
||||||
Iconvloaded: boolean = false;
|
Iconvloaded: boolean = false;
|
||||||
|
|
||||||
function SynaIconvOpen (const tocode, fromcode: string): iconv_t;
|
function SynaIconvOpen (const tocode, fromcode: Ansistring): iconv_t;
|
||||||
begin
|
begin
|
||||||
{$IFDEF CIL}
|
{$IFDEF CIL}
|
||||||
try
|
try
|
||||||
@ -167,18 +167,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
if InitIconvInterface and Assigned(_iconv_open) then
|
if InitIconvInterface and Assigned(_iconv_open) then
|
||||||
Result := _iconv_open(PChar(tocode), PChar(fromcode))
|
Result := _iconv_open(PAnsiChar(tocode), PAnsiChar(fromcode))
|
||||||
else
|
else
|
||||||
Result := iconv_t(-1);
|
Result := iconv_t(-1);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SynaIconvOpenTranslit (const tocode, fromcode: string): iconv_t;
|
function SynaIconvOpenTranslit (const tocode, fromcode: Ansistring): iconv_t;
|
||||||
begin
|
begin
|
||||||
Result := SynaIconvOpen(tocode + '//IGNORE//TRANSLIT', fromcode);
|
Result := SynaIconvOpen(tocode + '//IGNORE//TRANSLIT', fromcode);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SynaIconvOpenIgnore (const tocode, fromcode: string): iconv_t;
|
function SynaIconvOpenIgnore (const tocode, fromcode: Ansistring): iconv_t;
|
||||||
begin
|
begin
|
||||||
Result := SynaIconvOpen(tocode + '//IGNORE', fromcode);
|
Result := SynaIconvOpen(tocode + '//IGNORE', fromcode);
|
||||||
end;
|
end;
|
||||||
@ -283,10 +283,10 @@ begin
|
|||||||
if (IconvLibHandle <> 0) then
|
if (IconvLibHandle <> 0) then
|
||||||
begin
|
begin
|
||||||
{$IFNDEF CIL}
|
{$IFNDEF CIL}
|
||||||
_iconv_open := GetProcAddress(IconvLibHandle, Pchar('libiconv_open'));
|
_iconv_open := GetProcAddress(IconvLibHandle, PAnsiChar(AnsiString('libiconv_open')));
|
||||||
_iconv := GetProcAddress(IconvLibHandle, Pchar('libiconv'));
|
_iconv := GetProcAddress(IconvLibHandle, PAnsiChar(AnsiString('libiconv')));
|
||||||
_iconv_close := GetProcAddress(IconvLibHandle, Pchar('libiconv_close'));
|
_iconv_close := GetProcAddress(IconvLibHandle, PAnsiChar(AnsiString('libiconv_close')));
|
||||||
_iconvctl := GetProcAddress(IconvLibHandle, Pchar('libiconvctl'));
|
_iconvctl := GetProcAddress(IconvLibHandle, PAnsiChar(AnsiString('libiconvctl')));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result := True;
|
Result := True;
|
||||||
Iconvloaded := True;
|
Iconvloaded := True;
|
||||||
|
10
synaip.pas
10
synaip.pas
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.000.002 |
|
| Project : Ararat Synapse | 001.001.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: IP address support procedures and functions |
|
| Content: IP address support procedures and functions |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)2006, Lukas Gebauer |
|
| Copyright (c)2006-2008, Lukas Gebauer |
|
||||||
| All rights reserved. |
|
| All rights reserved. |
|
||||||
| |
|
| |
|
||||||
| Redistribution and use in source and binary forms, with or without |
|
| Redistribution and use in source and binary forms, with or without |
|
||||||
@ -33,7 +33,7 @@
|
|||||||
| DAMAGE. |
|
| DAMAGE. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
||||||
| Portions created by Lukas Gebauer are Copyright (c) 2006. |
|
| Portions created by Lukas Gebauer are Copyright (c) 2006-2008. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -71,7 +71,7 @@ function IsIP(const Value: string): Boolean;
|
|||||||
function IsIP6(const Value: string): Boolean;
|
function IsIP6(const Value: string): Boolean;
|
||||||
|
|
||||||
{:Returns a string with the "Host" ip address converted to binary form.}
|
{:Returns a string with the "Host" ip address converted to binary form.}
|
||||||
function IPToID(Host: string): string;
|
function IPToID(Host: string): Ansistring;
|
||||||
|
|
||||||
{:Convert IPv6 address from their string form to binary byte array.}
|
{:Convert IPv6 address from their string form to binary byte array.}
|
||||||
function StrToIp6(value: string): TIp6Bytes;
|
function StrToIp6(value: string): TIp6Bytes;
|
||||||
@ -180,7 +180,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
function IPToID(Host: string): string;
|
function IPToID(Host: string): Ansistring;
|
||||||
var
|
var
|
||||||
s: string;
|
s: string;
|
||||||
i, x: Integer;
|
i, x: Integer;
|
||||||
|
20
synamisc.pas
20
synamisc.pas
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.002.000 |
|
| Project : Ararat Synapse | 001.003.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: misc. procedures and functions |
|
| Content: misc. procedures and functions |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -104,8 +104,8 @@ implementation
|
|||||||
procedure WakeOnLan(MAC, IP: string);
|
procedure WakeOnLan(MAC, IP: string);
|
||||||
var
|
var
|
||||||
sock: TUDPBlockSocket;
|
sock: TUDPBlockSocket;
|
||||||
HexMac: string;
|
HexMac: Ansistring;
|
||||||
data: string;
|
data: Ansistring;
|
||||||
n: integer;
|
n: integer;
|
||||||
b: Byte;
|
b: Byte;
|
||||||
begin
|
begin
|
||||||
@ -144,7 +144,7 @@ end;
|
|||||||
function GetDNSbyIpHlp: string;
|
function GetDNSbyIpHlp: string;
|
||||||
type
|
type
|
||||||
PTIP_ADDRESS_STRING = ^TIP_ADDRESS_STRING;
|
PTIP_ADDRESS_STRING = ^TIP_ADDRESS_STRING;
|
||||||
TIP_ADDRESS_STRING = array[0..15] of char;
|
TIP_ADDRESS_STRING = array[0..15] of Ansichar;
|
||||||
PTIP_ADDR_STRING = ^TIP_ADDR_STRING;
|
PTIP_ADDR_STRING = ^TIP_ADDR_STRING;
|
||||||
TIP_ADDR_STRING = packed record
|
TIP_ADDR_STRING = packed record
|
||||||
Next: PTIP_ADDR_STRING;
|
Next: PTIP_ADDR_STRING;
|
||||||
@ -154,12 +154,12 @@ type
|
|||||||
end;
|
end;
|
||||||
PTFixedInfo = ^TFixedInfo;
|
PTFixedInfo = ^TFixedInfo;
|
||||||
TFixedInfo = packed record
|
TFixedInfo = packed record
|
||||||
HostName: array[1..128 + 4] of char;
|
HostName: array[1..128 + 4] of Ansichar;
|
||||||
DomainName: array[1..128 + 4] of char;
|
DomainName: array[1..128 + 4] of Ansichar;
|
||||||
CurrentDNSServer: PTIP_ADDR_STRING;
|
CurrentDNSServer: PTIP_ADDR_STRING;
|
||||||
DNSServerList: TIP_ADDR_STRING;
|
DNSServerList: TIP_ADDR_STRING;
|
||||||
NodeType: UINT;
|
NodeType: UINT;
|
||||||
ScopeID: array[1..256 + 4] of char;
|
ScopeID: array[1..256 + 4] of Ansichar;
|
||||||
EnableRouting: UINT;
|
EnableRouting: UINT;
|
||||||
EnableProxy: UINT;
|
EnableProxy: UINT;
|
||||||
EnableDNS: UINT;
|
EnableDNS: UINT;
|
||||||
@ -180,7 +180,7 @@ begin
|
|||||||
if IpHlpModule = 0 then
|
if IpHlpModule = 0 then
|
||||||
exit;
|
exit;
|
||||||
try
|
try
|
||||||
GetNetworkParams := GetProcAddress(IpHlpModule,'GetNetworkParams');
|
GetNetworkParams := GetProcAddress(IpHlpModule,PAnsiChar(AnsiString('GetNetworkParams')));
|
||||||
if @GetNetworkParams = nil then
|
if @GetNetworkParams = nil then
|
||||||
Exit;
|
Exit;
|
||||||
err := GetNetworkParams(Nil, @InfoSize);
|
err := GetNetworkParams(Nil, @InfoSize);
|
||||||
@ -225,7 +225,7 @@ begin
|
|||||||
DataType := REG_SZ;
|
DataType := REG_SZ;
|
||||||
DataSize := SizeOf(Temp);
|
DataSize := SizeOf(Temp);
|
||||||
if RegQueryValueEx(OpenKey, Vn, nil, @DataType, @Temp, @DataSize) = ERROR_SUCCESS then
|
if RegQueryValueEx(OpenKey, Vn, nil, @DataType, @Temp, @DataSize) = ERROR_SUCCESS then
|
||||||
Result := string(Temp);
|
SetString(Result, Temp, DataSize div SizeOf(Char) - 1);
|
||||||
RegCloseKey(OpenKey);
|
RegCloseKey(OpenKey);
|
||||||
end;
|
end;
|
||||||
end ;
|
end ;
|
||||||
@ -316,7 +316,7 @@ begin
|
|||||||
if WininetModule = 0 then
|
if WininetModule = 0 then
|
||||||
exit;
|
exit;
|
||||||
try
|
try
|
||||||
InternetQueryOption := GetProcAddress(WininetModule,'InternetQueryOptionA');
|
InternetQueryOption := GetProcAddress(WininetModule,PAnsiChar(AnsiString('InternetQueryOptionA')));
|
||||||
if @InternetQueryOption = nil then
|
if @InternetQueryOption = nil then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 007.002.000 |
|
| Project : Ararat Synapse | 007.003.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Serial port support |
|
| Content: Serial port support |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)2001-2007, Lukas Gebauer |
|
| Copyright (c)2001-2008, Lukas Gebauer |
|
||||||
| All rights reserved. |
|
| All rights reserved. |
|
||||||
| |
|
| |
|
||||||
| Redistribution and use in source and binary forms, with or without |
|
| Redistribution and use in source and binary forms, with or without |
|
||||||
@ -33,7 +33,7 @@
|
|||||||
| DAMAGE. |
|
| DAMAGE. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
||||||
| Portions created by Lukas Gebauer are Copyright (c)2001-2007. |
|
| Portions created by Lukas Gebauer are Copyright (c)2001-2008. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -1254,7 +1254,7 @@ var
|
|||||||
s: string;
|
s: string;
|
||||||
l: Integer;
|
l: Integer;
|
||||||
CorCRLF: Boolean;
|
CorCRLF: Boolean;
|
||||||
t: string;
|
t: ansistring;
|
||||||
tl: integer;
|
tl: integer;
|
||||||
ti: LongWord;
|
ti: LongWord;
|
||||||
begin
|
begin
|
||||||
|
19
synautil.pas
19
synautil.pas
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 004.012.000 |
|
| Project : Ararat Synapse | 004.013.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: support procedures and functions |
|
| Content: support procedures and functions |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -72,6 +72,11 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
SysUtils, Classes, SynaFpc;
|
SysUtils, Classes, SynaFpc;
|
||||||
|
|
||||||
|
{$IFDEF VER100}
|
||||||
|
type
|
||||||
|
int64 = integer;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
{:Return your timezone bias from UTC time in minutes.}
|
{:Return your timezone bias from UTC time in minutes.}
|
||||||
function TimeZoneBias: integer;
|
function TimeZoneBias: integer;
|
||||||
|
|
||||||
@ -226,7 +231,7 @@ function ParseURL(URL: string; var Prot, User, Pass, Host, Port, Path,
|
|||||||
|
|
||||||
{:Replaces all "Search" string values found within "Value" string, with the
|
{:Replaces all "Search" string values found within "Value" string, with the
|
||||||
"Replace" string value.}
|
"Replace" string value.}
|
||||||
function ReplaceString(Value, Search, Replace: string): string;
|
function ReplaceString(Value, Search, Replace: AnsiString): AnsiString;
|
||||||
|
|
||||||
{:It is like RPos, but search is from specified possition.}
|
{:It is like RPos, but search is from specified possition.}
|
||||||
function RPosEx(const Sub, Value: string; From: integer): Integer;
|
function RPosEx(const Sub, Value: string; From: integer): Integer;
|
||||||
@ -1283,7 +1288,7 @@ end;
|
|||||||
|
|
||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
|
|
||||||
function ReplaceString(Value, Search, Replace: string): string;
|
function ReplaceString(Value, Search, Replace: AnsiString): AnsiString;
|
||||||
var
|
var
|
||||||
x, l, ls, lr: Integer;
|
x, l, ls, lr: Integer;
|
||||||
begin
|
begin
|
||||||
@ -1489,7 +1494,7 @@ end;
|
|||||||
{$IFNDEF CIL}
|
{$IFNDEF CIL}
|
||||||
function IncPoint(const p: pointer; Value: integer): pointer;
|
function IncPoint(const p: pointer; Value: integer): pointer;
|
||||||
begin
|
begin
|
||||||
Result := PChar(p) + Value;
|
Result := PAnsiChar(p) + Value;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
@ -1664,7 +1669,7 @@ end;
|
|||||||
|
|
||||||
function SwapBytes(Value: integer): integer;
|
function SwapBytes(Value: integer): integer;
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
x, y, xl, yl: Byte;
|
x, y, xl, yl: Byte;
|
||||||
begin
|
begin
|
||||||
s := CodeLongInt(Value);
|
s := CodeLongInt(Value);
|
||||||
@ -1691,7 +1696,7 @@ begin
|
|||||||
Result := StringOf(Buf);
|
Result := StringOf(Buf);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Setlength(Result, Len);
|
Setlength(Result, Len);
|
||||||
x := Stream.read(Pchar(Result)^, Len);
|
x := Stream.read(PAnsiChar(Result)^, Len);
|
||||||
SetLength(Result, x);
|
SetLength(Result, x);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
@ -1708,7 +1713,7 @@ begin
|
|||||||
buf := BytesOf(Value);
|
buf := BytesOf(Value);
|
||||||
Stream.Write(buf,length(Value));
|
Stream.Write(buf,length(Value));
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Stream.Write(PChar(Value)^, Length(Value));
|
Stream.Write(PAnsiChar(Value)^, Length(Value));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
34
tlntsend.pas
34
tlntsend.pas
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.002.001 |
|
| Project : Ararat Synapse | 001.003.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: TELNET and SSH2 client |
|
| Content: TELNET and SSH2 client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2007, Lukas Gebauer |
|
| Copyright (c)1999-2008, Lukas Gebauer |
|
||||||
| All rights reserved. |
|
| All rights reserved. |
|
||||||
| |
|
| |
|
||||||
| Redistribution and use in source and binary forms, with or without |
|
| Redistribution and use in source and binary forms, with or without |
|
||||||
@ -33,7 +33,7 @@
|
|||||||
| DAMAGE. |
|
| DAMAGE. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
||||||
| Portions created by Lukas Gebauer are Copyright (c)2002-2007. |
|
| Portions created by Lukas Gebauer are Copyright (c)2002-2008. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -94,15 +94,15 @@ type
|
|||||||
TTelnetSend = class(TSynaClient)
|
TTelnetSend = class(TSynaClient)
|
||||||
private
|
private
|
||||||
FSock: TTCPBlockSocket;
|
FSock: TTCPBlockSocket;
|
||||||
FBuffer: string;
|
FBuffer: Ansistring;
|
||||||
FState: TTelnetState;
|
FState: TTelnetState;
|
||||||
FSessionLog: string;
|
FSessionLog: Ansistring;
|
||||||
FSubNeg: string;
|
FSubNeg: Ansistring;
|
||||||
FSubType: char;
|
FSubType: Ansichar;
|
||||||
FTermType: string;
|
FTermType: Ansistring;
|
||||||
function Connect: Boolean;
|
function Connect: Boolean;
|
||||||
function Negotiate(const Buf: string): string;
|
function Negotiate(const Buf: Ansistring): Ansistring;
|
||||||
procedure FilterHook(Sender: TObject; var Value: string);
|
procedure FilterHook(Sender: TObject; var Value: AnsiString);
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -136,10 +136,10 @@ type
|
|||||||
|
|
||||||
{:all readed datas in this session (from connect) is stored in this large
|
{:all readed datas in this session (from connect) is stored in this large
|
||||||
string.}
|
string.}
|
||||||
property SessionLog: string read FSessionLog write FSessionLog;
|
property SessionLog: Ansistring read FSessionLog write FSessionLog;
|
||||||
|
|
||||||
{:Terminal type indentification. By default is 'SYNAPSE'.}
|
{:Terminal type indentification. By default is 'SYNAPSE'.}
|
||||||
property TermType: string read FTermType write FTermType;
|
property TermType: Ansistring read FTermType write FTermType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -190,18 +190,18 @@ begin
|
|||||||
Result := FSock.RecvTerminated(FTimeout, Value) <> '';
|
Result := FSock.RecvTerminated(FTimeout, Value) <> '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTelnetSend.FilterHook(Sender: TObject; var Value: string);
|
procedure TTelnetSend.FilterHook(Sender: TObject; var Value: AnsiString);
|
||||||
begin
|
begin
|
||||||
Value := Negotiate(Value);
|
Value := Negotiate(Value);
|
||||||
FSessionLog := FSessionLog + Value;
|
FSessionLog := FSessionLog + Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TTelnetSend.Negotiate(const Buf: string): string;
|
function TTelnetSend.Negotiate(const Buf: Ansistring): Ansistring;
|
||||||
var
|
var
|
||||||
n: integer;
|
n: integer;
|
||||||
c: char;
|
c: Ansichar;
|
||||||
Reply: string;
|
Reply: Ansistring;
|
||||||
SubReply: string;
|
SubReply: Ansistring;
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
for n := 1 to Length(Buf) do
|
for n := 1 to Length(Buf) do
|
||||||
|
Loading…
Reference in New Issue
Block a user