mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-25 18:52:15 -05:00
Fixed issue with settings file being saved in the wrong directory.
Simba now has some parameters (-o/--open to open a file and -r/--run to run that file at startup). Simba now opens a file correctly if you double click an associated .simb file. Initalized several TPA-functions-results.. (BoxFromTPA could return random values when sending an empty TPA). Opening/Creating a 'script' will now happen in a new tab (unless the current tab is the same as the default script) Restructured the internets unit (+ implemented all of the HTTP-client stuff). And updated the Synapse units. git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@538 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
1865e848e2
commit
87c496ca85
@ -8,9 +8,6 @@ uses
|
|||||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||||
ComCtrls, StdCtrls, settings;
|
ComCtrls, StdCtrls, settings;
|
||||||
|
|
||||||
const
|
|
||||||
SimbaSettingsFile = 'settings.xml';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ TSettingsForm }
|
{ TSettingsForm }
|
||||||
@ -34,6 +31,7 @@ type
|
|||||||
|
|
||||||
var
|
var
|
||||||
SettingsForm: TSettingsForm;
|
SettingsForm: TSettingsForm;
|
||||||
|
SimbaSettingsFile : string;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ uses
|
|||||||
ColorBox , about, framefunctionlist, ocr, updateform, simbasettings;
|
ColorBox , about, framefunctionlist, ocr, updateform, simbasettings;
|
||||||
|
|
||||||
const
|
const
|
||||||
SimbaVersion = 537;
|
SimbaVersion = 538;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -342,6 +342,7 @@ type
|
|||||||
procedure RefreshTabSender(sender : PtrInt);
|
procedure RefreshTabSender(sender : PtrInt);
|
||||||
procedure CreateDefaultEnvironment;
|
procedure CreateDefaultEnvironment;
|
||||||
procedure InitalizeTMThread(var Thread : TMThread);
|
procedure InitalizeTMThread(var Thread : TMThread);
|
||||||
|
procedure HandleParameters;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure formWriteln( S : String);
|
procedure formWriteln( S : String);
|
||||||
@ -838,6 +839,7 @@ begin
|
|||||||
CreateSetting('Settings/Interpreter/UseCPascal', 'False');
|
CreateSetting('Settings/Interpreter/UseCPascal', 'False');
|
||||||
CreateSetting('Settings/Fonts/LoadOnStartUp', 'True');
|
CreateSetting('Settings/Fonts/LoadOnStartUp', 'True');
|
||||||
CreateSetting('Settings/Tabs/OpenNextOnClose','False');
|
CreateSetting('Settings/Tabs/OpenNextOnClose','False');
|
||||||
|
CreateSetting('Settings/Tabs/OpenScriptInNewTab','True');
|
||||||
CreateSetting('Settings/ColourPicker/ShowHistoryOnPick', 'True');
|
CreateSetting('Settings/ColourPicker/ShowHistoryOnPick', 'True');
|
||||||
CreateSetting('Settings/Updater/RemoteLink',
|
CreateSetting('Settings/Updater/RemoteLink',
|
||||||
'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS}+'.exe'{$ENDIF});
|
'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS}+'.exe'{$ENDIF});
|
||||||
@ -928,6 +930,34 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.HandleParameters;
|
||||||
|
var
|
||||||
|
DoRun : Boolean;
|
||||||
|
ErrorMsg : string;
|
||||||
|
begin
|
||||||
|
DoRun := false;
|
||||||
|
if Paramcount = 1 then
|
||||||
|
begin
|
||||||
|
if FileExists(ParamStr(1)) then
|
||||||
|
LoadScriptFile(paramstr(1));
|
||||||
|
end else
|
||||||
|
begin;
|
||||||
|
ErrorMsg:=Application.CheckOptions('ro:','run open:');
|
||||||
|
if ErrorMsg <> '' then
|
||||||
|
writeln(ErrorMSG)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if Application.HasOption('o','open') then
|
||||||
|
begin;
|
||||||
|
LoadScriptFile(Application.GetOptionValue('o','open'));
|
||||||
|
DoRun:= Application.HasOption('r','run');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if DoRun then
|
||||||
|
Self.RunScript;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TForm1.ActionTabLastExecute(Sender: TObject);
|
procedure TForm1.ActionTabLastExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
@ -1015,7 +1045,8 @@ end;
|
|||||||
|
|
||||||
procedure TForm1.ActionNewExecute(Sender: TObject);
|
procedure TForm1.ActionNewExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Self.ClearScript;
|
//Self.ClearScript;
|
||||||
|
Self.AddTab;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.ActionNewTabExecute(Sender: TObject);
|
procedure TForm1.ActionNewTabExecute(Sender: TObject);
|
||||||
@ -1336,7 +1367,8 @@ procedure TForm1.FormCreate(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
Randomize;
|
Randomize;
|
||||||
MainDir:= ExtractFileDir(Application.ExeName);
|
MainDir:= ExtractFileDir(Application.ExeName);
|
||||||
if FileExists(MainDir + DS + SimbaSettingsFile) then
|
SimbaSettingsFile := MainDir + DS + 'settings.xml';
|
||||||
|
if FileExists(SimbaSettingsFile) then
|
||||||
Application.CreateForm(TSettingsForm,SettingsForm)
|
Application.CreateForm(TSettingsForm,SettingsForm)
|
||||||
else begin
|
else begin
|
||||||
Application.CreateForm(TSettingsForm,SettingsForm);
|
Application.CreateForm(TSettingsForm,SettingsForm);
|
||||||
@ -1368,6 +1400,7 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
frmFunctionList.OnEndDock:= @frmFunctionList.FrameEndDock;
|
frmFunctionList.OnEndDock:= @frmFunctionList.FrameEndDock;
|
||||||
FirstRun := true;//Our next run is the first run.
|
FirstRun := true;//Our next run is the first run.
|
||||||
|
HandleParameters;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormDestroy(Sender: TObject);
|
procedure TForm1.FormDestroy(Sender: TObject);
|
||||||
@ -1827,24 +1860,34 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TForm1.OpenScript: boolean;
|
function TForm1.OpenScript: boolean;
|
||||||
|
var
|
||||||
|
OpenInNewTab : boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
if CanExitOrOpen = false then
|
OpenInNewTab:= (LowerCase(LoadSettingDef('Settings/Tabs/OpenScriptInNewTab','True')) = 'true');
|
||||||
Exit;
|
if not OpenInNewTab then
|
||||||
|
if CanExitOrOpen = false then
|
||||||
|
Exit;
|
||||||
with TOpenDialog.Create(nil) do
|
with TOpenDialog.Create(nil) do
|
||||||
try
|
try
|
||||||
Filter:= 'Simba Files|*.simb;*.cogat;*.mufa;*.txt|Any files|*.*';
|
Filter:= 'Simba Files|*.simb;*.cogat;*.mufa;*.txt|Any files|*.*';
|
||||||
if Execute then
|
if Execute then
|
||||||
result := LoadScriptFile(filename);
|
if FileExists(filename) then
|
||||||
|
result := LoadScriptFile(filename);
|
||||||
finally
|
finally
|
||||||
Free;
|
Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TForm1.LoadScriptFile(FileName : string): boolean;
|
function TForm1.LoadScriptFile(FileName : string): boolean;
|
||||||
|
var
|
||||||
|
OpenInNewTab : boolean;
|
||||||
begin
|
begin
|
||||||
|
OpenInNewTab:= (LowerCase(LoadSettingDef('Settings/Tabs/OpenScriptInNewTab','True')) = 'true');
|
||||||
if FileExists(FileName) then
|
if FileExists(FileName) then
|
||||||
begin;
|
begin;
|
||||||
|
if OpenInNewTab and (CurrScript.SynEdit.Text <> CurrScript.ScriptDefault) then //Add la tab!
|
||||||
|
self.addtab;
|
||||||
with CurrScript do
|
with CurrScript do
|
||||||
begin
|
begin
|
||||||
filename := SetDirSeparators(filename);
|
filename := SetDirSeparators(filename);
|
||||||
|
@ -2,3 +2,47 @@ function ps_GetPage(S: String): String; extdecl;
|
|||||||
begin
|
begin
|
||||||
result := GetPage(S);
|
result := GetPage(S);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ps_InitializeHTTPClient(HandleCookies, HandleRedirects: Boolean): Integer; extdecl;
|
||||||
|
begin
|
||||||
|
result := CurrThread.MInternet.CreateHTTPClient(HandleCookies); extdecl;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ps_FreeHTTPClient(Client: Integer); extdecl;
|
||||||
|
begin;
|
||||||
|
CurrThread.MInternet.GetHTTPClient(Client).Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ps_GetHTTPPage(Client: Integer; URL: string): string; extdecl;
|
||||||
|
begin
|
||||||
|
result := CurrThread.MInternet.GetHTTPClient(Client).GetHTTPPage(url);
|
||||||
|
end;
|
||||||
|
procedure ps_SetHTTPUserAgent(Client: Integer; Agent: string); extdecl;
|
||||||
|
begin
|
||||||
|
CurrThread.MInternet.GetHTTPClient(Client).SetHTTPUserAgent(agent);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ps_PostHTTPPage(Client: Integer; Url: string; PostData: string): string; extdecl;
|
||||||
|
begin
|
||||||
|
result := CurrThread.MInternet.GetHTTPClient(Client).PostHTTPPage(url,postdata);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ps_PostHTTPPageEx(Client: Integer; Url: string): string; extdecl;
|
||||||
|
begin
|
||||||
|
result := CurrThread.MInternet.GetHTTPClient(Client).PostHTTPPage(url);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ps_ClearPostData(Client: Integer); extdecl;
|
||||||
|
begin
|
||||||
|
CurrThread.MInternet.GetHTTPClient(Client).ClearPostData;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ps_AddPostVariable(Client: Integer; VarName, VarValue: string); extdecl;
|
||||||
|
begin
|
||||||
|
CurrThread.MInternet.GetHTTPClient(Client).AddPostVariable(varname,varvalue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ps_GetRawHeaders(Client: Integer): string; extdecl;
|
||||||
|
begin
|
||||||
|
result := CurrThread.MInternet.GetHTTPClient(client).GetRawHeaders;
|
||||||
|
end;
|
||||||
|
@ -150,6 +150,16 @@ AddFunction(@ps_Replace,'function ReplaceWrap(Text, FindStr, ReplaceStr: string;
|
|||||||
SetCurrSection('Web');
|
SetCurrSection('Web');
|
||||||
AddFunction(@OpenWebPage,'procedure OpenWebPage(url : string);');
|
AddFunction(@OpenWebPage,'procedure OpenWebPage(url : string);');
|
||||||
AddFunction(@ps_GetPage,'function GetPage(url : string): string;');
|
AddFunction(@ps_GetPage,'function GetPage(url : string): string;');
|
||||||
|
AddFunction(@ps_InitializeHTTPClient,'function InitializeHTTPClient(HandleCookies, HandleRedirects: Boolean): Integer;');
|
||||||
|
AddFunction(@ps_FreeHTTPClient,'procedure FreeHTTPClient(Client: Integer);');
|
||||||
|
AddFunction(@ps_GetHTTPPage,'function GetHTTPPage(Client: Integer; URL: string): string;');
|
||||||
|
AddFunction(@ps_SetHTTPUserAgent,'procedure SetHTTPUserAgent(Client: Integer; Agent: string);');
|
||||||
|
AddFunction(@ps_PostHTTPPage,'function PostHTTPPage(Client: Integer; Url: string; PostData: string): string;');
|
||||||
|
AddFunction(@ps_PostHTTPPageEx,'function PostHTTPPageEx(Client: Integer; Url: string): string;');
|
||||||
|
AddFunction(@ps_ClearPostData,'procedure ClearPostData(Client: Integer);');
|
||||||
|
AddFunction(@ps_AddPostVariable,'procedure AddPostVariable(Client: Integer; VarName, VarValue: string);');
|
||||||
|
AddFunction(@ps_GetRawHeaders,'function GetRawHeaders(Client: Integer): string;');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ Color Conversions and Speed }
|
{ Color Conversions and Speed }
|
||||||
|
@ -5,13 +5,47 @@ unit internets;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils;
|
Classes, SysUtils,httpsend;
|
||||||
|
|
||||||
function GetPage(URL: String): String;
|
function GetPage(URL: String): String;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ THTTPClient }
|
||||||
|
|
||||||
|
THTTPClient = class(TObject)
|
||||||
|
private
|
||||||
|
HTTPSend : THTTPSend;
|
||||||
|
fHandleCookies : boolean;
|
||||||
|
PostVariables : TStringList;
|
||||||
|
public
|
||||||
|
procedure SetHTTPUserAgent(agent : string);
|
||||||
|
function GetHTTPPage(url : string ) : string;
|
||||||
|
function PostHTTPPage(Url: string; PostData: string): string;overload;
|
||||||
|
function PostHTTPPage(Url: string): string;overload;
|
||||||
|
function GetRawHeaders: string;
|
||||||
|
procedure ClearPostData;
|
||||||
|
procedure AddPostVariable(VarName, VarValue: string);
|
||||||
|
constructor Create(HandleCookies : boolean = true);
|
||||||
|
destructor Destroy;override;
|
||||||
|
end;
|
||||||
|
{ TMInternet }
|
||||||
|
TMInternet = class(TObject)
|
||||||
|
protected
|
||||||
|
Client : TObject;
|
||||||
|
Connections : TList;
|
||||||
|
HTTPClients : TList;
|
||||||
|
public
|
||||||
|
function CreateHTTPClient(HandleCookies : boolean = true) : integer;
|
||||||
|
function GetHTTPClient(Index : integer) : THTTPClient;
|
||||||
|
procedure FreeHTTPClient(Index: Integer);
|
||||||
|
constructor Create(Owner : TObject);
|
||||||
|
destructor Destroy;override;
|
||||||
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
httpsend;
|
synacode;
|
||||||
|
|
||||||
{ OTHER }
|
{ OTHER }
|
||||||
function GetPage(URL: String): String;
|
function GetPage(URL: String): String;
|
||||||
@ -20,9 +54,133 @@ var
|
|||||||
begin
|
begin
|
||||||
s:=TStringList.Create;
|
s:=TStringList.Create;
|
||||||
HttpGetText(URL, s);
|
HttpGetText(URL, s);
|
||||||
result := String(s.GetText);
|
result := s.Text;
|
||||||
s.Free;
|
s.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TMInternet }
|
||||||
|
|
||||||
|
function TMInternet.CreateHTTPClient(HandleCookies: boolean = true): integer;
|
||||||
|
begin;
|
||||||
|
Result := HTTPClients.Add(THTTPClient.Create(HandleCookies));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMInternet.GetHTTPClient(Index: integer): THTTPClient;
|
||||||
|
begin
|
||||||
|
if (index < 0) or (index >= HTTPClients.Count) then
|
||||||
|
raise exception.CreateFmt('GetHTTPClient: Trying to acces an index(%d) that is out of range',[index]);
|
||||||
|
if HTTPClients[index] = nil then
|
||||||
|
raise exception.CreateFmt('GetHTTPClient: Trying to acces an index(%d) that is freed',[index]);
|
||||||
|
result := THTTPClient(httpclients[index]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMInternet.FreeHTTPClient(Index: Integer);
|
||||||
|
begin
|
||||||
|
if (index < 0) or (index >= HTTPClients.Count) then
|
||||||
|
raise exception.CreateFmt('FreeHTTPClient: Trying to free an index(%d) that is out of range',[index]);
|
||||||
|
if HTTPClients[index] = nil then
|
||||||
|
raise exception.CreateFmt('FreeHTTPClient: Trying to free an index(%d) that is already freed',[index]);
|
||||||
|
THTTPClient(HTTPClients[index]).Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TMInternet.Create(Owner: TObject);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
client := Owner;
|
||||||
|
Connections := TList.Create;
|
||||||
|
HTTPClients := TList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TMInternet.Destroy;
|
||||||
|
var
|
||||||
|
i : integer;
|
||||||
|
begin
|
||||||
|
for i := Connections.Count -1 downto 0 do
|
||||||
|
if Connections[i] <> nil then
|
||||||
|
TObject(Connections[i]).Free;
|
||||||
|
for i := HTTPClients.Count -1 downto 0 do
|
||||||
|
if HTTPClients[i] <> nil then
|
||||||
|
THTTPClient(HTTPClients[i]).Free;
|
||||||
|
Connections.Free;
|
||||||
|
HTTPClients.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ THTTPClient }
|
||||||
|
|
||||||
|
procedure THTTPClient.SetHTTPUserAgent(agent: string);
|
||||||
|
begin
|
||||||
|
HTTPSend.UserAgent := agent;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function THTTPClient.GetHTTPPage(url: string): string;
|
||||||
|
begin
|
||||||
|
if not fHandleCookies then
|
||||||
|
HTTPSend.Cookies.Clear;
|
||||||
|
HTTPSend.MimeType := 'text/html';
|
||||||
|
if HTTPSend.HTTPMethod('GET',url) then
|
||||||
|
begin;
|
||||||
|
SetLength(result,HTTPSend.Document.Size);
|
||||||
|
HTTPSend.Document.Read(result[1],length(result));
|
||||||
|
end else
|
||||||
|
result := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function THTTPClient.PostHTTPPage(Url: string; PostData: string): string;
|
||||||
|
begin
|
||||||
|
HTTPSend.MimeType := 'application/x-www-form-urlencoded';
|
||||||
|
HTTPSend.Document.Clear;
|
||||||
|
HTTPSend.Document.Write(Postdata[1],length(postdata));
|
||||||
|
if HTTPSend.HTTPMethod('POST',url) then
|
||||||
|
begin;
|
||||||
|
SetLength(result,HTTPSend.Document.Size);
|
||||||
|
HTTPSend.Document.Read(result[1],Length(result));
|
||||||
|
end else
|
||||||
|
result := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function THTTPClient.PostHTTPPage(Url: string): string;
|
||||||
|
var
|
||||||
|
PostData : string;
|
||||||
|
i : integer;
|
||||||
|
begin
|
||||||
|
PostData := '';
|
||||||
|
for i := 0 to PostVariables.Count - 1 do
|
||||||
|
PostData := PostData + PostVariables[i] +'&';
|
||||||
|
if Length(PostData) > 1 then
|
||||||
|
setlength(postdata,length(postdata) - 1); //Wipe away that last &
|
||||||
|
result := PostHTTPPage(url,postdata);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function THTTPClient.GetRawHeaders: string;
|
||||||
|
begin
|
||||||
|
Result := HTTPSend.Headers.Text;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure THTTPClient.ClearPostData;
|
||||||
|
begin
|
||||||
|
PostVariables.Clear;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure THTTPClient.AddPostVariable(VarName, VarValue: string);
|
||||||
|
begin
|
||||||
|
PostVariables.Add(Varname + '=' + VarValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor THTTPClient.Create(HandleCookies : boolean = true);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
HTTPSend := THTTPSend.Create;
|
||||||
|
fHandleCookies:= HandleCookies;
|
||||||
|
PostVariables := TStringList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor THTTPClient.Destroy;
|
||||||
|
begin
|
||||||
|
HTTPSend.Free;
|
||||||
|
PostVariables.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, client, uPSComponent,uPSCompiler,
|
Classes, SysUtils, client, uPSComponent,uPSCompiler,
|
||||||
uPSRuntime,stdCtrls, uPSPreProcessor,MufasaTypes, web,
|
uPSRuntime,stdCtrls, uPSPreProcessor,MufasaTypes, web,
|
||||||
bitmaps, plugins, libloader, dynlibs;
|
bitmaps, plugins, libloader, dynlibs,internets;
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -82,6 +82,7 @@ type
|
|||||||
|
|
||||||
public
|
public
|
||||||
Client : TClient;
|
Client : TClient;
|
||||||
|
MInternet : TMInternet;
|
||||||
StartTime : LongWord;
|
StartTime : LongWord;
|
||||||
DebugMemo : TMemo;
|
DebugMemo : TMemo;
|
||||||
|
|
||||||
@ -184,7 +185,6 @@ uses
|
|||||||
uPSR_extctrls, //Runtime-libs
|
uPSR_extctrls, //Runtime-libs
|
||||||
Graphics, //For Graphics types
|
Graphics, //For Graphics types
|
||||||
math, //Maths!
|
math, //Maths!
|
||||||
internets, // internets
|
|
||||||
strutils,
|
strutils,
|
||||||
tpa, //Tpa stuff
|
tpa, //Tpa stuff
|
||||||
forms,//Forms
|
forms,//Forms
|
||||||
@ -265,6 +265,7 @@ end;
|
|||||||
constructor TMThread.Create(CreateSuspended: boolean; TheSyncInfo: PSyncInfo; plugin_dir: string);
|
constructor TMThread.Create(CreateSuspended: boolean; TheSyncInfo: PSyncInfo; plugin_dir: string);
|
||||||
begin
|
begin
|
||||||
Client := TClient.Create(plugin_dir);
|
Client := TClient.Create(plugin_dir);
|
||||||
|
MInternet := TMInternet.Create(Client);
|
||||||
SyncInfo:= TheSyncInfo;
|
SyncInfo:= TheSyncInfo;
|
||||||
ExportedMethods:= GetExportedMethods;
|
ExportedMethods:= GetExportedMethods;
|
||||||
FreeOnTerminate := True;
|
FreeOnTerminate := True;
|
||||||
@ -276,6 +277,7 @@ end;
|
|||||||
|
|
||||||
destructor TMThread.Destroy;
|
destructor TMThread.Destroy;
|
||||||
begin
|
begin
|
||||||
|
MInternet.Free;
|
||||||
Client.Free;
|
Client.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
@ -51,7 +51,6 @@ It binds all the components together.
|
|||||||
MBitmaps : TMBitmaps;
|
MBitmaps : TMBitmaps;
|
||||||
MDTM: TMDTM;
|
MDTM: TMDTM;
|
||||||
MOCR: TMOCR;
|
MOCR: TMOCR;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
@ -672,6 +672,7 @@ function MiddleTPA(tpa: TPointArray): TPoint;
|
|||||||
var
|
var
|
||||||
i, l: Integer;
|
i, l: Integer;
|
||||||
begin
|
begin
|
||||||
|
FillChar(result,sizeof(TPoint),0);
|
||||||
l := High(tpa);
|
l := High(tpa);
|
||||||
if (l < 0) then Exit;
|
if (l < 0) then Exit;
|
||||||
Result.x := 0;
|
Result.x := 0;
|
||||||
@ -1073,6 +1074,7 @@ function GetATPABounds(ATPA: T2DPointArray): TBox;
|
|||||||
var
|
var
|
||||||
I,II,L2,L : Integer;
|
I,II,L2,L : Integer;
|
||||||
begin;
|
begin;
|
||||||
|
FillChar(result,sizeof(TBox),0);
|
||||||
L := High(ATPA);
|
L := High(ATPA);
|
||||||
if (l < 0) then Exit;
|
if (l < 0) then Exit;
|
||||||
For I := 0 to L do
|
For I := 0 to L do
|
||||||
@ -1108,6 +1110,7 @@ function GetTPABounds(TPA: TPointArray): TBox;
|
|||||||
var
|
var
|
||||||
I,L : Integer;
|
I,L : Integer;
|
||||||
begin;
|
begin;
|
||||||
|
FillChar(result,sizeof(TBox),0);
|
||||||
L := High(TPA);
|
L := High(TPA);
|
||||||
if (l < 0) then Exit;
|
if (l < 0) then Exit;
|
||||||
Result.x1 := TPA[0].x;
|
Result.x1 := TPA[0].x;
|
||||||
|
@ -62,6 +62,11 @@ For sample of using, look to @link(TSnmpSend) or @link(TLdapSend)class.
|
|||||||
{$MODE DELPHI}
|
{$MODE DELPHI}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit asn1util;
|
unit asn1util;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 009.006.000 |
|
| Project : Ararat Synapse | 009.008.002 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Library base |
|
| Content: Library base |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2008, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)1999-2008. |
|
| Portions created by Lukas Gebauer are Copyright (c)1999-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -82,6 +82,18 @@ Core with implementation basic socket classes.
|
|||||||
{$H+}
|
{$H+}
|
||||||
{$M+}
|
{$M+}
|
||||||
|
|
||||||
|
//old Delphi does not have MSWINDOWS define.
|
||||||
|
{$IFDEF WIN32}
|
||||||
|
{$IFNDEF MSWINDOWS}
|
||||||
|
{$DEFINE MSWINDOWS}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit blcksock;
|
unit blcksock;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -309,6 +321,7 @@ type
|
|||||||
FSocket: TSocket;
|
FSocket: TSocket;
|
||||||
FLastError: Integer;
|
FLastError: Integer;
|
||||||
FLastErrorDesc: string;
|
FLastErrorDesc: string;
|
||||||
|
FOwner: TObject;
|
||||||
procedure SetDelayedOption(const Value: TSynaOption);
|
procedure SetDelayedOption(const Value: TSynaOption);
|
||||||
procedure DelayedOption(const Value: TSynaOption);
|
procedure DelayedOption(const Value: TSynaOption);
|
||||||
procedure ProcessDelayedOptions;
|
procedure ProcessDelayedOptions;
|
||||||
@ -383,6 +396,16 @@ type
|
|||||||
address. (Not work properly on prilimitary winsock IPv6 support!)}
|
address. (Not work properly on prilimitary winsock IPv6 support!)}
|
||||||
procedure Connect(IP, Port: string); virtual;
|
procedure Connect(IP, Port: string); virtual;
|
||||||
|
|
||||||
|
{:Sets socket to receive mode for new incoming connections. It is necessary
|
||||||
|
to use @link(TBlockSocket.BIND) function call before this method to select
|
||||||
|
receiving port!}
|
||||||
|
procedure Listen; virtual;
|
||||||
|
|
||||||
|
{:Waits until new incoming connection comes. After it comes a new socket is
|
||||||
|
automatically created (socket handler is returned by this function as
|
||||||
|
result).}
|
||||||
|
function Accept: TSocket; virtual;
|
||||||
|
|
||||||
{:Sends data of LENGTH from BUFFER address via connected socket. System
|
{:Sends data of LENGTH from BUFFER address via connected socket. System
|
||||||
automatically splits data to packets.}
|
automatically splits data to packets.}
|
||||||
function SendBuffer(Buffer: Tmemory; Length: Integer): Integer; virtual;
|
function SendBuffer(Buffer: Tmemory; Length: Integer): Integer; virtual;
|
||||||
@ -672,10 +695,13 @@ type
|
|||||||
{:Return value of protocol type for socket creation.}
|
{:Return value of protocol type for socket creation.}
|
||||||
function GetSocketProtocol: integer; Virtual;
|
function GetSocketProtocol: integer; Virtual;
|
||||||
|
|
||||||
{:WSA structure with information about socket provider. On linux is this
|
{:WSA structure with information about socket provider. On non-windows
|
||||||
structure simulated!}
|
platforms this structure is simulated!}
|
||||||
property WSAData: TWSADATA read GetWsaData;
|
property WSAData: TWSADATA read GetWsaData;
|
||||||
|
|
||||||
|
{:FDset structure prepared for usage with this socket.}
|
||||||
|
property FDset: TFDSet read FFDset;
|
||||||
|
|
||||||
{:Structure describing local socket side.}
|
{:Structure describing local socket side.}
|
||||||
property LocalSin: TVarSin read FLocalSin write FLocalSin;
|
property LocalSin: TVarSin read FLocalSin write FLocalSin;
|
||||||
|
|
||||||
@ -821,6 +847,8 @@ type
|
|||||||
on real socket operations too!
|
on real socket operations too!
|
||||||
Note: Each heartbeat slowing socket processing.}
|
Note: Each heartbeat slowing socket processing.}
|
||||||
property HeartbeatRate: integer read FHeartbeatRate Write FHeartbeatRate;
|
property HeartbeatRate: integer read FHeartbeatRate Write FHeartbeatRate;
|
||||||
|
{:What class own this socket? Used by protocol implementation classes.}
|
||||||
|
property Owner: TObject read FOwner Write FOwner;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{:@abstract(Support for SOCKS4 and SOCKS5 proxy)
|
{:@abstract(Support for SOCKS4 and SOCKS5 proxy)
|
||||||
@ -923,10 +951,6 @@ type
|
|||||||
constructor CreateWithSSL(SSLPlugin: TSSLClass);
|
constructor CreateWithSSL(SSLPlugin: TSSLClass);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
{:Return descriptive string for @link(LastError). On case of error
|
|
||||||
in SSL/TLS subsystem, it returns right error description.}
|
|
||||||
function GetErrorDescEx: string; override;
|
|
||||||
|
|
||||||
{:See @link(TBlockSocket.CloseSocket)}
|
{:See @link(TBlockSocket.CloseSocket)}
|
||||||
procedure CloseSocket; override;
|
procedure CloseSocket; override;
|
||||||
|
|
||||||
@ -939,7 +963,7 @@ type
|
|||||||
|
|
||||||
If you use SOCKS, activate incoming TCP connection by this proxy. (By BIND
|
If you use SOCKS, activate incoming TCP connection by this proxy. (By BIND
|
||||||
method of SOCKS.)}
|
method of SOCKS.)}
|
||||||
procedure Listen; virtual;
|
procedure Listen; override;
|
||||||
|
|
||||||
{:Waits until new incoming connection comes. After it comes a new socket is
|
{:Waits until new incoming connection comes. After it comes a new socket is
|
||||||
automatically created (socket handler is returned by this function as
|
automatically created (socket handler is returned by this function as
|
||||||
@ -948,7 +972,7 @@ type
|
|||||||
If you use SOCKS, new socket is not created! In this case is used same
|
If you use SOCKS, new socket is not created! In this case is used same
|
||||||
socket as socket for listening! So, you can accept only one connection in
|
socket as socket for listening! So, you can accept only one connection in
|
||||||
SOCKS mode.}
|
SOCKS mode.}
|
||||||
function Accept: TSocket;
|
function Accept: TSocket; override;
|
||||||
|
|
||||||
{:Connects socket to remote IP address and PORT. The same rules as with
|
{:Connects socket to remote IP address and PORT. The same rules as with
|
||||||
@link(TBlockSocket.BIND) method are valid. The only exception is that PORT
|
@link(TBlockSocket.BIND) method are valid. The only exception is that PORT
|
||||||
@ -1017,6 +1041,10 @@ type
|
|||||||
{:@True if is used HTTP tunnel mode.}
|
{:@True if is used HTTP tunnel mode.}
|
||||||
property HTTPTunnel: Boolean read FHTTPTunnel;
|
property HTTPTunnel: Boolean read FHTTPTunnel;
|
||||||
published
|
published
|
||||||
|
{:Return descriptive string for @link(LastError). On case of error
|
||||||
|
in SSL/TLS subsystem, it returns right error description.}
|
||||||
|
function GetErrorDescEx: string; override;
|
||||||
|
|
||||||
{:Specify IP address of HTTP proxy. Assingning non-empty value to this
|
{:Specify IP address of HTTP proxy. Assingning non-empty value to this
|
||||||
property enable HTTP-tunnel mode. This mode is for tunnelling any outgoing
|
property enable HTTP-tunnel mode. This mode is for tunnelling any outgoing
|
||||||
TCP connection through HTTP proxy server. (If policy on HTTP proxy server
|
TCP connection through HTTP proxy server. (If policy on HTTP proxy server
|
||||||
@ -1136,6 +1164,30 @@ type
|
|||||||
function GetSocketProtocol: integer; override;
|
function GetSocketProtocol: integer; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{:@abstract(Implementation of PGM-message socket.)
|
||||||
|
Not all systems supports this protocol!}
|
||||||
|
TPGMMessageBlockSocket = class(TBlockSocket)
|
||||||
|
public
|
||||||
|
{:Return value of socket type. For PGM-message return SOCK_RDM.}
|
||||||
|
function GetSocketType: integer; override;
|
||||||
|
|
||||||
|
{:Return value of protocol type for socket creation. For PGM-message returns
|
||||||
|
IPPROTO_RM.}
|
||||||
|
function GetSocketProtocol: integer; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{:@abstract(Implementation of PGM-stream socket.)
|
||||||
|
Not all systems supports this protocol!}
|
||||||
|
TPGMStreamBlockSocket = class(TBlockSocket)
|
||||||
|
public
|
||||||
|
{:Return value of socket type. For PGM-stream return SOCK_STREAM.}
|
||||||
|
function GetSocketType: integer; override;
|
||||||
|
|
||||||
|
{:Return value of protocol type for socket creation. For PGM-stream returns
|
||||||
|
IPPROTO_RM.}
|
||||||
|
function GetSocketProtocol: integer; override;
|
||||||
|
end;
|
||||||
|
|
||||||
{:@abstract(Parent class for all SSL plugins.)
|
{:@abstract(Parent class for all SSL plugins.)
|
||||||
This is abstract class defining interface for other SSL plugins.
|
This is abstract class defining interface for other SSL plugins.
|
||||||
|
|
||||||
@ -1457,6 +1509,7 @@ begin
|
|||||||
FStopFlag := False;
|
FStopFlag := False;
|
||||||
FNonblockSendTimeout := 15000;
|
FNonblockSendTimeout := 15000;
|
||||||
FHeartbeatRate := 0;
|
FHeartbeatRate := 0;
|
||||||
|
FOwner := nil;
|
||||||
{$IFNDEF ONCEWINSOCK}
|
{$IFNDEF ONCEWINSOCK}
|
||||||
if Stub = '' then
|
if Stub = '' then
|
||||||
Stub := DLLStackName;
|
Stub := DLLStackName;
|
||||||
@ -1508,7 +1561,7 @@ var
|
|||||||
li: TLinger;
|
li: TLinger;
|
||||||
x: integer;
|
x: integer;
|
||||||
buf: TMemory;
|
buf: TMemory;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
timeval: TTimeval;
|
timeval: TTimeval;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
@ -1558,7 +1611,7 @@ begin
|
|||||||
synsock.SetSockOpt(FSocket, integer(SOL_SOCKET), integer(SO_RCVTIMEO),
|
synsock.SetSockOpt(FSocket, integer(SOL_SOCKET), integer(SO_RCVTIMEO),
|
||||||
buf, SizeOf(Value.Value));
|
buf, SizeOf(Value.Value));
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
buf := @Value.Value;
|
buf := @Value.Value;
|
||||||
synsock.SetSockOpt(FSocket, integer(SOL_SOCKET), integer(SO_RCVTIMEO),
|
synsock.SetSockOpt(FSocket, integer(SOL_SOCKET), integer(SO_RCVTIMEO),
|
||||||
buf, SizeOf(Value.Value));
|
buf, SizeOf(Value.Value));
|
||||||
@ -1575,7 +1628,7 @@ begin
|
|||||||
{$IFDEF CIL}
|
{$IFDEF CIL}
|
||||||
buf := System.BitConverter.GetBytes(value.Value);
|
buf := System.BitConverter.GetBytes(value.Value);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
buf := @Value.Value;
|
buf := @Value.Value;
|
||||||
synsock.SetSockOpt(FSocket, integer(SOL_SOCKET), integer(SO_SNDTIMEO),
|
synsock.SetSockOpt(FSocket, integer(SOL_SOCKET), integer(SO_SNDTIMEO),
|
||||||
buf, SizeOf(Value.Value));
|
buf, SizeOf(Value.Value));
|
||||||
@ -1840,6 +1893,22 @@ begin
|
|||||||
DoStatus(HR_Connect, IP + ':' + Port);
|
DoStatus(HR_Connect, IP + ':' + Port);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBlockSocket.Listen;
|
||||||
|
begin
|
||||||
|
SockCheck(synsock.Listen(FSocket, SOMAXCONN));
|
||||||
|
GetSins;
|
||||||
|
ExceptCheck;
|
||||||
|
DoStatus(HR_Listen, '');
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBlockSocket.Accept: TSocket;
|
||||||
|
begin
|
||||||
|
Result := synsock.Accept(FSocket, FRemoteSin);
|
||||||
|
/// SockCheck(Result);
|
||||||
|
ExceptCheck;
|
||||||
|
DoStatus(HR_Accept, '');
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBlockSocket.GetSinLocal;
|
procedure TBlockSocket.GetSinLocal;
|
||||||
begin
|
begin
|
||||||
synsock.GetSockName(FSocket, FLocalSin);
|
synsock.GetSockName(FSocket, FLocalSin);
|
||||||
@ -2014,6 +2083,7 @@ var
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
b := true;
|
b := true;
|
||||||
|
l := 0;
|
||||||
if WithSize then
|
if WithSize then
|
||||||
begin
|
begin
|
||||||
l := Stream.Size - Stream.Position;;
|
l := Stream.Size - Stream.Position;;
|
||||||
@ -2189,7 +2259,7 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
//not drain CPU on large downloads...
|
//not drain CPU on large downloads...
|
||||||
Sleep(0);
|
Sleep(0);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -3145,7 +3215,7 @@ end;
|
|||||||
|
|
||||||
function TSocksBlockSocket.SocksOpen: boolean;
|
function TSocksBlockSocket.SocksOpen: boolean;
|
||||||
var
|
var
|
||||||
Buf: string;
|
Buf: AnsiString;
|
||||||
n: integer;
|
n: integer;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
@ -3175,8 +3245,8 @@ begin
|
|||||||
;
|
;
|
||||||
2:
|
2:
|
||||||
begin
|
begin
|
||||||
Buf := #1 + char(Length(FSocksUsername)) + FSocksUsername
|
Buf := #1 + AnsiChar(Length(FSocksUsername)) + FSocksUsername
|
||||||
+ char(Length(FSocksPassword)) + FSocksPassword;
|
+ AnsiChar(Length(FSocksPassword)) + FSocksPassword;
|
||||||
SendString(Buf);
|
SendString(Buf);
|
||||||
Buf := RecvBufferStr(2, FSocksTimeout);
|
Buf := RecvBufferStr(2, FSocksTimeout);
|
||||||
if Length(Buf) < 2 then
|
if Length(Buf) < 2 then
|
||||||
@ -3199,14 +3269,14 @@ end;
|
|||||||
function TSocksBlockSocket.SocksRequest(Cmd: Byte;
|
function TSocksBlockSocket.SocksRequest(Cmd: Byte;
|
||||||
const IP, Port: string): Boolean;
|
const IP, Port: string): Boolean;
|
||||||
var
|
var
|
||||||
Buf: string;
|
Buf: AnsiString;
|
||||||
begin
|
begin
|
||||||
FBypassFlag := True;
|
FBypassFlag := True;
|
||||||
try
|
try
|
||||||
if FSocksType <> ST_Socks5 then
|
if FSocksType <> ST_Socks5 then
|
||||||
Buf := #4 + char(Cmd) + SocksCode(IP, Port)
|
Buf := #4 + AnsiChar(Cmd) + SocksCode(IP, Port)
|
||||||
else
|
else
|
||||||
Buf := #5 + char(Cmd) + #0 + SocksCode(IP, Port);
|
Buf := #5 + AnsiChar(Cmd) + #0 + SocksCode(IP, Port);
|
||||||
SendString(Buf);
|
SendString(Buf);
|
||||||
Result := FLastError = 0;
|
Result := FLastError = 0;
|
||||||
finally
|
finally
|
||||||
@ -3216,7 +3286,7 @@ end;
|
|||||||
|
|
||||||
function TSocksBlockSocket.SocksResponse: Boolean;
|
function TSocksBlockSocket.SocksResponse: Boolean;
|
||||||
var
|
var
|
||||||
Buf, s: string;
|
Buf, s: AnsiString;
|
||||||
x: integer;
|
x: integer;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
@ -3249,7 +3319,7 @@ begin
|
|||||||
x := RecvByte(FSocksTimeout);
|
x := RecvByte(FSocksTimeout);
|
||||||
if FLastError <> 0 then
|
if FLastError <> 0 then
|
||||||
Exit;
|
Exit;
|
||||||
s := char(x) + RecvBufferStr(x, FSocksTimeout);
|
s := AnsiChar(x) + RecvBufferStr(x, FSocksTimeout);
|
||||||
end;
|
end;
|
||||||
4:
|
4:
|
||||||
s := RecvBufferStr(16, FSocksTimeout);
|
s := RecvBufferStr(16, FSocksTimeout);
|
||||||
@ -3304,10 +3374,10 @@ begin
|
|||||||
ip6 := StrToIP6(IP);
|
ip6 := StrToIP6(IP);
|
||||||
Result := #4;
|
Result := #4;
|
||||||
for n := 0 to 15 do
|
for n := 0 to 15 do
|
||||||
Result := Result + char(ip6[n]);
|
Result := Result + AnsiChar(ip6[n]);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := #3 + char(Length(IP)) + IP;
|
Result := #3 + AnsiChar(Length(IP)) + IP;
|
||||||
Result := Result + CodeInt(ResolvePort(Port));
|
Result := Result + CodeInt(ResolvePort(Port));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -3667,8 +3737,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if FSocksIP = '' then
|
if FSocksIP = '' then
|
||||||
begin
|
begin
|
||||||
SockCheck(synsock.Listen(FSocket, SOMAXCONN));
|
inherited Listen;
|
||||||
GetSins;
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -3690,9 +3759,9 @@ begin
|
|||||||
FSocksLocalPort := FSocksResponsePort;
|
FSocksLocalPort := FSocksResponsePort;
|
||||||
FSocksRemoteIP := '';
|
FSocksRemoteIP := '';
|
||||||
FSocksRemotePort := '';
|
FSocksRemotePort := '';
|
||||||
|
ExceptCheck;
|
||||||
|
DoStatus(HR_Listen, '');
|
||||||
end;
|
end;
|
||||||
ExceptCheck;
|
|
||||||
DoStatus(HR_Listen, '');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TTCPBlockSocket.Accept: TSocket;
|
function TTCPBlockSocket.Accept: TSocket;
|
||||||
@ -3704,14 +3773,13 @@ begin
|
|||||||
FSocksRemoteIP := FSocksResponseIP;
|
FSocksRemoteIP := FSocksResponseIP;
|
||||||
FSocksRemotePort := FSocksResponsePort;
|
FSocksRemotePort := FSocksResponsePort;
|
||||||
Result := FSocket;
|
Result := FSocket;
|
||||||
|
ExceptCheck;
|
||||||
|
DoStatus(HR_Accept, '');
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Result := synsock.Accept(FSocket, FRemoteSin);
|
result := inherited Accept;
|
||||||
/// SockCheck(Result);
|
|
||||||
end;
|
end;
|
||||||
ExceptCheck;
|
|
||||||
DoStatus(HR_Accept, '');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTCPBlockSocket.Connect(IP, Port: string);
|
procedure TTCPBlockSocket.Connect(IP, Port: string);
|
||||||
@ -3956,6 +4024,30 @@ end;
|
|||||||
|
|
||||||
{======================================================================}
|
{======================================================================}
|
||||||
|
|
||||||
|
function TPGMmessageBlockSocket.GetSocketType: integer;
|
||||||
|
begin
|
||||||
|
Result := integer(SOCK_RDM);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TPGMmessageBlockSocket.GetSocketProtocol: integer;
|
||||||
|
begin
|
||||||
|
Result := integer(IPPROTO_RM);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{======================================================================}
|
||||||
|
|
||||||
|
function TPGMstreamBlockSocket.GetSocketType: integer;
|
||||||
|
begin
|
||||||
|
Result := integer(SOCK_STREAM);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TPGMstreamBlockSocket.GetSocketProtocol: integer;
|
||||||
|
begin
|
||||||
|
Result := integer(IPPROTO_RM);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{======================================================================}
|
||||||
|
|
||||||
constructor TSynaClient.Create;
|
constructor TSynaClient.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.001.000 |
|
| Project : Ararat Synapse | 001.001.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: ClamAV-daemon client |
|
| Content: ClamAV-daemon client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)2005-2009, Lukas Gebauer |
|
| Copyright (c)2005-2010, 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-2009. |
|
| Portions created by Lukas Gebauer are Copyright (c)2005-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -54,6 +54,11 @@ daemon from ClamAV. See more about ClamAV on @LINK(http://www.clamav.net)
|
|||||||
{$Q-}
|
{$Q-}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit clamsend;
|
unit clamsend;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -121,7 +126,9 @@ constructor TClamSend.Create;
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FSock := TTCPBlockSocket.Create;
|
FSock := TTCPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FDSock := TTCPBlockSocket.Create;
|
FDSock := TTCPBlockSocket.Create;
|
||||||
|
FDSock.Owner := self;
|
||||||
FTimeout := 60000;
|
FTimeout := 60000;
|
||||||
FTargetPort := cClamProtocol;
|
FTargetPort := cClamProtocol;
|
||||||
FSession := false;
|
FSession := false;
|
||||||
@ -247,7 +254,6 @@ end;
|
|||||||
function TClamSend.ScanStream2(const Value: TStream): AnsiString;
|
function TClamSend.ScanStream2(const Value: TStream): AnsiString;
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
s: AnsiString;
|
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
if not FSession then
|
if not FSession then
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 002.007.004 |
|
| Project : Ararat Synapse | 002.007.006 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: DNS client |
|
| Content: DNS client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2007, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)2000-2007. |
|
| Portions created by Lukas Gebauer are Copyright (c)2000-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -54,6 +54,11 @@ Used RFC: RFC-1035, RFC-1183, RFC1706, RFC1712, RFC2163, RFC2230
|
|||||||
{$Q-}
|
{$Q-}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit dnssend;
|
unit dnssend;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -212,7 +217,9 @@ constructor TDNSSend.Create;
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FSock := TUDPBlockSocket.Create;
|
FSock := TUDPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FTCPSock := TTCPBlockSocket.Create;
|
FTCPSock := TTCPBlockSocket.Create;
|
||||||
|
FTCPSock.Owner := self;
|
||||||
FUseTCP := False;
|
FUseTCP := False;
|
||||||
FTimeout := 10000;
|
FTimeout := 10000;
|
||||||
FTargetPort := cDnsProtocol;
|
FTargetPort := cDnsProtocol;
|
||||||
@ -246,13 +253,13 @@ begin
|
|||||||
for n := 1 to Length(Value) do
|
for n := 1 to Length(Value) do
|
||||||
if Value[n] = '.' then
|
if Value[n] = '.' then
|
||||||
begin
|
begin
|
||||||
Result := Result + Char(Length(s)) + s;
|
Result := Result + AnsiChar(Length(s)) + s;
|
||||||
s := '';
|
s := '';
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
s := s + Value[n];
|
s := s + Value[n];
|
||||||
if s <> '' then
|
if s <> '' then
|
||||||
Result := Result + Char(Length(s)) + s;
|
Result := Result + AnsiChar(Length(s)) + s;
|
||||||
Result := Result + #0;
|
Result := Result + #0;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 003.005.001 |
|
| Project : Ararat Synapse | 003.005.003 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: FTP client |
|
| Content: FTP client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2008, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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) 1999-2008. |
|
| Portions created by Lukas Gebauer are Copyright (c) 1999-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -53,6 +53,11 @@ Used RFC: RFC-959, RFC-2228, RFC-2428
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit ftpsend;
|
unit ftpsend;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -84,18 +89,17 @@ type
|
|||||||
listing of FTP server.}
|
listing of FTP server.}
|
||||||
TFTPListRec = class(TObject)
|
TFTPListRec = class(TObject)
|
||||||
private
|
private
|
||||||
FFileName: string;
|
FFileName: String;
|
||||||
FDirectory: Boolean;
|
FDirectory: Boolean;
|
||||||
FReadable: Boolean;
|
FReadable: Boolean;
|
||||||
FFileSize: Longint;
|
FFileSize: Longint;
|
||||||
FFileTime: TDateTime;
|
FFileTime: TDateTime;
|
||||||
FOriginalLine: string;
|
FOriginalLine: string;
|
||||||
FMask: string;
|
FMask: string;
|
||||||
FPermission: string;
|
FPermission: String;
|
||||||
public
|
public
|
||||||
{: You can assign another TFTPListRec to this object.}
|
{: You can assign another TFTPListRec to this object.}
|
||||||
procedure Assign(Value: TFTPListRec); virtual;
|
procedure Assign(Value: TFTPListRec); virtual;
|
||||||
published
|
|
||||||
{:name of file}
|
{:name of file}
|
||||||
property FileName: string read FFileName write FFileName;
|
property FileName: string read FFileName write FFileName;
|
||||||
{:if name is subdirectory not file.}
|
{:if name is subdirectory not file.}
|
||||||
@ -135,16 +139,16 @@ type
|
|||||||
YearTime: string;
|
YearTime: string;
|
||||||
Year: string;
|
Year: string;
|
||||||
Hours: string;
|
Hours: string;
|
||||||
HoursModif: string;
|
HoursModif: Ansistring;
|
||||||
Minutes: string;
|
Minutes: string;
|
||||||
Seconds: string;
|
Seconds: string;
|
||||||
Size: string;
|
Size: Ansistring;
|
||||||
Permissions: string;
|
Permissions: Ansistring;
|
||||||
DirFlag: string;
|
DirFlag: string;
|
||||||
function GetListItem(Index: integer): TFTPListRec; virtual;
|
function GetListItem(Index: integer): TFTPListRec; virtual;
|
||||||
function ParseEPLF(Value: string): Boolean; virtual;
|
function ParseEPLF(Value: string): Boolean; virtual;
|
||||||
procedure ClearStore; virtual;
|
procedure ClearStore; virtual;
|
||||||
function ParseByMask(Value, NextValue, Mask: string): Integer; virtual;
|
function ParseByMask(Value, NextValue, Mask: ansistring): Integer; virtual;
|
||||||
function CheckValues: Boolean; virtual;
|
function CheckValues: Boolean; virtual;
|
||||||
procedure FillRecord(const Value: TFTPListRec); virtual;
|
procedure FillRecord(const Value: TFTPListRec); virtual;
|
||||||
public
|
public
|
||||||
@ -465,8 +469,10 @@ begin
|
|||||||
FFullResult := TStringList.Create;
|
FFullResult := TStringList.Create;
|
||||||
FDataStream := TMemoryStream.Create;
|
FDataStream := TMemoryStream.Create;
|
||||||
FSock := TTCPBlockSocket.Create;
|
FSock := TTCPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FSock.ConvertLineEnd := True;
|
FSock.ConvertLineEnd := True;
|
||||||
FDSock := TTCPBlockSocket.Create;
|
FDSock := TTCPBlockSocket.Create;
|
||||||
|
FDSock.Owner := self;
|
||||||
FFtpList := TFTPList.Create;
|
FFtpList := TFTPList.Create;
|
||||||
FTimeout := 300000;
|
FTimeout := 300000;
|
||||||
FTargetPort := cFtpProtocol;
|
FTargetPort := cFtpProtocol;
|
||||||
@ -508,7 +514,7 @@ end;
|
|||||||
|
|
||||||
function TFTPSend.ReadResult: Integer;
|
function TFTPSend.ReadResult: Integer;
|
||||||
var
|
var
|
||||||
s, c: string;
|
s, c: AnsiString;
|
||||||
begin
|
begin
|
||||||
FFullResult.Clear;
|
FFullResult.Clear;
|
||||||
c := '';
|
c := '';
|
||||||
@ -818,7 +824,7 @@ end;
|
|||||||
procedure TFTPSend.ParseRemoteEPSV(Value: string);
|
procedure TFTPSend.ParseRemoteEPSV(Value: string);
|
||||||
var
|
var
|
||||||
n: integer;
|
n: integer;
|
||||||
s, v: string;
|
s, v: AnsiString;
|
||||||
begin
|
begin
|
||||||
s := SeparateRight(Value, '(');
|
s := SeparateRight(Value, '(');
|
||||||
s := Trim(SeparateLeft(s, ')'));
|
s := Trim(SeparateLeft(s, ')'));
|
||||||
@ -1336,11 +1342,11 @@ begin
|
|||||||
DirFlag := '';
|
DirFlag := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFTPList.ParseByMask(Value, NextValue, Mask: string): Integer;
|
function TFTPList.ParseByMask(Value, NextValue, Mask: AnsiString): Integer;
|
||||||
var
|
var
|
||||||
Ivalue, IMask: integer;
|
Ivalue, IMask: integer;
|
||||||
MaskC, LastMaskC: Char;
|
MaskC, LastMaskC: AnsiChar;
|
||||||
c: char;
|
c: AnsiChar;
|
||||||
s: string;
|
s: string;
|
||||||
begin
|
begin
|
||||||
ClearStore;
|
ClearStore;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.001.000 |
|
| Project : Ararat Synapse | 001.001.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Trivial FTP (TFTP) client and server |
|
| Content: Trivial FTP (TFTP) client and server |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2004, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)2003-2004. |
|
| Portions created by Lukas Gebauer are Copyright (c)2003-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -53,6 +53,11 @@ Used RFC: RFC-1350
|
|||||||
{$Q-}
|
{$Q-}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit ftptsend;
|
unit ftptsend;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -134,6 +139,7 @@ constructor TTFTPSend.Create;
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FSock := TUDPBlockSocket.Create;
|
FSock := TUDPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FTargetPort := cTFTPProtocol;
|
FTargetPort := cTFTPProtocol;
|
||||||
FData := TMemoryStream.Create;
|
FData := TMemoryStream.Create;
|
||||||
FErrorCode := 0;
|
FErrorCode := 0;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 003.012.002 |
|
| Project : Ararat Synapse | 003.012.004 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: HTTP client |
|
| Content: HTTP client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2008, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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) 1999-2008. |
|
| Portions created by Lukas Gebauer are Copyright (c) 1999-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -51,6 +51,17 @@ Used RFC: RFC-1867, RFC-1947, RFC-2388, RFC-2616
|
|||||||
{$MODE DELPHI}
|
{$MODE DELPHI}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
//old Delphi does not have MSWINDOWS define.
|
||||||
|
{$IFDEF WIN32}
|
||||||
|
{$IFNDEF MSWINDOWS}
|
||||||
|
{$DEFINE MSWINDOWS}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit httpsend;
|
unit httpsend;
|
||||||
|
|
||||||
@ -264,6 +275,7 @@ begin
|
|||||||
FCookies := TStringList.Create;
|
FCookies := TStringList.Create;
|
||||||
FDocument := TMemoryStream.Create;
|
FDocument := TMemoryStream.Create;
|
||||||
FSock := TTCPBlockSocket.Create;
|
FSock := TTCPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FSock.ConvertLineEnd := True;
|
FSock.ConvertLineEnd := True;
|
||||||
FSock.SizeRecvBuffer := c64k;
|
FSock.SizeRecvBuffer := c64k;
|
||||||
FSock.SizeSendBuffer := c64k;
|
FSock.SizeSendBuffer := c64k;
|
||||||
@ -321,7 +333,7 @@ begin
|
|||||||
if FProtocol = '0.9' then
|
if FProtocol = '0.9' then
|
||||||
Result := FHeaders[0] + CRLF
|
Result := FHeaders[0] + CRLF
|
||||||
else
|
else
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
Result := AdjustLineBreaks(FHeaders.Text, tlbsCRLF);
|
Result := AdjustLineBreaks(FHeaders.Text, tlbsCRLF);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Result := FHeaders.Text;
|
Result := FHeaders.Text;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 002.005.001 |
|
| Project : Ararat Synapse | 002.005.002 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: IMAP4rev1 client |
|
| Content: IMAP4rev1 client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2004, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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-2004. |
|
| Portions created by Lukas Gebauer are Copyright (c)2001-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -52,6 +52,11 @@ Used RFC: RFC-2060, RFC-2595
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit imapsend;
|
unit imapsend;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -269,6 +274,7 @@ begin
|
|||||||
FFullResult := TStringList.Create;
|
FFullResult := TStringList.Create;
|
||||||
FIMAPcap := TStringList.Create;
|
FIMAPcap := TStringList.Create;
|
||||||
FSock := TTCPBlockSocket.Create;
|
FSock := TTCPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FSock.ConvertLineEnd := True;
|
FSock.ConvertLineEnd := True;
|
||||||
FSock.SizeRecvBuffer := 32768;
|
FSock.SizeRecvBuffer := 32768;
|
||||||
FSock.SizeSendBuffer := 32768;
|
FSock.SizeSendBuffer := 32768;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.006.001 |
|
| Project : Ararat Synapse | 001.007.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: LDAP client |
|
| Content: LDAP client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2009, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)2003-2009. |
|
| Portions created by Lukas Gebauer are Copyright (c)2003-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -52,6 +52,11 @@ Used RFC: RFC-2251, RFC-2254, RFC-2829, RFC-2830
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit ldapsend;
|
unit ldapsend;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -124,6 +129,8 @@ type
|
|||||||
procedure Del(Index: integer);
|
procedure Del(Index: integer);
|
||||||
{:Find and return attribute with requested name. Returns nil if not found.}
|
{:Find and return attribute with requested name. Returns nil if not found.}
|
||||||
function Find(AttributeName: AnsiString): TLDAPAttribute;
|
function Find(AttributeName: AnsiString): TLDAPAttribute;
|
||||||
|
{:Find and return attribute value with requested name. Returns empty string if not found.}
|
||||||
|
function Get(AttributeName: AnsiString): string;
|
||||||
{:List of TLDAPAttribute objects.}
|
{:List of TLDAPAttribute objects.}
|
||||||
property Items[Index: Integer]: TLDAPAttribute read GetAttribute; default;
|
property Items[Index: Integer]: TLDAPAttribute read GetAttribute; default;
|
||||||
end;
|
end;
|
||||||
@ -391,6 +398,17 @@ begin
|
|||||||
Result := FAttributeList.Count;
|
Result := FAttributeList.Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLDAPAttributeList.Get(AttributeName: AnsiString): string;
|
||||||
|
var
|
||||||
|
x: TLDAPAttribute;
|
||||||
|
begin
|
||||||
|
Result := '';
|
||||||
|
x := self.Find(AttributeName);
|
||||||
|
if x <> nil then
|
||||||
|
if x.Count > 0 then
|
||||||
|
Result := x[0];
|
||||||
|
end;
|
||||||
|
|
||||||
function TLDAPAttributeList.GetAttribute(Index: integer): TLDAPAttribute;
|
function TLDAPAttributeList.GetAttribute(Index: integer): TLDAPAttribute;
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
@ -499,6 +517,7 @@ begin
|
|||||||
FReferals := TStringList.Create;
|
FReferals := TStringList.Create;
|
||||||
FFullResult := '';
|
FFullResult := '';
|
||||||
FSock := TTCPBlockSocket.Create;
|
FSock := TTCPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FTimeout := 60000;
|
FTimeout := 60000;
|
||||||
FTargetPort := cLDAPProtocol;
|
FTargetPort := cLDAPProtocol;
|
||||||
FAutoTLS := False;
|
FAutoTLS := False;
|
||||||
|
@ -53,6 +53,11 @@ Used RFC: RFC-2047, RFC-2231
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit mimeinln;
|
unit mimeinln;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
@ -55,6 +55,11 @@ Used RFC: RFC-2045
|
|||||||
{$Q-}
|
{$Q-}
|
||||||
{$R-}
|
{$R-}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit mimepart;
|
unit mimepart;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.005.001 |
|
| Project : Ararat Synapse | 001.005.002 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: NNTP client |
|
| Content: NNTP client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2007, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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) 1999-2007. |
|
| Portions created by Lukas Gebauer are Copyright (c) 1999-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -53,6 +53,12 @@ Used RFC: RFC-977, RFC-2980
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$WARN SUSPICIOUS_TYPECAST OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit nntpsend;
|
unit nntpsend;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -195,6 +201,7 @@ constructor TNNTPSend.Create;
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FSock := TTCPBlockSocket.Create;
|
FSock := TTCPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FData := TStringList.Create;
|
FData := TStringList.Create;
|
||||||
FDataToSend := TStringList.Create;
|
FDataToSend := TStringList.Create;
|
||||||
FNNTPcap := TStringList.Create;
|
FNNTPcap := TStringList.Create;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 004.000.000 |
|
| Project : Ararat Synapse | 004.000.002 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: PING sender |
|
| Content: PING sender |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2007, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)2000-2007. |
|
| Portions created by Lukas Gebauer are Copyright (c)2000-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -66,6 +66,17 @@ Note: This unit is NOT portable to .NET!
|
|||||||
{$IFDEF CIL}
|
{$IFDEF CIL}
|
||||||
Sorry, this unit is not for .NET!
|
Sorry, this unit is not for .NET!
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
//old Delphi does not have MSWINDOWS define.
|
||||||
|
{$IFDEF WIN32}
|
||||||
|
{$IFNDEF MSWINDOWS}
|
||||||
|
{$DEFINE MSWINDOWS}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit pingsend;
|
unit pingsend;
|
||||||
|
|
||||||
@ -74,7 +85,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
SysUtils,
|
SysUtils,
|
||||||
synsock, blcksock, synautil, synafpc, synaip
|
synsock, blcksock, synautil, synafpc, synaip
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
, windows
|
, windows
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
;
|
;
|
||||||
@ -107,7 +118,7 @@ type
|
|||||||
TPINGSend = class(TSynaClient)
|
TPINGSend = class(TSynaClient)
|
||||||
private
|
private
|
||||||
FSock: TICMPBlockSocket;
|
FSock: TICMPBlockSocket;
|
||||||
FBuffer: string;
|
FBuffer: Ansistring;
|
||||||
FSeq: Integer;
|
FSeq: Integer;
|
||||||
FId: Integer;
|
FId: Integer;
|
||||||
FPacketSize: Integer;
|
FPacketSize: Integer;
|
||||||
@ -122,8 +133,8 @@ type
|
|||||||
FReplyErrorDesc: string;
|
FReplyErrorDesc: string;
|
||||||
FTTL: Byte;
|
FTTL: Byte;
|
||||||
Fsin: TVarSin;
|
Fsin: TVarSin;
|
||||||
function Checksum(Value: string): Word;
|
function Checksum(Value: AnsiString): Word;
|
||||||
function Checksum6(Value: string): Word;
|
function Checksum6(Value: AnsiString): Word;
|
||||||
function ReadPacket: Boolean;
|
function ReadPacket: Boolean;
|
||||||
procedure TranslateError;
|
procedure TranslateError;
|
||||||
procedure TranslateErrorIpHlp(value: integer);
|
procedure TranslateErrorIpHlp(value: integer);
|
||||||
@ -184,7 +195,7 @@ implementation
|
|||||||
|
|
||||||
type
|
type
|
||||||
{:Record for ICMP ECHO packet header.}
|
{:Record for ICMP ECHO packet header.}
|
||||||
TIcmpEchoHeader = record
|
TIcmpEchoHeader = packed record
|
||||||
i_type: Byte;
|
i_type: Byte;
|
||||||
i_code: Byte;
|
i_code: Byte;
|
||||||
i_checkSum: Word;
|
i_checkSum: Word;
|
||||||
@ -195,7 +206,7 @@ type
|
|||||||
|
|
||||||
{:record used internally by TPingSend for compute checksum of ICMPv6 packet
|
{:record used internally by TPingSend for compute checksum of ICMPv6 packet
|
||||||
pseudoheader.}
|
pseudoheader.}
|
||||||
TICMP6Packet = record
|
TICMP6Packet = packed record
|
||||||
in_source: TInAddr6;
|
in_source: TInAddr6;
|
||||||
in_dest: TInAddr6;
|
in_dest: TInAddr6;
|
||||||
Length: integer;
|
Length: integer;
|
||||||
@ -205,20 +216,20 @@ type
|
|||||||
proto: Byte;
|
proto: Byte;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
const
|
const
|
||||||
DLLIcmpName = 'iphlpapi.dll';
|
DLLIcmpName = 'iphlpapi.dll';
|
||||||
type
|
type
|
||||||
TIP_OPTION_INFORMATION = packed record
|
TIP_OPTION_INFORMATION = record
|
||||||
TTL: Byte;
|
TTL: Byte;
|
||||||
TOS: Byte;
|
TOS: Byte;
|
||||||
Flags: Byte;
|
Flags: Byte;
|
||||||
OptionsSize: Byte;
|
OptionsSize: Byte;
|
||||||
OptionsData: PChar;
|
OptionsData: PAnsiChar;
|
||||||
end;
|
end;
|
||||||
PIP_OPTION_INFORMATION = ^TIP_OPTION_INFORMATION;
|
PIP_OPTION_INFORMATION = ^TIP_OPTION_INFORMATION;
|
||||||
|
|
||||||
TICMP_ECHO_REPLY = packed record
|
TICMP_ECHO_REPLY = record
|
||||||
Address: TInAddr;
|
Address: TInAddr;
|
||||||
Status: integer;
|
Status: integer;
|
||||||
RoundTripTime: integer;
|
RoundTripTime: integer;
|
||||||
@ -229,7 +240,7 @@ type
|
|||||||
end;
|
end;
|
||||||
PICMP_ECHO_REPLY = ^TICMP_ECHO_REPLY;
|
PICMP_ECHO_REPLY = ^TICMP_ECHO_REPLY;
|
||||||
|
|
||||||
TICMPV6_ECHO_REPLY = packed record
|
TICMPV6_ECHO_REPLY = record
|
||||||
Address: TSockAddrIn6;
|
Address: TSockAddrIn6;
|
||||||
Status: integer;
|
Status: integer;
|
||||||
RoundTripTime: integer;
|
RoundTripTime: integer;
|
||||||
@ -264,6 +275,7 @@ constructor TPINGSend.Create;
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FSock := TICMPBlockSocket.Create;
|
FSock := TICMPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FTimeout := 5000;
|
FTimeout := 5000;
|
||||||
FPacketSize := 32;
|
FPacketSize := 32;
|
||||||
FSeq := 0;
|
FSeq := 0;
|
||||||
@ -331,7 +343,7 @@ begin
|
|||||||
FReplyError := IE_Other;
|
FReplyError := IE_Other;
|
||||||
GenErrorDesc;
|
GenErrorDesc;
|
||||||
FBuffer := StringOfChar(#55, SizeOf(TICMPEchoHeader) + FPacketSize);
|
FBuffer := StringOfChar(#55, SizeOf(TICMPEchoHeader) + FPacketSize);
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
b := IsHostIP6(host);
|
b := IsHostIP6(host);
|
||||||
if not(b) and IcmpHelper4 then
|
if not(b) and IcmpHelper4 then
|
||||||
result := InternalPingIpHlp(host)
|
result := InternalPingIpHlp(host)
|
||||||
@ -399,7 +411,7 @@ begin
|
|||||||
break;
|
break;
|
||||||
if fSock.IP6used then
|
if fSock.IP6used then
|
||||||
begin
|
begin
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
IcmpEchoHeaderPtr := Pointer(FBuffer);
|
IcmpEchoHeaderPtr := Pointer(FBuffer);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
//WinXP SP1 with networking update doing this think by another way ;-O
|
//WinXP SP1 with networking update doing this think by another way ;-O
|
||||||
@ -436,7 +448,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPINGSend.Checksum(Value: string): Word;
|
function TPINGSend.Checksum(Value: AnsiString): Word;
|
||||||
var
|
var
|
||||||
CkSum: integer;
|
CkSum: integer;
|
||||||
Num, Remain: Integer;
|
Num, Remain: Integer;
|
||||||
@ -458,7 +470,7 @@ begin
|
|||||||
Result := Word(not CkSum);
|
Result := Word(not CkSum);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPINGSend.Checksum6(Value: string): Word;
|
function TPINGSend.Checksum6(Value: AnsiString): Word;
|
||||||
const
|
const
|
||||||
IOC_OUT = $40000000;
|
IOC_OUT = $40000000;
|
||||||
IOC_IN = $80000000;
|
IOC_IN = $80000000;
|
||||||
@ -467,13 +479,13 @@ const
|
|||||||
SIO_ROUTING_INTERFACE_QUERY = 20 or IOC_WS2 or IOC_INOUT;
|
SIO_ROUTING_INTERFACE_QUERY = 20 or IOC_WS2 or IOC_INOUT;
|
||||||
var
|
var
|
||||||
ICMP6Ptr: ^TICMP6Packet;
|
ICMP6Ptr: ^TICMP6Packet;
|
||||||
s: string;
|
s: AnsiString;
|
||||||
b: integer;
|
b: integer;
|
||||||
ip6: TSockAddrIn6;
|
ip6: TSockAddrIn6;
|
||||||
x: integer;
|
x: integer;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
s := StringOfChar(#0, SizeOf(TICMP6Packet)) + Value;
|
s := StringOfChar(#0, SizeOf(TICMP6Packet)) + Value;
|
||||||
ICMP6Ptr := Pointer(s);
|
ICMP6Ptr := Pointer(s);
|
||||||
x := synsock.WSAIoctl(FSock.Socket, SIO_ROUTING_INTERFACE_QUERY,
|
x := synsock.WSAIoctl(FSock.Socket, SIO_ROUTING_INTERFACE_QUERY,
|
||||||
@ -565,13 +577,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TPINGSend.InternalPingIpHlp(const Host: string): Boolean;
|
function TPINGSend.InternalPingIpHlp(const Host: string): Boolean;
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
var
|
var
|
||||||
PingIp6: boolean;
|
PingIp6: boolean;
|
||||||
PingHandle: integer;
|
PingHandle: integer;
|
||||||
r: integer;
|
r: integer;
|
||||||
ipo: TIP_OPTION_INFORMATION;
|
ipo: TIP_OPTION_INFORMATION;
|
||||||
RBuff: string;
|
RBuff: Ansistring;
|
||||||
ip4reply: PICMP_ECHO_REPLY;
|
ip4reply: PICMP_ECHO_REPLY;
|
||||||
ip6reply: PICMPV6_ECHO_REPLY;
|
ip6reply: PICMPV6_ECHO_REPLY;
|
||||||
ip6: TSockAddrIn6;
|
ip6: TSockAddrIn6;
|
||||||
@ -595,7 +607,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
FillChar(ip6, sizeof(ip6), 0);
|
FillChar(ip6, sizeof(ip6), 0);
|
||||||
r := Icmp6SendEcho2(PingHandle, nil, nil, nil, @ip6, @Fsin,
|
r := Icmp6SendEcho2(PingHandle, nil, nil, nil, @ip6, @Fsin,
|
||||||
Pchar(FBuffer), length(FBuffer), @ipo, pchar(RBuff), length(RBuff), FTimeout);
|
PAnsichar(FBuffer), length(FBuffer), @ipo, pAnsichar(RBuff), length(RBuff), FTimeout);
|
||||||
if r > 0 then
|
if r > 0 then
|
||||||
begin
|
begin
|
||||||
RBuff := #0 + #0 + RBuff;
|
RBuff := #0 + #0 + RBuff;
|
||||||
@ -610,7 +622,7 @@ begin
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
r := IcmpSendEcho2(PingHandle, nil, nil, nil, Fsin.sin_addr,
|
r := IcmpSendEcho2(PingHandle, nil, nil, nil, Fsin.sin_addr,
|
||||||
Pchar(FBuffer), length(FBuffer), @ipo, pchar(RBuff), length(RBuff), FTimeout);
|
PAnsichar(FBuffer), length(FBuffer), @ipo, pAnsichar(RBuff), length(RBuff), FTimeout);
|
||||||
if r > 0 then
|
if r > 0 then
|
||||||
begin
|
begin
|
||||||
ip4reply := PICMP_ECHO_REPLY(pointer(RBuff));
|
ip4reply := PICMP_ECHO_REPLY(pointer(RBuff));
|
||||||
@ -678,7 +690,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
initialization
|
initialization
|
||||||
begin
|
begin
|
||||||
IcmpHelper4 := false;
|
IcmpHelper4 := false;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 002.006.000 |
|
| Project : Ararat Synapse | 002.006.002 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: POP3 client |
|
| Content: POP3 client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2007, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -51,6 +51,12 @@ Used RFC: RFC-1734, RFC-1939, RFC-2195, RFC-2449, RFC-2595
|
|||||||
{$MODE DELPHI}
|
{$MODE DELPHI}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$M+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit pop3send;
|
unit pop3send;
|
||||||
|
|
||||||
@ -203,6 +209,7 @@ begin
|
|||||||
FFullResult := TStringList.Create;
|
FFullResult := TStringList.Create;
|
||||||
FPOP3cap := TStringList.Create;
|
FPOP3cap := TStringList.Create;
|
||||||
FSock := TTCPBlockSocket.Create;
|
FSock := TTCPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FSock.ConvertLineEnd := true;
|
FSock.ConvertLineEnd := true;
|
||||||
FTimeout := 60000;
|
FTimeout := 60000;
|
||||||
FTargetPort := cPop3Protocol;
|
FTargetPort := cPop3Protocol;
|
||||||
@ -224,7 +231,7 @@ end;
|
|||||||
|
|
||||||
function TPOP3Send.ReadResult(Full: Boolean): Integer;
|
function TPOP3Send.ReadResult(Full: Boolean): Integer;
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
FFullResult.Clear;
|
FFullResult.Clear;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.002.002 |
|
| Project : Ararat Synapse | 001.002.003 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: SysLog client |
|
| Content: SysLog client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2003, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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-2003. |
|
| Portions created by Lukas Gebauer are Copyright (c)2001-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -264,6 +264,7 @@ constructor TSyslogSend.Create;
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FSock := TUDPBlockSocket.Create;
|
FSock := TUDPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FSysLogMessage := TSysLogMessage.Create;
|
FSysLogMessage := TSysLogMessage.Create;
|
||||||
FTargetPort := cSysLogProtocol;
|
FTargetPort := cSysLogProtocol;
|
||||||
end;
|
end;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 003.005.000 |
|
| Project : Ararat Synapse | 003.005.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: SMTP client |
|
| Content: SMTP client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2009, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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) 1999-2009. |
|
| Portions created by Lukas Gebauer are Copyright (c) 1999-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -53,6 +53,11 @@ Used RFC: RFC-1869, RFC-1870, RFC-1893, RFC-2034, RFC-2104, RFC-2195, RFC-2487,
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit smtpsend;
|
unit smtpsend;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -261,6 +266,7 @@ begin
|
|||||||
FFullResult := TStringList.Create;
|
FFullResult := TStringList.Create;
|
||||||
FESMTPcap := TStringList.Create;
|
FESMTPcap := TStringList.Create;
|
||||||
FSock := TTCPBlockSocket.Create;
|
FSock := TTCPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FSock.ConvertLineEnd := true;
|
FSock.ConvertLineEnd := true;
|
||||||
FTimeout := 60000;
|
FTimeout := 60000;
|
||||||
FTargetPort := cSmtpProtocol;
|
FTargetPort := cSmtpProtocol;
|
||||||
@ -315,7 +321,7 @@ end;
|
|||||||
|
|
||||||
function TSMTPSend.ReadResult: Integer;
|
function TSMTPSend.ReadResult: Integer;
|
||||||
var
|
var
|
||||||
s: string;
|
s: String;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
FFullResult.Clear;
|
FFullResult.Clear;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 003.000.009 |
|
| Project : Ararat Synapse | 003.000.010 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: SNMP client |
|
| Content: SNMP client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2007, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)2000-2007. |
|
| Portions created by Lukas Gebauer are Copyright (c)2000-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -56,6 +56,11 @@ Used RFC: RFC-1157, RFC-1901, RFC-3412, RFC-3414, RFC-3416
|
|||||||
{$Q-}
|
{$Q-}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit snmpsend;
|
unit snmpsend;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -771,6 +776,7 @@ begin
|
|||||||
FQuery.Clear;
|
FQuery.Clear;
|
||||||
FReply.Clear;
|
FReply.Clear;
|
||||||
FSock := TUDPBlockSocket.Create;
|
FSock := TUDPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FTimeout := 5000;
|
FTimeout := 5000;
|
||||||
FTargetPort := cSnmpProtocol;
|
FTargetPort := cSnmpProtocol;
|
||||||
FHostIP := '';
|
FHostIP := '';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 003.000.002 |
|
| Project : Ararat Synapse | 003.000.003 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: SNTP client |
|
| Content: SNTP client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2007, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)2000-2007. |
|
| Portions created by Lukas Gebauer are Copyright (c)2000-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -101,7 +101,7 @@ type
|
|||||||
FMaxSyncDiff: double;
|
FMaxSyncDiff: double;
|
||||||
FSyncTime: Boolean;
|
FSyncTime: Boolean;
|
||||||
FSock: TUDPBlockSocket;
|
FSock: TUDPBlockSocket;
|
||||||
FBuffer: string;
|
FBuffer: AnsiString;
|
||||||
FLi, FVn, Fmode : byte;
|
FLi, FVn, Fmode : byte;
|
||||||
function StrToNTP(const Value: AnsiString): TNtp;
|
function StrToNTP(const Value: AnsiString): TNtp;
|
||||||
function NTPtoStr(const Value: Tntp): AnsiString;
|
function NTPtoStr(const Value: Tntp): AnsiString;
|
||||||
@ -162,6 +162,7 @@ constructor TSNTPSend.Create;
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FSock := TUDPBlockSocket.Create;
|
FSock := TUDPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FTimeout := 5000;
|
FTimeout := 5000;
|
||||||
FTargetPort := cNtpProtocol;
|
FTargetPort := cNtpProtocol;
|
||||||
FMaxSyncDiff := 3600;
|
FMaxSyncDiff := 3600;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.001.000 |
|
| Project : Ararat Synapse | 001.001.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Socket Independent Platform Layer - FreePascal definition include |
|
| Content: Socket Independent Platform Layer - FreePascal definition include |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)2006-2009, Lukas Gebauer |
|
| Copyright (c)2006-2010, 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-2009. |
|
| Portions created by Lukas Gebauer are Copyright (c)2006-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -113,6 +113,7 @@ const
|
|||||||
IPPROTO_UDP = 17; { User Datagram Protocol }
|
IPPROTO_UDP = 17; { User Datagram Protocol }
|
||||||
IPPROTO_IPV6 = 41;
|
IPPROTO_IPV6 = 41;
|
||||||
IPPROTO_ICMPV6 = 58;
|
IPPROTO_ICMPV6 = 58;
|
||||||
|
IPPROTO_RM = 113;
|
||||||
|
|
||||||
IPPROTO_RAW = 255;
|
IPPROTO_RAW = 255;
|
||||||
IPPROTO_MAX = 256;
|
IPPROTO_MAX = 256;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.001.000 |
|
| Project : Ararat Synapse | 001.001.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: SSL support by OpenSSL |
|
| Content: SSL support by OpenSSL |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -80,6 +80,11 @@ accepting of new connections!
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit ssl_openssl;
|
unit ssl_openssl;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -615,10 +620,9 @@ begin
|
|||||||
err := SslGetError(FSsl, Result);
|
err := SslGetError(FSsl, Result);
|
||||||
until (err <> SSL_ERROR_WANT_READ) and (err <> SSL_ERROR_WANT_WRITE);
|
until (err <> SSL_ERROR_WANT_READ) and (err <> SSL_ERROR_WANT_WRITE);
|
||||||
if err = SSL_ERROR_ZERO_RETURN then
|
if err = SSL_ERROR_ZERO_RETURN then
|
||||||
Result := 0
|
Result := 0;
|
||||||
else
|
if (err <> 0) then
|
||||||
if (err <> 0) then
|
FLastError := err;
|
||||||
FLastError := err;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSSLOpenSSL.WaitingData: Integer;
|
function TSSLOpenSSL.WaitingData: Integer;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 003.005.000 |
|
| Project : Ararat Synapse | 003.006.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: SSL support by OpenSSL |
|
| Content: SSL support by OpenSSL |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2008, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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-2008. |
|
| Portions created by Lukas Gebauer are Copyright (c)2002-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -60,6 +60,13 @@ Special thanks to Gregor Ibic <gregor.ibic@intelicom.si>
|
|||||||
(*$HPPEMIT 'namespace ssl_openssl_lib { using System::Shortint; }' *)
|
(*$HPPEMIT 'namespace ssl_openssl_lib { using System::Shortint; }' *)
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
//old Delphi does not have MSWINDOWS define.
|
||||||
|
{$IFDEF WIN32}
|
||||||
|
{$IFNDEF MSWINDOWS}
|
||||||
|
{$DEFINE MSWINDOWS}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
{:@abstract(OpenSSL support)
|
{:@abstract(OpenSSL support)
|
||||||
|
|
||||||
This unit is Pascal interface to OpenSSL library (used by @link(ssl_openssl) unit).
|
This unit is Pascal interface to OpenSSL library (used by @link(ssl_openssl) unit).
|
||||||
@ -77,7 +84,7 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes,
|
Classes,
|
||||||
synafpc,
|
synafpc,
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
Libc, SysUtils;
|
Libc, SysUtils;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Windows;
|
Windows;
|
||||||
@ -95,7 +102,7 @@ const
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
var
|
var
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
DLLSSLName: string = 'libssl.so';
|
DLLSSLName: string = 'libssl.so';
|
||||||
DLLUtilName: string = 'libcrypto.so';
|
DLLUtilName: string = 'libcrypto.so';
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -319,6 +326,11 @@ var
|
|||||||
EntryPoint = 'SSL_CTX_load_verify_locations')]
|
EntryPoint = 'SSL_CTX_load_verify_locations')]
|
||||||
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; CAfile: string; CApath: String):Integer; external;
|
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; CAfile: string; CApath: String):Integer; external;
|
||||||
|
|
||||||
|
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
|
||||||
|
SetLastError = False, CallingConvention= CallingConvention.cdecl,
|
||||||
|
EntryPoint = 'SSL_CTX_ctrl')]
|
||||||
|
function SslCtxCtrl(ctx: PSSL_CTX; cmd: integer; larg: integer; parg: IntPtr): integer; external;
|
||||||
|
|
||||||
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
|
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
|
||||||
SetLastError = False, CallingConvention= CallingConvention.cdecl,
|
SetLastError = False, CallingConvention= CallingConvention.cdecl,
|
||||||
EntryPoint = 'SSL_new')]
|
EntryPoint = 'SSL_new')]
|
||||||
@ -674,6 +686,7 @@ var
|
|||||||
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: AnsiString; const CApath: AnsiString):Integer;
|
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: AnsiString; const CApath: AnsiString):Integer;
|
||||||
|
function SslCtxCtrl(ctx: PSSL_CTX; cmd: integer; larg: integer; parg: SslPtr): 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;
|
||||||
@ -782,6 +795,7 @@ type
|
|||||||
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: PAnsiChar; const CApath: PAnsiChar):Integer; cdecl;
|
TSslCtxLoadVerifyLocations = function(ctx: PSSL_CTX; const CAfile: PAnsiChar; const CApath: PAnsiChar):Integer; cdecl;
|
||||||
|
TSslCtxCtrl = function(ctx: PSSL_CTX; cmd: integer; larg: integer; parg: SslPtr): 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;
|
||||||
@ -880,6 +894,7 @@ var
|
|||||||
_SslCtxSetDefaultPasswdCb: TSslCtxSetDefaultPasswdCb = nil;
|
_SslCtxSetDefaultPasswdCb: TSslCtxSetDefaultPasswdCb = nil;
|
||||||
_SslCtxSetDefaultPasswdCbUserdata: TSslCtxSetDefaultPasswdCbUserdata = nil;
|
_SslCtxSetDefaultPasswdCbUserdata: TSslCtxSetDefaultPasswdCbUserdata = nil;
|
||||||
_SslCtxLoadVerifyLocations: TSslCtxLoadVerifyLocations = nil;
|
_SslCtxLoadVerifyLocations: TSslCtxLoadVerifyLocations = nil;
|
||||||
|
_SslCtxCtrl: TSslCtxCtrl = nil;
|
||||||
_SslNew: TSslNew = nil;
|
_SslNew: TSslNew = nil;
|
||||||
_SslFree: TSslFree = nil;
|
_SslFree: TSslFree = nil;
|
||||||
_SslAccept: TSslAccept = nil;
|
_SslAccept: TSslAccept = nil;
|
||||||
@ -1135,6 +1150,14 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SslCtxCtrl(ctx: PSSL_CTX; cmd: integer; larg: integer; parg: SslPtr): integer;
|
||||||
|
begin
|
||||||
|
if InitSSLInterface and Assigned(_SslCtxCtrl) then
|
||||||
|
Result := _SslCtxCtrl(ctx, cmd, larg, parg)
|
||||||
|
else
|
||||||
|
Result := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
function SslNew(ctx: PSSL_CTX):PSSL;
|
function SslNew(ctx: PSSL_CTX):PSSL;
|
||||||
begin
|
begin
|
||||||
if InitSSLInterface and Assigned(_SslNew) then
|
if InitSSLInterface and Assigned(_SslNew) then
|
||||||
@ -1352,7 +1375,7 @@ 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);
|
||||||
buf := PChar(Buf);
|
buf := PAnsiChar(Buf);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ErrGetError: integer;
|
function ErrGetError: integer;
|
||||||
@ -1736,6 +1759,7 @@ begin
|
|||||||
_SslCtxSetDefaultPasswdCb := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_default_passwd_cb');
|
_SslCtxSetDefaultPasswdCb := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_default_passwd_cb');
|
||||||
_SslCtxSetDefaultPasswdCbUserdata := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_default_passwd_cb_userdata');
|
_SslCtxSetDefaultPasswdCbUserdata := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_default_passwd_cb_userdata');
|
||||||
_SslCtxLoadVerifyLocations := GetProcAddr(SSLLibHandle, 'SSL_CTX_load_verify_locations');
|
_SslCtxLoadVerifyLocations := GetProcAddr(SSLLibHandle, 'SSL_CTX_load_verify_locations');
|
||||||
|
_SslCtxCtrl := GetProcAddr(SSLLibHandle, 'SSL_CTX_ctrl');
|
||||||
_SslNew := GetProcAddr(SSLLibHandle, 'SSL_new');
|
_SslNew := GetProcAddr(SSLLibHandle, 'SSL_new');
|
||||||
_SslFree := GetProcAddr(SSLLibHandle, 'SSL_free');
|
_SslFree := GetProcAddr(SSLLibHandle, 'SSL_free');
|
||||||
_SslAccept := GetProcAddr(SSLLibHandle, 'SSL_accept');
|
_SslAccept := GetProcAddr(SSLLibHandle, 'SSL_accept');
|
||||||
@ -1919,6 +1943,7 @@ begin
|
|||||||
_SslCtxSetDefaultPasswdCb := nil;
|
_SslCtxSetDefaultPasswdCb := nil;
|
||||||
_SslCtxSetDefaultPasswdCbUserdata := nil;
|
_SslCtxSetDefaultPasswdCbUserdata := nil;
|
||||||
_SslCtxLoadVerifyLocations := nil;
|
_SslCtxLoadVerifyLocations := nil;
|
||||||
|
_SslCtxCtrl := nil;
|
||||||
_SslNew := nil;
|
_SslNew := nil;
|
||||||
_SslFree := nil;
|
_SslFree := nil;
|
||||||
_SslAccept := nil;
|
_SslAccept := nil;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 002.000.008 |
|
| Project : Ararat Synapse | 002.000.009 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Socket Independent Platform Layer - Linux definition include |
|
| Content: Socket Independent Platform Layer - Linux definition include |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2003, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)2003. |
|
| Portions created by Lukas Gebauer are Copyright (c)2003-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -129,6 +129,7 @@ const
|
|||||||
IPPROTO_UDP = 17; { User Datagram Protocol }
|
IPPROTO_UDP = 17; { User Datagram Protocol }
|
||||||
IPPROTO_IPV6 = 41;
|
IPPROTO_IPV6 = 41;
|
||||||
IPPROTO_ICMPV6 = 58;
|
IPPROTO_ICMPV6 = 58;
|
||||||
|
IPPROTO_RM = 113;
|
||||||
|
|
||||||
IPPROTO_RAW = 255;
|
IPPROTO_RAW = 255;
|
||||||
IPPROTO_MAX = 256;
|
IPPROTO_MAX = 256;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 002.002.000 |
|
| Project : Ararat Synapse | 002.002.003 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Socket Independent Platform Layer - Win32 definition include |
|
| Content: Socket Independent Platform Layer - Win32 definition include |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2008, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)2003. |
|
| Portions created by Lukas Gebauer are Copyright (c)2003-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -44,8 +44,6 @@
|
|||||||
|
|
||||||
{:@exclude}
|
{:@exclude}
|
||||||
|
|
||||||
{$IFDEF WIN32}
|
|
||||||
|
|
||||||
//{$DEFINE WINSOCK1}
|
//{$DEFINE WINSOCK1}
|
||||||
{Note about define WINSOCK1:
|
{Note about define WINSOCK1:
|
||||||
If you activate this compiler directive, then socket interface level 1.1 is
|
If you activate this compiler directive, then socket interface level 1.1 is
|
||||||
@ -260,7 +258,11 @@ type
|
|||||||
u_long = Longint;
|
u_long = Longint;
|
||||||
pu_long = ^u_long;
|
pu_long = ^u_long;
|
||||||
pu_short = ^u_short;
|
pu_short = ^u_short;
|
||||||
|
{$IFDEF FPC}
|
||||||
|
TSocket = ptruint;
|
||||||
|
{$ELSE}
|
||||||
TSocket = u_int;
|
TSocket = u_int;
|
||||||
|
{$ENDIF}
|
||||||
TAddrFamily = integer;
|
TAddrFamily = integer;
|
||||||
|
|
||||||
TMemory = pointer;
|
TMemory = pointer;
|
||||||
@ -286,7 +288,7 @@ const
|
|||||||
FD_SETSIZE = 64;
|
FD_SETSIZE = 64;
|
||||||
type
|
type
|
||||||
PFDSet = ^TFDSet;
|
PFDSet = ^TFDSet;
|
||||||
TFDSet = packed record
|
TFDSet = record
|
||||||
fd_count: u_int;
|
fd_count: u_int;
|
||||||
fd_array: array[0..FD_SETSIZE-1] of TSocket;
|
fd_array: array[0..FD_SETSIZE-1] of TSocket;
|
||||||
end;
|
end;
|
||||||
@ -298,7 +300,7 @@ const
|
|||||||
|
|
||||||
type
|
type
|
||||||
PTimeVal = ^TTimeVal;
|
PTimeVal = ^TTimeVal;
|
||||||
TTimeVal = packed record
|
TTimeVal = record
|
||||||
tv_sec: Longint;
|
tv_sec: Longint;
|
||||||
tv_usec: Longint;
|
tv_usec: Longint;
|
||||||
end;
|
end;
|
||||||
@ -311,6 +313,7 @@ const
|
|||||||
IPPROTO_UDP = 17; { User Datagram Protocol }
|
IPPROTO_UDP = 17; { User Datagram Protocol }
|
||||||
IPPROTO_IPV6 = 41;
|
IPPROTO_IPV6 = 41;
|
||||||
IPPROTO_ICMPV6 = 58;
|
IPPROTO_ICMPV6 = 58;
|
||||||
|
IPPROTO_RM = 113;
|
||||||
|
|
||||||
IPPROTO_RAW = 255;
|
IPPROTO_RAW = 255;
|
||||||
IPPROTO_MAX = 256;
|
IPPROTO_MAX = 256;
|
||||||
@ -318,14 +321,14 @@ const
|
|||||||
type
|
type
|
||||||
|
|
||||||
PInAddr = ^TInAddr;
|
PInAddr = ^TInAddr;
|
||||||
TInAddr = packed record
|
TInAddr = record
|
||||||
case integer of
|
case integer of
|
||||||
0: (S_bytes: packed array [0..3] of byte);
|
0: (S_bytes: packed array [0..3] of byte);
|
||||||
1: (S_addr: u_long);
|
1: (S_addr: u_long);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PSockAddrIn = ^TSockAddrIn;
|
PSockAddrIn = ^TSockAddrIn;
|
||||||
TSockAddrIn = packed record
|
TSockAddrIn = record
|
||||||
case Integer of
|
case Integer of
|
||||||
0: (sin_family: u_short;
|
0: (sin_family: u_short;
|
||||||
sin_port: u_short;
|
sin_port: u_short;
|
||||||
@ -341,7 +344,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
PInAddr6 = ^TInAddr6;
|
PInAddr6 = ^TInAddr6;
|
||||||
TInAddr6 = packed record
|
TInAddr6 = record
|
||||||
case integer of
|
case integer of
|
||||||
0: (S6_addr: packed array [0..15] of byte);
|
0: (S6_addr: packed array [0..15] of byte);
|
||||||
1: (u6_addr8: packed array [0..15] of byte);
|
1: (u6_addr8: packed array [0..15] of byte);
|
||||||
@ -350,7 +353,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
PSockAddrIn6 = ^TSockAddrIn6;
|
PSockAddrIn6 = ^TSockAddrIn6;
|
||||||
TSockAddrIn6 = packed record
|
TSockAddrIn6 = record
|
||||||
sin6_family: u_short; // AF_INET6
|
sin6_family: u_short; // AF_INET6
|
||||||
sin6_port: u_short; // Transport level port number
|
sin6_port: u_short; // Transport level port number
|
||||||
sin6_flowinfo: u_long; // IPv6 flow information
|
sin6_flowinfo: u_long; // IPv6 flow information
|
||||||
@ -366,7 +369,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
PHostEnt = ^THostEnt;
|
PHostEnt = ^THostEnt;
|
||||||
THostEnt = packed record
|
THostEnt = record
|
||||||
h_name: PAnsiChar;
|
h_name: PAnsiChar;
|
||||||
h_aliases: ^PAnsiChar;
|
h_aliases: ^PAnsiChar;
|
||||||
h_addrtype: Smallint;
|
h_addrtype: Smallint;
|
||||||
@ -377,7 +380,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
PNetEnt = ^TNetEnt;
|
PNetEnt = ^TNetEnt;
|
||||||
TNetEnt = packed record
|
TNetEnt = record
|
||||||
n_name: PAnsiChar;
|
n_name: PAnsiChar;
|
||||||
n_aliases: ^PAnsiChar;
|
n_aliases: ^PAnsiChar;
|
||||||
n_addrtype: Smallint;
|
n_addrtype: Smallint;
|
||||||
@ -385,15 +388,20 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
PServEnt = ^TServEnt;
|
PServEnt = ^TServEnt;
|
||||||
TServEnt = packed record
|
TServEnt = record
|
||||||
s_name: PAnsiChar;
|
s_name: PAnsiChar;
|
||||||
s_aliases: ^PAnsiChar;
|
s_aliases: ^PAnsiChar;
|
||||||
|
{$ifdef WIN64}
|
||||||
|
s_proto: PAnsiChar;
|
||||||
|
s_port: Smallint;
|
||||||
|
{$else}
|
||||||
s_port: Smallint;
|
s_port: Smallint;
|
||||||
s_proto: PAnsiChar;
|
s_proto: PAnsiChar;
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PProtoEnt = ^TProtoEnt;
|
PProtoEnt = ^TProtoEnt;
|
||||||
TProtoEnt = packed record
|
TProtoEnt = record
|
||||||
p_name: PAnsiChar;
|
p_name: PAnsiChar;
|
||||||
p_aliases: ^PAnsichar;
|
p_aliases: ^PAnsichar;
|
||||||
p_proto: Smallint;
|
p_proto: Smallint;
|
||||||
@ -526,7 +534,7 @@ type
|
|||||||
|
|
||||||
{ Structure used by kernel to pass protocol information in raw sockets. }
|
{ Structure used by kernel to pass protocol information in raw sockets. }
|
||||||
PSockProto = ^TSockProto;
|
PSockProto = ^TSockProto;
|
||||||
TSockProto = packed record
|
TSockProto = record
|
||||||
sp_family: u_short;
|
sp_family: u_short;
|
||||||
sp_protocol: u_short;
|
sp_protocol: u_short;
|
||||||
end;
|
end;
|
||||||
@ -553,7 +561,7 @@ const
|
|||||||
type
|
type
|
||||||
{ Structure used for manipulating linger option. }
|
{ Structure used for manipulating linger option. }
|
||||||
PLinger = ^TLinger;
|
PLinger = ^TLinger;
|
||||||
TLinger = packed record
|
TLinger = record
|
||||||
l_onoff: u_short;
|
l_onoff: u_short;
|
||||||
l_linger: u_short;
|
l_linger: u_short;
|
||||||
end;
|
end;
|
||||||
@ -715,14 +723,22 @@ const
|
|||||||
WSASYS_STATUS_LEN = 128;
|
WSASYS_STATUS_LEN = 128;
|
||||||
type
|
type
|
||||||
PWSAData = ^TWSAData;
|
PWSAData = ^TWSAData;
|
||||||
TWSAData = packed record
|
TWSAData = record
|
||||||
wVersion: Word;
|
wVersion: Word;
|
||||||
wHighVersion: Word;
|
wHighVersion: Word;
|
||||||
|
{$ifdef win64}
|
||||||
|
iMaxSockets : Word;
|
||||||
|
iMaxUdpDg : Word;
|
||||||
|
lpVendorInfo : PAnsiChar;
|
||||||
|
szDescription : array[0..WSADESCRIPTION_LEN] of AnsiChar;
|
||||||
|
szSystemStatus : array[0..WSASYS_STATUS_LEN] of AnsiChar;
|
||||||
|
{$else}
|
||||||
szDescription: array[0..WSADESCRIPTION_LEN] of AnsiChar;
|
szDescription: array[0..WSADESCRIPTION_LEN] of AnsiChar;
|
||||||
szSystemStatus: array[0..WSASYS_STATUS_LEN] of AnsiChar;
|
szSystemStatus: array[0..WSASYS_STATUS_LEN] of AnsiChar;
|
||||||
iMaxSockets: Word;
|
iMaxSockets: Word;
|
||||||
iMaxUdpDg: Word;
|
iMaxUdpDg: Word;
|
||||||
lpVendorInfo: PAnsiChar;
|
lpVendorInfo: PAnsiChar;
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function IN6_IS_ADDR_UNSPECIFIED(const a: PInAddr6): boolean;
|
function IN6_IS_ADDR_UNSPECIFIED(const a: PInAddr6): boolean;
|
||||||
@ -1167,10 +1183,10 @@ begin
|
|||||||
Sin.sin_family := AF_INET;
|
Sin.sin_family := AF_INET;
|
||||||
ProtoEnt := synsock.GetProtoByNumber(SockProtocol);
|
ProtoEnt := synsock.GetProtoByNumber(SockProtocol);
|
||||||
ServEnt := nil;
|
ServEnt := nil;
|
||||||
if ProtoEnt <> nil then
|
if (ProtoEnt <> nil) and (StrToIntDef(string(Port),-1) =-1) then
|
||||||
ServEnt := synsock.GetServByName(PAnsiChar(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(string(Port), 0))
|
||||||
else
|
else
|
||||||
Sin.sin_port := ServEnt^.s_port;
|
Sin.sin_port := ServEnt^.s_port;
|
||||||
if IP = cBroadcast then
|
if IP = cBroadcast then
|
||||||
@ -1282,7 +1298,7 @@ var
|
|||||||
IP: u_long;
|
IP: u_long;
|
||||||
PAdrPtr: PaPInAddr;
|
PAdrPtr: PaPInAddr;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
s: AnsiString;
|
s: String;
|
||||||
InAddr: TInAddr;
|
InAddr: TInAddr;
|
||||||
begin
|
begin
|
||||||
IPList.Clear;
|
IPList.Clear;
|
||||||
@ -1312,7 +1328,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
IPList.Add(Name);
|
IPList.Add(string(Name));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -1342,7 +1358,7 @@ begin
|
|||||||
if r = 0 then
|
if r = 0 then
|
||||||
begin
|
begin
|
||||||
host := PAnsiChar(host);
|
host := PAnsiChar(host);
|
||||||
IPList.Add(host);
|
IPList.Add(string(host));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
AddrNext := AddrNext^.ai_next;
|
AddrNext := AddrNext^.ai_next;
|
||||||
@ -1375,7 +1391,7 @@ begin
|
|||||||
if ProtoEnt <> nil then
|
if ProtoEnt <> nil then
|
||||||
ServEnt := synsock.GetServByName(PAnsiChar(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(string(Port), 0)
|
||||||
else
|
else
|
||||||
Result := synsock.htons(ServEnt^.s_port);
|
Result := synsock.htons(ServEnt^.s_port);
|
||||||
finally
|
finally
|
||||||
@ -1581,5 +1597,3 @@ finalization
|
|||||||
begin
|
begin
|
||||||
SynSockCS.Free;
|
SynSockCS.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ENDIF}
|
|
@ -60,6 +60,11 @@ Internal routines knows all major charsets for Europe or America. For East-Asian
|
|||||||
{$Q-}
|
{$Q-}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit synachar;
|
unit synachar;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 002.002.000 |
|
| Project : Ararat Synapse | 002.002.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Coding and decoding support |
|
| Content: Coding and decoding support |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2007, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)2000-2007. |
|
| Portions created by Lukas Gebauer are Copyright (c)2000-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -50,6 +50,12 @@
|
|||||||
{$R-}
|
{$R-}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$WARN SUSPICIOUS_TYPECAST OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit synacode;
|
unit synacode;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -66,7 +72,7 @@ const
|
|||||||
['=', '(', ')', '[', ']', '<', '>', ':', ';', ',', '@', '/', '?', '\',
|
['=', '(', ')', '[', ']', '<', '>', ':', ';', ',', '@', '/', '?', '\',
|
||||||
'"', '_'];
|
'"', '_'];
|
||||||
NonAsciiChar: TSpecials =
|
NonAsciiChar: TSpecials =
|
||||||
[Char(0)..Char(31), Char(127)..Char(255)];
|
[#0..#31, #127..#255];
|
||||||
URLFullSpecialChar: TSpecials =
|
URLFullSpecialChar: TSpecials =
|
||||||
[';', '/', '?', ':', '@', '=', '&', '#', '+'];
|
[';', '/', '?', ':', '@', '=', '&', '#', '+'];
|
||||||
URLSpecialChar: TSpecials =
|
URLSpecialChar: TSpecials =
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.000.000 |
|
| Project : Ararat Synapse | 001.000.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Encryption support |
|
| Content: Encryption support |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)2007, Lukas Gebauer |
|
| Copyright (c)2007-2010, 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)2007. |
|
| Portions created by Lukas Gebauer are Copyright (c)2007-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
| Based on work of David Barton and Eric Young |
|
| Based on work of David Barton and Eric Young |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -56,6 +56,11 @@ Implemented are DES and 3DES encryption/decryption by ECB, CBC, CFB-8bit,
|
|||||||
{$R-}
|
{$R-}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit synacrypt;
|
unit synacrypt;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.001.000 |
|
| Project : Ararat Synapse | 001.001.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Socket debug tools |
|
| Content: Socket debug tools |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)2008, Lukas Gebauer |
|
| Copyright (c)2008-2010, 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)2008. |
|
| Portions created by Lukas Gebauer are Copyright (c)2008-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -47,6 +47,10 @@
|
|||||||
Routines for help with debugging of events on the Sockets.
|
Routines for help with debugging of events on the Sockets.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit synadbg;
|
unit synadbg;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.001.001 |
|
| Project : Ararat Synapse | 001.001.002 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Utils for FreePascal compatibility |
|
| Content: Utils for FreePascal compatibility |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2007, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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)2003-2007. |
|
| Portions created by Lukas Gebauer are Copyright (c)2003-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -48,6 +48,12 @@
|
|||||||
{$MODE DELPHI}
|
{$MODE DELPHI}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
//old Delphi does not have MSWINDOWS define.
|
||||||
|
{$IFDEF WIN32}
|
||||||
|
{$IFNDEF MSWINDOWS}
|
||||||
|
{$DEFINE MSWINDOWS}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit synafpc;
|
unit synafpc;
|
||||||
|
|
||||||
@ -57,7 +63,7 @@ uses
|
|||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
dynlibs, sysutils;
|
dynlibs, sysutils;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
Windows;
|
Windows;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
SysUtils;
|
SysUtils;
|
||||||
@ -116,7 +122,7 @@ end;
|
|||||||
|
|
||||||
procedure Sleep(milliseconds: Cardinal);
|
procedure Sleep(milliseconds: Cardinal);
|
||||||
begin
|
begin
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
sysutils.sleep(milliseconds);
|
sysutils.sleep(milliseconds);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.001.000 |
|
| Project : Ararat Synapse | 001.001.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: ICONV support for Win32, Linux and .NET |
|
| Content: ICONV support for Win32, Linux and .NET |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)2004-2008, Lukas Gebauer |
|
| Copyright (c)2004-2010, 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-2008. |
|
| Portions created by Lukas Gebauer are Copyright (c)2004-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -46,6 +46,12 @@
|
|||||||
{$MODE DELPHI}
|
{$MODE DELPHI}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
//old Delphi does not have MSWINDOWS define.
|
||||||
|
{$IFDEF WIN32}
|
||||||
|
{$IFNDEF MSWINDOWS}
|
||||||
|
{$DEFINE MSWINDOWS}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
{:@abstract(LibIconv support)
|
{:@abstract(LibIconv support)
|
||||||
|
|
||||||
@ -63,7 +69,7 @@ uses
|
|||||||
System.Text,
|
System.Text,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
synafpc,
|
synafpc,
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
Libc,
|
Libc,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -74,7 +80,7 @@ uses
|
|||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
DLLIconvName = 'libiconv.so';
|
DLLIconvName = 'libiconv.so';
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
DLLIconvName = 'iconv.dll';
|
DLLIconvName = 'iconv.dll';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.002.000 |
|
| Project : Ararat Synapse | 001.002.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: IP address support procedures and functions |
|
| Content: IP address support procedures and functions |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)2006-2009, Lukas Gebauer |
|
| Copyright (c)2006-2010, 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-2008. |
|
| Portions created by Lukas Gebauer are Copyright (c) 2006-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -51,6 +51,12 @@
|
|||||||
{$R-}
|
{$R-}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$WARN SUSPICIOUS_TYPECAST OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit synaip;
|
unit synaip;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -112,7 +118,7 @@ var
|
|||||||
// i.e. "$80"
|
// i.e. "$80"
|
||||||
if Result then
|
if Result then
|
||||||
for n := 1 to length(Value) do
|
for n := 1 to length(Value) do
|
||||||
if not (Value[n] in ['0'..'9']) then
|
if not (AnsiChar(Value[n]) in ['0'..'9']) then
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
Break;
|
Break;
|
||||||
@ -193,7 +199,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
s := Fetch(Host, '.');
|
s := Fetch(Host, '.');
|
||||||
i := StrToIntDef(s, 0);
|
i := StrToIntDef(s, 0);
|
||||||
Result := Result + Chr(i);
|
Result := Result + AnsiChar(i);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: misc. procedures and functions |
|
| Content: misc. procedures and functions |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2008, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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-2008. |
|
| Portions created by Lukas Gebauer are Copyright (c) 2002-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -50,6 +50,11 @@
|
|||||||
{$Q-}
|
{$Q-}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit synamisc;
|
unit synamisc;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 007.003.000 |
|
| Project : Ararat Synapse | 007.004.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Serial port support |
|
| Content: Serial port support |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)2001-2008, Lukas Gebauer |
|
| Copyright (c)2001-2010, 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-2008. |
|
| Portions created by Lukas Gebauer are Copyright (c)2001-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -69,9 +69,16 @@ case with my USB modem):
|
|||||||
#)
|
#)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//old Delphi does not have MSWINDOWS define.
|
||||||
|
{$IFDEF WIN32}
|
||||||
|
{$IFNDEF MSWINDOWS}
|
||||||
|
{$DEFINE MSWINDOWS}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
{$MODE DELPHI}
|
{$MODE DELPHI}
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
{$ASMMODE intel}
|
{$ASMMODE intel}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{define working mode w/o LIBC for fpc}
|
{define working mode w/o LIBC for fpc}
|
||||||
@ -86,7 +93,7 @@ unit synaser;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
{$IFNDEF NO_LIBC}
|
{$IFNDEF NO_LIBC}
|
||||||
Libc,
|
Libc,
|
||||||
KernelIoctl,
|
KernelIoctl,
|
||||||
@ -156,13 +163,13 @@ const
|
|||||||
{:stopbit value for 2 stopbits}
|
{:stopbit value for 2 stopbits}
|
||||||
SB2 = 2;
|
SB2 = 2;
|
||||||
|
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
const
|
const
|
||||||
INVALID_HANDLE_VALUE = THandle(-1);
|
INVALID_HANDLE_VALUE = THandle(-1);
|
||||||
CS7fix = $0000020;
|
CS7fix = $0000020;
|
||||||
|
|
||||||
type
|
type
|
||||||
TDCB = packed record
|
TDCB = record
|
||||||
DCBlength: DWORD;
|
DCBlength: DWORD;
|
||||||
BaudRate: DWORD;
|
BaudRate: DWORD;
|
||||||
Flags: Longint;
|
Flags: Longint;
|
||||||
@ -182,8 +189,11 @@ type
|
|||||||
PDCB = ^TDCB;
|
PDCB = ^TDCB;
|
||||||
|
|
||||||
const
|
const
|
||||||
// MaxRates = 30;
|
{$IFDEF LINUX}
|
||||||
|
MaxRates = 30;
|
||||||
|
{$ELSE}
|
||||||
MaxRates = 19; //FPC on some platforms not know high speeds?
|
MaxRates = 19; //FPC on some platforms not know high speeds?
|
||||||
|
{$ENDIF}
|
||||||
Rates: array[0..MaxRates, 0..1] of cardinal =
|
Rates: array[0..MaxRates, 0..1] of cardinal =
|
||||||
(
|
(
|
||||||
(0, B0),
|
(0, B0),
|
||||||
@ -205,8 +215,9 @@ const
|
|||||||
(57600, B57600),
|
(57600, B57600),
|
||||||
(115200, B115200),
|
(115200, B115200),
|
||||||
(230400, B230400),
|
(230400, B230400),
|
||||||
(460800, B460800){,
|
(460800, B460800)
|
||||||
(500000, B500000),
|
{$IFDEF LINUX}
|
||||||
|
,(500000, B500000),
|
||||||
(576000, B576000),
|
(576000, B576000),
|
||||||
(921600, B921600),
|
(921600, B921600),
|
||||||
(1000000, B1000000),
|
(1000000, B1000000),
|
||||||
@ -216,7 +227,8 @@ const
|
|||||||
(2500000, B2500000),
|
(2500000, B2500000),
|
||||||
(3000000, B3000000),
|
(3000000, B3000000),
|
||||||
(3500000, B3500000),
|
(3500000, B3500000),
|
||||||
(4000000, B4000000)}
|
(4000000, B4000000)
|
||||||
|
{$ENDIF}
|
||||||
);
|
);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
@ -257,7 +269,7 @@ type
|
|||||||
FDevice: string;
|
FDevice: string;
|
||||||
FLastError: integer;
|
FLastError: integer;
|
||||||
FLastErrorDesc: string;
|
FLastErrorDesc: string;
|
||||||
FBuffer: string;
|
FBuffer: AnsiString;
|
||||||
FRaiseExcept: boolean;
|
FRaiseExcept: boolean;
|
||||||
FRecvBuffer: integer;
|
FRecvBuffer: integer;
|
||||||
FSendBuffer: integer;
|
FSendBuffer: integer;
|
||||||
@ -280,7 +292,7 @@ type
|
|||||||
FAtTimeout: integer;
|
FAtTimeout: integer;
|
||||||
FInterPacketTimeout: Boolean;
|
FInterPacketTimeout: Boolean;
|
||||||
FComNr: integer;
|
FComNr: integer;
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
FPortAddr: Word;
|
FPortAddr: Word;
|
||||||
function CanEvent(Event: dword; Timeout: integer): boolean;
|
function CanEvent(Event: dword; Timeout: integer): boolean;
|
||||||
procedure DecodeCommError(Error: DWord); virtual;
|
procedure DecodeCommError(Error: DWord); virtual;
|
||||||
@ -298,7 +310,7 @@ type
|
|||||||
procedure GetComNr(Value: string); virtual;
|
procedure GetComNr(Value: string); virtual;
|
||||||
function PreTestFailing: boolean; virtual;{HGJ}
|
function PreTestFailing: boolean; virtual;{HGJ}
|
||||||
function TestCtrlLine: Boolean; virtual;
|
function TestCtrlLine: Boolean; virtual;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
procedure DcbToTermios(const dcb: TDCB; var term: termios); virtual;
|
procedure DcbToTermios(const dcb: TDCB; var term: termios); virtual;
|
||||||
procedure TermiosToDcb(const term: termios; var dcb: TDCB); virtual;
|
procedure TermiosToDcb(const term: termios; var dcb: TDCB); virtual;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -313,7 +325,7 @@ type
|
|||||||
{: data Control Block with communication parameters. Usable only when you
|
{: data Control Block with communication parameters. Usable only when you
|
||||||
need to call API directly.}
|
need to call API directly.}
|
||||||
DCB: Tdcb;
|
DCB: Tdcb;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
TermiosStruc: termios;
|
TermiosStruc: termios;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{:Object constructor.}
|
{:Object constructor.}
|
||||||
@ -386,14 +398,14 @@ type
|
|||||||
|
|
||||||
Since no terminator is appended, you can use this function for sending
|
Since no terminator is appended, you can use this function for sending
|
||||||
binary data too.}
|
binary data too.}
|
||||||
procedure SendString(data: string); virtual;
|
procedure SendString(data: AnsiString); virtual;
|
||||||
|
|
||||||
{:send four bytes as integer.}
|
{:send four bytes as integer.}
|
||||||
procedure SendInteger(Data: integer); virtual;
|
procedure SendInteger(Data: integer); virtual;
|
||||||
|
|
||||||
{:send data as one block. Each block begins with integer value with Length
|
{:send data as one block. Each block begins with integer value with Length
|
||||||
of block.}
|
of block.}
|
||||||
procedure SendBlock(const Data: string); virtual;
|
procedure SendBlock(const Data: AnsiString); virtual;
|
||||||
|
|
||||||
{:send content of stream from current position}
|
{:send content of stream from current position}
|
||||||
procedure SendStreamRaw(const Stream: TStream); virtual;
|
procedure SendStreamRaw(const Stream: TStream); virtual;
|
||||||
@ -424,12 +436,12 @@ type
|
|||||||
|
|
||||||
{:It is like recvBufferEx, but data is readed to dynamicly allocated binary
|
{:It is like recvBufferEx, but data is readed to dynamicly allocated binary
|
||||||
string.}
|
string.}
|
||||||
function RecvBufferStr(Length: Integer; Timeout: Integer): string; virtual;
|
function RecvBufferStr(Length: Integer; Timeout: Integer): AnsiString; virtual;
|
||||||
|
|
||||||
{:Read all available data and return it in the function result string. This
|
{:Read all available data and return it in the function result string. This
|
||||||
function may be combined with @link(RecvString), @link(RecvByte) or related
|
function may be combined with @link(RecvString), @link(RecvByte) or related
|
||||||
methods.}
|
methods.}
|
||||||
function RecvPacket(Timeout: Integer): string; virtual;
|
function RecvPacket(Timeout: Integer): AnsiString; virtual;
|
||||||
|
|
||||||
{:Waits until one data byte is received which is returned as the function
|
{:Waits until one data byte is received which is returned as the function
|
||||||
result. If no data is received within the Timeout (in milliseconds) period,
|
result. If no data is received within the Timeout (in milliseconds) period,
|
||||||
@ -440,7 +452,7 @@ type
|
|||||||
is terminated by the Terminator string. The resulting string is returned
|
is terminated by the Terminator string. The resulting string is returned
|
||||||
without this termination string! If no data is received within the Timeout
|
without this termination string! If no data is received within the Timeout
|
||||||
(in milliseconds) period, @link(LastError) is set to @link(ErrTimeout).}
|
(in milliseconds) period, @link(LastError) is set to @link(ErrTimeout).}
|
||||||
function RecvTerminated(Timeout: Integer; const Terminator: string): string; virtual;
|
function RecvTerminated(Timeout: Integer; const Terminator: AnsiString): AnsiString; virtual;
|
||||||
|
|
||||||
{:This method waits until a terminated data string is received. The string
|
{:This method waits until a terminated data string is received. The string
|
||||||
is terminated by a CR/LF sequence. The resulting string is returned without
|
is terminated by a CR/LF sequence. The resulting string is returned without
|
||||||
@ -453,7 +465,7 @@ type
|
|||||||
This method serves for line protocol implementation and uses its own
|
This method serves for line protocol implementation and uses its own
|
||||||
buffers to maximize performance. Therefore do NOT use this method with the
|
buffers to maximize performance. Therefore do NOT use this method with the
|
||||||
@link(RecvBuffer) method to receive data as it may cause data loss.}
|
@link(RecvBuffer) method to receive data as it may cause data loss.}
|
||||||
function Recvstring(timeout: integer): string; virtual;
|
function Recvstring(timeout: integer): AnsiString; virtual;
|
||||||
|
|
||||||
{:Waits until four data bytes are received which is returned as the function
|
{:Waits until four data bytes are received which is returned as the function
|
||||||
integer result. If no data is received within the Timeout (in milliseconds) period,
|
integer result. If no data is received within the Timeout (in milliseconds) period,
|
||||||
@ -463,7 +475,7 @@ type
|
|||||||
{:Waits until one data block is received. See @link(sendblock). If no data
|
{:Waits until one data block is received. See @link(sendblock). If no data
|
||||||
is received within the Timeout (in milliseconds) period, @link(LastError)
|
is received within the Timeout (in milliseconds) period, @link(LastError)
|
||||||
is set to @link(ErrTimeout).}
|
is set to @link(ErrTimeout).}
|
||||||
function RecvBlock(Timeout: Integer): string; virtual;
|
function RecvBlock(Timeout: Integer): AnsiString; virtual;
|
||||||
|
|
||||||
{:Receive all data to stream, until some error occured. (for example timeout)}
|
{:Receive all data to stream, until some error occured. (for example timeout)}
|
||||||
procedure RecvStreamRaw(const Stream: TStream; Timeout: Integer); virtual;
|
procedure RecvStreamRaw(const Stream: TStream; Timeout: Integer); virtual;
|
||||||
@ -554,7 +566,7 @@ type
|
|||||||
Now you can send AT commands to the modem. If you need to transfer data to
|
Now you can send AT commands to the modem. If you need to transfer data to
|
||||||
the modem on the other side of the line, you must first switch to data mode
|
the modem on the other side of the line, you must first switch to data mode
|
||||||
using the @link(ATConnect) method.}
|
using the @link(ATConnect) method.}
|
||||||
function ATCommand(value: string): string; virtual;
|
function ATCommand(value: AnsiString): AnsiString; virtual;
|
||||||
|
|
||||||
{:This function is used to send connect type AT commands to the modem. It is
|
{:This function is used to send connect type AT commands to the modem. It is
|
||||||
for commands to switch to connected state. (ATD, ATA, ATO,...)
|
for commands to switch to connected state. (ATD, ATA, ATO,...)
|
||||||
@ -573,7 +585,7 @@ type
|
|||||||
modem on other side of the line. Now you can transfer your data.
|
modem on other side of the line. Now you can transfer your data.
|
||||||
If the connection attempt failed (@link(ATResult) is @False), then the
|
If the connection attempt failed (@link(ATResult) is @False), then the
|
||||||
modem is still in AT command mode.}
|
modem is still in AT command mode.}
|
||||||
function ATConnect(value: string): string; virtual;
|
function ATConnect(value: AnsiString): AnsiString; virtual;
|
||||||
|
|
||||||
{:If you "manually" call API functions, forward their return code in
|
{:If you "manually" call API functions, forward their return code in
|
||||||
the SerialResult parameter to this function, which evaluates it and sets
|
the SerialResult parameter to this function, which evaluates it and sets
|
||||||
@ -660,7 +672,7 @@ type
|
|||||||
property Handle: THandle read Fhandle write FHandle;
|
property Handle: THandle read Fhandle write FHandle;
|
||||||
|
|
||||||
{:Internally used read buffer.}
|
{:Internally used read buffer.}
|
||||||
property LineBuffer: string read FBuffer write FBuffer;
|
property LineBuffer: AnsiString read FBuffer write FBuffer;
|
||||||
|
|
||||||
{:If @true, communication errors raise exceptions. If @false (default), only
|
{:If @true, communication errors raise exceptions. If @false (default), only
|
||||||
the @link(LastError) value is set.}
|
the @link(LastError) value is set.}
|
||||||
@ -752,7 +764,7 @@ end;
|
|||||||
|
|
||||||
class function TBlockSerial.GetVersion: string;
|
class function TBlockSerial.GetVersion: string;
|
||||||
begin
|
begin
|
||||||
Result := 'SynaSer 6.3.5';
|
Result := 'SynaSer 7.4.0';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBlockSerial.CloseSocket;
|
procedure TBlockSerial.CloseSocket;
|
||||||
@ -762,7 +774,7 @@ begin
|
|||||||
Purge;
|
Purge;
|
||||||
RTS := False;
|
RTS := False;
|
||||||
DTR := False;
|
DTR := False;
|
||||||
FileClose(integer(FHandle));
|
FileClose(FHandle);
|
||||||
end;
|
end;
|
||||||
if InstanceActive then
|
if InstanceActive then
|
||||||
begin
|
begin
|
||||||
@ -778,7 +790,7 @@ begin
|
|||||||
DoStatus(HR_SerialClose, FDevice);
|
DoStatus(HR_SerialClose, FDevice);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
function TBlockSerial.GetPortAddr: Word;
|
function TBlockSerial.GetPortAddr: Word;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
@ -849,6 +861,7 @@ procedure TBlockSerial.Config(baud, bits: integer; parity: char; stop: integer;
|
|||||||
softflow, hardflow: boolean);
|
softflow, hardflow: boolean);
|
||||||
begin
|
begin
|
||||||
FillChar(dcb, SizeOf(dcb), 0);
|
FillChar(dcb, SizeOf(dcb), 0);
|
||||||
|
GetCommState;
|
||||||
dcb.DCBlength := SizeOf(dcb);
|
dcb.DCBlength := SizeOf(dcb);
|
||||||
dcb.BaudRate := baud;
|
dcb.BaudRate := baud;
|
||||||
dcb.ByteSize := bits;
|
dcb.ByteSize := bits;
|
||||||
@ -878,7 +891,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBlockSerial.Connect(comport: string);
|
procedure TBlockSerial.Connect(comport: string);
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
var
|
var
|
||||||
CommTimeouts: TCommTimeouts;
|
CommTimeouts: TCommTimeouts;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -892,7 +905,7 @@ begin
|
|||||||
FBuffer := '';
|
FBuffer := '';
|
||||||
FDevice := comport;
|
FDevice := comport;
|
||||||
GetComNr(comport);
|
GetComNr(comport);
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
SetLastError (sOK);
|
SetLastError (sOK);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
@ -901,7 +914,7 @@ begin
|
|||||||
fpSetErrno(sOK);
|
fpSetErrno(sOK);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
if FComNr <> PortIsClosed then
|
if FComNr <> PortIsClosed then
|
||||||
FDevice := '/dev/ttyS' + IntToStr(FComNr);
|
FDevice := '/dev/ttyS' + IntToStr(FComNr);
|
||||||
// Comport already owned by another process? {HGJ}
|
// Comport already owned by another process? {HGJ}
|
||||||
@ -916,7 +929,10 @@ begin
|
|||||||
{$ELSE}
|
{$ELSE}
|
||||||
FHandle := THandle(fpOpen(FDevice, O_RDWR or O_SYNC));
|
FHandle := THandle(fpOpen(FDevice, O_RDWR or O_SYNC));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
SerialCheck(integer(FHandle));
|
if FHandle = INVALID_HANDLE_VALUE then //because THandle is not integer on all platforms!
|
||||||
|
SerialCheck(-1)
|
||||||
|
else
|
||||||
|
SerialCheck(0);
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
if FLastError <> sOK then
|
if FLastError <> sOK then
|
||||||
if FLinuxLock then
|
if FLinuxLock then
|
||||||
@ -930,7 +946,10 @@ begin
|
|||||||
FDevice := '\\.\COM' + IntToStr(FComNr + 1);
|
FDevice := '\\.\COM' + IntToStr(FComNr + 1);
|
||||||
FHandle := THandle(CreateFile(PChar(FDevice), GENERIC_READ or GENERIC_WRITE,
|
FHandle := THandle(CreateFile(PChar(FDevice), GENERIC_READ or GENERIC_WRITE,
|
||||||
0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED, 0));
|
0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED, 0));
|
||||||
SerialCheck(integer(FHandle));
|
if FHandle = INVALID_HANDLE_VALUE then //because THandle is not integer on all platforms!
|
||||||
|
SerialCheck(-1)
|
||||||
|
else
|
||||||
|
SerialCheck(0);
|
||||||
ExceptCheck;
|
ExceptCheck;
|
||||||
if FLastError <> sOK then
|
if FLastError <> sOK then
|
||||||
Exit;
|
Exit;
|
||||||
@ -948,7 +967,7 @@ begin
|
|||||||
if not TestCtrlLine then {HGJ}
|
if not TestCtrlLine then {HGJ}
|
||||||
begin
|
begin
|
||||||
SetSynaError(ErrNoDeviceAnswer);
|
SetSynaError(ErrNoDeviceAnswer);
|
||||||
FileClose(integer(FHandle)); {HGJ}
|
FileClose(FHandle); {HGJ}
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
if FLinuxLock then
|
if FLinuxLock then
|
||||||
cpomReleaseComport; {HGJ}
|
cpomReleaseComport; {HGJ}
|
||||||
@ -968,7 +987,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TBlockSerial.SendBuffer(buffer: pointer; length: integer): integer;
|
function TBlockSerial.SendBuffer(buffer: pointer; length: integer): integer;
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
var
|
var
|
||||||
Overlapped: TOverlapped;
|
Overlapped: TOverlapped;
|
||||||
x, y, Err: DWord;
|
x, y, Err: DWord;
|
||||||
@ -983,8 +1002,8 @@ begin
|
|||||||
Flush;
|
Flush;
|
||||||
RTS := True;
|
RTS := True;
|
||||||
end;
|
end;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
result := FileWrite(integer(Fhandle), Buffer^, Length);
|
result := FileWrite(Fhandle, Buffer^, Length);
|
||||||
serialcheck(result);
|
serialcheck(result);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
FillChar(Overlapped, Sizeof(Overlapped), 0);
|
FillChar(Overlapped, Sizeof(Overlapped), 0);
|
||||||
@ -1023,7 +1042,7 @@ begin
|
|||||||
SendBuffer(@Data, 1);
|
SendBuffer(@Data, 1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBlockSerial.SendString(data: string);
|
procedure TBlockSerial.SendString(data: AnsiString);
|
||||||
begin
|
begin
|
||||||
SendBuffer(Pointer(Data), Length(Data));
|
SendBuffer(Pointer(Data), Length(Data));
|
||||||
end;
|
end;
|
||||||
@ -1033,7 +1052,7 @@ begin
|
|||||||
SendBuffer(@data, SizeOf(Data));
|
SendBuffer(@data, SizeOf(Data));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBlockSerial.SendBlock(const Data: string);
|
procedure TBlockSerial.SendBlock(const Data: AnsiString);
|
||||||
begin
|
begin
|
||||||
SendInteger(Length(data));
|
SendInteger(Length(data));
|
||||||
SendString(Data);
|
SendString(Data);
|
||||||
@ -1043,7 +1062,7 @@ procedure TBlockSerial.SendStreamRaw(const Stream: TStream);
|
|||||||
var
|
var
|
||||||
si: integer;
|
si: integer;
|
||||||
x, y, yr: integer;
|
x, y, yr: integer;
|
||||||
s: string;
|
s: AnsiString;
|
||||||
begin
|
begin
|
||||||
si := Stream.Size - Stream.Position;
|
si := Stream.Size - Stream.Position;
|
||||||
x := 0;
|
x := 0;
|
||||||
@ -1053,7 +1072,7 @@ begin
|
|||||||
if y > cSerialChunk then
|
if y > cSerialChunk then
|
||||||
y := cSerialChunk;
|
y := cSerialChunk;
|
||||||
Setlength(s, y);
|
Setlength(s, y);
|
||||||
yr := Stream.read(Pchar(s)^, y);
|
yr := Stream.read(PAnsiChar(s)^, y);
|
||||||
if yr > 0 then
|
if yr > 0 then
|
||||||
begin
|
begin
|
||||||
SetLength(s, yr);
|
SetLength(s, yr);
|
||||||
@ -1085,13 +1104,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TBlockSerial.RecvBuffer(buffer: pointer; length: integer): integer;
|
function TBlockSerial.RecvBuffer(buffer: pointer; length: integer): integer;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
if PreTestFailing then {HGJ}
|
if PreTestFailing then {HGJ}
|
||||||
Exit; {HGJ}
|
Exit; {HGJ}
|
||||||
LimitBandwidth(Length, FMaxRecvBandwidth, FNextRecv);
|
LimitBandwidth(Length, FMaxRecvBandwidth, FNextRecv);
|
||||||
result := FileRead(integer(FHandle), Buffer^, length);
|
result := FileRead(FHandle, Buffer^, length);
|
||||||
serialcheck(result);
|
serialcheck(result);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
var
|
var
|
||||||
@ -1129,7 +1148,7 @@ end;
|
|||||||
|
|
||||||
function TBlockSerial.RecvBufferEx(buffer: pointer; length: integer; timeout: integer): integer;
|
function TBlockSerial.RecvBufferEx(buffer: pointer; length: integer; timeout: integer): integer;
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
rl, l: integer;
|
rl, l: integer;
|
||||||
ti: LongWord;
|
ti: LongWord;
|
||||||
begin
|
begin
|
||||||
@ -1165,7 +1184,7 @@ begin
|
|||||||
Result := rl;
|
Result := rl;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBlockSerial.RecvBufferStr(Length: Integer; Timeout: Integer): string;
|
function TBlockSerial.RecvBufferStr(Length: Integer; Timeout: Integer): AnsiString;
|
||||||
var
|
var
|
||||||
x: integer;
|
x: integer;
|
||||||
begin
|
begin
|
||||||
@ -1176,7 +1195,7 @@ begin
|
|||||||
if Length > 0 then
|
if Length > 0 then
|
||||||
begin
|
begin
|
||||||
Setlength(Result, Length);
|
Setlength(Result, Length);
|
||||||
x := RecvBufferEx(PChar(Result), Length , Timeout);
|
x := RecvBufferEx(PAnsiChar(Result), Length , Timeout);
|
||||||
if FLastError = sOK then
|
if FLastError = sOK then
|
||||||
SetLength(Result, x)
|
SetLength(Result, x)
|
||||||
else
|
else
|
||||||
@ -1184,7 +1203,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBlockSerial.RecvPacket(Timeout: Integer): string;
|
function TBlockSerial.RecvPacket(Timeout: Integer): AnsiString;
|
||||||
var
|
var
|
||||||
x: integer;
|
x: integer;
|
||||||
begin
|
begin
|
||||||
@ -1248,10 +1267,10 @@ begin
|
|||||||
ExceptCheck;
|
ExceptCheck;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBlockSerial.RecvTerminated(Timeout: Integer; const Terminator: string): string;
|
function TBlockSerial.RecvTerminated(Timeout: Integer; const Terminator: AnsiString): AnsiString;
|
||||||
var
|
var
|
||||||
x: Integer;
|
x: Integer;
|
||||||
s: string;
|
s: AnsiString;
|
||||||
l: Integer;
|
l: Integer;
|
||||||
CorCRLF: Boolean;
|
CorCRLF: Boolean;
|
||||||
t: ansistring;
|
t: ansistring;
|
||||||
@ -1325,9 +1344,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TBlockSerial.RecvString(Timeout: Integer): string;
|
function TBlockSerial.RecvString(Timeout: Integer): AnsiString;
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
s := RecvTerminated(Timeout, #13 + #10);
|
s := RecvTerminated(Timeout, #13 + #10);
|
||||||
@ -1337,7 +1356,7 @@ end;
|
|||||||
|
|
||||||
function TBlockSerial.RecvInteger(Timeout: Integer): Integer;
|
function TBlockSerial.RecvInteger(Timeout: Integer): Integer;
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
s := RecvBufferStr(4, Timeout);
|
s := RecvBufferStr(4, Timeout);
|
||||||
@ -1345,7 +1364,7 @@ begin
|
|||||||
Result := (ord(s[1]) + ord(s[2]) * 256) + (ord(s[3]) + ord(s[4]) * 256) * 65536;
|
Result := (ord(s[1]) + ord(s[2]) * 256) + (ord(s[3]) + ord(s[4]) * 256) * 65536;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBlockSerial.RecvBlock(Timeout: Integer): string;
|
function TBlockSerial.RecvBlock(Timeout: Integer): AnsiString;
|
||||||
var
|
var
|
||||||
x: integer;
|
x: integer;
|
||||||
begin
|
begin
|
||||||
@ -1357,7 +1376,7 @@ end;
|
|||||||
|
|
||||||
procedure TBlockSerial.RecvStreamRaw(const Stream: TStream; Timeout: Integer);
|
procedure TBlockSerial.RecvStreamRaw(const Stream: TStream; Timeout: Integer);
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
begin
|
begin
|
||||||
repeat
|
repeat
|
||||||
s := RecvPacket(Timeout);
|
s := RecvPacket(Timeout);
|
||||||
@ -1368,7 +1387,7 @@ end;
|
|||||||
|
|
||||||
procedure TBlockSerial.RecvStreamSize(const Stream: TStream; Timeout: Integer; Size: Integer);
|
procedure TBlockSerial.RecvStreamSize(const Stream: TStream; Timeout: Integer; Size: Integer);
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
n: integer;
|
n: integer;
|
||||||
begin
|
begin
|
||||||
for n := 1 to (Size div cSerialChunk) do
|
for n := 1 to (Size div cSerialChunk) do
|
||||||
@ -1376,7 +1395,7 @@ begin
|
|||||||
s := RecvBufferStr(cSerialChunk, Timeout);
|
s := RecvBufferStr(cSerialChunk, Timeout);
|
||||||
if FLastError <> 0 then
|
if FLastError <> 0 then
|
||||||
Exit;
|
Exit;
|
||||||
Stream.Write(Pchar(s)^, cSerialChunk);
|
Stream.Write(PAnsichar(s)^, cSerialChunk);
|
||||||
end;
|
end;
|
||||||
n := Size mod cSerialChunk;
|
n := Size mod cSerialChunk;
|
||||||
if n > 0 then
|
if n > 0 then
|
||||||
@ -1384,7 +1403,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);
|
Stream.Write(PAnsichar(s)^, n);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1407,11 +1426,11 @@ begin
|
|||||||
RecvStreamSize(Stream, Timeout, x);
|
RecvStreamSize(Stream, Timeout, x);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
function TBlockSerial.WaitingData: integer;
|
function TBlockSerial.WaitingData: integer;
|
||||||
begin
|
begin
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
serialcheck(ioctl(integer(FHandle), FIONREAD, @result));
|
serialcheck(ioctl(FHandle, FIONREAD, @result));
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
serialcheck(fpIoctl(FHandle, FIONREAD, @result));
|
serialcheck(fpIoctl(FHandle, FIONREAD, @result));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1447,7 +1466,7 @@ begin
|
|||||||
Result := Waitingdata;
|
Result := Waitingdata;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
function TBlockSerial.SendingData: integer;
|
function TBlockSerial.SendingData: integer;
|
||||||
begin
|
begin
|
||||||
SetSynaError(sOK);
|
SetSynaError(sOK);
|
||||||
@ -1467,7 +1486,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
procedure TBlockSerial.DcbToTermios(const dcb: TDCB; var term: termios);
|
procedure TBlockSerial.DcbToTermios(const dcb: TDCB; var term: termios);
|
||||||
var
|
var
|
||||||
n: integer;
|
n: integer;
|
||||||
@ -1590,11 +1609,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
procedure TBlockSerial.SetCommState;
|
procedure TBlockSerial.SetCommState;
|
||||||
begin
|
begin
|
||||||
DcbToTermios(dcb, termiosstruc);
|
DcbToTermios(dcb, termiosstruc);
|
||||||
SerialCheck(tcsetattr(integer(FHandle), TCSANOW, termiosstruc));
|
SerialCheck(tcsetattr(FHandle, TCSANOW, termiosstruc));
|
||||||
ExceptCheck;
|
ExceptCheck;
|
||||||
end;
|
end;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -1607,10 +1626,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
procedure TBlockSerial.GetCommState;
|
procedure TBlockSerial.GetCommState;
|
||||||
begin
|
begin
|
||||||
SerialCheck(tcgetattr(integer(FHandle), termiosstruc));
|
SerialCheck(tcgetattr(FHandle, termiosstruc));
|
||||||
ExceptCheck;
|
ExceptCheck;
|
||||||
TermiostoDCB(termiosstruc, dcb);
|
TermiostoDCB(termiosstruc, dcb);
|
||||||
end;
|
end;
|
||||||
@ -1626,7 +1645,7 @@ end;
|
|||||||
|
|
||||||
procedure TBlockSerial.SetSizeRecvBuffer(size: integer);
|
procedure TBlockSerial.SetSizeRecvBuffer(size: integer);
|
||||||
begin
|
begin
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
SetupComm(Fhandle, size, 0);
|
SetupComm(Fhandle, size, 0);
|
||||||
GetCommState;
|
GetCommState;
|
||||||
dcb.XonLim := size div 4;
|
dcb.XonLim := size div 4;
|
||||||
@ -1639,7 +1658,7 @@ end;
|
|||||||
function TBlockSerial.GetDSR: Boolean;
|
function TBlockSerial.GetDSR: Boolean;
|
||||||
begin
|
begin
|
||||||
ModemStatus;
|
ModemStatus;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
Result := (FModemWord and TIOCM_DSR) > 0;
|
Result := (FModemWord and TIOCM_DSR) > 0;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Result := (FModemWord and MS_DSR_ON) > 0;
|
Result := (FModemWord and MS_DSR_ON) > 0;
|
||||||
@ -1648,16 +1667,16 @@ end;
|
|||||||
|
|
||||||
procedure TBlockSerial.SetDTRF(Value: Boolean);
|
procedure TBlockSerial.SetDTRF(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
ModemStatus;
|
ModemStatus;
|
||||||
if Value then
|
if Value then
|
||||||
FModemWord := FModemWord or TIOCM_DTR
|
FModemWord := FModemWord or TIOCM_DTR
|
||||||
else
|
else
|
||||||
FModemWord := FModemWord and not TIOCM_DTR;
|
FModemWord := FModemWord and not TIOCM_DTR;
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
ioctl(integer(FHandle), TIOCMSET, @FModemWord);
|
ioctl(FHandle, TIOCMSET, @FModemWord);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
fpioctl(integer(FHandle), TIOCMSET, @FModemWord);
|
fpioctl(FHandle, TIOCMSET, @FModemWord);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
if Value then
|
if Value then
|
||||||
@ -1670,7 +1689,7 @@ end;
|
|||||||
function TBlockSerial.GetCTS: Boolean;
|
function TBlockSerial.GetCTS: Boolean;
|
||||||
begin
|
begin
|
||||||
ModemStatus;
|
ModemStatus;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
Result := (FModemWord and TIOCM_CTS) > 0;
|
Result := (FModemWord and TIOCM_CTS) > 0;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Result := (FModemWord and MS_CTS_ON) > 0;
|
Result := (FModemWord and MS_CTS_ON) > 0;
|
||||||
@ -1679,16 +1698,16 @@ end;
|
|||||||
|
|
||||||
procedure TBlockSerial.SetRTSF(Value: Boolean);
|
procedure TBlockSerial.SetRTSF(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
ModemStatus;
|
ModemStatus;
|
||||||
if Value then
|
if Value then
|
||||||
FModemWord := FModemWord or TIOCM_RTS
|
FModemWord := FModemWord or TIOCM_RTS
|
||||||
else
|
else
|
||||||
FModemWord := FModemWord and not TIOCM_RTS;
|
FModemWord := FModemWord and not TIOCM_RTS;
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
ioctl(integer(FHandle), TIOCMSET, @FModemWord);
|
ioctl(FHandle, TIOCMSET, @FModemWord);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
fpioctl(integer(FHandle), TIOCMSET, @FModemWord);
|
fpioctl(FHandle, TIOCMSET, @FModemWord);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
if Value then
|
if Value then
|
||||||
@ -1701,7 +1720,7 @@ end;
|
|||||||
function TBlockSerial.GetCarrier: Boolean;
|
function TBlockSerial.GetCarrier: Boolean;
|
||||||
begin
|
begin
|
||||||
ModemStatus;
|
ModemStatus;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
Result := (FModemWord and TIOCM_CAR) > 0;
|
Result := (FModemWord and TIOCM_CAR) > 0;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Result := (FModemWord and MS_RLSD_ON) > 0;
|
Result := (FModemWord and MS_RLSD_ON) > 0;
|
||||||
@ -1711,14 +1730,14 @@ end;
|
|||||||
function TBlockSerial.GetRing: Boolean;
|
function TBlockSerial.GetRing: Boolean;
|
||||||
begin
|
begin
|
||||||
ModemStatus;
|
ModemStatus;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
Result := (FModemWord and TIOCM_RNG) > 0;
|
Result := (FModemWord and TIOCM_RNG) > 0;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Result := (FModemWord and MS_RING_ON) > 0;
|
Result := (FModemWord and MS_RING_ON) > 0;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
function TBlockSerial.CanEvent(Event: dword; Timeout: integer): boolean;
|
function TBlockSerial.CanEvent(Event: dword; Timeout: integer): boolean;
|
||||||
var
|
var
|
||||||
ex: DWord;
|
ex: DWord;
|
||||||
@ -1753,7 +1772,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
function TBlockSerial.CanRead(Timeout: integer): boolean;
|
function TBlockSerial.CanRead(Timeout: integer): boolean;
|
||||||
var
|
var
|
||||||
FDSet: TFDSet;
|
FDSet: TFDSet;
|
||||||
@ -1768,12 +1787,12 @@ begin
|
|||||||
TimeVal := nil;
|
TimeVal := nil;
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
FD_ZERO(FDSet);
|
FD_ZERO(FDSet);
|
||||||
FD_SET(integer(FHandle), FDSet);
|
FD_SET(FHandle, FDSet);
|
||||||
x := Select(integer(FHandle) + 1, @FDSet, nil, nil, TimeVal);
|
x := Select(FHandle + 1, @FDSet, nil, nil, TimeVal);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
fpFD_ZERO(FDSet);
|
fpFD_ZERO(FDSet);
|
||||||
fpFD_SET(integer(FHandle), FDSet);
|
fpFD_SET(FHandle, FDSet);
|
||||||
x := fpSelect(integer(FHandle) + 1, @FDSet, nil, nil, TimeVal);
|
x := fpSelect(FHandle + 1, @FDSet, nil, nil, TimeVal);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
SerialCheck(x);
|
SerialCheck(x);
|
||||||
if FLastError <> sOK then
|
if FLastError <> sOK then
|
||||||
@ -1794,7 +1813,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
function TBlockSerial.CanWrite(Timeout: integer): boolean;
|
function TBlockSerial.CanWrite(Timeout: integer): boolean;
|
||||||
var
|
var
|
||||||
FDSet: TFDSet;
|
FDSet: TFDSet;
|
||||||
@ -1809,12 +1828,12 @@ begin
|
|||||||
TimeVal := nil;
|
TimeVal := nil;
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
FD_ZERO(FDSet);
|
FD_ZERO(FDSet);
|
||||||
FD_SET(integer(FHandle), FDSet);
|
FD_SET(FHandle, FDSet);
|
||||||
x := Select(integer(FHandle) + 1, nil, @FDSet, nil, TimeVal);
|
x := Select(FHandle + 1, nil, @FDSet, nil, TimeVal);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
fpFD_ZERO(FDSet);
|
fpFD_ZERO(FDSet);
|
||||||
fpFD_SET(integer(FHandle), FDSet);
|
fpFD_SET(FHandle, FDSet);
|
||||||
x := fpSelect(integer(FHandle) + 1, nil, @FDSet, nil, TimeVal);
|
x := fpSelect(FHandle + 1, nil, @FDSet, nil, TimeVal);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
SerialCheck(x);
|
SerialCheck(x);
|
||||||
if FLastError <> sOK then
|
if FLastError <> sOK then
|
||||||
@ -1858,7 +1877,7 @@ end;
|
|||||||
procedure TBlockSerial.EnableRTSToggle(Value: boolean);
|
procedure TBlockSerial.EnableRTSToggle(Value: boolean);
|
||||||
begin
|
begin
|
||||||
SetSynaError(sOK);
|
SetSynaError(sOK);
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
FRTSToggle := Value;
|
FRTSToggle := Value;
|
||||||
if Value then
|
if Value then
|
||||||
RTS:=False;
|
RTS:=False;
|
||||||
@ -1883,8 +1902,8 @@ end;
|
|||||||
|
|
||||||
procedure TBlockSerial.Flush;
|
procedure TBlockSerial.Flush;
|
||||||
begin
|
begin
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
SerialCheck(tcdrain(integer(FHandle)));
|
SerialCheck(tcdrain(FHandle));
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
SetSynaError(sOK);
|
SetSynaError(sOK);
|
||||||
if not Flushfilebuffers(FHandle) then
|
if not Flushfilebuffers(FHandle) then
|
||||||
@ -1893,13 +1912,13 @@ begin
|
|||||||
ExceptCheck;
|
ExceptCheck;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
procedure TBlockSerial.Purge;
|
procedure TBlockSerial.Purge;
|
||||||
begin
|
begin
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
SerialCheck(ioctl(integer(FHandle), TCFLSH, TCIOFLUSH));
|
SerialCheck(ioctl(FHandle, TCFLSH, TCIOFLUSH));
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
SerialCheck(fpioctl(integer(FHandle), TCFLSH, TCIOFLUSH));
|
SerialCheck(fpioctl(FHandle, TCFLSH, TCIOFLUSH));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FBuffer := '';
|
FBuffer := '';
|
||||||
ExceptCheck;
|
ExceptCheck;
|
||||||
@ -1921,11 +1940,11 @@ end;
|
|||||||
function TBlockSerial.ModemStatus: integer;
|
function TBlockSerial.ModemStatus: integer;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
SerialCheck(ioctl(integer(FHandle), TIOCMGET, @Result));
|
SerialCheck(ioctl(FHandle, TIOCMGET, @Result));
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
SerialCheck(fpioctl(integer(FHandle), TIOCMGET, @Result));
|
SerialCheck(fpioctl(FHandle, TIOCMGET, @Result));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
SetSynaError(sOK);
|
SetSynaError(sOK);
|
||||||
@ -1938,8 +1957,8 @@ end;
|
|||||||
|
|
||||||
procedure TBlockSerial.SetBreak(Duration: integer);
|
procedure TBlockSerial.SetBreak(Duration: integer);
|
||||||
begin
|
begin
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
SerialCheck(tcsendbreak(integer(FHandle), Duration));
|
SerialCheck(tcsendbreak(FHandle, Duration));
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
SetCommBreak(FHandle);
|
SetCommBreak(FHandle);
|
||||||
Sleep(Duration);
|
Sleep(Duration);
|
||||||
@ -1949,7 +1968,7 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
procedure TBlockSerial.DecodeCommError(Error: DWord);
|
procedure TBlockSerial.DecodeCommError(Error: DWord);
|
||||||
begin
|
begin
|
||||||
if (Error and DWord(CE_FRAME)) > 1 then
|
if (Error and DWord(CE_FRAME)) > 1 then
|
||||||
@ -1984,9 +2003,9 @@ begin
|
|||||||
result := ((not FTestDSR) or DSR) and ((not FTestCTS) or CTS);
|
result := ((not FTestDSR) or DSR) and ((not FTestCTS) or CTS);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBlockSerial.ATCommand(value: string): string;
|
function TBlockSerial.ATCommand(value: AnsiString): AnsiString;
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
ConvSave: Boolean;
|
ConvSave: Boolean;
|
||||||
begin
|
begin
|
||||||
result := '';
|
result := '';
|
||||||
@ -2013,9 +2032,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TBlockSerial.ATConnect(value: string): string;
|
function TBlockSerial.ATConnect(value: AnsiString): AnsiString;
|
||||||
var
|
var
|
||||||
s: string;
|
s: AnsiString;
|
||||||
ConvSave: Boolean;
|
ConvSave: Boolean;
|
||||||
begin
|
begin
|
||||||
result := '';
|
result := '';
|
||||||
@ -2050,7 +2069,7 @@ end;
|
|||||||
function TBlockSerial.SerialCheck(SerialResult: integer): integer;
|
function TBlockSerial.SerialCheck(SerialResult: integer): integer;
|
||||||
begin
|
begin
|
||||||
if SerialResult = integer(INVALID_HANDLE_VALUE) then
|
if SerialResult = integer(INVALID_HANDLE_VALUE) then
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
result := GetLastError
|
result := GetLastError
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
@ -2166,7 +2185,8 @@ begin
|
|||||||
// Allow all users to enjoy the benefits of cpom
|
// Allow all users to enjoy the benefits of cpom
|
||||||
s := 'chmod a+rw ' + LockfileName;
|
s := 'chmod a+rw ' + LockfileName;
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
Libc.system(pchar(s));
|
FileSetReadOnly( LockfileName, False ) ;
|
||||||
|
// Libc.system(pchar(s));
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
fpSystem(s);
|
fpSystem(s);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -2236,7 +2256,7 @@ end;
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{----------------------------------------------------------------}
|
{----------------------------------------------------------------}
|
||||||
|
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
function GetSerialPortNames: string;
|
function GetSerialPortNames: string;
|
||||||
var
|
var
|
||||||
reg: TRegistry;
|
reg: TRegistry;
|
||||||
@ -2265,7 +2285,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
function GetSerialPortNames: string;
|
function GetSerialPortNames: string;
|
||||||
var
|
var
|
||||||
Index: Integer;
|
Index: Integer;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 004.013.000 |
|
| Project : Ararat Synapse | 004.014.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: support procedures and functions |
|
| Content: support procedures and functions |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2008, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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) 1999-2008. |
|
| Portions created by Lukas Gebauer are Copyright (c) 1999-2010. |
|
||||||
| Portions created by Hernan Sanchez are Copyright (c) 2000. |
|
| Portions created by Hernan Sanchez are Copyright (c) 2000. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -53,18 +53,31 @@
|
|||||||
{$R-}
|
{$R-}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
//old Delphi does not have MSWINDOWS define.
|
||||||
|
{$IFDEF WIN32}
|
||||||
|
{$IFNDEF MSWINDOWS}
|
||||||
|
{$DEFINE MSWINDOWS}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$WARN SUSPICIOUS_TYPECAST OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit synautil;
|
unit synautil;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
Windows,
|
Windows,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
UnixUtil, Unix, BaseUnix,
|
UnixUtil, Unix, BaseUnix,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Libc,
|
Libc,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF CIL}
|
{$IFDEF CIL}
|
||||||
@ -102,7 +115,7 @@ function AnsiCDateTime(t: TDateTime): string;
|
|||||||
{:Decode three-letter string with name of month to their month number. If string
|
{:Decode three-letter string with name of month to their month number. If string
|
||||||
not match any month name, then is returned 0. For parsing are used predefined
|
not match any month name, then is returned 0. For parsing are used predefined
|
||||||
names for English, French and German and names from system locale too.}
|
names for English, French and German and names from system locale too.}
|
||||||
function GetMonthNumber(Value: AnsiString): integer;
|
function GetMonthNumber(Value: String): integer;
|
||||||
|
|
||||||
{:Return decoded time from given string. Time must be witch separator ':'. You
|
{:Return decoded time from given string. Time must be witch separator ':'. You
|
||||||
can use "hh:mm" or "hh:mm:ss".}
|
can use "hh:mm" or "hh:mm:ss".}
|
||||||
@ -251,7 +264,7 @@ function FetchEx(var Value: string; const Delimiter, Quotation: string): string;
|
|||||||
|
|
||||||
{:If string is binary string (contains non-printable characters), then is
|
{:If string is binary string (contains non-printable characters), then is
|
||||||
returned true.}
|
returned true.}
|
||||||
function IsBinaryString(const Value: string): Boolean;
|
function IsBinaryString(const Value: AnsiString): Boolean;
|
||||||
|
|
||||||
{:return position of string terminator in string. If terminator found, then is
|
{:return position of string terminator in string. If terminator found, then is
|
||||||
returned in terminator parameter.
|
returned in terminator parameter.
|
||||||
@ -327,7 +340,7 @@ const
|
|||||||
MyDayNames: array[1..7] of AnsiString =
|
MyDayNames: array[1..7] of AnsiString =
|
||||||
('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
|
('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
|
||||||
var
|
var
|
||||||
MyMonthNames: array[0..6, 1..12] of AnsiString =
|
MyMonthNames: array[0..6, 1..12] of String =
|
||||||
(
|
(
|
||||||
('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', //rewrited by system locales
|
('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', //rewrited by system locales
|
||||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
|
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
|
||||||
@ -349,7 +362,7 @@ var
|
|||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
|
|
||||||
function TimeZoneBias: integer;
|
function TimeZoneBias: integer;
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
var
|
var
|
||||||
t: TTime_T;
|
t: TTime_T;
|
||||||
@ -526,10 +539,10 @@ end;
|
|||||||
|
|
||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
|
|
||||||
function GetMonthNumber(Value: AnsiString): integer;
|
function GetMonthNumber(Value: String): integer;
|
||||||
var
|
var
|
||||||
n: integer;
|
n: integer;
|
||||||
function TestMonth(Value: AnsiString; Index: Integer): Boolean;
|
function TestMonth(Value: String; Index: Integer): Boolean;
|
||||||
var
|
var
|
||||||
n: integer;
|
n: integer;
|
||||||
begin
|
begin
|
||||||
@ -700,7 +713,7 @@ end;
|
|||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
|
|
||||||
function GetUTTime: TDateTime;
|
function GetUTTime: TDateTime;
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
var
|
var
|
||||||
st: TSystemTime;
|
st: TSystemTime;
|
||||||
@ -742,7 +755,7 @@ end;
|
|||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
|
|
||||||
function SetUTTime(Newdt: TDateTime): Boolean;
|
function SetUTTime(Newdt: TDateTime): Boolean;
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
var
|
var
|
||||||
st: TSystemTime;
|
st: TSystemTime;
|
||||||
@ -795,7 +808,7 @@ end;
|
|||||||
|
|
||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
|
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
function GetTick: LongWord;
|
function GetTick: LongWord;
|
||||||
var
|
var
|
||||||
Stamp: TTimeStamp;
|
Stamp: TTimeStamp;
|
||||||
@ -1405,7 +1418,7 @@ end;
|
|||||||
|
|
||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
|
|
||||||
function IsBinaryString(const Value: string): Boolean;
|
function IsBinaryString(const Value: AnsiString): Boolean;
|
||||||
var
|
var
|
||||||
n: integer;
|
n: integer;
|
||||||
begin
|
begin
|
||||||
@ -1413,7 +1426,7 @@ begin
|
|||||||
for n := 1 to Length(Value) do
|
for n := 1 to Length(Value) do
|
||||||
if Value[n] in [#0..#8, #10..#31] then
|
if Value[n] in [#0..#8, #10..#31] then
|
||||||
//ignore null-terminated strings
|
//ignore null-terminated strings
|
||||||
if not ((n = Length(value)) and (Value[n] = #0)) then
|
if not ((n = Length(value)) and (Value[n] = AnsiChar(#0))) then
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := True;
|
||||||
Break;
|
Break;
|
||||||
@ -1720,7 +1733,7 @@ end;
|
|||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
function GetTempFile(const Dir, prefix: AnsiString): AnsiString;
|
function GetTempFile(const Dir, prefix: AnsiString): AnsiString;
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
{$IFDEF WIN32}
|
{$IFDEF MSWINDOWS}
|
||||||
var
|
var
|
||||||
Path: AnsiString;
|
Path: AnsiString;
|
||||||
x: integer;
|
x: integer;
|
||||||
@ -1730,7 +1743,7 @@ begin
|
|||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
Result := GetTempFileName(Dir, Prefix);
|
Result := GetTempFileName(Dir, Prefix);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$IFNDEF WIN32}
|
{$IFNDEF MSWINDOWS}
|
||||||
Result := tempnam(Pointer(Dir), Pointer(prefix));
|
Result := tempnam(Pointer(Dir), Pointer(prefix));
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$IFDEF CIL}
|
{$IFDEF CIL}
|
||||||
@ -1784,7 +1797,7 @@ begin
|
|||||||
for n := 1 to Length(t) do
|
for n := 1 to Length(t) do
|
||||||
if t[n] = #9 then
|
if t[n] = #9 then
|
||||||
t[n] := ' ';
|
t[n] := ' ';
|
||||||
if not(t[1] in [' ', '"', ':', '=']) then
|
if not(AnsiChar(t[1]) in [' ', '"', ':', '=']) then
|
||||||
Break
|
Break
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 005.001.000 |
|
| Project : Ararat Synapse | 005.002.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Socket Independent Platform Layer |
|
| Content: Socket Independent Platform Layer |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2003, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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-2003. |
|
| Portions created by Lukas Gebauer are Copyright (c)2001-20010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -48,20 +48,30 @@ unit synsock;
|
|||||||
|
|
||||||
{$MINENUMSIZE 4}
|
{$MINENUMSIZE 4}
|
||||||
|
|
||||||
{$IFDEF CIL}
|
//old Delphi does not have MSWINDOWS define.
|
||||||
{$I ssdotnet.pas}
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
{$IFDEF WIN32}
|
{$IFDEF WIN32}
|
||||||
{$I sswin32.pas}
|
{$IFNDEF MSWINDOWS}
|
||||||
{$ELSE}
|
{$DEFINE MSWINDOWS}
|
||||||
{$IFDEF FPC}
|
|
||||||
{$I ssfpc.pas}
|
|
||||||
{$ELSE}
|
|
||||||
{$I sslinux.pas}
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF CIL}
|
||||||
|
{$I ssdotnet.pas}
|
||||||
|
{$ELSE}
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
{$I sswin32.pas}
|
||||||
|
{$ELSE}
|
||||||
|
{$IFDEF WINCE}
|
||||||
|
{$I sswin32.pas} //not complete yet!
|
||||||
|
{$ELSE}
|
||||||
|
{$IFDEF FPC}
|
||||||
|
{$I ssfpc.pas}
|
||||||
|
{$ELSE}
|
||||||
|
{$I sslinux.pas}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Ararat Synapse | 001.003.000 |
|
| Project : Ararat Synapse | 001.003.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: TELNET and SSH2 client |
|
| Content: TELNET and SSH2 client |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Copyright (c)1999-2008, Lukas Gebauer |
|
| Copyright (c)1999-2010, 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-2008. |
|
| Portions created by Lukas Gebauer are Copyright (c)2002-2010. |
|
||||||
| All Rights Reserved. |
|
| All Rights Reserved. |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Contributor(s): |
|
| Contributor(s): |
|
||||||
@ -52,6 +52,11 @@ Used RFC: RFC-854
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$H+}
|
{$H+}
|
||||||
|
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST OFF}
|
||||||
|
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
unit tlntsend;
|
unit tlntsend;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -148,6 +153,7 @@ constructor TTelnetSend.Create;
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FSock := TTCPBlockSocket.Create;
|
FSock := TTCPBlockSocket.Create;
|
||||||
|
FSock.Owner := self;
|
||||||
FSock.OnReadFilter := FilterHook;
|
FSock.OnReadFilter := FilterHook;
|
||||||
FTimeout := 60000;
|
FTimeout := 60000;
|
||||||
FTargetPort := cTelnetProtocol;
|
FTargetPort := cTelnetProtocol;
|
||||||
|
Loading…
Reference in New Issue
Block a user