summaryrefslogtreecommitdiffstats
path: root/mbbsd/brc.c
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-05-24 08:31:48 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-05-24 08:31:48 +0800
commit0d1688520003011abbcb9c37074f2c2dce88f72a (patch)
tree2c02e8a6fdcef4191ef2ae45c10fb6ce63bf2172 /mbbsd/brc.c
parent919bd1cabc73f19279bd94f8bbae1b26bee84e87 (diff)
downloadpttbbs-0d1688520003011abbcb9c37074f2c2dce88f72a.tar
pttbbs-0d1688520003011abbcb9c37074f2c2dce88f72a.tar.gz
pttbbs-0d1688520003011abbcb9c37074f2c2dce88f72a.tar.bz2
pttbbs-0d1688520003011abbcb9c37074f2c2dce88f72a.tar.lz
pttbbs-0d1688520003011abbcb9c37074f2c2dce88f72a.tar.xz
pttbbs-0d1688520003011abbcb9c37074f2c2dce88f72a.tar.zst
pttbbs-0d1688520003011abbcb9c37074f2c2dce88f72a.zip
Merge from scw.angel.
*NOTE* Before running this revision, please read PttCurrent board at telnet://ptt.cc or http://scwg.wiki.ptt.cc/-Angel git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2014 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/brc.c')
-rw-r--r--mbbsd/brc.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/mbbsd/brc.c b/mbbsd/brc.c
index 7ad5e30c..7ba1f40e 100644
--- a/mbbsd/brc.c
+++ b/mbbsd/brc.c
@@ -9,7 +9,7 @@
#define BRC_BLOCKSIZE 1024
-#if MAX_BOARD > 32767 || BRC_MAXSIZE > 32767
+#if MAX_BOARD > 65535 || BRC_MAXSIZE > 65535
#error Max number of boards or BRC_MAXSIZE cannot fit in unsighed short, \
please rewrite brc.c
#endif
@@ -109,13 +109,10 @@ brc_putrecord(char *ptr, char *endp, brcbid_t bid, brcnbrd_t num, const time_t *
{
char * tmp;
if (num > 0 && list[0] > brc_expire_time &&
- ptr + sizeof(brcbid_t) + sizeof(brcnbrd_t) <= endp) {
+ ptr + sizeof(brcbid_t) + sizeof(brcnbrd_t) < endp) {
if (num > BRC_MAXNUM)
num = BRC_MAXNUM;
- while (num > 0 && list[num - 1] < brc_expire_time)
- num--; /* don't write the times before brc_expire_time */
-
if (num == 0) return ptr;
*(brcbid_t*)ptr = bid; /* write in bid */
@@ -164,7 +161,6 @@ brc_insert_record(brcbid_t bid, brcnbrd_t num, time_t* list)
ptr = brc_findrecord_in(brc_buf, brc_buf + brc_size, bid, &tnum);
- /* FIXME: this loop is copied from brc_putrecord() */
while (num > 0 && list[num - 1] < brc_expire_time)
num--; /* don't write the times before brc_expire_time */
@@ -172,8 +168,9 @@ brc_insert_record(brcbid_t bid, brcnbrd_t num, time_t* list)
brc_size -= tnum;
/* put on the beginning */
- if (num && (new_size =
- sizeof(brcbid_t) + sizeof(brcnbrd_t) + num * sizeof(time_t))){
+ if (num){
+ new_size = sizeof(brcbid_t) + sizeof(brcnbrd_t)
+ + num * sizeof(time_t);
brc_size += new_size;
if (brc_size > brc_alloc && !brc_enlarge_buf())
brc_size = BRC_MAXSIZE;
@@ -191,7 +188,7 @@ brc_insert_record(brcbid_t bid, brcnbrd_t num, time_t* list)
int sindex = ptr - brc_buf;
new_size = sizeof(brcbid_t) + sizeof(brcnbrd_t)
+ num * sizeof(time_t);
- brc_size += new_size - (tmpp - ptr);
+ brc_size += new_size - len;
if (brc_size > brc_alloc) {
if (brc_enlarge_buf()) {
ptr = brc_buf + sindex;
@@ -206,7 +203,7 @@ brc_insert_record(brcbid_t bid, brcnbrd_t num, time_t* list)
brc_putrecord(ptr, brc_buf + brc_alloc, bid, num, list);
} else { /* deleting record */
memmove(ptr, tmpp, end_size);
- brc_size -= (tmpp - ptr);
+ brc_size -= len;
}
}
@@ -336,6 +333,8 @@ brc_initial_board(const char *boardname)
brc_update(); /* write back first */
currbid = getbnum(boardname);
+ if( currbid == 0 )
+ currbid = getbnum(DEFAULT_BOARD);
currboard = bcache[currbid - 1].brdname;
currbrdattr = bcache[currbid - 1].brdattr;