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
71
72
73
74
|
/* $Id$ */
#include "bbs.h"
#include "daemons.h"
#ifdef USE_EMAILDB
int emaildb_check_email(char * email, int email_len)
{
int count = -1;
int fd = -1;
regmaildb_req req = {0};
// initialize request
req.cb = sizeof(req);
req.operation = REGMAILDB_REQ_COUNT;
strlcpy(req.userid, cuser.userid, sizeof(req.userid));
if ( (fd = toconnect(REGMAILD_ADDR)) < 0 )
{
// perror("toconnect");
return -1;
}
if (towrite(fd, &req, sizeof(req)) != sizeof(req)) {
// perror("towrite");
close(fd);
return -1;
}
if (toread(fd, &count, sizeof(count)) != sizeof(count)) {
// perror("toread");
close(fd);
return -1;
}
return count;
}
int emaildb_update_email(char * userid, int userid_len, char * email, int email_len)
{
int result = -1;
int fd = -1;
regmaildb_req req = {0};
// initialize request
req.cb = sizeof(req);
req.operation = REGMAILDB_REQ_SET;
strlcpy(req.userid, cuser.userid, sizeof(req.userid));
if ( (fd = toconnect(REGMAILD_ADDR)) < 0 )
{
// perror("toconnect");
return -1;
}
if (towrite(fd, &req, sizeof(req)) != sizeof(req)) {
// perror("towrite");
close(fd);
return -1;
}
if (toread(fd, &result, sizeof(result)) != sizeof(result)) {
// perror("toread");
close(fd);
return -1;
}
return result;
}
#endif
// vim:et
|