#ifndef NetUnitH
#define NetUnitH
-#include "stg/blowfish.h"
-
-#include <string>
-
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <list>
+#include <string>
+
+#include "stg/blowfish.h"
+
#define STG_HEADER "SG04"
#define OK_HEADER "OKHD"
#define ERR_HEADER "ERHD"
#define MAX_ERR_STR_LEN (64)
-typedef bool (* RxCallback_t)(void *, const std::string &, bool);
+typedef int(*RxCallback_t)(void *, std::list<std::string> *);
enum status
{
class NETTRANSACT
{
public:
- NETTRANSACT(const std::string & server, uint16_t port,
- const std::string & login, const std::string & password);
+ NETTRANSACT();
int Transact(const char * data);
const std::string & GetError() const;
void SetRxCallback(void * data, RxCallback_t);
+ void SetServer(const char * serverName);
+ void SetServerPort(short unsigned p);
+
+ void SetLogin(const char * l);
+ void SetPassword(const char * p);
+ ////////////////////////////////////////////
int Connect();
int Disconnect();
+ void Reset();
private:
int TxHeader();
int RxHeaderAnswer();
int RxLoginSAnswer();
int TxData(const char * text);
- int TxData(char * data);
int RxDataAnswer();
std::string server;
- uint16_t port;
+ short unsigned port;
std::string login;
std::string password;
int outerSocket;
+ std::list<std::string> answerList;
RxCallback_t RxCallBack;
void * dataRxCallBack;
std::string errorMsg;