summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-04-16 22:55:31 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-04-16 22:55:31 +0800
commit2e1bff00761c0628c3f697eb2bf2fb8cc6341b0d (patch)
tree8c56c9bc35c197ac8386212168fbbc7b13dbbf44
parentd8ab24df1d1aa454e23d7ee162c160c27958192b (diff)
downloadpttbbs-2e1bff00761c0628c3f697eb2bf2fb8cc6341b0d.tar
pttbbs-2e1bff00761c0628c3f697eb2bf2fb8cc6341b0d.tar.gz
pttbbs-2e1bff00761c0628c3f697eb2bf2fb8cc6341b0d.tar.bz2
pttbbs-2e1bff00761c0628c3f697eb2bf2fb8cc6341b0d.tar.lz
pttbbs-2e1bff00761c0628c3f697eb2bf2fb8cc6341b0d.tar.xz
pttbbs-2e1bff00761c0628c3f697eb2bf2fb8cc6341b0d.tar.zst
pttbbs-2e1bff00761c0628c3f697eb2bf2fb8cc6341b0d.zip
revert to 1.9
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@115 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/cache.c21
-rw-r--r--mbbsd/more.c6
2 files changed, 13 insertions, 14 deletions
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index d62652a8..cbb042f2 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -1,4 +1,4 @@
-/* $Id: cache.c,v 1.15 2002/04/16 10:07:19 in2 Exp $ */
+/* $Id: cache.c,v 1.16 2002/04/16 14:55:31 in2 Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -1026,13 +1026,15 @@ int hbflcheck(int bid, int uid)
}
#ifdef MDCACHE
-void cachepath(char *cpath, const char *fpath)
+char *cachepath(const char *fpath)
{
+ static char cpath[128];
char *ptr;
- sprintf(cpath, "cache/%s", fpath);
+ snprintf(cpath, sizeof(cpath), "cache/%s", fpath);
for( ptr = &cpath[6] ; *ptr != 0 ; ++ptr )
if( *ptr == '/' )
*ptr = '.';
+ return cpath;
}
int updatemdcache(const char *CPATH, const char *fpath)
@@ -1043,10 +1045,7 @@ int updatemdcache(const char *CPATH, const char *fpath)
*/
int len, sourcefd, targetfd;
char buf[1024], *cpath;
- if( CPATH == NULL )
- cachepath(cpath = buf, fpath);
- else
- cpath = (char *)CPATH;
+ cpath = (CPATH == NULL) ? cachepath(fpath) : CPATH;
if( (sourcefd = open(fpath, O_RDONLY)) < 0 )
return -1;
if( (targetfd = open(cpath, O_RDWR | O_CREAT, 0600)) < 0 )
@@ -1057,10 +1056,10 @@ int updatemdcache(const char *CPATH, const char *fpath)
/* md is full? */
close(targetfd);
unlink(cpath);
+ return sourcefd;
}
- close(targetfd);
- lseek(sourcefd, 0, SEEK_SET);
-
- return sourcefd;
+ close(sourcefd);
+ lseek(targetfd, 0, SEEK_SET);
+ return targetfd;
}
#endif
diff --git a/mbbsd/more.c b/mbbsd/more.c
index 0a6cbb59..a932d585 100644
--- a/mbbsd/more.c
+++ b/mbbsd/more.c
@@ -1,4 +1,4 @@
-/* $Id: more.c,v 1.6 2002/04/15 19:56:53 in2 Exp $ */
+/* $Id: more.c,v 1.7 2002/04/16 14:55:31 in2 Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -236,8 +236,8 @@ int more(char *fpath, int promptend) {
//if(!promptend && strncmp(fpath,"home",4)){
if( strncmp(fpath, "boards/", 7) == 0 || strncmp(fpath, "etc/", 4) == 0 ){
/* we only cache boards/ and etc/ */
- char cpath[256];
- cachepath(cpath,fpath);
+ char *cpath;
+ cpath = cachepath(fpath);
++GLOBE[0];
if( (fd = open(cpath, O_RDONLY)) < 0 &&
(fd = updatemdcache(cpath, fpath)) < 0 )