summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/Makefile5
-rw-r--r--mbbsd/announce.c9
-rw-r--r--mbbsd/bbs.c5
-rw-r--r--mbbsd/board.c7
-rw-r--r--mbbsd/cache.c307
-rw-r--r--mbbsd/mail.c8
-rw-r--r--mbbsd/mbbsd.c17
-rw-r--r--mbbsd/stuff.c23
-rw-r--r--mbbsd/toolkit.c13
-rw-r--r--mbbsd/var.c4
10 files changed, 220 insertions, 178 deletions
diff --git a/mbbsd/Makefile b/mbbsd/Makefile
index 7d16b04f..5762a2d7 100644
--- a/mbbsd/Makefile
+++ b/mbbsd/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.28 2003/07/06 03:41:08 in2 Exp $
+# $Id: Makefile,v 1.29 2003/07/20 00:55:34 in2 Exp $
.include "../pttbbs.mk"
@@ -14,8 +14,7 @@ OBJS= admin.o announce.o args.o bbs.o board.o cache.o cal.o card.o\
kaede.o lovepaper.o mail.o mbbsd.o menu.o more.o name.o osdep.o\
othello.o page.o read.o record.o register.o screen.o stuff.o\
talk.o term.o topsong.o user.o vice.o vote.o xyz.o\
- voteboard.o syspost.o var.o toolkit.o passwd.o\
- calendar.o
+ voteboard.o syspost.o var.o passwd.o calendar.o
.SUFFIXES: .c .o
.c.o: ../include/var.h
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index f0db7535..92b89d7f 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -1,4 +1,4 @@
-/* $Id: announce.c,v 1.30 2003/07/06 03:41:08 in2 Exp $ */
+/* $Id: announce.c,v 1.31 2003/07/20 00:55:34 in2 Exp $ */
#include "bbs.h"
#define PATHLEN 256
@@ -863,7 +863,8 @@ a_menu(char *maintitle, char *path, int lastlevel)
還是檔案竟然是用 fstat(2) 而不是直接存在 .DIR 內 |||b
須等該資料寫入 .DIR 內再 implement才有效率.
*/
- if( !lastlevel && !HAS_PERM(PERM_SYSOP) && !HAS_PERM(PERM_SYSSUBOP) && !is_BM(bcache[currbid - 1].BM) &&
+ if( !lastlevel && !HAS_PERM(PERM_SYSOP) &&
+ !HAS_PERM(PERM_SYSSUBOP) && is_BM_cache(currbid) &&
dashd(fname) )
vmsg("只有板主才可以拷貝目錄唷!");
else
@@ -961,7 +962,7 @@ a_menu(char *maintitle, char *path, int lastlevel)
#ifdef BLOG
case 'b':
- if( !HAS_PERM(SYSOP) && !is_BM(bcache[currbid - 1].BM) )
+ if( !HAS_PERM(PERM_SYSOP) && !is_BM_cache(currbid) )
vmsg("只有板主才可以用唷!");
else{
char genbuf[128];
@@ -974,7 +975,7 @@ a_menu(char *maintitle, char *path, int lastlevel)
break;
case 'B':
- if( !HAS_PERM(SYSOP) && !is_BM(bcache[currbid - 1].BM) )
+ if( !HAS_PERM(SYSOP) && !is_BM_cache(currbid) )
vmsg("只有板主才可以用唷!");
else
BlogMain(me.now);
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index a113b03d..3aaae9c2 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1,4 +1,4 @@
-/* $Id: bbs.c,v 1.103 2003/07/06 23:09:25 kcwu Exp $ */
+/* $Id: bbs.c,v 1.104 2003/07/20 00:55:34 in2 Exp $ */
#include "bbs.h"
static int recommend(int ent, fileheader_t * fhdr, char *direct);
@@ -121,7 +121,7 @@ set_board()
bp->title + 7);
currmode = (currmode & (MODE_DIRTY | MODE_MENU)) | MODE_STARTED;
- if (HAS_PERM(PERM_ALLBOARD) || is_BM(bp->BM))
+ if (HAS_PERM(PERM_ALLBOARD) || is_BM_cache(currbid))
currmode = currmode | MODE_BOARD | MODE_POST;
else if (haspostperm(currboard))
currmode |= MODE_POST;
@@ -1466,6 +1466,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
if (!not_owned && strcmp(currboard, "Test")) {
if (cuser.numposts)
cuser.numposts--;
+ /* XXX: is_BM(cuser.userid) is always true @_@ */
if (!(currmode & MODE_DIGEST && is_BM(cuser.userid))){
move(b_lines - 1, 0);
clrtoeol();
diff --git a/mbbsd/board.c b/mbbsd/board.c
index 415dabe1..7351d1e9 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -1,4 +1,4 @@
-/* $Id: board.c,v 1.132 2003/07/03 03:37:39 victor Exp $ */
+/* $Id: board.c,v 1.133 2003/07/20 00:55:34 in2 Exp $ */
#include "bbs.h"
#define BRC_STRLEN 15 /* Length of board name */
#define BRC_MAXSIZE 24576
@@ -575,7 +575,6 @@ int
Ben_Perm(boardheader_t * bptr)
{
register int level, brdattr;
- register char *ptr;
level = bptr->level;
brdattr = bptr->brdattr;
@@ -583,8 +582,7 @@ Ben_Perm(boardheader_t * bptr)
if (HAS_PERM(PERM_SYSOP))
return 1;
- ptr = bptr->BM;
- if (is_BM(ptr))
+ if( is_BM_cache(bptr - bcache + 1) ) /* XXXbid */
return 1;
/* 祕密看板:核對首席板主的好友名單 */
@@ -688,6 +686,7 @@ load_uidofgid(const int gid, const int type)
else
currbptr->next[type] = (boardheader_t *) ~ 0;
}
+
static boardstat_t *
addnewbrdstat(int n, int state)
{
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index fb7baca8..ad2d7a7d 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -1,15 +1,10 @@
-/* $Id: cache.c,v 1.62 2003/06/07 14:19:12 kcwu Exp $ */
+/* $Id: cache.c,v 1.63 2003/07/20 00:55:34 in2 Exp $ */
#include "bbs.h"
-#ifndef __FreeBSD__
-union semun {
- int val; /* value for SETVAL */
- struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
- unsigned short int *array; /* array for GETALL, SETALL */
- struct seminfo *__buf; /* buffer for IPC_INFO */
-};
+#ifdef _BBS_UTIL_C_
+# define log_usies(a, b) ;
+# define abort_bbs(a) exit(1)
#endif
-
/*
* the reason for "safe_sleep" is that we may call sleep during SIGALRM
* handler routine, while SIGALRM is blocked. if we use the original sleep,
@@ -25,9 +20,7 @@ safe_sleep(unsigned int seconds)
sigprocmask(SIG_BLOCK, &set, &oldset);
if (sigismember(&oldset, SIGALRM)) {
unsigned long retv;
-#if !defined(_BBS_UTIL_C_)
log_usies("SAFE_SLEEP ", "avoid hang");
-#endif
sigemptyset(&set);
sigaddset(&set, SIGALRM);
sigprocmask(SIG_UNBLOCK, &set, NULL);
@@ -38,22 +31,9 @@ safe_sleep(unsigned int seconds)
return sleep(seconds);
}
-#if defined(_BBS_UTIL_C_)
-static void
-setapath(char *buf, char *boardname)
-{
- snprintf(buf, "man/boards/%c/%s", boardname[0], boardname);
-}
-
-static char *str_dotdir = ".DIR";
-
-static void
-setadir(char *buf, char *path)
-{
- sprintf(buf, "%s/%s", path, str_dotdir);
-}
-#endif
-
+/*
+ * section - SHM
+ */
static void
attach_err(int shmkey, char *name)
{
@@ -70,7 +50,7 @@ attach_shm(int shmkey, int shmsize)
shmid = shmget(shmkey, shmsize, 0);
if (shmid < 0) {
- // SHM should be created by uhash_loader, NOT mbbsd.
+ // SHM should be created by uhash_loader, NOT mbbsd or other utils
attach_err(shmkey, "shmget");
} else {
shmptr = (void *)shmat(shmid, NULL, 0);
@@ -81,12 +61,40 @@ attach_shm(int shmkey, int shmsize)
return shmptr;
}
+void
+attach_SHM(void)
+{
+ SHM = attach_shm(SHM_KEY, sizeof(SHM_t));
+ if (!SHM->loaded) /* (uhash) assume fresh shared memory is
+ * zeroed */
+ exit(1);
+ if (SHM->Btouchtime == 0)
+ SHM->Btouchtime = 1;
+ bcache = SHM->bcache;
-#define SEM_FLG 0600 /* semaphore mode */
+ GLOBALVAR = SHM->GLOBALVAR;
+ if (SHM->Ptouchtime == 0)
+ SHM->Ptouchtime = 1;
+
+ if (SHM->Ftouchtime == 0)
+ SHM->Ftouchtime = 1;
+}
/* ----------------------------------------------------- */
/* semaphore : for critical section */
/* ----------------------------------------------------- */
+#define SEM_FLG 0600 /* semaphore mode */
+
+#ifndef __FreeBSD__
+/* according to X/OPEN, we have to define it ourselves */
+union semun {
+ int val; /* value for SETVAL */
+ struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
+ unsigned short int *array; /* array for GETALL, SETALL */
+ struct seminfo *__buf; /* buffer for IPC_INFO */
+};
+#endif
+
void
sem_init(int semkey, int *semid)
{
@@ -116,6 +124,9 @@ sem_lock(int op, int semid)
}
}
+/*
+ * section - user cache(including uhash)
+ */
/* uhash ****************************************** */
/*
* the design is this: we use another stand-alone program to create and load
@@ -127,27 +138,6 @@ sem_lock(int op, int semid)
* loaded yet.
*/
-/* attach_uhash should be called before using uhash */
-
-void
-attach_SHM(void)
-{
- SHM = attach_shm(SHM_KEY, sizeof(SHM_t));
- if (!SHM->loaded) /* (uhash) assume fresh shared memory is
- * zeroed */
- exit(1);
- if (SHM->Btouchtime == 0)
- SHM->Btouchtime = 1;
- bcache = SHM->bcache;
-
- GLOBALVAR = SHM->GLOBALVAR;
- if (SHM->Ptouchtime == 0)
- SHM->Ptouchtime = 1;
-
- if (SHM->Ftouchtime == 0)
- SHM->Ftouchtime = 1;
-}
-
void
add_to_uhash(int n, char *id)
{
@@ -166,13 +156,13 @@ add_to_uhash(int n, char *id)
SHM->next_in_hash[*p = n] = -1;
}
+void
+remove_from_uhash(int n)
+{
/*
* note: after remove_from_uhash(), you should add_to_uhash() (likely with a
* different name)
*/
-void
-remove_from_uhash(int n)
-{
int h = StringHash(SHM->userid[n]);
int *p = &(SHM->hash_head[h]);
int times;
@@ -188,32 +178,6 @@ remove_from_uhash(int n)
}
int
-setumoney(int uid, int money)
-{
- SHM->money[uid - 1] = money;
- passwd_update_money(uid);
- return SHM->money[uid - 1];
-}
-
-int
-deumoney(int uid, int money)
-{
- if (money < 0 && SHM->money[uid - 1] < -money)
- return setumoney(uid, 0);
- else
- return setumoney(uid, SHM->money[uid - 1] + money);
-}
-int
-demoney(int money)
-{
- return deumoney(usernum, money);
-}
-int
-moneyof(int uid)
-{ /* ptt 改進金錢處理效率 */
- return SHM->money[uid - 1];
-}
-int
searchuser(char *userid)
{
int h, p, times;
@@ -231,8 +195,6 @@ searchuser(char *userid)
return 0;
}
-#if !defined(_BBS_UTIL_C_)
-
int
getuser(char *userid)
{
@@ -284,6 +246,7 @@ searchnewuser(int mode)
return 0;
}
+#ifndef _BBS_UTIL_C_
char *
u_namearray(char buf[][IDLEN + 1], int *pnum, char *tag)
{
@@ -315,30 +278,10 @@ u_namearray(char buf[][IDLEN + 1], int *pnum, char *tag)
}
#endif
-/*-------------------------------------------------------*/
-/* .UTMP cache */
-/*-------------------------------------------------------*/
-#if !defined(_BBS_UTIL_C_)
-void
-setutmpmode(unsigned int mode)
-{
- if (currstat != mode)
- currutmp->mode = currstat = mode;
-
- /* 追蹤使用者 */
- if (HAS_PERM(PERM_LOGUSER)) {
- char msg[200];
- snprintf(msg, sizeof(msg), "%s setutmpmode to %s(%d) at %s",
- cuser.userid, modestring(currutmp, 0), mode, Cdate(&now));
- log_user(msg);
- }
-}
-#endif
-
-/* Ptt:這裡加上 hash 觀念找空的 utmp */
void
getnewutmpent(userinfo_t * up)
{
+/* Ptt:這裡加上 hash 觀念找空的 utmp */
register int i, p;
register userinfo_t *uentp;
for (i = 0, p = StringHash(up->userid) % USHM_SIZE; i < USHM_SIZE; i++, p++) {
@@ -375,7 +318,6 @@ search_ulist(int uid)
return search_ulistn(uid, 1);
}
-#if !defined(_BBS_UTIL_C_)
userinfo_t *
search_ulist_pid(int pid)
{
@@ -401,6 +343,7 @@ search_ulist_pid(int pid)
}
return 0;
}
+
userinfo_t *
search_ulistn(int uid, int unum)
{
@@ -432,6 +375,7 @@ search_ulistn(int uid, int unum)
}
return 0;
}
+
userinfo_t *
search_ulist_userid(char *userid)
{
@@ -458,6 +402,7 @@ search_ulist_userid(char *userid)
return 0;
}
+#ifndef _BBS_UTIL_C_
int
count_logins(int uid, int show)
{
@@ -491,7 +436,6 @@ count_logins(int uid, int show)
return 0;
}
-
void
purge_utmp(userinfo_t * uentp)
{
@@ -499,12 +443,68 @@ purge_utmp(userinfo_t * uentp)
memset(uentp, 0, sizeof(userinfo_t));
SHM->UTMPneedsort = 1;
}
+#endif
+
+/*
+ * section - money cache
+ */
+int
+setumoney(int uid, int money)
+{
+ SHM->money[uid - 1] = money;
+ passwd_update_money(uid);
+ return SHM->money[uid - 1];
+}
+
+int
+deumoney(int uid, int money)
+{
+ if (money < 0 && SHM->money[uid - 1] < -money)
+ return setumoney(uid, 0);
+ else
+ return setumoney(uid, SHM->money[uid - 1] + money);
+}
+
+int
+demoney(int money)
+{
+ return deumoney(usernum, money);
+}
+
+int
+moneyof(int uid)
+{ /* ptt 改進金錢處理效率 */
+ return SHM->money[uid - 1];
+}
+
+/*
+ * section - utmp
+ */
+#if !defined(_BBS_UTIL_C_) /* _BBS_UTIL_C_ 不會有 utmp */
+void
+setutmpmode(unsigned int mode)
+{
+ if (currstat != mode)
+ currutmp->mode = currstat = mode;
+ /* 追蹤使用者 */
+ if (HAS_PERM(PERM_LOGUSER)) {
+ char msg[200];
+ snprintf(msg, sizeof(msg), "%s setutmpmode to %s(%d) at %s",
+ cuser.userid, modestring(currutmp, 0), mode, Cdate(&now));
+ log_user(msg);
+ }
+}
#endif
-/*-------------------------------------------------------*/
-/* .BOARDS cache */
-/*-------------------------------------------------------*/
+/*
+ * section - board cache
+ */
+void touchbtotal(int bid) {
+ SHM->total[bid - 1] = 0;
+ SHM->lastposttime[bid - 1] = 0;
+}
+
void
touchdircache(int bid)
{
@@ -552,19 +552,22 @@ get_fileheader_cache(int bid, char *direct, fileheader_t * headers,
memcpy(headers, &(SHM->dircache[bid - 1][n]), sizeof(fileheader_t) * ret);
return ret;
}
+
static int
cmpboardname(boardheader_t ** brd, boardheader_t ** tmp)
{
return strcasecmp((*brd)->brdname, (*tmp)->brdname);
}
+
static int
cmpboardclass(boardheader_t ** brd, boardheader_t ** tmp)
{
return (strncmp((*brd)->title, (*tmp)->title, 4) << 8) +
strcasecmp((*brd)->brdname, (*tmp)->brdname);
}
+
static void
-sort_bcache()
+sort_bcache(void)
{
int i;
/* critical section 不能單獨呼叫 呼叫reload_bcache or reset_board */
@@ -576,13 +579,13 @@ sort_bcache()
qsort(SHM->bsorted[1], SHM->Bnumber, sizeof(boardheader_t *),
(QCAST) cmpboardclass);
}
-static void
-reload_bcache()
+
+void
+reload_bcache(void)
{
if (SHM->Bbusystate) {
safe_sleep(1);
}
-#if !defined(_BBS_UTIL_C_)
else {
int fd, i;
@@ -604,11 +607,9 @@ reload_bcache()
}
SHM->Bbusystate = 0;
}
-#endif
}
-void
-resolve_boards()
+void resolve_boards(void)
{
while (SHM->Buptime < SHM->Btouchtime) {
reload_bcache();
@@ -616,35 +617,32 @@ resolve_boards()
numboards = SHM->Bnumber;
}
-void
-touch_boards()
+void touch_boards(void)
{
SHM->Btouchtime = now;
numboards = -1;
resolve_boards();
}
-void
-addbrd_touchcache()
+void addbrd_touchcache(void)
{
SHM->Bnumber++;
numboards = SHM->Bnumber;
reset_board(numboards);
}
-#if !defined(_BBS_UTIL_C_)
+
void
-reset_board(int bid)
+reset_board(int bid) /* XXXbid: from 1 */
{ /* Ptt: 這樣就不用老是touch board了 */
int fd, i, nuser;
boardheader_t *bhdr;
-
if (--bid < 0)
return;
- if (SHM->Bbusystate || now - SHM->busystate_b[bid - 1] < 10) {
+ if (SHM->Bbusystate || now - SHM->busystate_b[bid] < 10) {
safe_sleep(1);
} else {
- SHM->busystate_b[bid - 1] = now;
- nuser = bcache[bid - 1].nuser;
+ SHM->busystate_b[bid] = now;
+ nuser = bcache[bid].nuser;
bhdr = bcache;
bhdr += bid;
@@ -658,11 +656,13 @@ reset_board(int bid)
bcache[i].firstchild[0] = NULL;
bcache[i].firstchild[1] = NULL;
}
- nuser = bcache[bid - 1].nuser;
- SHM->busystate_b[bid - 1] = 0;
+ SHM->busystate_b[bid] = 0;
+
+ buildBMcache(bid + 1); /* XXXbid */
}
}
+#ifndef _BBS_UTIL_C_ /* because of Ben_Perm() in board.c */
int
apply_boards(int (*func) (boardheader_t *))
{
@@ -683,11 +683,13 @@ getbcache(int bid)
{ /* Ptt改寫 */
return bcache + bid - 1;
}
+
int
getbtotal(int bid)
{
return SHM->total[bid - 1];
}
+
void
setbtotal(int bid)
{
@@ -725,7 +727,6 @@ touchbpostnum(int bid, int delta)
*total += delta;
}
-
int
getbnum(char *bname)
{
@@ -748,7 +749,6 @@ getbnum(char *bname)
return 0;
}
-#if !defined(_BBS_UTIL_C_)
int
haspostperm(char *bname)
{
@@ -784,14 +784,46 @@ haspostperm(char *bname)
return HAS_PERM(i & ~PERM_POST);
}
-#endif
+
+void buildBMcache(int bid) /* bid starts from 1 */
+{
+ char s[IDLEN * 3 + 3], *ptr;
+ int i, uid;
+ --bid;
+
+ strncpy(s, bcache[bid].BM, sizeof(s));
+ for( i = 0 ; s[i] != 0 ; ++i )
+ if( !isalpha(s[i]) && !isdigit(s[i]) )
+ s[i] = ' ';
+
+ for( ptr = strtok(s, " "), i = 0 ;
+ i < MAX_BMs && ptr != NULL ;
+ ptr = strtok(NULL, " "), ++i )
+ if( (uid = searchuser(ptr)) != 0 )
+ SHM->BMcache[bid][i] = uid;
+ for( ; i < MAX_BMs ; ++i )
+ SHM->BMcache[bid][i] = -1;
+}
+
+int is_BM_cache(int bid) /* bid starts from 1 */
+{
+ --bid;
+ if( currutmp->uid == SHM->BMcache[bid][0] ||
+ currutmp->uid == SHM->BMcache[bid][1] ||
+ currutmp->uid == SHM->BMcache[bid][2] ||
+ currutmp->uid == SHM->BMcache[bid][3] ){
+ cuser.userlevel |= PERM_BM;
+ return 1;
+ }
+ return 0;
+}
/*-------------------------------------------------------*/
/* PTT cache */
/*-------------------------------------------------------*/
-/* cachefor 動態看板 */
+/* cache for 動態看板 */
void
-reload_pttcache()
+reload_pttcache(void)
{
if (SHM->Pbusystate)
safe_sleep(1);
@@ -855,15 +887,13 @@ reload_pttcache()
/* 等所有資料更新後再設定 uptime */
SHM->Puptime = SHM->Ptouchtime;
-#if !defined(_BBS_UTIL_C_)
log_usies("CACHE", "reload pttcache");
-#endif
SHM->Pbusystate = 0;
}
}
void
-resolve_garbage()
+resolve_garbage(void)
{
int count = 0;
@@ -887,9 +917,9 @@ resolve_garbage()
/*-------------------------------------------------------*/
/* PTT's cache */
/*-------------------------------------------------------*/
-/* cachefor from host 與最多上線人數 */
+/* cache for from host 與最多上線人數 */
static void
-reload_fcache()
+reload_fcache(void)
{
if (SHM->Fbusystate)
safe_sleep(1);
@@ -931,12 +961,15 @@ reload_fcache()
}
void
-resolve_fcache()
+resolve_fcache(void)
{
while (SHM->Fuptime < SHM->Ftouchtime)
reload_fcache();
}
+/*
+ * section - hbfl (hidden board friend list)
+ */
void
hbflreload(int bid)
{
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index 70549fbe..ff434498 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -1,4 +1,4 @@
-/* $Id: mail.c,v 1.27 2003/05/19 07:10:19 in2 Exp $ */
+/* $Id: mail.c,v 1.28 2003/07/20 00:55:34 in2 Exp $ */
#include "bbs.h"
char currmaildir[32];
static char msg_cc[] = "\033[32m[群組名單]\033[m\n";
@@ -1230,7 +1230,7 @@ mail_cite(int ent, fileheader_t * fhdr, char *direct)
char title[TTLEN + 1];
static char xboard[20];
char buf[20];
- boardheader_t *bp;
+ int bid;
setuserfile(fpath, fhdr->filename);
strlcpy(title, "◇ ", sizeof(title));
@@ -1253,11 +1253,11 @@ mail_cite(int ent, fileheader_t * fhdr, char *direct)
completeboard_getname);
if (*buf)
strlcpy(xboard, buf, sizeof(xboard));
- if (*xboard && (bp = getbcache(getbnum(xboard)))) {
+ if (*xboard && ((bid = getbnum(xboard)) >= 0)){ /* XXXbid */
setapath(fpath, xboard);
setutmpmode(ANNOUNCE);
a_menu(xboard, fpath, HAS_PERM(PERM_ALLBOARD) ? 2 :
- is_BM(bp->BM) ? 1 : 0);
+ is_BM_cache(bid) ? 1 : 0);
} else {
mail_man();
}
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index da5c6c94..4220f9b0 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -1,4 +1,4 @@
-/* $Id: mbbsd.c,v 1.89 2003/07/17 00:57:21 in2 Exp $ */
+/* $Id: mbbsd.c,v 1.90 2003/07/20 00:55:34 in2 Exp $ */
#include "bbs.h"
#define SOCKET_QLEN 4
@@ -162,7 +162,7 @@ u_exit(char *mode)
//userec_t xuser;
int diff = (time(0) - login_start_time) / 60;
- /* close fd 0 & a to terminate network */
+ /* close fd 0 & 1 to terminate network */
close(0);
close(1);
@@ -697,13 +697,16 @@ where(char *from)
#endif
static void
-check_BM()
+check_BM(void)
{
+ /* XXX: -_- */
int i;
- boardheader_t *bhdr;
cuser.userlevel &= ~PERM_BM;
- for (i = 0, bhdr = bcache; i < numboards && !is_BM(bhdr->BM); i++, bhdr++);
+ for( i = 0 ; i < numboards ; ++i )
+ if( is_BM_cache(i + 1) ) /* XXXbid */
+ return;
+ //for (i = 0, bhdr = bcache; i < numboards && !is_BM(bhdr->BM); i++, bhdr++);
}
static void
@@ -715,8 +718,6 @@ setup_utmp(int mode)
uinfo.uid = usernum;
uinfo.mode = currstat = mode;
uinfo.mailalert = load_mailalert(cuser.userid);
- if (!(cuser.numlogins % 20) && cuser.userlevel & PERM_BM)
- check_BM(); /* Ptt 自動取下離職板主權力 */
uinfo.userlevel = cuser.userlevel;
uinfo.sex = cuser.sex % 8;
@@ -749,6 +750,8 @@ setup_utmp(int mode)
uinfo.invisible = YEA;
getnewutmpent(&uinfo);
SHM->UTMPneedsort = 1;
+ if (!(cuser.numlogins % 20) && cuser.userlevel & PERM_BM)
+ check_BM(); /* Ptt 自動取下離職板主權力 */
#ifndef _BBS_UTIL_C_
friend_load();
nice(3);
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index a254b42c..80428954 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -1,4 +1,4 @@
-/* $Id: stuff.c,v 1.12 2003/06/28 08:47:45 kcwu Exp $ */
+/* $Id: stuff.c,v 1.13 2003/07/20 00:55:34 in2 Exp $ */
#include "bbs.h"
/* ----------------------------------------------------- */
@@ -336,6 +336,7 @@ belong(char *filelist, char *key)
return rc;
}
+#ifndef _BBS_UTIL_C_ /* getdata_buf */
time_t
gettime(int line, time_t dt)
{
@@ -361,6 +362,8 @@ gettime(int line, time_t dt)
} while ((endtime.tm_hour = atoi(yn)) < 0 || endtime.tm_hour > 23);
return mktime(&endtime);
}
+#endif
+
char *
Cdate(time_t * clock)
{
@@ -391,6 +394,8 @@ Cdatedate(time_t * clock)
return foo;
}
+#ifndef _BBS_UTIL_C_
+/* 這一區都是有關於畫面處理的, 故 _BBS_UTIL_C_ 不須要 */
static void
capture_screen()
{
@@ -619,6 +624,7 @@ show_help(char *helptext[])
}
pressanykey();
}
+#endif // _BBS_UTIL_C_
/* ----------------------------------------------------- */
/* use mmap() to malloc large memory in CRITICAL_MEMORY */
@@ -629,7 +635,7 @@ void *MALLOC(int size)
int *p;
p = (int *)mmap(NULL, (size + 4), PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
p[0] = size;
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(_BBS_UTIL_C_)
vmsg("critical malloc %d bytes", size);
#endif
return (void *)&p[1];
@@ -639,8 +645,19 @@ void FREE(void *ptr)
{
int size = ((int *)ptr)[-1];
munmap((void *)(&(((int *)ptr)[-1])), size);
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(_BBS_UTIL_C_)
vmsg("critical free %d bytes", size);
#endif
}
#endif
+
+unsigned
+StringHash(unsigned char *s)
+{
+ unsigned int v = 0;
+ while (*s) {
+ v = (v << 8) | (v >> 24);
+ v ^= toupper(*s++); /* note this is case insensitive */
+ }
+ return (v * 2654435769UL) >> (32 - HASH_BITS);
+}
diff --git a/mbbsd/toolkit.c b/mbbsd/toolkit.c
deleted file mode 100644
index 99f80e0b..00000000
--- a/mbbsd/toolkit.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* $Id: toolkit.c,v 1.4 2002/07/21 09:26:02 in2 Exp $ */
-#include "bbs.h"
-
-unsigned
-StringHash(unsigned char *s)
-{
- unsigned int v = 0;
- while (*s) {
- v = (v << 8) | (v >> 24);
- v ^= toupper(*s++); /* note this is case insensitive */
- }
- return (v * 2654435769UL) >> (32 - HASH_BITS);
-}
diff --git a/mbbsd/var.c b/mbbsd/var.c
index 59e40eb4..4ba3cf9e 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -1,4 +1,4 @@
-/* $Id: var.c,v 1.20 2003/07/06 23:09:25 kcwu Exp $ */
+/* $Id: var.c,v 1.21 2003/07/20 00:55:34 in2 Exp $ */
#define INCLUDE_VAR_H
#include "bbs.h"
@@ -591,6 +591,7 @@ unsigned char *adv_gomoku /* [978] */ =
/* name.c */
word_t *toplev;
+#ifndef _BBS_UTIL_C_
/* menu.c */
commands_t cmdlist[] = {
{admin, PERM_SYSOP | PERM_VIEWSYSOP, "00Admin 【 系統維護區 】"},
@@ -606,6 +607,7 @@ commands_t cmdlist[] = {
{Goodbye, 0, "GGoodbye 離開,再見……"},
{NULL, 0, NULL}
};
+#endif
/* friend.c */
/* Ptt 各種特別名單的檔名 */