topal-80/ 0000755 0001750 0001750 00000000000 13434071426 010536 5 ustar pjb pjb topal-80/externals.adb 0000644 0001750 0001750 00000066227 13434071426 013230 0 ustar pjb pjb -- Topal: GPG/GnuPG and Alpine/Pine integration
-- Copyright (C) 2001--2018 Phillip J. Brooke
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License version 3 as
-- published by the Free Software Foundation.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see .
with Ada.Text_IO;
with GNAT.OS_Lib;
with Interfaces.C;
with Interfaces.C.Strings;
with Misc;
package body Externals is
pragma Linker_Options("externals-c.o");
procedure C_Perror (S : in Interfaces.C.char_array);
pragma Import(C, C_Perror, "perror");
function C_Errno return Interfaces.C.Int;
pragma Import(C, C_Errno, "errno_wrapper");
function C_Glob_Actual (Pattern : in Interfaces.C.Char_Array)
return Interfaces.C.Int;
pragma Import(C, C_Glob_Actual, "glob_actual");
function C_Glob_Text (Index : Interfaces.C.Int)
return Interfaces.C.Strings.Chars_Ptr;
pragma Import(C, C_Glob_Text, "glob_text");
procedure C_Glob_Free;
pragma Import(C, C_Glob_Free, "glob_free");
function Glob (Pattern : in String) return UBS_Array is
C : Natural;
begin
Misc.Debug("Glob: Looking for pattern `" & Pattern & "'");
C := Natural(C_Glob_Actual(Interfaces.C.To_C(Pattern)));
Misc.Debug("Glob: Count (C) is " & Integer'Image(C));
declare
A : UBS_Array(1..C);
begin
for I in 1 .. C loop
A(I) := ToUBS(Interfaces.C.Strings.Value(C_Glob_Text(Interfaces.C.Int(I - 1))));
Misc.Debug("Glob: Item "
& Integer'Image(I)
& " is `"
& ToStr(A(I))
& "'");
end loop;
Misc.Debug("Glob: Free'ing...");
C_Glob_Free;
Misc.Debug("Glob: A'First = " & Integer'Image(A'First));
Misc.Debug("Glob: A'Last = " & Integer'Image(A'Last));
Misc.Debug("Glob: A'Length = " & Integer'Image(A'Length));
Misc.Debug("Glob: Done");
return A;
end;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.Glob");
raise;
end Glob;
-- Execute a command via `execvp'.
function C_Execvp (File : in Interfaces.C.Char_Array;
Argv : in Interfaces.C.Strings.Chars_Ptr_Array)
return Interfaces.C.int;
pragma Import(C, C_Execvp, "execvp");
-- Our wrapper for execvp.
procedure Execvp (File : in String;
Argv : in UBS) is
AVA : constant UBS_Array := Misc.Split_Arguments(Argv);
begin
-- Handoff to Execvp (B).
Execvp(File, AVA);
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.Execvp (A)");
raise;
end Execvp;
-- And another wrapper for execvp.
procedure Execvp (File : in String;
Argv : in UBS_Array) is
use type Interfaces.C.Size_T;
use type Interfaces.C.Strings.Chars_Ptr;
use type UBS;
LI : constant Interfaces.C.Size_T := Interfaces.C.Size_T(Argv'Last);
AVC : Interfaces.C.Strings.Chars_Ptr_Array(0..LI+1);
-- Last item should be NULL!
RV : Integer;
begin
Misc.Debug("Execvp (B)");
if Argv'First /= 0 then
Misc.Error("Argv first element should be 0.");
end if;
Misc.Debug("Argv is 0 to " & Integer'Image(Argv'Last));
Misc.Debug("Argv length (number of items) is " & Integer'Image(Argv'Length));
Misc.Debug("The C items are 0 to " & Integer'Image(Integer(LI)));
for I in 0 .. LI loop
AVC(I) := Interfaces.C.Strings.New_String(ToStr(Argv(Integer(I))));
Misc.Debug("Argc["
& Integer'Image(Integer(I))
& "]=`" & ToStr(Argv(Integer(I))) & "'");
end loop;
-- Last item should be null!
AVC(LI+1) := Interfaces.C.Strings.Null_Ptr;
-- Check that the executable actually exists.
declare
use GNAT.OS_Lib;
EP : String_Access;
begin
EP := Locate_Exec_On_Path(File);
if EP = null then
-- It's not there.
Misc.Error("‘" & File & "’ is either not present or not executable.");
end if;
-- Free it.
Free(EP);
end;
-- Actually do the exec.
RV := Integer(C_Execvp(Interfaces.C.To_C(File), AVC));
if RV = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in Execvp (B)"));
end if;
Misc.Debug("Execvp: Command return value "
& Misc.Trim_Leading_Spaces(Integer'Image(RV)));
if RV = -1 then
raise Exec_Failed;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.Execvp (B), File=`" & File &"'");
raise;
end Execvp;
-- Pipe binding.
type Filedes_Array is array (Positive range 1..2) of Interfaces.C.Int;
pragma Convention (C, Filedes_Array);
function C_Pipe (Files : in Filedes_Array) return Interfaces.C.int;
pragma Import(C, C_Pipe, "pipe");
procedure Pipe (Reading : out Integer;
Writing : out Integer) is
RV : Integer;
Filedes : Filedes_Array;
begin
Filedes := (0, 1); -- Suppress that warning.
RV := Integer(C_Pipe(Filedes));
if RV = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in Pipe"));
end if;
Misc.Debug("Pipe: Command return value "
& Misc.Trim_Leading_Spaces(Integer'Image(RV)));
if RV = -1 then
raise Pipe_Failed;
end if;
Reading := Integer(Filedes(1));
Writing := Integer(Filedes(2));
Misc.Debug("Pipe created; reading is "
& Integer'Image(Reading)
& " writing is "
& Integer'Image(Writing));
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.Pipe");
raise;
end Pipe;
-- Fork binding.
function C_Fork return Interfaces.C.int;
pragma Import(C, C_Fork, "fork");
function Fork return Integer is
RV : Integer;
begin
RV := Integer(C_Fork);
if RV = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in Fork"));
end if;
Misc.Debug("Fork: Command return value "
& Misc.Trim_Leading_Spaces(Integer'Image(RV)));
if RV = -1 then
raise Fork_Failed;
end if;
return RV;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.Fork");
raise;
end Fork;
-- Dup2 binding
function C_Dup2 (Oldfd, Newfd : Interfaces.C.Int) return Interfaces.C.int;
pragma Import(C, C_Dup2, "dup2");
procedure Dup2 (Oldfd, Newfd : in Integer) is
RV : Integer;
begin
RV := Integer(C_Dup2(Interfaces.C.Int(Oldfd),
Interfaces.C.Int(Newfd)));
if RV = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in Dup2"));
end if;
Misc.Debug("Dup2: Command return value "
& Misc.Trim_Leading_Spaces(Integer'Image(RV)));
if RV = -1 then
raise Dup2_Failed;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.Dup2");
raise;
end Dup2;
-- Binding for C Close. We'll need this to tidy up nicely.
function C_Close (FD : Interfaces.C.Int) return Interfaces.C.int;
pragma Import(C, C_Close, "close");
procedure CClose (FD : in Integer) is
RV : Integer;
begin
RV := Integer(C_Close(Interfaces.C.Int(FD)));
if RV = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in CClose"));
end if;
Misc.Debug("CClose: Command return value "
& Misc.Trim_Leading_Spaces(Integer'Image(RV)));
if RV = -1 then
raise CClose_Failed;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.CClose");
raise;
end CClose;
-- Binding for waitpid. We return the subprocess exit code.
function C_Waitpid_Wrapper (PID : Interfaces.C.Int)
return Interfaces.C.int;
pragma Import(C, C_Waitpid_Wrapper, "waitpid_wrapper");
function Waitpid (PID : Integer) return Integer is
RV : Integer;
begin
RV := Integer(C_Waitpid_Wrapper(Interfaces.C.Int(PID)));
if RV = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in Waitpid"));
end if;
Misc.Debug("Waitpid: Command return value "
& Misc.Trim_Leading_Spaces(Integer'Image(RV)));
if RV = -1 then
raise Waitpid_Failed;
end if;
return RV;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.Waitpid");
raise;
end Waitpid;
-- ForkExec: a replacement for System.
function ForkExec (File : in String;
Argv : in UBS_Array) return Integer is
P, E : Integer;
begin
P := Fork;
if P = 0 then
-- Child.
Execvp(File, Argv);
return -1;
else
-- Parent. Wait for the child to finish.
E := Waitpid(P);
return E;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec");
raise;
end ForkExec;
function ForkExec (File : in String;
Argv : in UBS) return Integer is
AVA : constant UBS_Array := Misc.Split_Arguments(Argv);
begin
return ForkExec(File, AVA);
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec (B)");
raise;
end ForkExec;
function C_Open_Append_Wrapper (S : Interfaces.C.Char_Array)
return Interfaces.C.int;
pragma Import(C, C_Open_Append_Wrapper, "open_append_wrapper");
function ForkExec_Append (File : in String;
Argv : in UBS_Array;
Target : in String) return Integer is
T, P, E : Integer;
begin
P := Fork;
if P = 0 then
-- Child.
-- Get new file handle.
T := Integer(C_Open_Append_Wrapper(Interfaces.C.To_C(Target)));
if T = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in ForkExec_Append"));
raise Open_Append_Failed;
end if;
Dup2(T, 1);
Execvp(File, Argv);
return -1;
else
-- Parent. Wait for the child to finish.
E := Waitpid(P);
return E;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec_Append");
raise;
end ForkExec_Append;
function C_Open_Out_Wrapper (S : Interfaces.C.Char_Array)
return Interfaces.C.int;
pragma Import(C, C_Open_Out_Wrapper, "open_out_wrapper");
function ForkExec_Out (File : in String;
Argv : in UBS_Array;
Target : in String) return Integer is
T, P, E : Integer;
begin
P := Fork;
if P = 0 then
-- Child.
-- Get new file handle.
T := Integer(C_Open_Out_Wrapper(Interfaces.C.To_C(Target)));
if T = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in ForkExec_Out"));
raise Open_Out_Failed;
end if;
Dup2(T, 1);
Execvp(File, Argv);
return -1;
else
-- Parent. Wait for the child to finish.
E := Waitpid(P);
return E;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec_Out");
raise;
end ForkExec_Out;
function ForkExec_Out (File : in String;
Argv : in UBS;
Target : in String) return Integer is
AVA : constant UBS_Array := Misc.Split_Arguments(Argv);
begin
return ForkExec_Out(File, AVA, Target);
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec_Out (B)");
raise;
end ForkExec_Out;
function C_Open_In_Wrapper (S : Interfaces.C.Char_Array)
return Interfaces.C.int;
pragma Import(C, C_Open_In_Wrapper, "open_in_wrapper");
function ForkExec_In (File : in String;
Argv : in UBS_Array;
Source : in String) return Integer is
S, P, E : Integer;
begin
P := Fork;
if P = 0 then
-- Child.
-- Get new file handle.
S := Integer(C_Open_In_Wrapper(Interfaces.C.To_C(Source)));
if S = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in ForkExec_In"));
raise Open_In_Failed;
end if;
Dup2(S, 0);
Execvp(File, Argv);
return -1;
else
-- Parent. Wait for the child to finish.
E := Waitpid(P);
return E;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec_In");
raise;
end ForkExec_In;
function ForkExec_InOut (File : in String;
Argv : in UBS_Array;
Source : in String;
Target : in String) return Integer is
S, T, P, E : Integer;
begin
P := Fork;
if P = 0 then
-- Child.
-- Get new file handle.
S := Integer(C_Open_In_Wrapper(Interfaces.C.To_C(Source)));
if S = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in ForkExec_InOut"));
raise Open_In_Failed;
end if;
Dup2(S, 0);
-- Get new file handle.
T := Integer(C_Open_Out_Wrapper(Interfaces.C.To_C(Target)));
if T = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in ForkExec_InOut"));
raise Open_Out_Failed;
end if;
Dup2(T, 1);
Execvp(File, Argv);
return -1;
else
-- Parent. Wait for the child to finish.
E := Waitpid(P);
return E;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec_InOut");
raise;
end ForkExec_InOut;
function ForkExec_InOut (File : in String;
Argv : in UBS;
Source : in String;
Target : in String) return Integer is
AVA : constant UBS_Array := Misc.Split_Arguments(Argv);
begin
return ForkExec_InOut(File,
AVA,
Source,
Target);
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec_InOut (B)");
raise;
end ForkExec_InOut;
procedure ForkExec2 (File1 : in String;
Argv1 : in UBS_Array;
Exit1 : out Integer;
File2 : in String;
Argv2 : in UBS_Array;
Exit2 : out Integer;
Merge_StdErr1 : in Boolean := False;
Report : in Boolean := False) is
R, W, P1, P2 : Integer;
begin
if Report then
Ada.Text_IO.New_Line;
Ada.Text_IO.Put("Executing `"
& File1
& "' and `"
& File2
& "' with arguments ");
for I in Argv1'First .. Argv1'Last loop
Ada.Text_IO.Put("`" & ToStr(Argv1(I)) & "' ");
end loop;
Ada.Text_IO.Put(" and ");
for I in Argv2'First .. Argv2'Last loop
Ada.Text_IO.Put("`" & ToStr(Argv2(I)) & "' ");
end loop;
Ada.Text_IO.New_Line(2);
end if;
Pipe(R, W);
P1 := Fork;
if P1 = 0 then -- child1
CClose(R);
Dup2(W, 1);
if Merge_StdErr1 then
Dup2(W, 2);
end if;
Execvp(File1,
Argv1);
else
P2 := Fork;
if P2 = 0 then -- child2
CClose(W);
Dup2(R, 0);
Execvp(File2,
Argv2);
else
CClose(R);
CClose(W);
Exit1 := Waitpid(P1);
Exit2 := Waitpid(P2);
end if;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec2");
raise;
end ForkExec2;
procedure ForkExec2 (File1 : in String;
Argv1 : in UBS;
Exit1 : out Integer;
File2 : in String;
Argv2 : in UBS;
Exit2 : out Integer;
Merge_StdErr1 : in Boolean := False;
Report : in Boolean := False) is
AVA1 : constant UBS_Array := Misc.Split_Arguments(Argv1);
AVA2 : constant UBS_Array := Misc.Split_Arguments(Argv2);
begin
ForkExec2(File1,
AVA1,
Exit1,
File2,
AVA2,
Exit2,
Merge_StdErr1,
Report);
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec2 (B)");
raise;
end ForkExec2;
procedure ForkExec2_Out (File1 : in String;
Argv1 : in UBS_Array;
Exit1 : out Integer;
File2 : in String;
Argv2 : in UBS_Array;
Exit2 : out Integer;
Target : in String) is
T, R, W, P1, P2 : Integer;
begin
Pipe(R, W);
P1 := Fork;
if P1 = 0 then -- child1
CClose(R);
Dup2(W, 1);
Execvp(File1,
Argv1);
else
P2 := Fork;
if P2 = 0 then -- child2
CClose(W);
Dup2(R, 0);
-- Get new file handle.
T := Integer(C_Open_Out_Wrapper(Interfaces.C.To_C(Target)));
if T = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in ForkExec2_Out"));
raise Open_Out_Failed;
end if;
Dup2(T, 1);
Execvp(File2,
Argv2);
else
CClose(R);
CClose(W);
Exit1 := Waitpid(P1);
Exit2 := Waitpid(P2);
end if;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec2_Out");
raise;
end ForkExec2_Out;
procedure ForkExec2_Out (File1 : in String;
Argv1 : in UBS;
Exit1 : out Integer;
File2 : in String;
Argv2 : in UBS_Array;
Exit2 : out Integer;
Target : in String) is
AVA1 : constant UBS_Array := Misc.Split_Arguments(Argv1);
begin
ForkExec2_Out(File1, AVA1, Exit1,
File2, Argv2, Exit2,
Target);
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec2_Out(B)");
raise;
end ForkExec2_Out;
procedure ForkExec2_InOut (File1 : in String;
Argv1 : in UBS_Array;
Exit1 : out Integer;
File2 : in String;
Argv2 : in UBS_Array;
Exit2 : out Integer;
Source : in String;
Target : in String) is
S, T, R, W, P1, P2 : Integer;
begin
Pipe(R, W);
P1 := Fork;
if P1 = 0 then -- child1
CClose(R);
Dup2(W, 1);
-- Get new file handle.
S := Integer(C_Open_In_Wrapper(Interfaces.C.To_C(Source)));
if S = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in ForkExec2_InOut"));
raise Open_In_Failed;
end if;
Dup2(S, 0);
-- Get new file handle.
Execvp(File1,
Argv1);
else
P2 := Fork;
if P2 = 0 then -- child2
CClose(W);
Dup2(R, 0);
-- Get new file handle.
T := Integer(C_Open_Out_Wrapper(Interfaces.C.To_C(Target)));
if T = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in ForkExec2_InOut"));
raise Open_Out_Failed;
end if;
Dup2(T, 1);
Execvp(File2,
Argv2);
else
CClose(R);
CClose(W);
Exit1 := Waitpid(P1);
Exit2 := Waitpid(P2);
end if;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec2_InOut");
raise;
end ForkExec2_InOut;
procedure ForkExec3_Out (File1 : in String;
Argv1 : in UBS;
Exit1 : out Integer;
File2 : in String;
Argv2 : in UBS_Array;
Exit2 : out Integer;
File3 : in String;
Argv3 : in UBS_Array;
Exit3 : out Integer;
Target : in String) is
T, R1, W1, R2, W2, P1, P2, P3 : Integer;
AVA1 : constant UBS_Array := Misc.Split_Arguments(Argv1);
begin
Pipe(R1, W1);
Pipe(R2, W2);
P1 := Fork;
if P1 = 0 then -- child1
CClose(R1);
CClose(R2);
CClose(W2);
Dup2(W1, 1);
Execvp(File1,
AVA1);
else
P2 := Fork;
if P2 = 0 then -- child2
CClose(W1);
CClose(R2);
Dup2(R1, 0);
Dup2(W2, 1);
Execvp(File2,
Argv2);
else
P3 := Fork;
if P3 = 0 then -- child3
CClose(R1);
CClose(W1);
CClose(W2);
Dup2(R2, 0);
-- Get new file handle.
T := Integer(C_Open_Out_Wrapper(Interfaces.C.To_C(Target)));
if T = -1 then
Misc.Debug("Errno is "
& Misc.Trim_Leading_Spaces(Integer'Image(Integer(C_Errno))));
C_Perror(Interfaces.C.To_C("Topal: problem in ForkExec3_Out"));
raise Open_Out_Failed;
end if;
Dup2(T, 1);
Execvp(File3,
Argv3);
else
CClose(R1);
CClose(W1);
CClose(R2);
CClose(W2);
Exit1 := Waitpid(P1);
Exit2 := Waitpid(P2);
Exit3 := Waitpid(P3);
end if;
end if;
end if;
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.ForkExec3_Out");
raise;
end ForkExec3_Out;
-- More wrappers.
function Open_Append (S : String) return Integer is
begin
return Integer(C_Open_Append_Wrapper(Interfaces.C.To_C(S)));
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.Open_Append");
raise;
end Open_Append;
function Open_Out (S : String) return Integer is
begin
return Integer(C_Open_Out_Wrapper(Interfaces.C.To_C(S)));
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.Open_Out");
raise;
end Open_Out;
function Open_In (S : String) return Integer is
begin
return Integer(C_Open_In_Wrapper(Interfaces.C.To_C(S)));
exception
when others =>
Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error,
"Exception raised in Externals.Open_In");
raise;
end Open_In;
end Externals;
topal-80/echo.ads 0000644 0001750 0001750 00000001532 13434071426 012146 0 ustar pjb pjb -- Topal: GPG/GnuPG and Alpine/Pine integration
-- Copyright (C) 2001--2018 Phillip J. Brooke
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License version 3 as
-- published by the Free Software Foundation.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see .
package Echo is
Operation_Failed : exception;
procedure Set_Echo;
procedure Clear_Echo;
procedure Save_Terminal;
procedure Restore_Terminal;
end Echo;
topal-80/readline.ads 0000644 0001750 0001750 00000002014 13434071426 013007 0 ustar pjb pjb -- Topal: GPG/GnuPG and Alpine/Pine integration
-- Copyright (C) 2001--2008 Phillip J. Brooke
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License version 3 as
-- published by the Free Software Foundation.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see .
package Readline is
function Get_String (Prompt : String := "";
Enable_Tab_Completion : Boolean := False)
return String;
procedure Add_History (History : in String;
Remove_Empty : in Boolean := True);
procedure Save_History;
procedure Load_History;
end Readline;
topal-80/char_menus.adb 0000644 0001750 0001750 00000006350 13434071426 013336 0 ustar pjb pjb -- Topal: GPG/GnuPG and Alpine/Pine integration
-- Copyright (C) 2001--2010 Phillip J. Brooke
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License version 3 as
-- published by the Free Software Foundation.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see .
with Ada.Exceptions;
with Ada.Strings.Maps;
with Ada.Text_IO;
with Echo;
with Misc; use Misc;
package body Char_Menus is
function Menu (Prompt : in String := Default_Prompt) return Index is
use Ada.Strings.Maps;
use Ada.Text_IO;
C : Character;
begin
Debug("+Char_Menu.Menu");
if Accept_Chars'Length /= Char_Words'Length
or Accept_Chars'First /= Char_Words'First then
raise Arrays_Not_Matched;
end if;
if Config.Boolean_Opts(Debug) then
Debug("Char_Menu.Menu: Prompt is `" & Prompt & "'");
begin
for I in Accept_Chars'Range loop
Debug("Char_Menu.Menu: Group "
& Index'Image(I)
& " Accept_Chars=`" & ToStr(Accept_Chars(I)) & "'");
end loop;
exception
when The_Exception : others =>
Debug("Exception raised in Accept_Chars bit: "
& Ada.Exceptions.Exception_Name(The_Exception));
end;
begin
for I in Char_Words'Range loop
Debug("Char_Menu.Menu: Group "
& Index'Image(I)
& " Char_Words=`" & ToStr(Char_Words(I)) & "'");
end loop;
exception
when The_Exception : others =>
Debug("Exception raised in Char_Words bit: "
& Ada.Exceptions.Exception_Name(The_Exception));
end;
end if;
Put(Rewrite_Menu_Prompt(Prompt));
Entry_Loop:
loop
Echo.Clear_Echo;
Debug("Menu.Char_Menu: About to Get_Immediate");
Get_Immediate(C);
Debug("Menu.Char_Menu: Got: `" & C
& "' value " & Integer'Image(Character'Pos(C)));
Echo.Set_Echo;
-- Now, run through the menu.
for I in Accept_Chars'Range loop
if Is_In(C, To_Set(ToStr(Accept_Chars(I)))) then
Put(Do_SGR(Config.UBS_Opts(Colour_Menu_Choice))
& ToStr(Char_Words(I))
& Reset_SGR);
New_Line(2);
Debug("-Char_Menu.Menu with value "
& Index'Image(I)
& " for character `"
& C & "'");
return I;
end if;
end loop;
Debug("Menu.Char_Menu: No match for character `" & C & "'");
end loop Entry_Loop;
exception
when others =>
ErrorNE("Char_Menu.Menu: In exception handler. Re-raising.");
raise;
return Index'First; -- Never executed.
end Menu;
end Char_Menus;
topal-80/pine-4.50.patch 0000644 0001750 0001750 00000017355 13434071426 013111 0 ustar pjb pjb Only in pine4.50/: .bld.hlp
Only in pine4.50/: bin
diff -cr OP/pine4.50/imap/src/c-client/mail.h pine4.50/imap/src/c-client/mail.h
*** OP/pine4.50/imap/src/c-client/mail.h Tue Oct 29 01:10:29 2002
--- pine4.50/imap/src/c-client/mail.h Fri Nov 22 11:42:08 2002
***************
*** 651,656 ****
--- 651,657 ----
unsigned long bytes; /* size of text in octets */
} size;
char *md5; /* MD5 checksum */
+ unsigned short topal_hack; /* set to 1 if topal has wrecked the sending */
};
Only in pine4.50/imap/src/c-client: mail.h.orig
Only in pine4.50/pine: date.c
diff -cr OP/pine4.50/pine/pine.h pine4.50/pine/pine.h
*** OP/pine4.50/pine/pine.h Wed Nov 20 18:19:44 2002
--- pine4.50/pine/pine.h Fri Nov 22 11:42:38 2002
***************
*** 63,69 ****
#ifndef _PINE_INCLUDED
#define _PINE_INCLUDED
! #define PINE_VERSION "4.50"
#define PHONE_HOME_VERSION "-count"
#define PHONE_HOME_HOST "docserver.cac.washington.edu"
--- 63,69 ----
#ifndef _PINE_INCLUDED
#define _PINE_INCLUDED
! #define PINE_VERSION "4.50T"
#define PHONE_HOME_VERSION "-count"
#define PHONE_HOME_HOST "docserver.cac.washington.edu"
Only in pine4.50/pine: pine.h.orig
Only in pine4.50/pine: pine.h.rej
diff -cr OP/pine4.50/pine/send.c pine4.50/pine/send.c
*** OP/pine4.50/pine/send.c Wed Nov 20 22:51:49 2002
--- pine4.50/pine/send.c Fri Nov 22 11:42:08 2002
***************
*** 4764,4769 ****
--- 4764,4779 ----
pbf = save_previous_pbuf;
g_rolenick = NULL;
+ if ((*body)->type == TYPEMULTIPART
+ && (*body)->topal_hack == 1)
+ /* This was a single part message which Topal mangled. */
+ (*body)->type = TYPETEXT;
+ if ((*body)->type == TYPEMULTIPART
+ && (*body)->topal_hack != 1)
+ /* Topal mangled a multipart message. So the first nested part
+ is really TYPETEXT. */
+ (*body)->nested.part->body.type = TYPETEXT;
+
dprint(4, (debugfile, "=== send returning ===\n"));
}
***************
*** 6076,6088 ****
;
rfc822_parse_content_header(nb,ucase(buf+8),s);
! if(nb->type == TYPETEXT
! && nb->subtype
&& (!b->subtype
|| strucmp(b->subtype, nb->subtype))){
if(b->subtype)
fs_give((void **) &b->subtype);
b->subtype = nb->subtype;
nb->subtype = NULL;
--- 6086,6098 ----
;
rfc822_parse_content_header(nb,ucase(buf+8),s);
! if(nb->subtype
&& (!b->subtype
|| strucmp(b->subtype, nb->subtype))){
if(b->subtype)
fs_give((void **) &b->subtype);
+ b->type = nb->type;
b->subtype = nb->subtype;
nb->subtype = NULL;
***************
*** 6090,6095 ****
--- 6100,6107 ----
b->parameter = nb->parameter;
nb->parameter = NULL;
mail_free_body_parameter(&nb->parameter);
+ if (b->type != TYPETEXT)
+ b->topal_hack = 1;
}
mail_free_body(&nb);
***************
*** 8726,8742 ****
dprint(4, (debugfile, "-- pine_encode_body: %d\n", body ? body->type : 0));
if (body) switch (body->type) {
case TYPEMULTIPART: /* multi-part */
! if (!body->parameter) { /* cookie not set up yet? */
! char tmp[MAILTMPLEN]; /* make cookie not in BASE64 or QUOTEPRINT*/
! sprintf (tmp,"%ld-%ld-%ld=:%ld",gethostid (),random (),time (0),
! getpid ());
! body->parameter = mail_newbody_parameter ();
! body->parameter->attribute = cpystr ("BOUNDARY");
! body->parameter->value = cpystr (tmp);
! }
! part = body->nested.part; /* encode body parts */
! do pine_encode_body (&part->body);
! while (part = part->next); /* until done */
break;
/* case MESSAGE: */ /* here for documentation */
/* Encapsulated messages are always treated as text objects at this point.
--- 8738,8756 ----
dprint(4, (debugfile, "-- pine_encode_body: %d\n", body ? body->type : 0));
if (body) switch (body->type) {
case TYPEMULTIPART: /* multi-part */
! if (body->topal_hack != 1){
! if (!body->parameter) { /* cookie not set up yet? */
! char tmp[MAILTMPLEN]; /* make cookie not in BASE64 or QUOTEPRINT*/
! sprintf (tmp,"%ld-%ld-%ld=:%ld",gethostid (),random (),time (0),
! getpid ());
! body->parameter = mail_newbody_parameter ();
! body->parameter->attribute = cpystr ("BOUNDARY");
! body->parameter->value = cpystr (tmp);
! }
! part = body->nested.part; /* encode body parts */
! do pine_encode_body (&part->body);
! while (part = part->next); /* until done */
! }
break;
/* case MESSAGE: */ /* here for documentation */
/* Encapsulated messages are always treated as text objects at this point.
***************
*** 8906,8912 ****
dprint(4, (debugfile, "-- pine_rfc822_output_body: %d\n",
body ? body->type : 0));
! if(body->type == TYPEMULTIPART) { /* multipart gets special handling */
part = body->nested.part; /* first body part */
/* find cookie */
for (param = body->parameter; param && !cookie; param = param->next)
--- 8920,8927 ----
dprint(4, (debugfile, "-- pine_rfc822_output_body: %d\n",
body ? body->type : 0));
! if(body->type == TYPEMULTIPART
! && body->topal_hack != 1) { /* multipart gets special handling */
part = body->nested.part; /* first body part */
/* find cookie */
for (param = body->parameter; param && !cookie; param = param->next)
***************
*** 8966,8972 ****
* Convert text pieces to canonical form
* BEFORE applying any encoding (rfc1341: appendix G)...
*/
! if(body->type == TYPETEXT){
gf_link_filter(gf_local_nvtnl, NULL);
}
--- 8981,8988 ----
* Convert text pieces to canonical form
* BEFORE applying any encoding (rfc1341: appendix G)...
*/
! if(body->type == TYPETEXT
! | (body->type == TYPEMULTIPART && body->topal_hack == 1)){
gf_link_filter(gf_local_nvtnl, NULL);
}
***************
*** 9075,9089 ****
? body->subtype
: rfc822_default_subtype (body->type))))
return(pwbh_finish(0, so));
!
if (param){
! do
! if(!(so_puts(so, "; ")
! && rfc2231_output(so, param->attribute, param->value,
! (char *) tspecials,
! ps_global->VAR_CHAR_SET)))
! return(pwbh_finish(0, so));
! while (param = param->next);
}
else if(!so_puts(so, "; CHARSET=US-ASCII"))
return(pwbh_finish(0, so));
--- 9091,9117 ----
? body->subtype
: rfc822_default_subtype (body->type))))
return(pwbh_finish(0, so));
!
if (param){
! do
! if(body->topal_hack == 1
! && !struncmp(param->attribute, "protocol", 9))
! {
! if(!(so_puts(so, "; \015\012\011")
! && rfc2231_output(so, param->attribute, param->value,
! (char *) tspecials,
! ps_global->VAR_CHAR_SET)))
! return(pwbh_finish(0, so));
! }
! else
! {
! if(!(so_puts(so, "; ")
! && rfc2231_output(so, param->attribute, param->value,
! (char *) tspecials,
! ps_global->VAR_CHAR_SET)))
! return(pwbh_finish(0, so));
! }
! while (param = param->next);
}
else if(!so_puts(so, "; CHARSET=US-ASCII"))
return(pwbh_finish(0, so));
***************
*** 9341,9347 ****
long l = 0L;
PART *part;
! if(body->type == TYPEMULTIPART) { /* multipart gets special handling */
part = body->nested.part; /* first body part */
do /* for each part */
l += send_body_size(&part->body);
--- 9369,9376 ----
long l = 0L;
PART *part;
! if(body->type == TYPEMULTIPART
! && body->topal_hack != 1) { /* multipart gets special handling */
part = body->nested.part; /* first body part */
do /* for each part */
l += send_body_size(&part->body);
topal-80/configuration.ads 0000644 0001750 0001750 00000002721 13434071426 014100 0 ustar pjb pjb -- Topal: GPG/GnuPG and Alpine/Pine integration
-- Copyright (C) 2001--2018 Phillip J. Brooke
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License version 3 as
-- published by the Free Software Foundation.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see .
with Globals; use Globals;
package Configuration is
Switch_Parse_Error : exception;
function Set_Two_Way (S : String) return Boolean;
Two_Way : constant array (Boolean) of UBS
:= (True => ToUBS("on"),
False => ToUBS("off"));
Config_Parse_Error : exception;
procedure Read_Config_File (Warnings : out Boolean);
procedure Dump (Overwrite_Config : in Boolean := False);
procedure Edit_Configuration;
procedure Edit_Own_Key(SMIME : in Boolean);
procedure Default_Configuration (C : in out Config_Record);
-- Deep copy the configuration. Right is the original; Left is the
-- newly instantiated configuration.
procedure Copy_Configuration(Left : in out Config_Record;
Right : in Config_Record);
end Configuration;
topal-80/topal.man 0000644 0001750 0001750 00000001741 13434071426 012355 0 ustar pjb pjb .TH TOPAL 1 "November 2, 2002"
.SH NAME
topal \- GPG/GnuPG and Alpine/Pine integration
.SH SYNOPSIS
.B topal
[
.I options
]
.LP
.SH DESCRIPTION
Topal is yet another program that links GnuPG and Pine/Alpine. It
offers facilities to encrypt, decrypt, sign, and verify messages. It
can also be used directly from the command-line.
Multiple PGP blocks included in the text of a message are
processed. Decryption and verification output can be cached to reduce
the number of times the passphrase is entered. RFC2015/3156 multipart
messages can be sent and received with help from some scripts,
procmail and a (deprecated) patch to Pine/Alpine. It includes basic
support for verifying S/MIME multipart/signed messages. There is a
remote sending mode for reading email on a distant computer via SSH
with secret keys on the local computer. There is a high level of
configurability.
.SH USAGE REFERENCE
Use the -help option, or see the README file.
.SH AUTHOR
Phil Brooke, p.j.brooke@bcs.org.uk
topal-80/Changelog.html 0000644 0001750 0001750 00000072207 13434071426 013323 0 ustar pjb pjb
Topal — Changelog
Topal — Changelog
Copyright © 2001–2018 Phillip J. Brooke
- 06/2001, 0.1
- First alpha release.
- 06/2001, 0.2
- Minor changes.
- 06/2001, 0.3
- Major changes to how keys are identified and
looked up.
- 06/2001, 0.4
- Adding more customization features.
- 11/2001, 0.4.4
- Cleaned up some error messages; added -nps
mode.
- 11/2001, 0.4.5
- Added ‘gpg-options’ config item with
default ‘--no-options’. (Forgot to add this note as well....)
- 11/2001, 0.5.0
- Dumped -verify and -decrypt modes in
favour of the multiple-block ‘-display’ mode. Added -help. Added
caching. Added more switches relating to caching. Better output
formatting.
- 11/2001, 0.5.1
- Improved menus. Tidied up some of the
interface. Added -s, which does the same as -nps.
- 12/2001, 0.5.2
- Tidied disclaimer. Added synonyms for
-help (-h, -?, --help, --h) Cleaned up menus; keypresses aren't echoed
any longer.
- 12/2001, 0.5.3
- Altered packaging to include version in
directory name. Changed names of some -clear options to be a bit more
sensible. Changing config settings method (big change). Making -s
the default operation. Some rearrangement of code, constants. Some
configuration editing possible via Topal. Send has access to
configuration menu.
- 12/2001, 0.5.4
- Bug fix; one-off error in the sending
menus.
- 12/2001, 0.5.5
- Removed redundant examples directory.
Changed over to HTML documentation. Tweaked the RELEASE stuff. Use
space instead of enter when waiting to continue: this looks forward to
offering a help option at every prompt. The receive/blocks
stuff now uses an expanding array. The GPG return value is checked
when receiving: if it's bad, then some bits of the output are omitted;
the cache file is not written. The date bit of Topal output moved
onto the previous line (echo -n blah blah).
- 12/2001, 0.5.6
- Adding installation instructions. Using
tee and PIPESTATUS to get stderr on screen during receiving while also
saving that output and recording gpg's exit status. Changed RELEASE
filename to release. Tidied up the Makefile. Invalid passphrase
messages are grep'd out of the output. Added ‘fast continue’ options.
Key lists in the configuration section now use expanding arrays.
Changed key details selection message. Secret key selection now
offers a menu of secret keys on the secret keyring. Initial recipient
search excludes keys in XK list. Added key search/selection menu
choice - much nicer to use than the add menu. More configuration
stuff added (still more to do, although the config file can always be
used). Partial documentation update.
- 2/2002, 0.5.7
- Adding limited RFC2015/MIME decoding of
multipart email.
- 2/2002, 0.5.8
- Adding mime-construct to configuration in
expectation of more RFC2015 features. Put test for the config file
existing before actually attempting to read it (oops). Added -O2
-Wall and the TOPALDEBUG variable for compiling. Put up WWW page via
own Freeserve site. Announcing via Freshmeat. Automating output WWW
site generation (all the grunge in the Makefile).
- 3/2002, 0.6.0
- Distribution uses a gzip'd binary now....
Added a pre-built binary that is statically linked against the GNAT
stuff so that people don't need to acquire GNAT first (this, I
believe, complies with the GNAT licence).
Added the scripts
topal-fix-email and topal-fix-folder. This makes it a lot easier to
work with other people's multipart/signed or /encrypted email.
Procmail recipe added to this README.
Added display of
application/pgp messages. Including the text of one of these in a
reply might be difficult, but then, it was difficult without topal's
mangling. At least they can be verified and read now.
-sendmime
option added. Hack needed (in topal-pine-patch [now pine-4.44.patch])
to allow non-text/blah content-types in Pine. RFC2015 send and
received done (including micalg detection when sending clearsigned
messages: list used from RFC3156.). Ditto for application/pgp, but
I'm not sure of some of the parameters, since I've only ever seen
signed emails of this form.
Removed some of the waits for execution,
since it seems reliable. Added error checking on return value of GPG
in sends.
- 3/2002, 0.6.1
- The Content-Type for MIME sending is
displayed on the screen using ‘cat’ rather than ‘less’, which was
getting to be annoying.
Two changes that are related to how I
manage the source code: Slight tweak to makefile for keeping track
of RCS files; and using rcs -n<symbolic-name> to tag the
released files.
- 3/2002, 0.6.2
- MIME clear-signed messages: trailing blank
lines are now deleted before signing (this would cause BAD signature
when verifying on some other MTAs). Added remarks to documentation
about the patch to Pine and attachments.
- 4/2002, 0.6.3
- RFC1847 multipart encapsulation added.
(See section 6.1 of RFC3156.) Cleaned up related receiving/caching
behaviour.
Another MIME clear-signed messages bugfix. This one
sorts out line-end conventions correctly.
New patch for Pine: this
stops a SEGFAULT when using RFC2015 stuff and other attachments at the
same time.
Updated documentation; added man pages for the two scripts.
- 4/2002, 0.6.4
- New patch for Pine. Adds a workaround for
the problem where some versions of MS Exchange would silently lose
inbound MIME clearsigned email. It turns out that a slight formatting
change stops the problem.
- 5/2002, 6/2002; 0.6.5, 0.6.6, 0.6.7, 0.6.8
- Adding more debugging,
mostly to the menus code. Used for tracking down a nasty problem
causing exceptions. Many thanks to Felix Madlener for pointing this
out and testing the revised code.
- 7/2002, 0.6.9
- Renamed the Pine patch for when new versions
come out. (It's still the same patch as for Topal 0.6.4.) Added trap
for non-existent file when using ‘-s’. Cache directory as well as
.topal directory is also chmod'd to 700. Added README.txt to package
file (even though it's generated from the .html) so that those who
just want to ‘less’ it (instead of firing up a HTML reader) can do so.
- 8/2002, 0.7.0
- Changed email address in man page. Lots more
exception handling for extra info when something goes wrong. Moderate
code reorganisation: mostly splitting blocks of code out for future
work. Fixed ‘bug’ (feature?) where send fails if a public key is
unusable (although this may risk sending plaintext through; we assume
that if an output file was generated, then the GPG errors weren't
fatal). Now we check instead if the output file exists. Checking all
source files for any similar bugs in menus (cf. the 5/2002 entry).
Modified MIME RFC2015 receiving function so that it isn't so reliant
on shell calls of sed (which can fall over with nasty characters in an
incoming emails boundary). Moreover, it can now cope with MIME parts
that don't end with a newline. Tweaking MIME/verify cache handling:
we shouldn't actually get an output file from GPG (since we're only
verifying one part with the other); we put a vague warning if this
happens, and trap when reading the cache. Added content-type to
plaintext for MIME/encrypted. Documentation update.
- 8/2002, 0.7.1
- Fixed minor bug with inverted return code
(‘-s’ trap). Doc update.
- 9/2002, 0.7.2
- Fixed minor bug in key list handling code
(dealing with key selection).
- 9/2002; 0.7.3, 0.7.4 (BETA)
- Disposed of the dependency on a shell by
introducing Ada bindings for fork/exec/dup/pipe/glob, etc.. Several
external binaries are no longer needed (cat, echo). Most return codes
are now properly checked (although still need to do a better audit).
Followed Eduardo Chappa's advice and changed Pine patch version
letter. Miscellaneous cleanups and fixes. Many thanks to Peter
Losher for giving me the incentive to sort out the external calls.
- 9/2002; 0.7.5 (BETA)
- Tidying up structure of external calls, and
how the various messages are built up and torn down. Changed the lynx
switches at the suggestion of Felix Madlener (many thanks!). When
receiving MIME encrypted attachments, the output is not included in
the Topal output, but only in the metamail invocation.
- 10/2002; 0.7.6 (BETA)
- Explicitly noted which versions are
not intended for general use (beta versions). Rearranged command line
parsing for more flexibility in future.
- 10/2002; 0.7.7 (BETA)
- Re-implementing topal-fix-email and
topal-fix-folder as part of the main topal binary. This removes the
(script) dependency on munpack, but adds formail and diff to the main
binary. Fixed some missing bits for particular binaries in
configuration handling. Adding ‘important changes from last stable
version’ documentation. Tweaked the body extraction procedure.
Tweaked some output messages. Major changes to menus: they now use
enumerated types rather than integers.... Tweaking cl_menu some
more. Added ‘pass-thu’ option to send menu (so you can always use the
Topal filter. This might also fix the minor problem with text/html
occasionally being sent when it shouldn't be....) Fixed bug where
MIME decrypt failure would still cause metamail to be invoked, but
that's a waste of time.
- 10/2002; 0.7.8
- Clearing out case statements with ‘when
others’. Tidying up sending.adb. Fixed problem in MIME output where
a leading blank line was added. Finally implemented ‘topal
--fix-folders’ functionality added. No longer need the two old
scripts (I hope)! Another documentation tidy-up. Added
‘inline-separate-output’ option: this effectively turns off the GnuPG/Topal
wrappers in output. However, the side-effect is that the cache must
be cleared when upgrading to this version.
- 11/2002; 0.7.9
- Added some infrastructure for
encrypting/signing attachments (but this is nowhere near working yet).
Documentation and manpage update (again). Seems stable, will release.
- 2/2003; 0.7.10, 0.7.11
- Tweaking distribution pages (mkdistrib).
Including patches against Pine versions 4.50 and 4.53. (They're all
more-or-less the same patch. It's pretty
easy to apply them against 4.51 and 4.52 if you feel so inclined.)
Further doc clean up (particular the stuff about important changes
from previous stable versions). Implemented Felix M.'s suggestion for
handling non-existant command-line options: things that aren't valid
options, but are prefixed with a ‘-’ get a more helpful error
message. --fix-email workaround also writes out the original input in
the exception handler. Changed recommended procmail recipe so that
Topal's exit code is checked.
- 2/2003; 0.7.12
- Adding ‘workaround-error-log’ file to
.topal. This accepts output from topal --fix-email when it fails to
exit cleanly. Not quite clear if this bit works yet (was tracking
down other problem). It appears that when running without a real
terminal, the call to set_echo fails. Odd. Nasty workaround
implemented.
- 2/2002; 0.7.13
- Added missing includes to ada-echo-c.c.
Perhaps related to issue in the previous entry.
- 4/2003; 0.7.13b
- Bug fix release only - backported from
(not-yet-released 0.8.0). Fixed bug when
changing own signing key using the -config option - thanks to Stewart
James for the bug report.
- 10/2003; 0.7.13.2
- Bug fix release only - backported from
(not-yet-released 0.8.0). Changed bug fix versioning scheme.
Makefile now links properly against static GNAT runtime. Fixed
problem which manifests as: ‘relocation error: /lib/libreadline.so.4:
undefined symbol: BC’ (needed instruction to link against ncurses) -
thanks to Marty Hoff for the bug report. Added patch against Pine
version 4.58.
- 10/2003; 0.7.13.3
- Now use -gnatwa and -gnato for all Ada
compilation. It was omitted from the main binary build command
before. Fixed all the resulting warnings.
- 1/2004; 0.7.13.4
- Patched externals calls for errno to
prevent (in some cases) warnings from ld.so, and in other cases,
failures to build.
- 6/2004; 0.7.13.5
- Added patch against Pine version
4.60. Updated some notices.
- 1/4/2005; 0.7.13.6
- Calls to the GPG binary now have LANG
set to C before exec so that we don't have to worry about different
language output in GPG. Thanks for Joern Brederec for the bug report
and suggestion of how to fix it.
- 2005-2007
- Four internal development releases junked.
- 8/1/2008; release 55
-
--fix-email now replaces the original message with a
multipart/misc wrapper, rather than expanding it into a
multipart/alternative message.
Replaced some key selection code. Hopefully, this reduces the number
of locale-dependent and GPG version-specific problems. Additionally,
revoked, disabled and invalid keys are no longer offered; checks are
made to ensure that the key is valid for encryption/signing when applicable.
New patch for Alpine 1.00. Includes configuration setting.
The ‘pass through unchanged’ send option no longer modifies the
content-type to text/plain.
Should now build and run on Cygwin.
Licence is now GPL-3.
Attempt to prevent potential memory leak (if running for a long time)
by making the implementation of expanding_array a controlled type.
Cleaned up Ada source to reduce warnings.
Other minor changes, e.g., better checks on keylists, documentation clean-up.
Changed release numbering.
HTML cleaned up and CSS added.
- 8/1/2008; release 56
-
--read-from option added to select different signing keys
depending on the From line. Also added sake and sxk
configurations.
Fixed bug in Keys.Remove.Key (didn't match if the full fingerprint
wasn't given).
Command-line parser now accepts 1 or more hyphens for any option.
Improved keylist documentation.
Corrected release date for release 55... oops.
- 8/1/2008; release 57
-
Initial attempt at supporting attachments within Topal.
Changed MIME boundary detection code (the previous algorithm couldn't
cope with multipart included in a signed email). Please tell me if
this breaks your emails....
Bug fix to _INCLUDEALLHDRS_ - it needs to turn the CRLF back into LF
or it might chop off some of your message....
- 22/6/2008; release 58
-
UI improvements (count keys in keylist, clearer indication of position
in menus).
Added patch for Alpine 1.10. Renamed all patch files.
Default paths for binaries are no longer absolute.
Configuration files now allow comments, but they're not preserved by Topal.
Added more exception handling messages.
Sending and receiving both save off original input as tempfiles to
help debugging.
Added --ask-charset command line option. This is really only for
testing a new workaround for locale-related bad signatures. Please
see locale problems in the notes and
send feedback.
Started removing dependency on mime-construct; new source files mime.ad[sb].
Build date added to binary.
- 3/7/2008; release 59
-
Added sequence numbers to temporary files to reduce possible name
conflicts.
The makefile's install target now installs to INSTALLPATH. This can
be overridden, e.g., make install INSTALLPATH=/usr/local.
The four more specific paths, INSTALLPATHBIN, INSTALLPATHMAN,
INSTALLPATHDOC and INSTALLPATHPATCHES can also be overridden. Fixes
request from Nils Schlupp re: ebuild.
The --ask-charset command-line option is now only used if a bad signature
is returned; a second attempt is then made if a different character
set is suggested by the user.
- 13/7/2008; release 60
-
Update installation instructions for make install.
We now use a modified version of Jeffrey S. Dutky's mime-tool instead
of mime-construct for creating MIME messages. We include our modified
version in the Topal tarball (since both are GPL, and our
modifications are needed if creating MIME messages).
MIME viewing can now use metamail, use run-mailcap or save the attachment to the
folder ~/.topal/viewmime (which you can then open in
Alpine). run-mailcap and saving support are new.
Sending menu allows user to view and edit the email. A quicker
method for changing/setting the signing (own) key is available.
- 14/7/2008; release 61
-
An initial, rather crude, but (for my purposes at least) effective
remote mode for sending.
Some history is now saved.
- 17/7/2008; release 62
-
Added basic support for S/MIME verification of messages.
Quoted-printable encoder (in MIME-tool) improved (single dots and
leading "From ") as per RFC2049.
Decode quoted-printable and base64 before calling run-mailcap.
Ignore errors in strip in Makefile (trips up Cygwin, which expects the
executable to be foo.exe).
Update feature list for remote sending.
Internal changes to configuration storage.
- 31/8/2008; release 63
-
Update change list for release 62 (omitted some items...).
Give a sensible warning message instead of dying with an exception
when (1) signing operations are called without own key set; (2)
attempting to choose own key without any secret keys available.
Added some hints in the documentation.
Initial attempt at supporting remote decryption.
Handle SIGINT ourselves so that temporary files are cleaned up. Also
clean up more often when exceptions occur.
- 24/10/2008; release 64
-
Update feature list for release 63's remote decryption support.
Add patch to Topal sources for Cygwin. (The recent interrupt code
doesn't build.)
Bug fix: temporary files weren't being deleted, because
Rm_Tempfiles_PID hadn't been changed to match Temp_File_Name.
Added patch for Alpine 2.00. Alpine's S/MIME needs to be turned off
for Topal's S/MIME verification to work.
Bug fix in Externals.Simple.Guess_Content_Type.
- 1/5/2009; release 65
-
MIME sending now uses the current locale as the content-type header charset.
MIME receiving (verification) tries to use the character set given in
its first attempt.
Signing calls to GPG use --textmode flag (shouldn't be needed
if the dos2unix calls work, but experiments suggest some problems if
we don't do this).
Fix remote server so that emails with multiple recipients are handled
properly.
Added new patch to Alpine that might make it easier to read
multipart signed/encrypted messages. This makes the procmail recipe
redundant, but needs more testing.
Attempt to manage different character sets when verifying S/MIME.
MIME messages now include a prolog explaining that they're OpenPGP
messages. Also added appropriate Content-Disposition headers to help
client programs.
Update docs re: Alpine patches.
Code cleanup (e.g., vars that could be declared constant, and some
unused procedure formals).
- 6/6/2009; release 66
-
Removed spurious spaces from Topal ‘-----’ text that were messing up
format=flowed text. Note that this doesn't fix cache files that
already have this problem.
Changed the default sending and receiving GPG options (use
the -default option to see them). This does not override
whatever is in your current .topal/config file.
Added a configuration option ‘omit-inline-disposition-name’:
apparently some mail services mistreat inline MIME parts if they have
a filename. If this option is set, then no filename parameter is
added to inline content-disposition headers. The option can be
changed via the configuration menu.
- 6/6/2009; release 67
-
Added another configuration option ‘omit-inline-disposition-header’.
If a disposition header of value inline would be added, it's simply
omitted altogether.
- 27/6/2009; release 68
-
Minor bug fix with configuration handling of
omit-inline-disposition-header.
Added new configuration option save-on-send.
A range of major and minor changes to the sending interface.
Added the sd configuration option that allows keys or emails to be
associated with particularly sending options.
When secret keys aren't available, still try to add a suitable key for
self for encryption.
MIME viewer setting has been replaced by two: one for decrypt and one
for verify.
Bad lines in the configuration file now result in a warning, not an exception.
Internal modifications to configuration handling.
- 21/7/2009; release 69
-
No longer calling an external app for line-end conversions.
Added a note re: Alpine's S/MIME message about certificates.
Show the list of recipients just before sending (from the to/cc/bcc
lists; not lcc, as Alpine doesn't pass those to in the _RECIPIENTS_
token). The idea is to allow the user to spot the “oh no, I didn't
intend to email that person” problem.
- 22/9/2009; release 70
-
Added use-agent configuration option. This has three values:
(1) never use an agent, (2) only use it for decryption, (3) always use
it. Don't put GPG's --[no-]use-agent options in any other
configuration options or it might be confusing.
Adding attachments when using a non-MIME mode forces a change to a
suitable mode (where possible).
Presentation changes for recipient list check.
Fixed a minor typo in a user message.
- 25/2/2010; release 71
-
Added more MICALGs from RFC4880.
Handle missing Content-Type headers in multipart messages.
Reorganise menus: hopefully, they're easier to read now.
Add some colourisation (this can be disabled by
setting ansi-terminal to off).
Assorted tidying.
Warn if sending defaults to encryption, but some keys are missing.
Add -pd - pipe-display mode. Takes stdin and treats it as a MIME
email for display/verification.
Release code is now taken from the README.html file rather
than a separate release file.
Slight clean-up of this README.
- 25/2/2010; release 72
-
Fix menus for non-Pine sending. (‘Go’ wasn't working!)
Trap attempts to encrypt when no keys are in the key list.
Minor change to distrib text and Makefile.
Distrib target in Makefile now uses GPG agent.
- 29/4/2011; release 73
-
Fix crash when sending attachments with spaces in filenames.
Add new switch, wait-if-missing-keys, which requires the user
to acknowledge if keys are missing when defaulting to encryption.
Slightly reorganise configuration menu to keep it within 24 lines.
Update documentation re: crashes related to the second patch and
mailcap files.
Topal makes greater efforts to check that external commands exist
before running them.
Exception messages are repeated via Ada's exception handling (if Topal
panics).
Added decrypt-prereq option. See this note.
Experimental S/MIME sending support added.
More use of GnuPG's --status-fd option so that we can determine exit
status properly.
Replaced ancient expanding_array package
with Ada.Containers.Vectors.
Adding sendmail-path filter mode. This is needed for the S/MIME
encrypted and S/MIME sign+encrypted modes. (Otherwise only Topal can
read them; neither Outlook nor Thunderbird will cope with an S/MIME
part inside multipart/mixed.) This mode also
needs pinentry-qt
for gpgsm: pinentry-curses doesn't like this environment.
In the sendmail-path filter mode, we no longer need the content-type
guessing. We can simply re-use the content-type from the original
header.
Added replace-ids option which can replace Message-ID (and also
Content-ID) in sendmail-path filter mode.
The sendmail-path mode can also add a token to help spot our cc'd
emails. Use something like st=user@domain,token to set a
password. This is hashed with some headers for each email and added
to an X-Topal-Send-Token header. Topal then has a -cst
token mode which adds a X-Topal-Check-Send-Token
header with either yes or no for that header.
Investigation suggests that group addresses are handled other than I
expect. E.g., Group name:; in the to: field and the actual
list of addresses in lcc field will result in the addresses appearing
in the bcc field in sendmail-path filter mode.
Rewrite main documentation in LaTeX: the main manual is
now topal.pdf. The
change log is still in HTML.
Start adding interoperability notes to manual.
Diagnosing issue with clearsigned (both OpenPGP and S/MIME) emails
that have passed through an MS Exchange server being corrupted.
Added opaque signing option for S/MIME.
Added attachment-trap boolean option. In -asend
mode, this causes Topal to complain if the message body contains the
string “attach” but doesn't have any attachments.
- 23/6/2011; release 74
-
Oops, wrong year in release 73 date….
Topal needs GNAT's -gnat05 switch.
Documentation update:
- Noted the need for GNU's sed (particularly
important if you're using
Mac OS X).
- Noted that gpg-agent needs HUPing
if trustlist.txt is updated.
Added include-send-token switch, where 1 never includes them,
2 asks and 3 always includes them.
Warnings about configuration errors now go to stderr, rather than
messing up other processing output.
Heuristic for attachment trap is improved. This now copes with the
case where the email comprises a single multipart/mixed MIME part.
Some comparisons for content-types are case-insensitive now.
- 26/2/2012; release 75
-
Most changes this time are to cope with non-cryptographic meddling for
my work environment.
Fix Clean_Email_Address to cope with mailboxes with double quotes and
commas.
Added fix-fcc option that modifies a X-Topal-Fcc header. It
is encrypted using the send-token for that sender to X-Topal-Fcce.
The --check-send-token filter will also reverse this.
Added fix-bcc option that adds a X-Topal-Bcce header. It's
handled similarly to X-Topal-Fcce, but records the Bcc contents.
The --check-send-token filter will also reverse this.
Fix token hashing so that it copes with different outputs
from openssl sha1.
- 22/2/2015; release 76
-
- Add -raw command, that can be used by piping a raw
message (with free output) from Alpine. Also usable on an mbox from
the command-line.
Multiple documentation updates, including deprecation of the two
patches to Alpine, contact email address and copyright dates.
- 20/9/2015; release 77
-
Fix bad HTML formatting in this file.
Bug fix for clearsigning MIME files that don't have a MIME prologue.
Typo fixes from Nicolas Boulenguez to MIME-tool README, man page and
mime.c. Thank you!
- 22/7/2018; release 78
-
Replace some ancient use of DES3 with AES128CBC.
Move from SHA1 to SHA256.
Packaging improvements (remove unnecessary binaries and change
detached signature name).
Improvements to Makefile for downstream distributors.
Some of these changes are based on suggestions from Nicolas
Boulenguez (particularly around the Makefile). Thank you again!
- 22/2/2019; release 79
-
Correct last changelog to show that we really did move from SHA1 to
SHA256, not the other way!
Refactor key handling so that key selection works better. (If this
breaks your setup, please let me know which GPG version you're using.)
Improved de-duplication.
Change debug handling so that debug data goes to a file rather than
messing up terminals.
- 22/2/2019; release 80
-
Fix broken build of mime-tool.
See the documentation in topal.pdf
for further details.
topal-80/mkversionidtex 0000755 0001750 0001750 00000001365 13434071426 013544 0 ustar pjb pjb #!/bin/sh
# Topal: GPG/GnuPG and Alpine/Pine integration
# Copyright (C) 2001--2018 Phillip J. Brooke
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
cat > versionid.tex <