Skip to content

Commit ad2cb26

Browse files
committed
Merge branch 'po/disable-prog-ini'
* po/disable-prog-ini: Do not part program specific ini file if asked. New configuration option Disable_Program_Ini.
2 parents fd9b020 + a2bc94d commit ad2cb26

File tree

10 files changed

+142
-6
lines changed

10 files changed

+142
-6
lines changed

docs/build.adb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2000-2018, AdaCore --
4+
-- Copyright (C) 2000-2020, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it --
77
-- under terms of the GNU General Public License as published by the --
@@ -144,6 +144,7 @@ begin
144144
Add ("SESSION_ID_LENGTH", Default.Session_Id_Length);
145145
Add ("TLS_TICKET_SUPPORT", Default.TLS_Ticket_Support);
146146
Add ("CONFIG_DIRECTORY", Default.Config_Directory);
147+
Add ("DISABLE_PROGRAM_INI", Default.Disable_Program_Ini);
147148
Add ("USER_AGENT", Default.User_Agent);
148149
Add ("SERVER_HEADER", Default.Server_Header);
149150
Text_IO.Put_Line ("""""""");

docs/source/using_aws.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,17 @@ Current supported options are:
862862
Specify the filename for the directory browser template page. The
863863
default value is |DIRECTORY_BROWSER_PAGE|.
864864

865+
*Disable_Program_Ini (boolean)*
866+
867+
.. index:: Disable_Program_Ini
868+
869+
Specify whether the configuration file :file:`program_name.ini` should be
870+
parsed or not. If this option is set to FALSE the program specific
871+
configuration file won't be parsed. This may be useful if another
872+
application is using such a file and cannot be shared. This setting
873+
is expected to be set in :file:`aws.ini` before the :file:`program_name.ini`
874+
file is parsed. The default value is |DISABLE_PROGRAM_INI|.
875+
865876
*Down_Image (string)*
866877

867878
.. index:: Down_Image
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2020, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
with Ada.Text_IO;
20+
21+
with AWS.Config;
22+
with AWS.Utils;
23+
24+
procedure Prog_Config is
25+
26+
use Ada;
27+
use AWS;
28+
29+
Conf : constant Config.Object := Config.Get_Current;
30+
-- Config as read from the ini files
31+
32+
-------------
33+
-- Display --
34+
-------------
35+
36+
procedure Display (O : Config.Object) is
37+
begin
38+
Text_IO.Put_Line
39+
("Disable Program Ini : "
40+
& Boolean'Image (Config.Disable_Program_Ini));
41+
Text_IO.Put_Line (Config.Server_Name (O));
42+
Text_IO.Put_Line (Config.WWW_Root (O));
43+
Text_IO.Put_Line (Utils.Image (Config.Server_Port (O)));
44+
Text_IO.Put_Line (Utils.Image (Config.Max_Connection (O)));
45+
Text_IO.Put_Line (Config.Directory_Browser_Page (O));
46+
Text_IO.New_Line;
47+
end Display;
48+
49+
begin
50+
Display (Conf);
51+
end Prog_Config;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2020, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
with "aws";
20+
21+
project Prog_Config is
22+
for Source_Dirs use (".");
23+
for Main use ("prog_config.adb");
24+
end Prog_Config;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
directory_browser_page prog_config.ini-directory_browser_page
2+
max_connection 10

regtests/0327_prog_config/test.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Disable Program Ini : FALSE
2+
AWS Module
3+
./
4+
8080
5+
10
6+
prog_config.ini-directory_browser_page
7+
8+
Disable Program Ini : TRUE
9+
AWS Module
10+
./
11+
8080
12+
5
13+
aws.ini-directory_browser_page

regtests/0327_prog_config/test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from test_support import *
2+
3+
with open('aws.ini', 'w') as ini_file:
4+
ini_file.write("status_page aws.ini-status_page\n")
5+
ini_file.write("directory_browser_page aws.ini-directory_browser_page\n")
6+
7+
build_and_run('prog_config')
8+
9+
with open('aws.ini', 'w') as ini_file:
10+
ini_file.write("status_page aws.ini-status_page\n")
11+
ini_file.write("directory_browser_page aws.ini-directory_browser_page\n")
12+
ini_file.write("disable_program_ini true\n")
13+
14+
run('prog_config')

src/core/aws-config.adb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2000-2019, AdaCore --
4+
-- Copyright (C) 2000-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -237,6 +237,15 @@ package body AWS.Config is
237237
return To_String (O.P (Directory_Browser_Page).Str_Value);
238238
end Directory_Browser_Page;
239239

240+
-------------------------
241+
-- Disable_Program_Ini --
242+
-------------------------
243+
244+
function Disable_Program_Ini return Boolean is
245+
begin
246+
return Process_Options (Disable_Program_Ini).Bool_Value;
247+
end Disable_Program_Ini;
248+
240249
----------------
241250
-- Down_Image --
242251
----------------
@@ -430,8 +439,11 @@ package body AWS.Config is
430439
Read_If_Present
431440
(Config_Directory & OS_Lib.Directory_Separator & "aws.ini");
432441
Read_If_Present ("aws.ini");
433-
Read_If_Present (Ini.Program_Ini_File (Full_Path => True));
434-
Read_If_Present (Ini.Program_Ini_File (Full_Path => False));
442+
443+
if not Disable_Program_Ini then
444+
Read_If_Present (Ini.Program_Ini_File (Full_Path => True));
445+
Read_If_Present (Ini.Program_Ini_File (Full_Path => False));
446+
end if;
435447
end Load_Config;
436448

437449
-------------------

src/core/aws-config.ads

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2000-2019, AdaCore --
4+
-- Copyright (C) 2000-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -382,6 +382,9 @@ package AWS.Config is
382382
function Config_Directory return String with Inline;
383383
-- Directory where AWS parameter files are located
384384

385+
function Disable_Program_Ini return Boolean with Inline;
386+
-- Whether the <program_name>.ini file should be read
387+
385388
function Transient_Cleanup_Interval return Duration with Inline;
386389
-- Number of seconds between each run of the cleaner task to remove
387390
-- transient pages.
@@ -520,6 +523,7 @@ private
520523
Session_Cleaner_Priority,
521524
Service_Priority,
522525
Config_Directory,
526+
Disable_Program_Ini,
523527
User_Agent,
524528
Transient_Cleanup_Interval,
525529
Transient_Lifetime,
@@ -796,6 +800,9 @@ private
796800
Config_Directory =>
797801
(Str, +Default.Config_Directory),
798802

803+
Disable_Program_Ini =>
804+
(Bool, Default.Disable_Program_Ini),
805+
799806
User_Agent =>
800807
(Str, +Default.User_Agent),
801808

src/core/aws-default.ads

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2000-2019, AdaCore --
4+
-- Copyright (C) 2000-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -157,6 +157,7 @@ package AWS.Default with Pure is
157157
Security : constant Boolean := False;
158158
Security_Mode : constant String := "TLS";
159159
Config_Directory : constant String := ".config/ada-web-srv";
160+
Disable_Program_Ini : constant Boolean := False;
160161
Cipher_Priorities : constant String := "";
161162
TLS_Ticket_Support : constant Boolean := False;
162163
Certificate : constant String := "cert.pem";

0 commit comments

Comments
 (0)