diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-08-06 16:58:25 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-08-06 16:58:25 +0800 |
commit | a2ab3f51c0451a715fc57be7379a87ce547869ff (patch) | |
tree | a09bb1bb0d7741ae7359e0e8173b46da6e2c05c8 /mbbsd/cache.c | |
parent | 1f2d1734d6fd8c4d1306b5f7eed66b1f88be3d21 (diff) | |
download | pttbbs-a2ab3f51c0451a715fc57be7379a87ce547869ff.tar pttbbs-a2ab3f51c0451a715fc57be7379a87ce547869ff.tar.gz pttbbs-a2ab3f51c0451a715fc57be7379a87ce547869ff.tar.bz2 pttbbs-a2ab3f51c0451a715fc57be7379a87ce547869ff.tar.lz pttbbs-a2ab3f51c0451a715fc57be7379a87ce547869ff.tar.xz pttbbs-a2ab3f51c0451a715fc57be7379a87ce547869ff.tar.zst pttbbs-a2ab3f51c0451a715fc57be7379a87ce547869ff.zip |
general outta_swap
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@455 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/cache.c')
-rw-r--r-- | mbbsd/cache.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/mbbsd/cache.c b/mbbsd/cache.c index 2ddfefb4..630390c1 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -1,4 +1,4 @@ -/* $Id: cache.c,v 1.45 2002/07/27 10:11:39 kcwu Exp $ */ +/* $Id: cache.c,v 1.46 2002/08/06 08:58:25 in2 Exp $ */ #include "bbs.h" #ifndef __FreeBSD__ @@ -1129,3 +1129,31 @@ mdcacheopen(char *fpath) return fd; } #endif + +#ifdef OUTTA_CACHE +void outta_swapout(void **ptr, int length, char cacheid) +{ + char fn[64]; + int fd; + sprintf(fn, "cache/" MYHOSTNAME "%c%d", cacheid, currpid); + if( (fd = open(fn, O_WRONLY | O_CREAT, 0600)) < 0 ) + abort_bbs(0); + write(fd, *ptr, length); + close(fd); + free(*ptr); + *ptr = NULL; +} + +void outta_swapin(void **ptr, int length, char cacheid) +{ + char fn[64]; + int fd; + sprintf(fn, "cache/" MYHOSTNAME "%c%d", cacheid, currpid); + if( (fd = open(fn, O_RDONLY)) < 0 ) + abort_bbs(0); + *ptr = (void *)malloc(length); + read(fd, *ptr, length); + close(fd); + unlink(fn); +} +#endif |