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 : Boris Mikhailenko <stg34@stargazer.dp.ua>
23 $Date: 2010/04/14 09:01:29 $
33 #include "stg/common.h"
40 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
45 std::cout << "sgauth <path_to_config>" << std::endl;
47 //-----------------------------------------------------------------------------
48 void StatUpdate(const LOADSTAT &, void *)
51 //-----------------------------------------------------------------------------
52 void StatusChanged(int, void *)
55 //-----------------------------------------------------------------------------
56 void ShowMessage(const string &, int, int, int, void *)
59 //-----------------------------------------------------------------------------
60 void ShowError(const string &, int, void *)
63 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
69 static void SetSignalHandlers()
71 struct sigaction newsa, oldsa;
74 sigemptyset(&sigmask);
75 sigaddset(&sigmask, SIGTERM);
76 newsa.sa_handler = CatchTERM;
77 newsa.sa_mask = sigmask;
79 sigaction(SIGTERM, &newsa, &oldsa);
81 sigemptyset(&sigmask);
82 sigaddset(&sigmask, SIGINT);
83 newsa.sa_handler = CatchTERM;
84 newsa.sa_mask = sigmask;
86 sigaction(SIGINT, &newsa, &oldsa);
90 //-----------------------------------------------------------------------------
91 int main(int argc, char *argv[])
97 settings.SetConfFile(argv[1]);
100 if (settings.ReadSettings())
102 std::cerr << "Failed to read settings\n"
103 << settings.GetStrError() << std::endl;
110 IA_CLIENT_PROT proto(settings.GetServerName(), settings.GetServerPort(), settings.GetLocalPort());
112 proto.SetLogin(settings.GetLogin());
113 proto.SetPassword(settings.GetPassword());
115 proto.SetStatusChangedCb(StatusChanged, NULL);
116 proto.SetInfoCb(ShowMessage, NULL);
117 proto.SetErrorCb(ShowError, NULL);
118 proto.SetStatChangedCb(StatUpdate, NULL);
136 //-----------------------------------------------------------------------------