annotate gcc/ada/libgnat/g-cgicoo.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- G N A T . C G I . C O O K I E --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2000-2018, AdaCore --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This is a package to interface a GNAT program with a Web server via the
kono
parents:
diff changeset
33 -- Common Gateway Interface (CGI). It exports services to deal with Web
kono
parents:
diff changeset
34 -- cookies (piece of information kept in the Web client software).
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 -- The complete CGI Cookie specification can be found in the RFC2109 at:
kono
parents:
diff changeset
37 -- http://www.ics.uci.edu/pub/ietf/http/rfc2109.txt
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 -- This package builds up data tables whose memory is not released. A CGI
kono
parents:
diff changeset
40 -- program is expected to be a short lived program and so it is adequate to
kono
parents:
diff changeset
41 -- have the underlying OS free the program on exit.
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 package GNAT.CGI.Cookie is
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 -- The package will initialize itself by parsing the HTTP_Cookie runtime
kono
parents:
diff changeset
46 -- CGI environment variable during elaboration but we do not want to raise
kono
parents:
diff changeset
47 -- an exception at this time, so the exception Data_Error is deferred and
kono
parents:
diff changeset
48 -- will be raised when calling any services below (except for Ok).
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 Cookie_Not_Found : exception;
kono
parents:
diff changeset
51 -- This exception is raised when a specific parameter is not found
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 procedure Put_Header
kono
parents:
diff changeset
54 (Header : String := Default_Header;
kono
parents:
diff changeset
55 Force : Boolean := False);
kono
parents:
diff changeset
56 -- Output standard CGI header by default. This header must be returned
kono
parents:
diff changeset
57 -- back to the server at the very beginning and will be output only for
kono
parents:
diff changeset
58 -- the first call to Put_Header if Force is set to False. This procedure
kono
parents:
diff changeset
59 -- also outputs the Cookies that have been defined. If the program uses
kono
parents:
diff changeset
60 -- the GNAT.CGI.Put_Header service, cookies will not be set.
kono
parents:
diff changeset
61 --
kono
parents:
diff changeset
62 -- Cookies are passed back to the server in the header, the format is:
kono
parents:
diff changeset
63 --
kono
parents:
diff changeset
64 -- Set-Cookie: <key>=<value>; comment=<comment>; domain=<domain>;
kono
parents:
diff changeset
65 -- max_age=<max_age>; path=<path>[; secured]
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 function Ok return Boolean;
kono
parents:
diff changeset
68 -- Returns True if the CGI cookie environment is valid and False otherwise.
kono
parents:
diff changeset
69 -- Every service used when the CGI environment is not valid will raise the
kono
parents:
diff changeset
70 -- exception Data_Error.
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 function Count return Natural;
kono
parents:
diff changeset
73 -- Returns the number of cookies received by the CGI
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 function Value
kono
parents:
diff changeset
76 (Key : String;
kono
parents:
diff changeset
77 Required : Boolean := False) return String;
kono
parents:
diff changeset
78 -- Returns the cookie value associated with the cookie named Key. If cookie
kono
parents:
diff changeset
79 -- does not exist, returns an empty string if Required is False and raises
kono
parents:
diff changeset
80 -- the exception Cookie_Not_Found otherwise.
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 function Value (Position : Positive) return String;
kono
parents:
diff changeset
83 -- Returns the value associated with the cookie number Position of the CGI.
kono
parents:
diff changeset
84 -- It raises Cookie_Not_Found if there is no such cookie (i.e. Position >
kono
parents:
diff changeset
85 -- Count)
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 function Exists (Key : String) return Boolean;
kono
parents:
diff changeset
88 -- Returns True if the cookie named Key exist and False otherwise
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 function Key (Position : Positive) return String;
kono
parents:
diff changeset
91 -- Returns the key associated with the cookie number Position of the CGI.
kono
parents:
diff changeset
92 -- It raises Cookie_Not_Found if there is no such cookie (i.e. Position >
kono
parents:
diff changeset
93 -- Count)
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 procedure Set
kono
parents:
diff changeset
96 (Key : String;
kono
parents:
diff changeset
97 Value : String;
kono
parents:
diff changeset
98 Comment : String := "";
kono
parents:
diff changeset
99 Domain : String := "";
kono
parents:
diff changeset
100 Max_Age : Natural := Natural'Last;
kono
parents:
diff changeset
101 Path : String := "/";
kono
parents:
diff changeset
102 Secure : Boolean := False);
kono
parents:
diff changeset
103 -- Add a cookie to the list of cookies. This will be sent back to the
kono
parents:
diff changeset
104 -- server by the Put_Header service above.
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 generic
kono
parents:
diff changeset
107 with procedure
kono
parents:
diff changeset
108 Action
kono
parents:
diff changeset
109 (Key : String;
kono
parents:
diff changeset
110 Value : String;
kono
parents:
diff changeset
111 Position : Positive;
kono
parents:
diff changeset
112 Quit : in out Boolean);
kono
parents:
diff changeset
113 procedure For_Every_Cookie;
kono
parents:
diff changeset
114 -- Iterate through all cookies received from the server and call
kono
parents:
diff changeset
115 -- the Action supplied procedure. The Key, Value parameters are set
kono
parents:
diff changeset
116 -- appropriately, Position is the cookie order in the list, Quit is set to
kono
parents:
diff changeset
117 -- True by default. Quit can be set to False to control the iterator
kono
parents:
diff changeset
118 -- termination.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 end GNAT.CGI.Cookie;