|
0
|
1 |
#ifndef VMAILMGR__RESPONSE__H__
|
|
|
2 |
#define VMAILMGR__RESPONSE__H__
|
|
|
3 |
|
|
|
4 |
#include "mystring/mystring.h"
|
|
|
5 |
|
|
|
6 |
struct response
|
|
|
7 |
{
|
|
|
8 |
enum response_code { ok=0, bad=1, err=2, econn=3 };
|
|
|
9 |
const response_code code;
|
|
|
10 |
const mystring msg;
|
|
|
11 |
|
|
|
12 |
response(response_code c, mystring m) : code(c), msg(m) { }
|
|
|
13 |
response(const response& r) : code(r.code), msg(r.msg) { }
|
|
|
14 |
~response() { }
|
|
|
15 |
|
|
|
16 |
static response read(int fd);
|
|
|
17 |
bool write(int fd) const;
|
|
|
18 |
bool operator!() const { return code != ok; }
|
|
|
19 |
mystring message() const;
|
|
|
20 |
mystring codestr() const;
|
|
|
21 |
|
|
|
22 |
static const unsigned long maxsize = 1<<16-1;
|
|
|
23 |
};
|
|
|
24 |
|
|
|
25 |
#define RETURN(CODE,STR) return response(response::CODE, STR)
|
|
|
26 |
|
|
|
27 |
#endif
|