-- --
-- B o d y --
-- --
--- --
--- Copyright (C) 2000-2001 Ada Core Technologies, Inc.
+-- Copyright (C) 2000-2005, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- 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 distributed with GNAT; see file COPYING. If not, write --
--- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
--- MA 02111-1307, USA. --
+-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
+-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
--- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). --
+-- GNAT was originally developed by the GNAT team at New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
use Ada;
Valid_Environment : Boolean := False;
- -- This boolean will be set to True if the initialization was fine.
+ -- This boolean will be set to True if the initialization was fine
Header_Sent : Boolean := False;
- -- Will be set to True when the header will be sent.
+ -- Will be set to True when the header will be sent
- -- Cookie data that have been added.
+ -- Cookie data that has been added
type String_Access is access String;
end record;
package Cookie_Table is new Table (Cookie_Data, Positive, 1, 5, 50);
- -- This is the table to keep all cookies to be sent back to the server.
+ -- This is the table to keep all cookies to be sent back to the server
package Key_Value_Table is new Table (Key_Value, Positive, 1, 1, 50);
- -- This is the table to keep all cookies received from the server.
+ -- This is the table to keep all cookies received from the server
procedure Check_Environment;
pragma Inline (Check_Environment);
- -- This procedure will raise Data_Error if Valid_Environment is False.
+ -- This procedure will raise Data_Error if Valid_Environment is False
procedure Initialize;
-- Initialize CGI package by reading the runtime environment. This
HTTP_COOKIE : constant String := Metavariable (CGI.HTTP_Cookie);
procedure Set_Parameter_Table (Data : String);
- -- Parse Data and insert information in Key_Value_Table.
+ -- Parse Data and insert information in Key_Value_Table
-------------------------
-- Set_Parameter_Table --
-- Add a single parameter into the table at index K. The parameter
-- format is "key=value".
- Count : constant Positive
- := 1 + Strings.Fixed.Count (Data, Strings.Maps.To_Set (";"));
+ Count : constant Positive :=
+ 1 + Strings.Fixed.Count (Data, Strings.Maps.To_Set (";"));
-- Count is the number of parameters in the string. Parameters are
-- separated by ampersand character.
end if;
end Add_Parameter;
+ -- Start of processing for Set_Parameter_Table
+
begin
Key_Value_Table.Set_Last (Count);
Index := Sep + 2;
end loop;
- -- add last parameter
+ -- Add last parameter
Add_Parameter (Count, Data (Index .. Data'Last));
end Set_Parameter_Table;
+ -- Start of processing for Initialize
+
begin
if HTTP_COOKIE /= "" then
Set_Parameter_Table (HTTP_COOKIE);
(Header : String := Default_Header;
Force : Boolean := False)
is
-
procedure Output_Cookies;
-- Iterate through the list of cookies to be sent to the server
-- and output them.
Max_Age : Natural;
Path : String;
Secure : Boolean);
- -- Output one cookie in the CGI header.
+ -- Output one cookie in the CGI header
-----------------------
-- Output_One_Cookie --
Domain : String := "";
Max_Age : Natural := Natural'Last;
Path : String := "/";
- Secure : Boolean := False) is
+ Secure : Boolean := False)
+ is
begin
Cookie_Table.Increment_Last;
function Value
(Key : String;
- Required : Boolean := False)
- return String
+ Required : Boolean := False) return String
is
begin
Check_Environment;