/************************************************************** * VERCHK num * 設定所使用的Client版本編號 * 系統內定值為20 ***************************************************************/ DoVersionCheck() { int ver; ver = Get_para_number(1); if (ver <= 0) RespondProtocol(SYNTAX_ERROR); else { if (ver >= VERSION_NEWEST) RespondProtocol(VER_OK); else if (ver >= VERSION_LEAST) RespondProtocol(VER_GETNEW); else RespondProtocol(VER_NOT); } /*------------------------------------------- NextToken=GetToken(NextToken,tmp,10); if(tmp[0]=='\0') RespondProtocol(SYNTAX_ERROR); else { ver=atoi(tmp); if(ver>=VERSION_NEWEST) RespondProtocol(VER_OK); else if(ver>=VERSION_LEAST) RespondProtocol(VER_GETNEW); else RespondProtocol(VER_NOT); } ----------------------------------------------*/ }
/*********************************************************** * ANNOUNCE * 取得近站公告 ************************************************************/ DoAnnounce() { if (!isfile(WELCOME)) RespondProtocol(NO_ANNOUNCE); else SendArticle(WELCOME, TRUE); }
/* * HELLO * 連線後與系統打招呼 */ static void DoHello() { if (!ifSayHello) ifSayHello = TRUE; RespondProtocol(OK_CMD); }
/*********************************************************** * CHKANNOUNCE * 取得公告最後修改日期 ************************************************************/ DoChkAnnounce() { struct stat st; if (stat(WELCOME, &st) < 0) RespondProtocol(NO_ANNOUNCE); else inet_printf("%d\t%ld\r\n", ANN_TIME, st.st_mtime); }
/************************************************************ * BBSINFO * 取得BBS name,Terminal及Client的人數 *************************************************************/ static void DoAskBBSInformation() { int t_user, c_user, w_user; num_ulist(&t_user, &c_user, &w_user); RespondProtocol(OK_CMD); inet_printf("BBSNAME:\t%s\r\nT-USER:\t%d\r\nC-USER:\t%d\r\nW-USER:\t%d\r\n.\r\n", BBSNAME, t_user, c_user, w_user); }
/***************************************************** * Syntax: FORWARD * 自動轉寄信件開關 *****************************************************/ DoForward() { if (!strcmp(curuser.userid, GUEST)) { /* 如果使用者為 guest 登陸 */ RespondProtocol(WORK_ERROR); return; } if (curuser.flags[0] & FORWARD_FLAG) /* 已開啟 */ curuser.flags[0] &= ~FORWARD_FLAG; else { if (!is_emailaddr(curuser.email)) /* lthuang */ { RespondProtocol(WORK_ERROR); return; } curuser.flags[0] |= FORWARD_FLAG; } RespondProtocol(OK_CMD); }
/***************************************************** * Syntax: MAILHEAD startnum [endnum] * 取得信件資料 * Respond: MailNum State-Condition Owner Date Title * 取得信件資料 *****************************************************/ DoGetMailHead() { int start, end, num, fd, i; struct fileheader fh; char mail_state, chdate[6], c; time_t date; start = Get_para_number(1); if (start < 1) { RespondProtocol(MAIL_NOT_EXIST); return; } end = Get_para_number(2); if (end < 1) end = start; else if (end < start) { RespondProtocol(SYNTAX_ERROR); return; } num = get_num_records(maildirect, FH_SIZE); /* get mail count */ if (start > num || end > num) { RespondProtocol(MAIL_NOT_EXIST); return; } if ((fd = open(maildirect, O_RDWR)) < 0) { RespondProtocol(WORK_ERROR); return; } if (lseek(fd, FH_SIZE * (start - 1), SEEK_SET) == -1) { RespondProtocol(WORK_ERROR); close(fd); return; } RespondProtocol(OK_CMD); net_cache_init(); for (i = start; i <= end; i++) { if (read(fd, &fh, FH_SIZE) == FH_SIZE) { if (fh.accessed & FILE_DELE) mail_state = 'D'; /* deleted mail */ else if (fh.accessed & FILE_READ) mail_state = 'R'; /* readed mail */ else mail_state = 'N'; /* new mail */ date = atol((fh.filename) + 2); strftime(chdate, 6, "%m/%d", localtime(&date)); chk_str2(fh.owner); chk_str2(fh.title); if (curuser.ident == 7) c = fh.ident + '0'; else c = '*'; if (mail_state != 'D') net_cache_printf("%d\t%c\t%c\t%s\t%s\t%s\r\n", i, mail_state, c, fh.owner, chdate, fh.title); else net_cache_printf("%d\t%c\t%c\t%s\t%s\r\n", i, mail_state, c, fh.owner, chdate); } else break; } close(fd); net_cache_write(".\r\n", 3); /* end */ net_cache_refresh(); }