summaryrefslogtreecommitdiffstats
path: root/daemon/regmaild/regmailc.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/regmaild/regmailc.c')
-rw-r--r--daemon/regmaild/regmailc.c59
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;
+}
+
+