diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-19 18:39:25 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-19 18:39:25 +0800 |
commit | 5ec0b0c8dc4b9aa479f8010f7a94aa3d99b0aac5 (patch) | |
tree | 1fff81f99998e464662b39e7f515ecd2fa2480a8 /daemon/regmaild/regmailc.c | |
parent | 7f2af2544f444e62db177d0848928a485c0cfcf4 (diff) | |
download | pttbbs-5ec0b0c8dc4b9aa479f8010f7a94aa3d99b0aac5.tar pttbbs-5ec0b0c8dc4b9aa479f8010f7a94aa3d99b0aac5.tar.gz pttbbs-5ec0b0c8dc4b9aa479f8010f7a94aa3d99b0aac5.tar.bz2 pttbbs-5ec0b0c8dc4b9aa479f8010f7a94aa3d99b0aac5.tar.lz pttbbs-5ec0b0c8dc4b9aa479f8010f7a94aa3d99b0aac5.tar.xz pttbbs-5ec0b0c8dc4b9aa479f8010f7a94aa3d99b0aac5.tar.zst pttbbs-5ec0b0c8dc4b9aa479f8010f7a94aa3d99b0aac5.zip |
* move emaildb to standalone regmaildb
* integrate the daemon structure to daemons.h
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4671 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'daemon/regmaild/regmailc.c')
-rw-r--r-- | daemon/regmaild/regmailc.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/daemon/regmaild/regmailc.c b/daemon/regmaild/regmailc.c new file mode 100644 index 00000000..cd5d2be8 --- /dev/null +++ b/daemon/regmaild/regmailc.c @@ -0,0 +1,59 @@ +// $Id$ +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +#include "bbs.h" +#include "daemons.h" + +// standalone client to test fromd + +int main(int argc, char *argv[]) +{ + int fd, ret = 0; + int op = 0; + regmaildb_req req = {0}; + + if (argc < 4) { + fprintf(stderr, "Usage: %s operation userid email\n", argv[0]); + return 0; + } + + if ( (fd = toconnect(REGMAILD_ADDR)) < 0 ) { + perror("toconnect"); + return 1; + } + + if (strcmp(argv[1], "count") == 0) + { + op = REGMAILDB_REQ_COUNT; + strlcpy(req.userid, argv[2], sizeof(req.userid)); + strlcpy(req.email, argv[3], sizeof(req.email)); + } + else if (strcmp(argv[1], "set") == 0) + { + op = REGMAILDB_REQ_SET; + strlcpy(req.userid, argv[2], sizeof(req.userid)); + strlcpy(req.email, argv[3], sizeof(req.email)); + } + else + return 0; + + req.cb = sizeof(req); + req.operation = op; + + if (towrite(fd, &req, sizeof(req)) != sizeof(req)) { + perror("towrite"); + return 1; + } + + if (toread(fd, &ret, sizeof(ret)) != sizeof(ret)) { + perror("toread"); + return 1; + } + + printf("count: %d\n", ret); + return 0; +} + + |