const std::string * value;
};
//-----------------------------------------------------------------------------
-void GetUserCallback(bool result, const std::string& reason, const PARSER_GET_USER::INFO & info, void * d)
+void GetUserCallback(bool result, const std::string& reason, const GET_USER::INFO & info, void * d)
{
GetUserData * data = static_cast<GetUserData *>(d);
data->result = false;
+++ /dev/null
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
- * Author : Maxim Mamontov <faust@stargazer.dp.ua>
- */
-
-#ifndef __STG_STGLIBS_SRVCONF_PARSER_GET_USER_H__
-#define __STG_STGLIBS_SRVCONF_PARSER_GET_USER_H__
-
-#include "parser.h"
-
-#include "property_parsers.h"
-
-#include "stg/os_int.h"
-#include "stg/const.h"
-
-#include <string>
-
-#include <ctime>
-
-namespace STG
-{
-
-class PARSER_GET_USER: public PARSER
-{
-public:
- struct STAT
- {
- long long su[DIR_NUM];
- long long sd[DIR_NUM];
- long long mu[DIR_NUM];
- long long md[DIR_NUM];
- double freeMb;
- };
-
- struct INFO
- {
- std::string login;
- std::string password;
- double cash;
- double credit;
- time_t creditExpire;
- double lastCash;
- double prepaidTraff;
- int down;
- int passive;
- int disableDetailStat;
- int connected;
- int alwaysOnline;
- uint32_t ip;
- std::string ips;
- std::string tariff;
- std::string group;
- std::string note;
- std::string email;
- std::string name;
- std::string address;
- std::string phone;
- STAT stat;
- std::string userData[USERDATA_NUM];
- };
-
- typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
-
- PARSER_GET_USER();
- virtual ~PARSER_GET_USER();
- int ParseStart(const char *el, const char **attr);
- void ParseEnd(const char *el);
- void SetCallback(CALLBACK f, void * data);
-private:
- PROPERTY_PARSERS propertyParsers;
- CALLBACK callback;
- void * data;
- INFO info;
- int depth;
- bool parsingAnswer;
- std::string error;
-
- void ParseUser(const char *el, const char **attr);
- void ParseUserParams(const char *el, const char **attr);
-};
-
-} // namespace STG
-
-#endif
+++ /dev/null
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
- * Author : Maxim Mamontov <faust@stargazer.dp.ua>
- */
-
-#ifndef __STG_STGLIBS_SRVCONF_PARSER_GET_USERS_H__
-#define __STG_STGLIBS_SRVCONF_PARSER_GET_USERS_H__
-
-#include "parser.h"
-
-#include "parser_get_user.h"
-
-#include <vector>
-
-namespace STG
-{
-
-class PARSER_GET_USERS: public PARSER
-{
-public:
- typedef std::vector<PARSER_GET_USER::INFO> INFO;
- typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
-
- PARSER_GET_USERS();
- int ParseStart(const char * el, const char ** attr);
- void ParseEnd(const char * el);
- void SetCallback(CALLBACK f, void * data);
-private:
- CALLBACK callback;
- void * data;
- PARSER_GET_USER userParser;
- INFO info;
- int depth;
- bool parsingAnswer;
- std::string error;
-
- void AddUser(const PARSER_GET_USER::INFO & userInfo);
- void SetError(const std::string & e) { error = e; }
-
- static void UserCallback(bool result, const std::string& reason, const PARSER_GET_USER::INFO & info, void * data);
-};
-
-} // namespace STG
-
-#endif
#ifndef __STG_STGLIBS_SERVCONF_H__
#define __STG_STGLIBS_SERVCONF_H__
-#include "stg/parser_get_user.h"
-#include "stg/parser_get_users.h"
#include "stg/parser_chg_user.h"
#include "stg/parser_send_message.h"
const std::string & login, const std::string & password);
~SERVCONF();
- int GetUsers(PARSER_GET_USERS::CALLBACK f, void * data);
- int GetUser(const std::string & login, PARSER_GET_USER::CALLBACK f, void * data);
+ int GetUsers(GET_USERS::CALLBACK f, void * data);
+ int GetUser(const std::string & login, GET_USER::CALLBACK f, void * data);
int ChgUser(const std::string & request, PARSER_CHG_USER::CALLBACK f, void * data);
int AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data);
int SendMessage(const std::string & request, PARSER_SEND_MESSAGE::CALLBACK f, void * data);
#define __STG_STGLIBS_SRVCONF_TYPES_H__
#include "stg/const.h" // DIR_NUM
+#include "stg/os_int.h" // uint32_t, etc...
#include <string>
#include <vector>
typedef int (* CALLBACK)(bool result, const std::string & reason, void * data);
-}
+} // namespace CHECK_USER
+
+namespace GET_USER
+{
+
+struct STAT
+{
+ long long su[DIR_NUM];
+ long long sd[DIR_NUM];
+ long long mu[DIR_NUM];
+ long long md[DIR_NUM];
+ double freeMb;
+};
+
+struct INFO
+{
+ std::string login;
+ std::string password;
+ double cash;
+ double credit;
+ time_t creditExpire;
+ double lastCash;
+ double prepaidTraff;
+ int down;
+ int passive;
+ int disableDetailStat;
+ int connected;
+ int alwaysOnline;
+ uint32_t ip;
+ std::string ips;
+ std::string tariff;
+ std::string group;
+ std::string note;
+ std::string email;
+ std::string name;
+ std::string address;
+ std::string phone;
+ STAT stat;
+ std::string userData[USERDATA_NUM];
+};
+
+typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
+
+} // namespace GET_USER
+
+namespace GET_USERS
+{
+
+typedef std::vector<GET_USER::INFO> INFO;
+typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & info, void * data);
+
+} // namespace GET_USERS
+
} // namespace STG
#endif
* Author : Maxim Mamontov <faust@stargazer.dp.ua>
*/
-#include "stg/parser_get_user.h"
+#include "parser_get_user.h"
#include "stg/common.h"
using namespace STG;
template <>
-bool GetValue<PARSER_GET_USER::STAT>(const char ** attr, PARSER_GET_USER::STAT & value)
+bool GetValue<GET_USER::STAT>(const char ** attr, GET_USER::STAT & value)
{
if (!attr)
return false;
return true;
}
-PARSER_GET_USER::PARSER_GET_USER()
+GET_USER::PARSER::PARSER()
: callback(NULL),
data(NULL),
depth(0),
AddParser(propertyParsers, "userData" + x2str(i), info.userData[i], GetEncodedValue);
}
//-----------------------------------------------------------------------------
-PARSER_GET_USER::~PARSER_GET_USER()
+GET_USER::PARSER::~PARSER()
{
PROPERTY_PARSERS::iterator it(propertyParsers.begin());
while (it != propertyParsers.end())
delete (it++)->second;
}
//-----------------------------------------------------------------------------
-int PARSER_GET_USER::ParseStart(const char * el, const char ** attr)
+int GET_USER::PARSER::ParseStart(const char * el, const char ** attr)
{
depth++;
if (depth == 1)
return 0;
}
//-----------------------------------------------------------------------------
-void PARSER_GET_USER::ParseEnd(const char * /*el*/)
+void GET_USER::PARSER::ParseEnd(const char * /*el*/)
{
depth--;
if (depth == 0 && parsingAnswer)
}
}
//-----------------------------------------------------------------------------
-void PARSER_GET_USER::ParseUser(const char * el, const char ** attr)
+void GET_USER::PARSER::ParseUser(const char * el, const char ** attr)
{
if (strcasecmp(el, "user") == 0)
if (attr && attr[0] && attr[1])
parsingAnswer = true;
}
//-----------------------------------------------------------------------------
-void PARSER_GET_USER::ParseUserParams(const char * el, const char ** attr)
+void GET_USER::PARSER::ParseUserParams(const char * el, const char ** attr)
{
if (!TryParse(propertyParsers, ToLower(el), attr))
error = "Invalid parameter.";
}
//-----------------------------------------------------------------------------
-void PARSER_GET_USER::SetCallback(CALLBACK f, void * d)
+void GET_USER::PARSER::SetCallback(CALLBACK f, void * d)
{
callback = f;
data = d;
--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
+ * Author : Maxim Mamontov <faust@stargazer.dp.ua>
+ */
+
+#ifndef __STG_STGLIBS_SRVCONF_PARSER_GET_USER_H__
+#define __STG_STGLIBS_SRVCONF_PARSER_GET_USER_H__
+
+#include "stg/parser.h"
+
+#include "stg/property_parsers.h"
+#include "stg/servconf_types.h"
+
+#include <string>
+
+#include <ctime>
+
+namespace STG
+{
+namespace GET_USER
+{
+
+class PARSER: public STG::PARSER
+{
+public:
+
+ PARSER();
+ virtual ~PARSER();
+ int ParseStart(const char *el, const char **attr);
+ void ParseEnd(const char *el);
+ void SetCallback(CALLBACK f, void * data);
+private:
+ PROPERTY_PARSERS propertyParsers;
+ CALLBACK callback;
+ void * data;
+ INFO info;
+ int depth;
+ bool parsingAnswer;
+ std::string error;
+
+ void ParseUser(const char *el, const char **attr);
+ void ParseUserParams(const char *el, const char **attr);
+};
+
+} // namespace GET_USER
+} // namespace STG
+
+#endif
* Author : Maxim Mamontov <faust@stargazer.dp.ua>
*/
-#include "stg/parser_get_users.h"
+#include "parser_get_users.h"
#include <cstddef>
using namespace STG;
-PARSER_GET_USERS::PARSER_GET_USERS()
+GET_USERS::PARSER::PARSER()
: callback(NULL),
data(NULL),
depth(0),
parsingAnswer(false)
{
- userParser.SetCallback(&PARSER_GET_USERS::UserCallback, this);
+ userParser.SetCallback(&GET_USERS::PARSER::UserCallback, this);
}
//-----------------------------------------------------------------------------
-int PARSER_GET_USERS::ParseStart(const char * el, const char ** attr)
+int GET_USERS::PARSER::ParseStart(const char * el, const char ** attr)
{
depth++;
if (depth == 1 && strcasecmp(el, "users") == 0)
return 0;
}
//-----------------------------------------------------------------------------
-void PARSER_GET_USERS::ParseEnd(const char * el)
+void GET_USERS::PARSER::ParseEnd(const char * el)
{
depth--;
if (depth > 0 && parsingAnswer)
}
}
//-----------------------------------------------------------------------------
-void PARSER_GET_USERS::AddUser(const PARSER_GET_USER::INFO & userInfo)
+void GET_USERS::PARSER::AddUser(const GET_USER::INFO & userInfo)
{
info.push_back(userInfo);
}
//-----------------------------------------------------------------------------
-void PARSER_GET_USERS::SetCallback(CALLBACK f, void * d)
+void GET_USERS::PARSER::SetCallback(CALLBACK f, void * d)
{
callback = f;
data = d;
}
//-----------------------------------------------------------------------------
-void PARSER_GET_USERS::UserCallback(bool result, const std::string & error, const PARSER_GET_USER::INFO & info, void * data)
+void GET_USERS::PARSER::UserCallback(bool result, const std::string & error, const GET_USER::INFO & info, void * data)
{
- PARSER_GET_USERS * parser = static_cast<PARSER_GET_USERS *>(data);
+ GET_USERS::PARSER * parser = static_cast<GET_USERS::PARSER *>(data);
if (!result)
parser->SetError(error);
else
--- /dev/null
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
+ * Author : Maxim Mamontov <faust@stargazer.dp.ua>
+ */
+
+#ifndef __STG_STGLIBS_SRVCONF_PARSER_GET_USERS_H__
+#define __STG_STGLIBS_SRVCONF_PARSER_GET_USERS_H__
+
+#include "stg/parser.h"
+#include "stg/servconf_types.h"
+
+#include "parser_get_user.h"
+
+#include <vector>
+
+namespace STG
+{
+namespace GET_USERS
+{
+
+class PARSER: public STG::PARSER
+{
+public:
+
+ PARSER();
+ int ParseStart(const char * el, const char ** attr);
+ void ParseEnd(const char * el);
+ void SetCallback(CALLBACK f, void * data);
+private:
+ CALLBACK callback;
+ void * data;
+ GET_USER::PARSER userParser;
+ INFO info;
+ int depth;
+ bool parsingAnswer;
+ std::string error;
+
+ void AddUser(const GET_USER::INFO & userInfo);
+ void SetError(const std::string & e) { error = e; }
+
+ static void UserCallback(bool result, const std::string& reason, const GET_USER::INFO & info, void * data);
+};
+
+} // namespace GET_USERS
+} // namespace STG
+
+#endif
#include "parser_auth_by.h"
#include "parser_server_info.h"
#include "parser_check_user.h"
+#include "parser_get_users.h"
+#include "parser_get_user.h"
#include "stg/common.h"
IMPL(const std::string & server, uint16_t port,
const std::string & login, const std::string & password);
- int GetUsers(PARSER_GET_USERS::CALLBACK f, void * data);
- int GetUser(const std::string & login, PARSER_GET_USER::CALLBACK f, void * data);
+ int GetUsers(GET_USERS::CALLBACK f, void * data);
+ int GetUser(const std::string & login, GET_USER::CALLBACK f, void * data);
int ChgUser(const std::string & request, PARSER_CHG_USER::CALLBACK f, void * data);
int AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data);
int SendMessage(const std::string & request, PARSER_SEND_MESSAGE::CALLBACK f, void * data);
static void End(void * data, const char * el);
private:
- PARSER_GET_USERS parserGetUsers;
- PARSER_GET_USER parserGetUser;
+ GET_USERS::PARSER parserGetUsers;
+ GET_USER::PARSER parserGetUser;
AUTH_BY::PARSER parserAuthBy;
SERVER_INFO::PARSER parserServerInfo;
PARSER_CHG_USER parserChgUser;
delete pImpl;
}
-int SERVCONF::GetUsers(PARSER_GET_USERS::CALLBACK f, void * data)
+int SERVCONF::GetUsers(GET_USERS::CALLBACK f, void * data)
{
return pImpl->GetUsers( f, data );
}
-int SERVCONF::GetUser(const std::string & login, PARSER_GET_USER::CALLBACK f, void * data)
+int SERVCONF::GetUser(const std::string & login, GET_USER::CALLBACK f, void * data)
{
return pImpl->GetUser(login, f, data);
}
nt.SetRxCallback(this, AnsRecv);
}
//-----------------------------------------------------------------------------
-int SERVCONF::IMPL::GetUser(const std::string & login, PARSER_GET_USER::CALLBACK f, void * data)
+int SERVCONF::IMPL::GetUser(const std::string & login, GET_USER::CALLBACK f, void * data)
{
parserGetUser.SetCallback(f, data);
return Exec("<GetUser login=\"" + login + "\"/>", parserGetUser);
return Exec("<GetUserAuthBy login=\"" + login + "\"/>", parserAuthBy);
}
//-----------------------------------------------------------------------------
-int SERVCONF::IMPL::GetUsers(PARSER_GET_USERS::CALLBACK f, void * data)
+int SERVCONF::IMPL::GetUsers(GET_USERS::CALLBACK f, void * data)
{
parserGetUsers.SetCallback(f, data);
return Exec("<GetUsers/>", parserGetUsers);