blob: 6d9ffc1415ef47431f70f8b59aad340333926c18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/**
* @file session.h
* @brief <--->
* @author Andreas Aardal Hanssen
* @date 2002-2005
*/
#ifndef session_h_included
#define session_h_included
#include "argparser.h"
#include <map>
#include <string>
#include <vector>
#include <sys/types.h>
namespace Binc {
class Depot;
class Session {
public:
std::map<std::string, std::string> attrs;
char **unparsedArgs;
struct {
bool help;
bool version;
bool ssl;
} command;
bool mailboxchanges;
enum State {
NONAUTHENTICATED = 0x01,
AUTHENTICATED = 0x02,
SELECTED = 0x04,
LOGOUT = 0x00
};
CommandLineArgs args;
int timeout() const;
bool hasEnv(const std::string &key) const;
std::string getEnv(const std::string &key);
void setEnv(const std::string &key, const std::string &value);
int getState() const;
void setState(int n);
bool parseCommandLine(int argc, char *argv[]);
void assignCommandLineArgs();
int getWriteBytes() const;
int getReadBytes() const;
void addWriteBytes(int);
void addReadBytes(int);
int getBodies() const;
int getStatements() const;
void addBody();
void addStatement();
void setLogFacility(int facility);
int getLogFacility() const;
const std::string &getLastError() const;
const std::string &getResponseCode() const;
const std::string &getIP() const;
const std::string &getUserID() const;
pid_t getPid();
const std::string &getHostname();
void setLastError(const std::string &error) const;
void setResponseCode(const std::string &error) const;
void clearResponseCode() const;
void setIP(const std::string &ip);
void setUserID(const std::string &s);
inline Depot *getDepot() const;
static Session &getInstance();
bool initialize(int argc, char *argv[]);
private:
int state;
std::string userid;
std::string ip;
char **argv;
int argc;
int logfacility;
int readbytes;
int writebytes;
int statements;
int bodies;
Depot *depot;
mutable std::string lastError;
mutable std::string responseCode;
pid_t pid;
std::string hostname;
Session();
};
inline Depot *Session::getDepot() const
{
return depot;
}
}
#endif
|