2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author : Maxim Mamontov <faust@stargazer.dp.ua>
24 #include "stg/common.h"
25 #include "stg/conffiles.h"
26 #include "settings_impl.h"
28 SETTINGS_IMPL::SETTINGS_IMPL()
37 confFile("/etc/sgauth.conf")
40 //-----------------------------------------------------------------------------
41 int SETTINGS_IMPL::ReadSettings()
43 CONFIGFILE cf(confFile);
47 strError = "Cannot read file '" + confFile + "'";
51 cf.ReadString("Login", &login, "/?--?--?*");
52 if (login == "/?--?--?*")
54 strError = "Parameter 'Login' not found.";
58 cf.ReadString("Password", &password, "/?--?--?*");
59 if (login == "/?--?--?*")
61 strError = "Parameter 'Password' not found.";
65 cf.ReadString("ServerName", &serverName, "?*?*?");
66 if (serverName == "?*?*?")
68 strError = "Parameter 'ServerName' not found.";
73 cf.ReadString("ListenWebIP", &temp, "127.0.0.1");
74 listenWebIP = inet_strington(temp);
77 strError = "Parameter 'ListenWebIP' is not valid.";
81 cf.ReadString("ServerPort", &temp, "5555");
82 if (ParseIntInRange(temp, 1, 65535, &port))
84 strError = "Parameter 'ServerPort' is not valid.";
88 cf.ReadString("LocalPort", &temp, "0");
89 if (ParseIntInRange(temp, 0, 65535, &localPort))
91 strError = "Parameter 'LocalPort' is not valid.";
95 cf.ReadString("RefreshPeriod", &temp, "5");
96 if (ParseIntInRange(temp, 1, 24*3600, &refreshPeriod))
98 strError = "Parameter 'RefreshPeriod' is not valid.";
102 cf.ReadString("Reconnect", &temp, "yes");
103 if (ParseYesNo(temp, &reconnect))
105 strError = "Parameter 'Reconnect' is not valid.";
109 cf.ReadString("Daemon", &temp, "yes");
110 if (ParseYesNo(temp, &daemon))
112 strError = "Parameter 'Daemon' is not valid.";
116 cf.ReadString("ShowPid", &temp, "no");
117 if (ParseYesNo(temp, &showPid))
119 strError = "Parameter 'ShowPid' is not valid.";
123 cf.ReadString("DisableWeb", &temp, "no");
124 if (ParseYesNo(temp, &noWeb))
126 strError = "Parameter 'DisableWeb' is not valid.";
132 //-----------------------------------------------------------------------------
133 void SETTINGS_IMPL::Print() const
135 std::cout << "Login = " << login << "\n"
136 << "Password = " << password << "\n"
137 << "Ip = " << serverName << "\n"
138 << "Port = " << port << "\n"
139 << "LocalPort = " << localPort << "\n"
140 << "ListenWebIP = " << inet_ntostring(listenWebIP) << "\n"
141 << "RefreshPeriod = " << refreshPeriod << "\n"
142 << "Daemon = " << daemon << "\n"
143 << "DisableWeb = " << noWeb << "\n"
144 << "Reconnect = " << reconnect << "\n"
145 << "ShowPid = " << showPid << std::endl;