This file is indexed.

/usr/share/ada/adainclude/aws/aws-smtp.adb is in libaws3.2.0-dev 3.2.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
------------------------------------------------------------------------------
--                              Ada Web Server                              --
--                                                                          --
--                     Copyright (C) 2000-2013, AdaCore                     --
--                                                                          --
--  This library is free software;  you can redistribute it and/or modify   --
--  it under terms of the  GNU General Public License  as published by the  --
--  Free Software  Foundation;  either version 3,  or (at your  option) any --
--  later version. This library 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.                    --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--  You should have received a copy of the GNU General Public License and   --
--  a copy of the GCC Runtime Library Exception along with this program;    --
--  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see   --
--  <http://www.gnu.org/licenses/>.                                         --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
------------------------------------------------------------------------------

with Ada.Strings.Fixed;

with AWS.Net.Buffered;

package body AWS.SMTP is

   use Ada;

   C_211 : aliased constant String := "System status";
   C_214 : aliased constant String := "Help message";
   C_220 : aliased constant String := "AdaSC Service ready";
   C_221 : aliased constant String := "Service closing transmission channel";
   C_235 : aliased constant String := "Authentication successful";
   C_250 : aliased constant String := "Requested mail action okay, completed";
   C_251 : aliased constant String := "User not local; will forward";
   C_334 : aliased constant String := "Provide BASE64 watchword";
   C_354 : aliased constant String :=
             "Start mail input; end with <CRLF>.<CRLF>";
   C_421 : aliased constant String :=
             "Service not available, closing transmission channel";
   C_450 : aliased constant String :=
             "Requested mail action not taken: mailbox unavailable";
   C_451 : aliased constant String :=
             "Requested action aborted: local error in processing";
   C_452 : aliased constant String :=
             "Requested action not taken: insufficient system storage";
   C_500 : aliased constant String := "Syntax error, command unrecognized";
   C_501 : aliased constant String :=
             "Syntax error in parameters or arguments";
   C_502 : aliased constant String := "Command not implemented";
   C_503 : aliased constant String := "Bad sequence of commands";
   C_504 : aliased constant String := "Command parameter not implemented";
   C_550 : aliased constant String :=
             "Requested action not taken: mailbox unavailable";
   C_551 : aliased constant String :=
             "User not local; please try <forward-path>";
   C_552 : aliased constant String :=
             "Requested mail action aborted: exceeded storage allocation";
   C_553 : aliased constant String :=
             "Requested action not taken: mailbox name not allowed";
   C_554 : aliased constant String := "Transaction failed";

   type Reply_Code_Data is record
      Code : Reply_Code;
      Name : access constant String;
   end record;

   Code_Table : constant array (Positive range <>) of Reply_Code_Data :=
     ((211, C_211'Access), (214, C_214'Access), (220, C_220'Access),
      (221, C_221'Access), (235, C_235'Access), (334, C_334'Access),
      (250, C_250'Access), (251, C_251'Access), (354, C_354'Access),
      (421, C_421'Access), (450, C_450'Access), (451, C_451'Access),
      (452, C_452'Access), (500, C_500'Access), (501, C_501'Access),
      (502, C_502'Access), (503, C_503'Access), (504, C_504'Access),
      (550, C_550'Access), (551, C_551'Access), (552, C_552'Access),
      (553, C_553'Access), (554, C_554'Access));

   ---------
   -- Add --
   ---------

   procedure Add (Answer : in out Server_Reply; Status : in out SMTP.Status) is
   begin
      if Status.Reason /= Null_Unbounded_String then
         Append (Status.Reason, ASCII.LF);
      end if;

      Append (Status.Reason, Image (Answer));

      Status.Code := Answer.Code;
   end Add;

   ------------------
   -- Check_Answer --
   ------------------

   procedure Check_Answer
     (Sock  : Net.Socket_Type'Class;
      Reply : out Server_Reply)
   is
      Buffer : constant String := Net.Buffered.Get_Line (Sock);
   begin
      Reply :=
        (Reply_Code'Value (Buffer (Buffer'First .. Buffer'First + 2)),
         To_Unbounded_String (Buffer (Buffer'First + 4 .. Buffer'Last)));
   end Check_Answer;

   -----------
   -- Clear --
   -----------

   procedure Clear (Status : in out SMTP.Status) is
   begin
      Status := (Requested_Action_Ok, Null_Unbounded_String);
   end Clear;

   ------------
   -- E_Mail --
   ------------

   function E_Mail (Name : String; Address : String)
     return E_Mail_Data is
   begin
      return (To_Unbounded_String (Name), To_Unbounded_String (Address));
   end E_Mail;

   -----------
   -- Image --
   -----------

   function Image (R : Reply_Code) return String is
      RI : constant String := Reply_Code'Image (R);
   begin
      for K in Code_Table'Range loop
         if Code_Table (K).Code = R then
            return RI (RI'First + 1 .. RI'Last);
         end if;
      end loop;

      raise Reply_Code_Error;
   end Image;

   function Image
     (E_Mail : E_Mail_Data;
      Mode   : Address_Mode := Full) return String is
   begin
      case Mode is
         when Full =>
            return To_String (E_Mail.Name)
              & " <" & To_String (E_Mail.Address) & '>';
         when Name =>
            return To_String (E_Mail.Name);
         when Address =>
            return To_String (E_Mail.Address);
      end case;
   end Image;

   function Image (Answer : Server_Reply) return String is
      Code_Image : constant String := Reply_Code'Image (Answer.Code);
   begin
      return Code_Image (Code_Image'First + 1 .. Code_Image'Last)
        & ' ' & To_String (Answer.Reason);
   end Image;

   ----------------
   -- Initialize --
   ----------------

   function Initialize
     (Server_Name : String;
      Port        : Positive := Default_SMTP_Port;
      Secure      : Boolean  := False;
      Family      : Net.Family_Type := Net.Family_Unspec;
      Credential  : access constant Authentication.Credential'Class := null)
      return Receiver is
   begin
      return (Family, To_Unbounded_String (Server_Name), Port, Secure, null,
              Credential);
   end Initialize;

   -----------
   -- Is_Ok --
   -----------

   function Is_Ok (Status : SMTP.Status) return Boolean is
   begin
      return Status.Reason = Null_Unbounded_String;
   end Is_Ok;

   -------------
   -- Message --
   -------------

   function Message (R : Reply_Code) return String is
   begin
      return Image (R) & ' ' & Name (R);
   end Message;

   ----------
   -- Name --
   ----------

   function Name (R : Reply_Code) return String is
   begin
      for K in Code_Table'Range loop
         if Code_Table (K).Code = R then
            return Code_Table (K).Name.all;
         end if;
      end loop;

      raise Reply_Code_Error;
   end Name;

   -----------
   -- Parse --
   -----------

   function Parse (E_Mail : String) return E_Mail_Data is
      use Strings.Fixed;

      I1, I2 : Natural;
   begin
      I1 := Index (E_Mail, "<");
      I2 := Index (E_Mail, ">");

      if I1 = 0 or else I2 = 0 or else I1 > I2 then
         I1 := Index (E_Mail, "(");
         I2 := Index (E_Mail, ")");

         if I1 = 0 or else I2 = 0 or else I1 > I2 then
            raise Constraint_Error;
         else
            --  Syntax: e-mail (Name)
            return SMTP.E_Mail
              (Address => Trim (E_Mail (E_Mail'First .. I1 - 1), Strings.Both),
               Name    => Trim (E_Mail (I1 + 1 .. I2 - 1), Strings.Both));
         end if;

      else
         --  Syntax: Name <e-mail>
         return SMTP.E_Mail
           (Name    => Trim (E_Mail (E_Mail'First .. I1 - 1), Strings.Both),
            Address => Trim (E_Mail (I1 + 1 .. I2 - 1), Strings.Both));
      end if;
   end Parse;

   -----------------
   -- Status_Code --
   -----------------

   function Status_Code (Status : SMTP.Status) return Reply_Code is
   begin
      return Status.Code;
   end Status_Code;

   --------------------
   -- Status_Message --
   --------------------

   function Status_Message (Status : SMTP.Status) return String is
   begin
      return To_String (Status.Reason);
   end Status_Message;

end AWS.SMTP;