-
Notifications
You must be signed in to change notification settings - Fork 16
/
RemoteSignTool_Client.dpr
73 lines (66 loc) · 1.82 KB
/
RemoteSignTool_Client.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
program RemoteSignTool_Client;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.IniFiles,
IdBaseComponent,
IdComponent,
IdHTTP,
signtool_client in 'signtool_client.pas';
var
client: TRemoteSignToolClient;
ini: TIniFile;
filetosign: string;
additional: string;
I: Integer;
begin
try
ExitCode := 2;
client := TRemoteSignToolClient.Create;
try
ini := TIniFile.Create(ChangeFileExt(ParamStr(0),'.ini'));
try
client.host := ini.ReadString('server','host','localhost');
client.port := ini.ReadInteger('server','port',8090);
finally
ini.Free;
end;
filetosign := '';
for I := ParamCount downto 1 do
begin
if (filetosign = '') and (length(ParamStr(I)) > 0) and (ParamStr(I)[1] <> '/') and FileExists(ParamStr(I)) then
filetosign := ParamStr(I)
else
if not((I > 2) and (ParamStr(I-1).ToLower = '/ac')) then
if ParamStr(I).IndexOf(' ') > 0 then
additional := '"'+ParamStr(I)+'" '+additional
else
additional := ParamStr(I)+' '+additional;
end;
if filetosign = '' then
begin
WriteLn(ErrOutput, 'Error: File not found or not specified');
WriteLn('You must specify at least file to sign!');
ExitCode := 1;
exit;
end;
if not client.SignFile(filetosign, additional) then
begin
WriteLn(ErrOutput, 'Error: '+client.ErrorMessage);
ExitCode := client.ErrorCode;
exit;
end else
begin
WriteLn('File signed succesfully');
ExitCode := 0;
exit;
end;
finally
client.Free;
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.