📄 00000008.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER>发信人: Leeward (X 14% completed), 信区: Linux <BR>标 题: FireBirdBBS(2.5) pop3d (tested AIX/SUN/Linux) <BR>发信站: BBS 水木清华站 (Sun Jun 14 16:25:00 1998) <BR> <BR>补充说明:该程序启动成功后,自动脱离终端,以守护进程方式运行。 <BR> <BR>/* Leeward: usage: bbspop3d [port] <BR> Note: <BR> 1. If no port given, I use 110 (in fact, using macro POP3PORT) <BR> 2. If atoi(port) returns zero, I use 110 (the same as above) <BR> 3. Using port 110 needs starting by root <BR> If started by bbsroot, try port over 1023 <BR> 4. Three macros defined below: BBSHOME, POP3PORT and BBSNAME <BR> You may need modify these three macros to fit your BBS settings <BR> 5. I added codes to support two functions: <BR> (1) Top // extended POP3 function <BR> (2) nextwordX // enable passwords including space character(s) <BR> 6. While making bbspop3d, you might encounter linker errors <BR> Try to pass the linker some libraries <BR> (For example: link under SUNOS, you may need add -lnsl and -lsocket) <BR> 7. bbspop3d.c is put in the same directory as bbs.h <BR> 8. Client settings: <BR> (1) pop3 server : Your BBS server <BR> (2) pop3 port : 110(POP3PORT) or the argv[1] while starting pop3d <BR> (3) pop3 account : BBSID.bbs (For example: mine is "Leeward.bbs") <BR> (4) pop3 password: The same as the client's BBSID's password <BR> Last modified: 98.06.14 <BR>*/ <BR> <BR>#include <sys/ioctl.h> <BR>#include "bbs.h" <BR> <BR>#include <sys/wait.h> <BR>#include <netinet/in.h> <BR>#include <sys/socket.h> <BR>#include <netdb.h> <BR> <BR>#include <sys/time.h> <BR>#include <sys/stat.h> <BR> <BR>#define BBSUID 9999 <BR>#define BBSGID 99 <BR>#define BUFSIZE 1024 <BR>#define BBSHOME "/home0/bbs" <BR>#define BBSNAME "<A HREF="mailto:.bbs@bbs.net.tsinghua.edu.cn"">.bbs@bbs.net.tsinghua.edu.cn"</A> <BR>#define POP3PORT 110 <BR> <BR>struct fileheader currentmail; <BR>struct userec currentuser; <BR> <BR>char LowUserid[20]; <BR>char genbuf[BUFSIZE]; <BR> <BR>#define QLEN 5 <BR> <BR>#define S_CONNECT 1 <BR>#define S_LOGIN 2 <BR> <BR> <BR>#define STRN_CPY(d,s,l) { strncpy((d),(s),(l)); (d)[(l)-1] = 0; } <BR>#define ANY_PORT 0 <BR>#define RFC931_PORT 113 <BR>#define RFC931_TIMEOUT 5 <BR>/*#define POP3_TIMEOUT 60*/ <BR>/* Leeward 98.05.06 Increases TIMEOUT value for slow modem users */ <BR>#define POP3_TIMEOUT 180 <BR> <BR>static jmp_buf timebuf; <BR> <BR>int State; <BR>int msock,sock; /* master server socket */ <BR>static int reaper(); <BR>char fromhost[ STRLEN ]; <BR>char inbuf[ BUFSIZE ]; <BR>char remote_userid[ STRLEN ]; <BR>FILE *cfp; <BR>char *msg,*cmd; <BR>int fd; <BR>struct fileheader *fcache; <BR>int totalnum, totalbyte, markdel, idletime; <BR>int *postlen; <BR> <BR>void log_usies(); <BR>int Quit(), User(), Pass(), Noop(), Stat(), List(), Retr(), Rset(); <BR>int Last(), Dele(), Uidl(); <BR>int Top(); /* Leeward adds, 98.01.21 */ <BR> <BR>struct commandlist { <BR> char *name; <BR> int (*fptr)(); <BR>} cmdlists[] = { <BR> "retr", Retr, <BR> "dele", Dele, <BR> "user", User, <BR> "pass", Pass, <BR> "stat", Stat, <BR> "list", List, <BR> "uidl", Uidl, <BR> "quit", Quit, <BR> "rset", Rset, <BR> "last", Last, <BR> "noop", Noop, <BR> "top", Top, /* Leeward adds, 98.01.21 */ <BR> NULL, NULL <BR>}; <BR> <BR>char *crypt(); <BR> <BR>int <BR>checkpasswd(passwd, test) <BR>char *passwd, *test; <BR>{ <BR> static char pwbuf[14]; <BR> char *pw; <BR> <BR> strncpy(pwbuf, test, 14); <BR> pw = crypt(pwbuf, passwd); <BR> return (!strcmp(pw, passwd)); <BR>} <BR> <BR>static int <BR>abort_server() <BR>{ <BR> log_usies("ABORT SERVER"); <BR> close(msock); <BR> close(sock); <BR> exit(1); <BR>} <BR> <BR>int dokill() <BR>{ <BR> kill(0,SIGKILL); <BR>} <BR> <BR>static FILE *fsocket(domain, type, protocol) <BR>int domain; <BR>int type; <BR>int protocol; <BR>{ <BR> int s; <BR> FILE *fp; <BR> <BR> if ((s = socket(domain, type, protocol)) < 0) { <BR> return (0); <BR> } else { <BR> if ((fp = fdopen(s, "r+")) == 0) { <BR> close(s); <BR> } <BR> return (fp); <BR> } <BR>} <BR> <BR>void <BR>outs(str) <BR>char *str; <BR>{ <BR> char sendbuf[BUFSIZE]; <BR> <BR> (void)bzero(sendbuf, sizeof(sendbuf)); <BR> (void)sprintf(sendbuf, "%s\r\n", str); <BR> (void)write(sock, sendbuf, strlen(sendbuf)); <BR>} <BR> <BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -