diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-28 23:33:57 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-28 23:33:57 +0800 |
commit | 4012bf960377f4281d2a47d22378e1b30f520190 (patch) | |
tree | a01acc60ddf80f4616150f75cc3b175e370062c9 | |
parent | 834a22995914e8987ddc99cd3bba20942606f335 (diff) | |
download | pttbbs-4012bf960377f4281d2a47d22378e1b30f520190.tar pttbbs-4012bf960377f4281d2a47d22378e1b30f520190.tar.gz pttbbs-4012bf960377f4281d2a47d22378e1b30f520190.tar.bz2 pttbbs-4012bf960377f4281d2a47d22378e1b30f520190.tar.lz pttbbs-4012bf960377f4281d2a47d22378e1b30f520190.tar.xz pttbbs-4012bf960377f4281d2a47d22378e1b30f520190.tar.zst pttbbs-4012bf960377f4281d2a47d22378e1b30f520190.zip |
explicit fav entrance
description:
1. A user enters Class of the main menu.
Now fav is loaded, and fav_stack[0] is fav root.
2. Go some dir, press 'y'.
fav_stack[0] != NULL, so the user WAS in fav tree.
3. press 'a' or 'i' can break the program.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3108 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/proto.h | 2 | ||||
-rw-r--r-- | mbbsd/board.c | 8 | ||||
-rw-r--r-- | mbbsd/fav.c | 22 |
3 files changed, 22 insertions, 10 deletions
diff --git a/include/proto.h b/include/proto.h index 4c0003d2..aeb81090 100644 --- a/include/proto.h +++ b/include/proto.h @@ -257,6 +257,8 @@ void fav_set_folder_title(fav_type_t *ft, char *title); int fav_stack_full(void); void fav_folder_in(short fid); void fav_folder_out(void); +void fav_enter(void); +void fav_leave(void); void fav_free(void); int fav_v3_to_v4(void); int is_set_attr(fav_type_t *ft, char bit); diff --git a/mbbsd/board.c b/mbbsd/board.c index f9331bc2..d75a3a78 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -675,8 +675,6 @@ choose_board(int newflag) char keyword[13] = "", buf[64]; setutmpmode(newflag ? READNEW : READBRD); - if( get_current_fav() == NULL ) - fav_load(); ++choose_board_depth; brdnum = 0; if (!cuser.userlevel) /* guest yank all boards */ @@ -873,7 +871,7 @@ choose_board(int newflag) brdnum = -1; break; case 'y': - if (get_current_fav() != NULL || !IS_LISTING_FAV()){ + if (get_current_fav() != NULL) { if (cuser.userlevel) yank_flag ^= 1; /* FAV <=> BRD */ else @@ -1275,7 +1273,11 @@ Boards(void) init_brdbuf(); class_bid = 0; LIST_FAV(); + if( get_current_fav() == NULL ) + fav_load(); + fav_enter(); choose_board(0); + fav_leave(); return 0; } diff --git a/mbbsd/fav.c b/mbbsd/fav.c index 56b3b8c3..8aa132e2 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -43,6 +43,7 @@ static int fav_number; /* definition of fav stack, the top one is in use now. */ static int fav_stack_num = 0; static fav_t *fav_stack[FAV_MAXDEPTH] = {0}; +static fav_t *fav_root = NULL; static char dirty = 0; @@ -288,7 +289,7 @@ fav_item_copy(fav_type_t *target, const fav_type_t *source){ } inline fav_t *get_fav_root(void){ - return fav_stack[0]; + return fav_root; } /** @@ -444,6 +445,16 @@ void fav_folder_out(void) fav_stack_pop(); } +void fav_enter(void) +{ + fav_stack_push_fav(fav_root); +} + +void fav_leave(void) +{ + fav_stack_pop(); +} + static void read_favrec(FILE *frp, fav_t *fp) { int i; @@ -503,14 +514,12 @@ int fav_load(void) { FILE *frp; char buf[128]; - fav_t *fp; if (fav_stack_num > 0) return -1; setuserfile(buf, FAV4); if (!dashf(buf)) { - fp = (fav_t *)fav_malloc(sizeof(fav_t)); - fav_stack_push_fav(fp); + fav_root = (fav_t *)fav_malloc(sizeof(fav_t)); #ifdef MEM_CHECK fav_set_memcheck(MEM_CHECK); #endif @@ -519,10 +528,9 @@ int fav_load(void) if ((frp = fopen(buf, "r")) == NULL) return -1; - fp = (fav_t *)fav_malloc(sizeof(fav_t)); + fav_root = (fav_t *)fav_malloc(sizeof(fav_t)); fav_number = 0; - read_favrec(frp, fp); - fav_stack_push_fav(fp); + read_favrec(frp, fav_root); fclose(frp); #ifdef MEM_CHECK fav_set_memcheck(MEM_CHECK); |