/usr/share/ada/adainclude/aws/aws-attachments.ads 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 | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2004-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/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
with Ada.Strings.Unbounded;
with AWS.Headers;
with AWS.MIME;
with AWS.Net;
private with Ada.Containers.Vectors;
package AWS.Attachments is
use Ada.Strings.Unbounded;
type Element is private;
type List is tagged private;
Empty_List : constant List;
type Content is private;
type Encoding is (None, Base64);
function File
(Filename : String;
Encode : Encoding := None;
Content_Id : String := "";
Content_Type : String := MIME.Text_Plain) return Content;
-- A filename as content, if Encode is set to Base64 the file content will
-- be base64 encoded.
function Value
(Data : String;
Name : String := "";
Encode : Encoding := None;
Content_Id : String := "";
Content_Type : String := MIME.Text_Plain) return Content;
-- A string as content
type Attachment_Kind is (Data, Alternative);
-- Data : for a standard MIME attachment
-- Alternative : for a set of alternative content
procedure Add
(Attachments : in out List;
Filename : String;
Content_Id : String;
Headers : AWS.Headers.List := AWS.Headers.Empty_List;
Name : String := "";
Encode : Encoding := None);
-- Adds an Attachment to the list.
-- Note that the encoding will overwrite the corresponding entry in
-- headers.
procedure Add
(Attachments : in out List;
Filename : String;
Headers : AWS.Headers.List;
Name : String := "";
Encode : Encoding := None);
-- Adds an Attachment to the list.
-- Note that the encoding will overwrite the corresponding entry in
-- headers.
procedure Add
(Attachments : in out List;
Name : String;
Data : Content;
Headers : AWS.Headers.List := AWS.Headers.Empty_List);
-- Adds an Attachment to the list.
-- Note that the encoding and content type attached to Data will
-- overwrite the corresponding entry in headers.
-- Alternatives content
type Alternatives is private;
procedure Add
(Parts : in out Alternatives;
Data : Content);
-- Add an alternative content
procedure Add
(Attachments : in out List;
Parts : Alternatives);
-- Add an alternative group to the current attachment list
procedure Reset
(Attachments : in out List;
Delete_Files : Boolean);
-- Reset the list to be empty. If Delete_Files is set to true the
-- attached files are removed from the file system.
function Count (Attachments : List) return Natural with Inline;
-- Returns the number of Attachments in the data
function Get
(Attachments : List;
Index : Positive) return Element;
-- Returns specified Attachment
function Get
(Attachments : List;
Content_Id : String) return Element;
-- Returns the Attachment with the Content Id
generic
with procedure Action
(Attachment : Element;
Index : Positive;
Quit : in out Boolean);
procedure For_Every_Attachment (Attachments : List);
-- Calls action for every Attachment in Message. Stop iterator if Quit is
-- set to True, Quit is set to False by default.
procedure Iterate
(Attachments : List;
Process : not null access procedure (Attachment : Element));
-- Calls Process for every Attachment in Message
function Headers (Attachment : Element) return AWS.Headers.List with Inline;
-- Returns the list of header lines for the attachment
function Content_Type (Attachment : Element) return String;
-- Get value for "Content-Type:" header
function Content_Id (Attachment : Element) return String;
-- Returns Attachment's content id
function Local_Filename (Attachment : Element) return String;
-- Returns the local filename of the Attachment.
-- Local filename is the name the receiver used when extracting the
-- Attachment into a file.
function Filename (Attachment : Element) return String;
-- Original filename on the server side. This is generally encoded on the
-- content-type or content-disposition header.
function Kind (Attachment : Element) return Attachment_Kind with Inline;
-- Returns the kind of the given attachment
function Length
(Attachments : List;
Boundary : String) return Natural;
-- Returns the complete size of all attachments including the surrounding
-- boundaries.
procedure Send_MIME_Header
(Socket : Net.Socket_Type'Class;
Attachments : List;
Boundary : out Unbounded_String;
Alternative : Boolean := False);
-- Output MIME header, returns the boundary for the content
procedure Send
(Socket : AWS.Net.Socket_Type'Class;
Attachments : List;
Boundary : String);
-- Send all Attachments, including the surrounding boundarys, in the list
-- to the socket.
type Root_MIME_Kind is (Multipart_Mixed, Multipart_Alternative);
function Root_MIME (Attachments : List) return Root_MIME_Kind;
-- Returns the root MIME kind for the given attachment list
private
use Ada;
type Content_Kind is (File, Data);
type Content (Kind : Content_Kind := File) is record
Length : Natural;
Content_Id : Unbounded_String;
Content_Type : Unbounded_String;
Filename : Unbounded_String;
Encode : Encoding;
case Kind is
when File =>
null;
when Data =>
Content : Unbounded_String;
end case;
end record;
package Alternative_Table is new Containers.Vectors (Positive, Content);
type Element (Kind : Attachment_Kind := Data) is record
Headers : AWS.Headers.List;
Total_Length : Natural;
case Kind is
when Data =>
Data : Content;
when Alternative =>
Parts : Alternative_Table.Vector;
end case;
end record;
type Alternatives is new Element (Kind => Alternative);
package Attachment_Table is new Ada.Containers.Vectors (Positive, Element);
type List is tagged record
Vector : Attachment_Table.Vector;
end record;
Empty_List : constant List := (Vector => Attachment_Table.Empty_Vector);
end AWS.Attachments;
|