File: globals.ads

package info (click to toggle)
topal 75-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,272 kB
  • sloc: ada: 11,008; ansic: 783; sh: 217; makefile: 146
file content (192 lines) | stat: -rw-r--r-- 7,373 bytes parent folder | download | duplicates (3)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
-- Topal: GPG/GnuPG and Alpine/Pine integration
-- Copyright (C) 2001--2012  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 <http://www.gnu.org/licenses/>.

with Ada.Characters.Latin_1;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Ada.Text_IO;

package Globals is

   -- Initial number of keys to be associated.
   Initial_KL : constant Positive := 300;

   Not_Implemented : exception;

   -- Some renamings of unbounded strings.
   subtype UBS is Ada.Strings.Unbounded.Unbounded_String;

   NullUBS : UBS renames Ada.Strings.Unbounded.Null_Unbounded_String;

   function ToUBS(S : String) return UBS
     renames Ada.Strings.Unbounded.To_Unbounded_String;

   function ToStr(U : UBS) return String
     renames Ada.Strings.Unbounded.To_String;

   -- We will want to play with arrays of UBS.
   type UBS_Array is array (Integer range <>) of UBS;

   -- Pointers to UBS arrays.
   type UBS_Array_Pointer is access UBS_Array;

   -- We also want expanding arrays....
   package UVP
   is new Ada.Containers.Vectors (Index_Type => Positive,
                                  Element_Type => UBS,
                                  "=" => Ada.Strings.Unbounded."=");
   subtype UVV is UVP.Vector;

   -- We also want key-value pairs of UBS.
   type UP is record
      Key, Value : UBS;
   end record;
   package UPP
   is new Ada.Containers.Vectors (Index_Type => Positive,
				  Element_Type => UP);
   subtype UPV is UPP.Vector;

   -- Want to insert line feeds in some strings.
   NL : constant String    := Ada.Characters.Latin_1.LF & "";

   -- Some terminal twiddling.
   ANSI_CSI : constant String := Ada.Characters.Latin_1.ESC & "[";
   ANSI_SGR : constant String := "m";
   ANSI_SGR_Reset : constant String := ANSI_CSI & ANSI_SGR;

   -- The result file stuff.
   Result_File : Ada.Text_IO.File_Type;

   -- What is our process ID?  (Needed for tempfiles.)
   Our_PID : Integer;

   -- Our home directory.
   Topal_Directory : UBS;

   type Binaries is
     (Chmod, Clear, Cut, Date, Diff, File,
      Formail, GPGOP, GPGSM, Grep, Iconv, Less, Locale,
      Md5sum, Metamail, Mimeconstruct, Mimetool,
      Mkdir, Mkfifo, Mv, Openssl, Rm, Runmailcap,
      Scp, Sed, Ssh, Stty, Tee, Test);

   type Binaries_UBS is array (Binaries) of UBS;

   type UBS_Opts_Keys is (My_Key, General_Options, 
			  GPG_Options, GPGSM_Options,
                          Receiving_Options, Sending_Options,
                          Colour_Menu_Title, Colour_Menu_Key,
                          Colour_Menu_Choice, Colour_Important,
                          Colour_Banner, Colour_Info, Decrypt_Prereq);

   type Boolean_Opts_Keys is (Decrypt_Cached_Fast_Continue,
                              Verify_Cached_Fast_Continue,
                              Verify_Not_Cached_Fast_Continue,
                              FE_Simple,
                              Inline_Separate_Output,
                              Omit_Inline_Disposition_Name,
                              Omit_Inline_Disposition_Header,
                              Save_On_Send, -- If true, write to .topal/lastmail
                              ANSI_Terminal,
                              Wait_If_Missing_Keys,
			      Attachment_Trap,
			      Fix_Fcc,
			      Fix_Bcc,
                              Debug,
                              -- The following are not in the config file.
                              No_Clean, -- Not preserved in config file.
                              All_Headers, -- Not config file.
                              Read_From, -- Not config file.
                              Ask_Charset -- Not config file.
                             );
   subtype Boolean_Opts_Keys_Save is Boolean_Opts_Keys
     range Decrypt_Cached_Fast_Continue .. Debug;

   type Positive_Opts_Keys is (Decrypt_Not_Cached,
                               Decrypt_Not_Cached_Use_Cache,
                               Decrypt_Cached,
                               Decrypt_Cached_Use_Cache,
                               Verify_Not_Cached,
                               Verify_Not_Cached_Use_Cache,
                               Verify_Cached,
                               Verify_Cached_Use_Cache,
                               Mime_Viewer_Decrypt,
                               Mime_Viewer_Verify,
                               Use_Agent,
			       Replace_IDs,
			       Include_Send_Token);
   type UBS_Opts_Array is array (UBS_Opts_Keys) of UBS;

   type Boolean_Opts_Array is array (Boolean_Opts_Keys) of Boolean;

   type Positive_Opts_Array is array (Positive_Opts_Keys) of Positive;


   -- Configuration data types.
   type Config_Record is
      record
         Binary : Binaries_UBS;
         UBS_Opts : UBS_Opts_Array;
         Boolean_Opts : Boolean_Opts_Array;
         Positive_Opts : Positive_Opts_Array;
         --  decrypt-not-cached: 1 always, 2 ask, 3 never
         --  decrypt-not-cached-use-cache: 1 always, 2 ask, 3 never
         --  decrypt-cached: 1 always, 2 ask, 3 never
         --  decrypt-cached-use-cache: 1 use, 2 again-replace,
         --                            3 again-ask-replace,
         --                            4 again-never, 5 offer

         --  Ditto for verify-not-cached, verify-not-cached-use-cache,
         --  verify-cached, verify-cached-use-Cache

         -- MIME_Viewer: 1 ask, 2 use metamail, 3 use run-mailcap,
         --              4 save dummy message to ~/mail, 5 skip attachments
         -- There is one for _Decrypt and one of _Verify.

         -- Use_Agent: asks about using gpg-agent.
         -- 1 never, 2 only for decrypting (not signing!), 3 always
	 
	 -- Replace_IDs: only effective in sendmail-path mode.
	 -- 0 do nothing, 1 replace only Message-ID, 2 replace both Message-ID and Content-ID.
	 -- 1 & 2 use this pattern replacement:
	 --   <alpine.DEB.2.00.1103061044360.3250@catbert.scm.tees.ac.uk>
	 -- to
	 --   <1103061044360.3250%pjb@scm.tees.ac.uk>
	 -- where the address used is Alt_Sign (from the From line).
	 
	 -- Include_Send_Token: only effective in sendmail-path mode.
	 -- 1 never, 2 ask, 3 always. Defaults to 3, but you may find 2 more useful.

         -- A list of keys to be associated with email addresses.
	 -- Key: the crypto key; Value: the email.
	 AKE : UPV;
         -- A list of keys to be excluded from the key list.
         XK : UVV;
         -- And the same again, this time for the secret key lists.
         SAKE : UPV;
         -- A list of keys to be excluded from the key list.
         SXK : UVV;
         -- A list of keys and the default send mode.
         SD : UPV;
	 -- A list of email addresses (Key) and the sendmail command to use (value).
	 SC : UPV;
	 -- Sending tokens.  A list of email addresses (from) and the
	 --  token to use.  @ANY@ isn't valid.
	 ST : UPV;
      end record;

   Config : Config_Record;

end Globals;