Reset Msg Pointers

This commit is contained in:
Andrew Pamment 2017-09-21 16:07:31 +10:00
parent dd1453d6ed
commit 0e8ec762bf
4 changed files with 47 additions and 0 deletions

2
bbs.h
View File

@ -280,6 +280,8 @@ extern void next_mail_area(struct user_record *user);
extern void prev_mail_area(struct user_record *user);
extern void post_message(struct user_record *user);
extern void msg_conf_sub_bases();
extern void msgbase_reset_pointers(int conference, int msgarea);
extern void msgbase_reset_all_pointers();
extern void rundoor(struct user_record *user, char *cmd, int stdio, char *codepage);
extern void runexternal(struct user_record *user, char *cmd, int stdio, char **argv, char *cwd, int raw, char *codepage);

View File

@ -2680,3 +2680,31 @@ void msg_conf_sub_bases() {
}
} while (!done);
}
void msgbase_reset_pointers(int conference, int msgarea) {
s_JamBase *jb;
s_JamBaseHeader jbh;
s_JamLastRead jlr;
jb = open_jam_base(conf.mail_conferences[conference]->mail_areas[msgarea]->path);
if (!jb) {
dolog("Unable to open message base");
return;
}
if (JAM_ReadLastRead(jb, gUser->id, &jlr) != JAM_NO_USER) {
jlr.LastReadMsg = 0;
jlr.HighReadMsg = 0;
JAM_WriteLastRead(jb, gUser->id, &jlr);
}
JAM_CloseMB(jb);
}
void msgbase_reset_all_pointers() {
int i, j;
for (i=0;i<conf.mail_conference_count;i++) {
for (j=0;j<conf.mail_conferences[i]->mail_area_count;j++) {
msgbase_reset_pointers(i, j);
}
}
}

12
menus.c
View File

@ -47,6 +47,8 @@
#define MENU_DOSCRIPT 37
#define MENU_SENDNODEMSG 38
#define MENU_SUBUNSUBCONF 39
#define MENU_RESETPOINTERS 40
#define MENU_RESETALLPOINTERS 41
extern struct bbs_config conf;
extern struct user_record *gUser;
@ -190,6 +192,10 @@ int menu_system(char *menufile) {
menu[menu_items-1]->command = MENU_SENDNODEMSG;
} else if (strncasecmp(&buffer[8], "SUBUNSUBCONF", 12) == 0) {
menu[menu_items-1]->command = MENU_SUBUNSUBCONF;
} else if (strncasecmp(&buffer[8], "RESETMSGPTRS", 12) == 0) {
menu[menu_items-1]->command = MENU_RESETPOINTERS;
} else if (strncasecmp(&buffer[8], "RESETALLMSGPTRS", 15) == 0) {
menu[menu_items-1]->command = MENU_RESETALLPOINTERS;
}
} else if (strncasecmp(buffer, "SECLEVEL", 8) == 0) {
menu[menu_items-1]->seclevel = atoi(&buffer[9]);
@ -474,6 +480,12 @@ int menu_system(char *menufile) {
case MENU_SUBUNSUBCONF:
msg_conf_sub_bases();
break;
case MENU_RESETPOINTERS:
msgbase_reset_pointers(gUser->cur_mail_conf, gUser->cur_mail_area);
break;
case MENU_RESETALLPOINTERS:
msgbase_reset_all_pointers();
break;
default:
break;
}

View File

@ -53,3 +53,8 @@ COMMAND BLUEWAVEUPLOAD
HOTKEY S
COMMAND SUBUNSUBCONF
HOTKEY Z
COMMAND RESETMSGPTRS
HOTKEY X
COMMAND RESETALLMSGPTRS