diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-09 22:17:57 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-09 22:17:57 +0800 |
commit | d4e063b55ca7c7ffbea4d8601cae008e64a28521 (patch) | |
tree | 38f2f97acb8277899cb8d2beddf92a928f48187b /daemon/logind/loginc.c | |
parent | 4370dd5a94a80d21a9bcb7d5e464d4653f021dff (diff) | |
download | pttbbs-d4e063b55ca7c7ffbea4d8601cae008e64a28521.tar pttbbs-d4e063b55ca7c7ffbea4d8601cae008e64a28521.tar.gz pttbbs-d4e063b55ca7c7ffbea4d8601cae008e64a28521.tar.bz2 pttbbs-d4e063b55ca7c7ffbea4d8601cae008e64a28521.tar.lz pttbbs-d4e063b55ca7c7ffbea4d8601cae008e64a28521.tar.xz pttbbs-d4e063b55ca7c7ffbea4d8601cae008e64a28521.tar.zst pttbbs-d4e063b55ca7c7ffbea4d8601cae008e64a28521.zip |
* the long-waited high performance login daemon
* works only with tunnel mode mbbsd
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4527 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'daemon/logind/loginc.c')
-rw-r--r-- | daemon/logind/loginc.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/daemon/logind/loginc.c b/daemon/logind/loginc.c new file mode 100644 index 00000000..21a4d434 --- /dev/null +++ b/daemon/logind/loginc.c @@ -0,0 +1,81 @@ +// $Id$ +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +#include "bbs.h" +#include "logind.h" + +// standalone client to test logind + +int main(int argc, char *argv[]) +{ + int fd; + char buf[64]; + + memset(buf, 0, sizeof(buf)); + + if (argc < 2) { + fprintf(stderr, "Usage: %s tunnel_path\n", argv[0]); + return 0; + } + + if ( (fd = toconnect(argv[1])) < 0 ) { + perror("toconnect"); + return 1; + } + + puts("start waiting!\n"); + while (1) + { + int xfd = 0, ok = 1, i; + const char *encoding = ""; + login_data dat = {0}; + + if ((xfd = recv_remote_fd(fd)) < 0) + { + fprintf(stderr, "recv_remote_fd error. abort.\r\n"); + break; + } + puts("got recv_remote_fd"); + if (read(fd, &dat, sizeof(dat)) <= 0) + { + fprintf(stderr, "recv error. abort.\r\n"); + break; + } +#ifdef CONVERT + switch (dat.encoding) + { + case CONV_GB: + encoding = "[GB] "; + break; + case CONV_UTF8: + encoding = "[UTF-8] "; + break; + } +#endif + fprintf(stderr, "got login data: userid=%s, (%dx%d) %sfrom: %s\r\n", + dat.userid, dat.t_cols, dat.t_lines, + encoding, dat.hostip); + write(fd, &ok, sizeof(ok)); + + dup2(xfd, 0); + dup2(xfd, 1); + + // write something to user! + printf("\r\nwelcome, %s from %s! greetings from loginc!\r\n", dat.userid, dat.hostip); + printf("please give me 3 key hits to test i/o!\r\n"); + + for (i = 0; i < 3; i++) + { + char c; + read(0, &c, sizeof(c)); + printf("you hit %02X\r\n", c); + } + printf("\r\ntest complete. connection closed.\r\n"); + close(xfd); + } + return 0; +} + + |