diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-14 16:35:54 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-14 16:35:54 +0800 |
commit | 155b3632c418a8a7c25fc9fb4c2dbe684b0aa29f (patch) | |
tree | e7a2fcdfd89e6fa1d1c53edf2ea92fdcf218f839 | |
parent | c465925682db6fe601b1292dead369cd68c85ecb (diff) | |
download | pttbbs-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
-rw-r--r-- | include/fav.h | 2 | ||||
-rw-r--r-- | mbbsd/cache.c | 2 | ||||
-rw-r--r-- | mbbsd/fav.c | 50 | ||||
-rw-r--r-- | pttbbs.mk | 2 |
4 files changed, 46 insertions, 10 deletions
diff --git a/include/fav.h b/include/fav.h index 2604aae6..418f4062 100644 --- a/include/fav.h +++ b/include/fav.h @@ -46,7 +46,7 @@ typedef struct { typedef struct { short bid; - time_t lastvisit; + time4_t lastvisit; char attr; } fav_board_t; diff --git a/mbbsd/cache.c b/mbbsd/cache.c index 7976342e..786db7aa 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -605,7 +605,7 @@ void addbrd_touchcache(void) void reset_board(int bid) /* XXXbid: from 1 */ { /* Ptt: 這樣就不用老是touch board了 */ - int fd, nuser; + int fd; boardheader_t *bhdr; if (--bid < 0) 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++){ @@ -12,7 +12,7 @@ CC= gcc CCACHE!= which ccache|sed -e 's/^.*\///' PTT_CFLAGS= -Wall -pipe -DBBSHOME='"$(BBSHOME)"' -I../include PTT_LDFLAGS= -pipe -Wall -L/usr/local/lib -PTT_LIBS= -lcrypt -lhz +PTT_LIBS= -lcrypt # -lhz # enable assert() #PTT_CFLAGS+= -DNDEBUG |