"Fossies" - the Fresh Open Source Software Archive 
Member "postal-0.76/bhmusers.cpp" (10 Apr 2008, 817 Bytes) of package /linux/privat/postal-0.76.tgz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "bhmusers.cpp" see the
Fossies "Dox" file reference documentation.
1 #include "bhmusers.h"
2 #include <stdio.h>
3 #include <cstring>
4 #include "expand.h"
5
6 BHMUsers::BHMUsers(const char *userListFile)
7 {
8 char buf[1024];
9 FILE *fp = fopen(userListFile, "r");
10 if(!fp)
11 {
12 printf("Can't open \"%s\".\n", userListFile);
13 exit(1);
14 }
15
16 while(fgets(buf, sizeof(buf), fp) )
17 {
18 USER_SMTP_ACTION action = eNone;
19 strtok(buf, "\n");
20 BHM_DATA data;
21 if(buf[0] && buf[0] != '#')
22 {
23 strtok(buf, " ");
24 char *pass = strtok(NULL, " ");
25 if(pass)
26 {
27 char *type_char = strtok(NULL, " ");
28 if(type_char)
29 action = chrToAction(type_char[0]);
30 }
31 data.action = action;
32 data.sync_time = 0;
33 m_map[buf] = data;
34 }
35 }
36 if(m_map.size() == 0)
37 {
38 printf("No users in file.\n");
39 exit(1);
40 }
41 fclose(fp);
42 }