File: bhmusers.cpp

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 (42 lines) | stat: -rw-r--r-- 817 bytes parent folder | download | duplicates (7)
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
#include "bhmusers.h"
#include <stdio.h>
#include <cstring>
#include "expand.h"

BHMUsers::BHMUsers(const char *userListFile)
{
  char buf[1024];
  FILE *fp = fopen(userListFile, "r");
  if(!fp)
  {
    printf("Can't open \"%s\".\n", userListFile);
    exit(1);
  }

  while(fgets(buf, sizeof(buf), fp) )
  {
    USER_SMTP_ACTION action = eNone;
    strtok(buf, "\n");
    BHM_DATA data;
    if(buf[0] && buf[0] != '#')
    {
      strtok(buf, " ");
      char *pass = strtok(NULL, " ");
      if(pass)
      {
        char *type_char = strtok(NULL, " ");
        if(type_char)
          action = chrToAction(type_char[0]);
      }
      data.action = action;
      data.sync_time = 0;
      m_map[buf] = data;
    }
  }
  if(m_map.size() == 0)
  {
    printf("No users in file.\n");
    exit(1);
  }
  fclose(fp);
}