matreshka_league_21.0.0_0c8f4d47/source/web/fastcgi/matreshka-fastcgi-protocol.ads

  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
------------------------------------------------------------------------------
--                                                                          --
--                            Matreshka Project                             --
--                                                                          --
--                               Web Framework                              --
--                                                                          --
--                        Runtime Library Component                         --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2013, Vadim Godunko <vgodunko@gmail.com>                     --
-- All rights reserved.                                                     --
--                                                                          --
-- Redistribution and use in source and binary forms, with or without       --
-- modification, are permitted provided that the following conditions       --
-- are met:                                                                 --
--                                                                          --
--  * Redistributions of source code must retain the above copyright        --
--    notice, this list of conditions and the following disclaimer.         --
--                                                                          --
--  * Redistributions in binary form must reproduce the above copyright     --
--    notice, this list of conditions and the following disclaimer in the   --
--    documentation and/or other materials provided with the distribution.  --
--                                                                          --
--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
--    contributors may be used to endorse or promote products derived from  --
--    this software without specific prior written permission.              --
--                                                                          --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 4257 $ $Date: 2013-11-13 13:07:34 +0400 (Ср, 13 ноя 2013) $
------------------------------------------------------------------------------
--  Definition of data structures of FastCGI protocol.
------------------------------------------------------------------------------
with Ada.Streams;

package Matreshka.FastCGI.Protocol is

   pragma Preelaborate;

   type FCGI_Version is mod 2 ** 8;

   Supported_FCGI_Version : constant FCGI_Version := 1;

   type FCGI_Packet_Type is mod 2 ** 8;

   FCGI_Begin_Request     : constant FCGI_Packet_Type := 1;
   FCGI_Abort_Request     : constant FCGI_Packet_Type := 2;
   FCGI_End_Request       : constant FCGI_Packet_Type := 3;
   FCGI_Params            : constant FCGI_Packet_Type := 4;
   FCGI_Stdin             : constant FCGI_Packet_Type := 5;
   FCGI_Stdout            : constant FCGI_Packet_Type := 6;
   FCGI_Stderr            : constant FCGI_Packet_Type := 7;
   FCGI_Data              : constant FCGI_Packet_Type := 8;
   FCGI_Get_Values        : constant FCGI_Packet_Type := 9;
   FCGI_Get_Values_Result : constant FCGI_Packet_Type := 10;
   FCGI_Unknown_Type      : constant FCGI_Packet_Type := 11;

   subtype FCGI_Content_Length is Ada.Streams.Stream_Element_Offset
     range 0 .. 65_535;

   subtype FCGI_Padding_Length is Ada.Streams.Stream_Element_Offset
     range 0 .. 65_535;

   type FCGI_Role is mod 2 ** 16;

   FCGI_Responder  : constant FCGI_Role := 1;
   FCGI_Authorizer : constant FCGI_Role := 2;
   FCGI_Filter     : constant FCGI_Role := 3;

   type FCGI_Flags is record
      FCGI_Keep_Conn : Boolean;
      Reserved_1     : Boolean;
      Reserved_2     : Boolean;
      Reserved_3     : Boolean;
      Reserved_4     : Boolean;
      Reserved_5     : Boolean;
      Reserved_6     : Boolean;
      Reserved_7     : Boolean;
   end record;
   pragma Pack (FCGI_Flags);
   for FCGI_Flags'Size use 8;

   -----------------
   -- FCGI_Header --
   -----------------

   type FCGI_Header is private;

   subtype Raw_FCGI_Header is Ada.Streams.Stream_Element_Array (0 .. 7);

   function Get_Version (Header : FCGI_Header) return FCGI_Version;
   pragma Inline (Get_Version);

   function Get_Packet_Type (Header : FCGI_Header) return FCGI_Packet_Type;
   pragma Inline (Get_Packet_Type);

   function Get_Request_Id
    (Header : FCGI_Header) return FCGI_Request_Identifier;
   pragma Inline (Get_Request_Id);

   function Get_Content_Length
    (Header : FCGI_Header) return FCGI_Content_Length;
   pragma Inline (Get_Content_Length);

   function Get_Padding_Length
    (Header : FCGI_Header) return FCGI_Padding_Length;
   pragma Inline (Get_Padding_Length);

   procedure Initialize
    (Header         : out FCGI_Header;
     Packet_Type    : FCGI_Packet_Type;
     Request_Id     : FCGI_Request_Identifier;
     Content_Length : FCGI_Content_Length;
     Padding_Length : FCGI_Padding_Length);

   -------------------------------
   -- FCGI_Begin_Request_Record --
   -------------------------------

   type FCGI_Begin_Request_Record is private;

   subtype Raw_FCGI_Begin_Request_Record
     is Ada.Streams.Stream_Element_Array (0 .. 7);

   function Get_Role (Item : FCGI_Begin_Request_Record) return FCGI_Role;
   pragma Inline (Get_Role);

   function Get_Flags (Item : FCGI_Begin_Request_Record) return FCGI_Flags;
   pragma Inline (Get_Flags);

private

   type FCGI_Header is record
      Version               : Ada.Streams.Stream_Element;
      Packet_Type           : Ada.Streams.Stream_Element;
      Request_Id_Byte_1     : Ada.Streams.Stream_Element;
      Request_Id_Byte_0     : Ada.Streams.Stream_Element;
      Content_Length_Byte_1 : Ada.Streams.Stream_Element;
      Content_Length_Byte_0 : Ada.Streams.Stream_Element;
      Padding_Length        : Ada.Streams.Stream_Element;
      Reserved              : Ada.Streams.Stream_Element;
   end record;

   type FCGI_Begin_Request_Record is record
      Role_Byte_1 : Ada.Streams.Stream_Element;
      Role_Byte_0 : Ada.Streams.Stream_Element;
      Flags       : Ada.Streams.Stream_Element;
      Reserved_1  : Ada.Streams.Stream_Element;
      Reserved_2  : Ada.Streams.Stream_Element;
      Reserved_3  : Ada.Streams.Stream_Element;
      Reserved_4  : Ada.Streams.Stream_Element;
      Reserved_5  : Ada.Streams.Stream_Element;
   end record;

end Matreshka.FastCGI.Protocol;