diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-04-19 05:27:23 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-04-19 05:27:23 +0800 |
commit | 11e52b0142264ab2df6581daf65556d7e5a38c96 (patch) | |
tree | 9edb7f0f8f5c2a73b1ec9ac7d375467d2a118dbd /mbbsd | |
parent | 167c26cf38bebc8c0ce3efca5d8e26eff0b91432 (diff) | |
download | pttbbs-11e52b0142264ab2df6581daf65556d7e5a38c96.tar pttbbs-11e52b0142264ab2df6581daf65556d7e5a38c96.tar.gz pttbbs-11e52b0142264ab2df6581daf65556d7e5a38c96.tar.bz2 pttbbs-11e52b0142264ab2df6581daf65556d7e5a38c96.tar.lz pttbbs-11e52b0142264ab2df6581daf65556d7e5a38c96.tar.xz pttbbs-11e52b0142264ab2df6581daf65556d7e5a38c96.tar.zst pttbbs-11e52b0142264ab2df6581daf65556d7e5a38c96.zip |
patch MDCACHE
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@122 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/cache.c | 17 | ||||
-rw-r--r-- | mbbsd/more.c | 17 |
2 files changed, 17 insertions, 17 deletions
diff --git a/mbbsd/cache.c b/mbbsd/cache.c index b7a485ad..1be9d32a 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -1,4 +1,4 @@ -/* $Id: cache.c,v 1.17 2002/04/16 16:38:25 in2 Exp $ */ +/* $Id: cache.c,v 1.18 2002/04/18 21:27:23 in2 Exp $ */ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -1045,7 +1045,7 @@ int updatemdcache(const char *CPATH, const char *fpath) */ int len, sourcefd, targetfd; char buf[1024], *cpath; - cpath = (CPATH == NULL) ? cachepath(fpath) : CPATH; + cpath = (CPATH == NULL) ? cachepath(fpath) : (char *)CPATH; if( (sourcefd = open(fpath, O_RDONLY)) < 0 ) return -1; if( (targetfd = open(cpath, O_RDWR | O_CREAT, 0600)) < 0 ) @@ -1063,4 +1063,17 @@ int updatemdcache(const char *CPATH, const char *fpath) lseek(targetfd, 0, SEEK_SET); return targetfd; } + +int mdcacheopen(char *fpath) +{ + int fd; + char *cpath; + if( strncmp(fpath, "boards/", 7) && strncmp(fpath, "etc/", 4) ) + return open(fpath, O_RDONLY); + + if( (fd = open((cpath = cachepath(fpath)), O_RDONLY)) < 0 ) + return updatemdcache(cpath, fpath); + + return fd; +} #endif diff --git a/mbbsd/more.c b/mbbsd/more.c index 0ffc3793..b0c57611 100644 --- a/mbbsd/more.c +++ b/mbbsd/more.c @@ -1,4 +1,4 @@ -/* $Id: more.c,v 1.8 2002/04/16 15:27:54 in2 Exp $ */ +/* $Id: more.c,v 1.9 2002/04/18 21:27:23 in2 Exp $ */ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -233,20 +233,7 @@ int more(char *fpath, int promptend) { *search_str = 0; #ifdef MDCACHE - //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; - cpath = cachepath(fpath); - ++GLOBE[8]; - if( (fd = open(cpath, O_RDONLY)) >= 0 ) - ++GLOBE[9]; - else - if( (fd = updatemdcache(cpath, fpath)) < 0 ) - return -1; - } - else - fd = open (fpath, O_RDONLY, 0600); + fd = mdcacheopen(fpath); #else fd = open (fpath, O_RDONLY, 0600); #endif |