1 ------------------------------------------------------------------------------
4 -- Copyright (C) 2007 --
7 -- This library is free software; you can redistribute it and/or modify --
8 -- it under the terms of the GNU General Public License as published by --
9 -- the Free Software Foundation; either version 2 of the License, or (at --
10 -- your option) any later version. --
12 -- This library is distributed in the hope that it will be useful, but --
13 -- WITHOUT ANY WARRANTY; without even the implied warranty of --
14 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
15 -- General Public License for more details. --
17 -- You should have received a copy of the GNU General Public License --
18 -- along with this library; if not, write to the Free Software Foundation, --
19 -- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --
20 ------------------------------------------------------------------------------
25 with Morzhol
.Iniparser
;
28 package body Gwiad
.Config
.Settings
is
32 Config_Filename
: constant String := "gwiad.ini";
34 type Attributes
is (Auth_Username
, Auth_Password
,
35 Web_Default_Directory
, Web_Default_Page
);
37 package Conf
is new Morzhol
.Iniparser
(Parameter_Name
=> Attributes
);
43 function Auth_Password
return String is
45 return Conf
.Get_Value
(Auth_Password
);
52 function Auth_Username
return String is
54 return Conf
.Get_Value
(Auth_Username
);
57 ---------------------------
58 -- Web_Default_Directory --
59 ---------------------------
61 function Web_Default_Directory
return String is
63 return Conf
.Get_Value
(Web_Default_Directory
);
64 end Web_Default_Directory
;
66 ----------------------
67 -- Web_Default_Page --
68 ----------------------
70 function Web_Default_Page
return String is
72 return Conf
.Get_Value
(Web_Default_Page
);
75 begin -- Gwiad.Config.Settings
76 -- Sets default option and reads configuration file
78 Conf
.Set_Value
(Auth_Username
, Gwiad
.Config
.Auth_Username
);
79 Conf
.Set_Value
(Auth_Password
, Gwiad
.Config
.Auth_Password
);
80 Conf
.Set_Value
(Web_Default_Directory
, Gwiad
.Config
.Web_Default_Directory
);
81 Conf
.Set_Value
(Web_Default_Page
, Gwiad
.Config
.Web_Default_Page
);
83 -- Now read the config file if any
85 Conf
.IO
.Open
(Config_Filename
);
89 when Conf
.IO
.Uncomplete_Config
=>
91 when UP
: Conf
.IO
.Unknown_Parameter
=>
92 Text_IO
.Put_Line
(Exceptions
.Exception_Message
(UP
));
94 when Text_IO
.Name_Error
=>
96 end Gwiad
.Config
.Settings
;