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("LocalName", &localName, "");
90 cf.ReadString("LocalPort", &temp, "0");
91 if (ParseIntInRange(temp, 0, 65535, &localPort))
93 strError = "Parameter 'LocalPort' is not valid.";
97 cf.ReadString("RefreshPeriod", &temp, "5");
98 if (ParseIntInRange(temp, 1, 24*3600, &refreshPeriod))
100 strError = "Parameter 'RefreshPeriod' is not valid.";
104 cf.ReadString("Reconnect", &temp, "yes");
105 if (ParseYesNo(temp, &reconnect))
107 strError = "Parameter 'Reconnect' is not valid.";
111 cf.ReadString("Daemon", &temp, "yes");
112 if (ParseYesNo(temp, &daemon))
114 strError = "Parameter 'Daemon' is not valid.";
118 cf.ReadString("ShowPid", &temp, "no");
119 if (ParseYesNo(temp, &showPid))
121 strError = "Parameter 'ShowPid' is not valid.";
125 cf.ReadString("DisableWeb", &temp, "no");
126 if (ParseYesNo(temp, &noWeb))
128 strError = "Parameter 'DisableWeb' is not valid.";
134 //-----------------------------------------------------------------------------
135 void SETTINGS_IMPL::Print() const
137 std::cout << "Login = " << login << "\n"
138 << "Password = " << password << "\n"
139 << "Ip = " << serverName << "\n"
140 << "Port = " << port << "\n"
141 << "LocalPort = " << localPort << "\n"
142 << "ListenWebIP = " << inet_ntostring(listenWebIP) << "\n"
143 << "RefreshPeriod = " << refreshPeriod << "\n"
144 << "Daemon = " << daemon << "\n"
145 << "DisableWeb = " << noWeb << "\n"
146 << "Reconnect = " << reconnect << "\n"
147 << "ShowPid = " << showPid << std::endl;