summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-08-06 16:58:25 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-08-06 16:58:25 +0800
commite436c3626d57e536d2f1891c16ac7e6760a7fc40 (patch)
treee50baa94bde29c5b7e193947b4cb72c38a93839d
parent56770ab2f36d9be01f889f99d55d5d50fad7da4f (diff)
downloadpttbbs-e436c3626d57e536d2f1891c16ac7e6760a7fc40.tar
pttbbs-e436c3626d57e536d2f1891c16ac7e6760a7fc40.tar.gz
pttbbs-e436c3626d57e536d2f1891c16ac7e6760a7fc40.tar.bz2
pttbbs-e436c3626d57e536d2f1891c16ac7e6760a7fc40.tar.lz
pttbbs-e436c3626d57e536d2f1891c16ac7e6760a7fc40.tar.xz
pttbbs-e436c3626d57e536d2f1891c16ac7e6760a7fc40.tar.zst
pttbbs-e436c3626d57e536d2f1891c16ac7e6760a7fc40.zip
general outta_swap
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk@455 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/mbbsd/board.c24
-rw-r--r--pttbbs/mbbsd/cache.c30
2 files changed, 34 insertions, 20 deletions
diff --git a/pttbbs/mbbsd/board.c b/pttbbs/mbbsd/board.c
index d665360f..9f20b645 100644
--- a/pttbbs/mbbsd/board.c
+++ b/pttbbs/mbbsd/board.c
@@ -1,4 +1,4 @@
-/* $Id: board.c,v 1.46 2002/08/06 08:43:06 in2 Exp $ */
+/* $Id: board.c,v 1.47 2002/08/06 08:58:25 in2 Exp $ */
#include "bbs.h"
#define BRC_STRLEN 15 /* Length of board name */
#define BRC_MAXSIZE 24576
@@ -1018,26 +1018,12 @@ choose_board(int newflag)
if (!(ptr->myattr & BRD_ZAP))
zapbuf[ptr->bid - 1] = now;
#ifdef OUTTA_CACHE
- {
- int fd;
- char fn[64];
- sprintf(fn, "cache/" MYHOSTNAME ".b%d", currpid);
- if( (fd = open(fn, O_WRONLY | O_CREAT, 0600)) < 0 )
- abort_bbs(0);
- write(fd, nbrd, nbrdlength);
- close(fd);
- free(nbrd);
+ outta_swapout(&nbrd, nbrdlength, 'b');
#endif
- Read();
+ Read();
#ifdef OUTTA_CACHE
- if( (fd = open(fn, O_RDONLY)) < 0 )
- abort_bbs(0);
- nbrd = (boardstat_t *) malloc(nbrdlength);
- read(fd, nbrd, nbrdlength);
- close(fd);
- unlink(fn);
- ptr = &nbrd[num];
- }
+ outta_swapin(&nbrd, nbrdlength, 'b');
+ ptr = &nbrd[num];
#endif
check_newpost(ptr);
head = -1;
diff --git a/pttbbs/mbbsd/cache.c b/pttbbs/mbbsd/cache.c
index 2ddfefb4..630390c1 100644
--- a/pttbbs/mbbsd/cache.c
+++ b/pttbbs/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