summaryrefslogtreecommitdiffstats
path: root/mbbsd/cache.c
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-12 12:16:35 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-12 12:16:35 +0800
commitfda6d63bafd474518327879633b2231a5aaa6825 (patch)
tree5b3d291865da567e4ff0592facb0d58913a480bb /mbbsd/cache.c
parent3f76b17cecfae6af61240a7ef9e5f21118e39f40 (diff)
downloadpttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar.gz
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar.bz2
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar.lz
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar.xz
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar.zst
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.zip
rewrite few lines.
comment on strange lines. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2496 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/cache.c')
-rw-r--r--mbbsd/cache.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index c5936331..3f989885 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -555,17 +555,14 @@ reload_bcache(void)
for( i = 0 ; i < MAX_BOARD ; ++i )
if( SHM->bcache[i].brdname[0] ){
char fn[128];
- struct stat st;
+ int n;
sprintf(fn, "boards/%c/%s/.DIR.bottom",
SHM->bcache[i].brdname[0],
SHM->bcache[i].brdname);
- if( stat(fn, &st) == -1 )
- SHM->n_bottom[i] = 0;
- else {
- SHM->n_bottom[i] = st.st_size / sizeof(fileheader_t);
- if( SHM->n_bottom[i] > 5 )
- SHM->n_bottom[i] = 5;
- }
+ n = get_num_records(fn, sizeof(fileheader_t));
+ if( n > 5 )
+ n = 5;
+ SHM->n_bottom[i] = n;
}
}
@@ -608,7 +605,6 @@ reset_board(int bid) /* XXXbid: from 1 */
safe_sleep(1);
} else {
SHM->busystate_b[bid] = COMMON_TIME;
- nuser = bcache[bid].nuser;
bhdr = bcache;
bhdr += bid;
@@ -757,9 +753,8 @@ 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));
+ strlcpy(s, bcache[bid-1].BM, sizeof(s));
for( i = 0 ; s[i] != 0 ; ++i )
if( !isalpha((int)s[i]) && !isdigit((int)s[i]) )
s[i] = ' ';
@@ -768,14 +763,15 @@ void buildBMcache(int bid) /* bid starts from 1 */
i < MAX_BMs && ptr != NULL ;
ptr = strtok(NULL, " "), ++i )
if( (uid = searchuser(ptr)) != 0 )
- SHM->BMcache[bid][i] = uid;
+ SHM->BMcache[bid-1][i] = uid;
for( ; i < MAX_BMs ; ++i )
- SHM->BMcache[bid][i] = -1;
+ SHM->BMcache[bid-1][i] = -1;
}
int is_BM_cache(int bid) /* bid starts from 1 */
{
--bid;
+ // XXX hard coded MAX_BMs=4
if( currutmp->uid == SHM->BMcache[bid][0] ||
currutmp->uid == SHM->BMcache[bid][1] ||
currutmp->uid == SHM->BMcache[bid][2] ||
@@ -822,8 +818,8 @@ reload_pttcache(void)
subitem.filename);
if (!(fp2 = fopen(buf, "r")))
continue;
- fread(SHM->notes[id], sizeof(char), 200 * 11, fp2);
- SHM->notes[id][200 * 11 - 1] = 0;
+ fread(SHM->notes[id], sizeof(char), sizeof(SHM->notes[0]), fp2);
+ SHM->notes[id][sizeof(SHM->notes[0]) - 1] = 0;
id++;
fclose(fp2);
if (id >= MAX_MOVIE)
@@ -986,7 +982,7 @@ hbflreload(int bid)
fclose(fp);
}
hbfl[0] = COMMON_TIME;
- memcpy(SHM->hbfl[bid], hbfl, sizeof(hbfl));
+ memcpy(SHM->hbfl[bid], hbfl, sizeof(hbfl)); // FIXME bid-1 ?
}
int
@@ -994,6 +990,7 @@ hbflcheck(int bid, int uid)
{
int i;
+ // FIXME bid-1?
if (SHM->hbfl[bid][0] < login_start_time - HBFLexpire)
hbflreload(bid);
for (i = 1; SHM->hbfl[bid][i] != 0 && i <= MAX_FRIEND; ++i) {