-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbhmusers.cpp
More file actions
39 lines (36 loc) · 999 Bytes
/
bhmusers.cpp
File metadata and controls
39 lines (36 loc) · 999 Bytes
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
#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 );
}