summaryrefslogtreecommitdiffstats
path: root/mbbsd/fav.c
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-14 16:35:54 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-14 16:35:54 +0800
commit155b3632c418a8a7c25fc9fb4c2dbe684b0aa29f (patch)
treee7a2fcdfd89e6fa1d1c53edf2ea92fdcf218f839 /mbbsd/fav.c
parentc465925682db6fe601b1292dead369cd68c85ecb (diff)
downloadpttbbs-155b3632c418a8a7c25fc9fb4c2dbe684b0aa29f.tar
pttbbs-155b3632c418a8a7c25fc9fb4c2dbe684b0aa29f.tar.gz
pttbbs-155b3632c418a8a7c25fc9fb4c2dbe684b0aa29f.tar.bz2
pttbbs-155b3632c418a8a7c25fc9fb4c2dbe684b0aa29f.tar.lz
pttbbs-155b3632c418a8a7c25fc9fb4c2dbe684b0aa29f.tar.xz
pttbbs-155b3632c418a8a7c25fc9fb4c2dbe684b0aa29f.tar.zst
pttbbs-155b3632c418a8a7c25fc9fb4c2dbe684b0aa29f.zip
commit local change of {read,write}_favrec, which solved the problem of pointer size in 32 and 64-bit arch
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2509 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/fav.c')
-rw-r--r--mbbsd/fav.c50
1 files changed, 43 insertions, 7 deletions
diff --git a/mbbsd/fav.c b/mbbsd/fav.c
index 71780d65..3a1c1bce 100644
--- a/mbbsd/fav.c
+++ b/mbbsd/fav.c
@@ -49,6 +49,13 @@ static fav_t *fav_tmp;
//static int fav_tmp_snum; /* the sequence number in favh in fav_t */
+// DEPRECATED
+typedef struct {
+ char fid;
+ char title[BTLEN + 1];
+ int this_folder;
+} fav_folder4_t;
+
/**
* cast_(board|line|folder) 一族用於將 base class 作轉型
* (不檢查實際 data type)
@@ -421,6 +428,7 @@ static void read_favrec(int fd, fav_t *fp)
{
int i;
fav_type_t *ft;
+
read(fd, &fp->nBoards, sizeof(fp->nBoards));
read(fd, &fp->nLines, sizeof(fp->nLines));
read(fd, &fp->nFolders, sizeof(fp->nFolders));
@@ -430,10 +438,24 @@ static void read_favrec(int fd, fav_t *fp)
fp->favh = (fav_type_t *)fav_malloc(sizeof(fav_type_t) * fp->nAllocs);
for(i = 0; i < fp->DataTail; i++){
- read(fd, &fp->favh[i].type, sizeof(fp->favh[i].type));
- read(fd, &fp->favh[i].attr, sizeof(fp->favh[i].attr));
- fp->favh[i].fp = (void *)fav_malloc(get_type_size(fp->favh[i].type));
- read(fd, fp->favh[i].fp, get_type_size(fp->favh[i].type));
+ ft = &fp->favh[i];
+ read(fd, &ft->type, sizeof(ft->type));
+ read(fd, &ft->attr, sizeof(ft->attr));
+ ft->fp = (void *)fav_malloc(get_type_size(ft->type));
+
+ /* TODO A pointer has different size between 32 and 64-bit arch.
+ * But the pointer in fav_folder_t is irrelevant here.
+ * In order not to touch the current .fav4, fav_folder4_t is used
+ * here. It should be FIXED in the next version. */
+ switch (ft->type) {
+ case FAVT_FOLDER:
+ read(fd, ft->fp, sizeof(fav_folder4_t));
+ break;
+ case FAVT_BOARD:
+ case FAVT_LINE:
+ read(fd, ft->fp, get_type_size(ft->type));
+ break;
+ }
}
for(i = 0; i < fp->DataTail; i++){
@@ -490,17 +512,31 @@ int fav_load(void)
static void write_favrec(int fd, fav_t *fp)
{
int i;
+ fav_type_t *ft;
+
if (fp == NULL)
return;
+
write(fd, &fp->nBoards, sizeof(fp->nBoards));
write(fd, &fp->nLines, sizeof(fp->nLines));
write(fd, &fp->nFolders, sizeof(fp->nFolders));
fp->DataTail = get_data_number(fp);
for(i = 0; i < fp->DataTail; i++){
- write(fd, &fp->favh[i].type, sizeof(fp->favh[i].type));
- write(fd, &fp->favh[i].attr, sizeof(fp->favh[i].attr));
- write(fd, fp->favh[i].fp, get_type_size(fp->favh[i].type));
+ ft = &fp->favh[i];
+ write(fd, &ft->type, sizeof(ft->type));
+ write(fd, &ft->attr, sizeof(ft->attr));
+
+ /* TODO Please refer to read_favrec() */
+ switch (ft->type) {
+ case FAVT_FOLDER:
+ write(fd, ft->fp, sizeof(fav_folder4_t));
+ break;
+ case FAVT_BOARD:
+ case FAVT_LINE:
+ write(fd, ft->fp, get_type_size(ft->type));
+ break;
+ }
}
for(i = 0; i < fp->DataTail; i++){