File: bhmusers.h

package info (click to toggle)
postal 0.70
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 540 kB
  • ctags: 525
  • sloc: cpp: 4,131; sh: 289; ansic: 258; makefile: 134
file content (70 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download | duplicates (3)
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
#ifndef USERLIST_H
#define USERLIST_H

using namespace std;

#include <string>
#include "conf.h"

#ifdef HAVE_EXT_HASH_MAP
using namespace __gnu_cxx;
#include <ext/hash_map>
#else
#include <hash_map.h>
#endif

#include "postal.h"

typedef enum { eNone = 0, eDefer, eReject, eBounce, eGrey } USER_SMTP_ACTION;

typedef struct
{
  USER_SMTP_ACTION action;
  int sync_time;
} BHM_DATA;

namespace __gnu_cxx
{
  template<> struct hash< std::string >
  {
    size_t operator() ( const std::string &x ) const
    {
      return hash < const char * >() ( x.c_str() );
    }
  };
}

typedef hash_map<string, BHM_DATA , hash<string> > NAME_MAP;

class BHMUsers
{
public:
  BHMUsers(const char *userListFile);
  ~BHMUsers() {};

private:
  BHMUsers(BHMUsers &list);

  NAME_MAP m_map;

  USER_SMTP_ACTION chrToAction(char c)
  {
    switch(c)
    {
    case 'd':
      return eDefer;
    case 'r':
      return eReject;
    case 'b':
      return eBounce;
    case 'g':
      return eGrey;
    }
    return eNone;
  }

  BHMUsers(const BHMUsers&);
  BHMUsers & operator=(const BHMUsers&);
};

#endif