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>
23 $Date: 2008/07/05 12:35:53 $
27 #ifndef __USERSTAT_H__
28 #define __USERSTAT_H__
32 #include <netinet/in.h>
34 #include "base_plugin.h"
36 extern "C" BASE_PLUGIN * GetPlugin();
47 uint32_t n2l(unsigned char * c)
49 uint32_t t = *c++ << 24;
56 void l2n(uint32_t t, unsigned char * c)
58 *c++ = t >> 24 & 0x000000FF;
59 *c++ = t >> 16 & 0x000000FF;
60 *c++ = t >> 8 & 0x000000FF;
61 *c++ = t & 0x000000FF;
64 class USERSTAT : public BASE_PLUGIN
70 virtual void SetUsers(USERS * u) { users = u; };
71 virtual void SetTariffs(TARIFFS * t) {};
72 virtual void SetAdmins(ADMINS * a) {};
73 virtual void SetTraffcounter(TRAFFCOUNTER * tc) {};
74 virtual void SetStore(BASE_STORE * st) { store = st; };
75 virtual void SetStgSettings(const SETTINGS * s) {};
76 virtual void SetSettings(const MODULE_SETTINGS & s) { settings = s; };
77 virtual int ParseSettings();
81 virtual bool IsRunning() { return isRunning; };
82 virtual const string & GetStrError() const { return errorStr; };
83 virtual const string GetVersion() const { return version; };
84 virtual uint16_t GetStartPosition() const { return 0; };
85 virtual uint16_t GetStopPosition() const { return 0; };
88 struct IsDone : public unary_function<THREAD_INFO, bool>
90 bool operator()(const THREAD_INFO & info) { return info.done; };
92 struct ToLower : public unary_function<char, char>
94 char operator() (char c) const { return std::tolower(c); }
100 std::vector<THREAD_INFO> pool;
105 struct sockaddr_in listenAddr;
107 pthread_mutex_t mutex;
111 MODULE_SETTINGS settings;
113 XML_Parser xmlParser;
117 static void * Run(void *);
118 static void * Operate(void *);
120 friend void ParseXMLStart(void * data, char * name, char ** attr);
121 friend void ParseXMLEnd(void * data, char * name);