/usr/share/ada/adainclude/aws/aws-resources.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 | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2002-2014, 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.Calendar;
with Ada.Streams;
with Ada.Unchecked_Deallocation;
with AWS.Utils;
package AWS.Resources is
use Ada.Streams;
Resource_Error : exception;
type File_Type is limited private;
type File_Instance is (None, Plain, GZip, Both);
-- None : No instance of this file present.
-- Plain : A non-compressed version of this file exists.
-- GZip : A gzip encoded version of this file exists.
-- Both : Both versions of this file exists.
function "or" (I1, I2 : File_Instance) return File_Instance;
-- Returns the union of I1 and I2
subtype Content_Length_Type is Stream_Element_Offset;
Undefined_Length : constant Content_Length_Type;
-- Undefined length could be used when we do not know the message stream
-- length at the start of transfer. The end of message could be determined
-- by the chunked transfer-encoding in the HTTP/1.1, or by the closing
-- connection in the HTTP/1.0.
procedure Open
(File : out File_Type;
Name : String;
Form : String := "");
-- Open file in mode In_File. Only reading from the file is supported.
-- This procedure open the in-memory (embedded) file if present, otherwise
-- the file on disk is opened. Note that if Name file is not found, it
-- checks for Name & ".gz" and unzipped the file content in this case.
procedure Open
(File : out File_Type;
Name : String;
Form : String := "";
GZip : in out Boolean);
-- Open file in mode In_File. Only reading from the file is supported.
-- This procedure open the in-memory (embedded) file if present, otherwise
-- the file on disk is opened. If GZip parameter is False this call is
-- equivalent to the Open routine above. If GZip is True this routine will
-- first check for the compressed version of the resource (Name & ".gz"),
-- if found GZip output value will remain True. If GZip value is True and
-- the compressed version of the resource does not exist it looks for
-- non-compressed version and set GZip value to False.
procedure Reset (Resource : in out File_Type);
-- Reset the file, reading will restart at the beginning
procedure Set_Index
(Resource : in out File_Type;
To : Stream_Element_Offset);
-- Set the position in the stream, next Read will start at the position
-- whose index is To. If To is outside the content the index is set to
-- Last + 1 to ensure that next End_Of_File will return True.
procedure Close (Resource : in out File_Type);
-- Close the file
procedure Read
(Resource : in out File_Type;
Buffer : out Stream_Element_Array;
Last : out Stream_Element_Offset);
-- Returns a set of bytes from the file
procedure Get_Line
(Resource : in out File_Type;
Buffer : out String;
Last : out Natural);
-- Returns a line from the file. A line is a set of character terminated
-- by ASCII.LF (UNIX style EOL) or ASCII.CR+ASCII.LF (DOS style EOL).
function End_Of_File (Resource : File_Type) return Boolean;
-- Returns true if there is no more data to read
function LF_Terminated (Resource : File_Type) return Boolean;
-- Returns True if last line returned by Get_Line was terminated with a LF
-- or CR+LF on DOS based systems.
function Size (Resource : File_Type) return Content_Length_Type;
-- Returns the size (in bytes) of the resource. If the size of the
-- resource is not defined, the routine Size returns Undefined_Length
-- value.
function Exist (Name : String) return File_Instance;
-- Return GZip if only file Name & ".gz" exists.
-- Return Plain if only file Name exists.
-- Return Both if both file Name and Name & ".gz" exists.
-- Return None if files neither Name nor Name & ".gz" exist.
function Is_Regular_File (Name : String) return Boolean;
-- Returns True if Filename is a regular file and is readable. Checks
-- first for in memory file then for disk file.
function File_Size (Name : String) return Utils.File_Size_Type;
-- Returns Filename's size in bytes. Checks first for in memory file
-- then for disk file.
function File_Timestamp (Name : String) return Ada.Calendar.Time;
-- Get the time for last modification to a file in UTC/GMT. Checks first
-- for in memory file then for disk file.
private
Undefined_Length : constant Content_Length_Type := -1;
GZip_Ext : constant String := ".gz";
type File_Tagged is abstract tagged limited record
LFT : Boolean; -- LF terminated state
end record;
-- Abstract file, operations below must be implemented. The goal here is
-- to abstract the file location. Currently there is two implementations,
-- one for files on a hard disk and files in memory (array of bytes).
type File_Type is access all File_Tagged'Class;
function Is_GZip (Name : String) return Boolean;
-- Return true if filename is with .gz extension
function End_Of_File (Resource : File_Tagged) return Boolean is abstract;
procedure Read
(Resource : in out File_Tagged;
Buffer : out Stream_Element_Array;
Last : out Stream_Element_Offset) is abstract;
function Size
(Resource : File_Tagged) return Stream_Element_Offset is abstract;
procedure Close (File : in out File_Tagged) is abstract;
procedure Reset (File : in out File_Tagged) is abstract;
procedure Set_Index
(File : in out File_Tagged;
To : Stream_Element_Offset) is abstract;
procedure Unchecked_Free is
new Ada.Unchecked_Deallocation (Resources.File_Tagged'Class, File_Type);
end AWS.Resources;
|