Skip to content
Snippets Groups Projects
Commit e5a6b0b0 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Allow a "max message count" to be specified in AreaMgr "rescan" requests

- The -R option (in the subject), can now include a message count
  i.e. -R=<count>
  I don't think this follows any existing area manager example usage, but I
  figured as long as we support a -R option, -R=<count> makes sense.
- The %RESCAN function (in the body) can now include a message count
  i.e. %RESCAN [area-tag] [R=<count>]
  This mimics the Mystic area manager usage, though we don't yet support
  a "D=days" option.

This at least partially addresses issue #929, but I sure would like some
people to test it an let me know how well it works (!)
parent 13da926e
No related branches found
No related tags found
No related merge requests found
Address all Area Management requests to 'AreaFix' (without quotes). Address all Area Management requests to 'AreaFix' (without quotes).
Your Area Manager password goes in the message subject followed optionally Your Area Manager password goes in the message subject followed optionally
by -R, -L, or -Q for Rescan, List, or Query functions, respectively. by -R, -L, or -Q for Rescan, List, or Query functions, respectively.
The Rescan option may include a maximum message count (e.g. -R=<count>).
In the body of the message, one or more: In the body of the message, one or more:
...@@ -15,7 +16,9 @@ In the body of the message, one or more: ...@@ -15,7 +16,9 @@ In the body of the message, one or more:
%PKTPWD <password> Set or change your Packet password %PKTPWD <password> Set or change your Packet password
%TICPWD <password> Set or change your TIC File password %TICPWD <password> Set or change your TIC File password
%RESCAN Request a rescan of all connected areas %RESCAN Request a rescan of all connected areas
%RESCAN R=<count> ... and specify a maximum message count per area
%RESCAN <areatag> Request a rescan of a single connected area %RESCAN <areatag> Request a rescan of a single connected area
%RESCAN <area> R=cnt ... and specify a maximum message count
%ECHOSTATS <areatag> Request statistics (import/export details) of an area %ECHOSTATS <areatag> Request statistics (import/export details) of an area
%ACTIVE Reconnect (resume) all temporarily disconnected areas %ACTIVE Reconnect (resume) all temporarily disconnected areas
%PASSIVE Temporarily disconnect (pause) all connected areas %PASSIVE Temporarily disconnect (pause) all connected areas
......
...@@ -115,7 +115,7 @@ __attribute__ ((format (printf, 2, 3))); ...@@ -115,7 +115,7 @@ __attribute__ ((format (printf, 2, 3)));
; ;
int mv(const char *insrc, const char *indest, bool copy); int mv(const char *insrc, const char *indest, bool copy);
time_t fmsgtime(const char *str); time_t fmsgtime(const char *str);
ulong export_echomail(const char *sub_code, const nodecfg_t*, bool rescan); ulong export_echomail(const char *sub_code, const nodecfg_t*, uint32_t rescan);
const char* area_desc(const char* areatag); const char* area_desc(const char* areatag);
/* FTN-compliant "Program Identifier"/PID (also used as a "Tosser Identifier"/TID) */ /* FTN-compliant "Program Identifier"/PID (also used as a "Tosser Identifier"/TID) */
...@@ -1597,7 +1597,7 @@ void add_areas_from_echolists(FILE* afileout, FILE* nmfile ...@@ -1597,7 +1597,7 @@ void add_areas_from_echolists(FILE* afileout, FILE* nmfile
void alter_areas_ini(FILE* afilein, FILE* afileout, FILE* nmfile void alter_areas_ini(FILE* afilein, FILE* afileout, FILE* nmfile
, bool add_all, str_list_t add_area, size_t* added , bool add_all, str_list_t add_area, size_t* added
, bool del_all, str_list_t del_area, size_t* deleted , bool del_all, str_list_t del_area, size_t* deleted
, nodecfg_t* nodecfg, const char* to, bool rescan) , nodecfg_t* nodecfg, const char* to, uint32_t rescan)
{ {
faddr_t addr = nodecfg->addr; faddr_t addr = nodecfg->addr;
const char* addr_str = smb_faddrtoa(&addr, NULL); const char* addr_str = smb_faddrtoa(&addr, NULL);
...@@ -1668,8 +1668,8 @@ void alter_areas_ini(FILE* afilein, FILE* afileout, FILE* nmfile ...@@ -1668,8 +1668,8 @@ void alter_areas_ini(FILE* afilein, FILE* afileout, FILE* nmfile
fprintf(nmfile, "%s added.\r\n", echotag); fprintf(nmfile, "%s added.\r\n", echotag);
(*added)++; (*added)++;
} }
if (rescan && area_is_linked(areanum, &addr) && subnum_is_valid(&scfg, cfg.area[areanum].sub)) { if (rescan > 0 && area_is_linked(areanum, &addr) && subnum_is_valid(&scfg, cfg.area[areanum].sub)) {
ulong exported = export_echomail(scfg.sub[cfg.area[areanum].sub]->code, nodecfg, true); ulong exported = export_echomail(scfg.sub[cfg.area[areanum].sub]->code, nodecfg, rescan);
fprintf(nmfile, "%s rescanned and %lu messages exported.\r\n", echotag, exported); fprintf(nmfile, "%s rescanned and %lu messages exported.\r\n", echotag, exported);
} }
continue; continue;
...@@ -1683,7 +1683,7 @@ void alter_areas_ini(FILE* afilein, FILE* afileout, FILE* nmfile ...@@ -1683,7 +1683,7 @@ void alter_areas_ini(FILE* afilein, FILE* afileout, FILE* nmfile
void alter_areas_bbs(FILE* afilein, FILE* afileout, FILE* nmfile void alter_areas_bbs(FILE* afilein, FILE* afileout, FILE* nmfile
, bool add_all, str_list_t add_area, size_t* added , bool add_all, str_list_t add_area, size_t* added
, bool del_all, str_list_t del_area, size_t* deleted , bool del_all, str_list_t del_area, size_t* deleted
, nodecfg_t* nodecfg, const char* to, bool rescan) , nodecfg_t* nodecfg, const char* to, uint32_t rescan)
{ {
char fields[1024], code[LEN_EXTCODE + 1], echotag[FIDO_AREATAG_LEN + 1], comment[256] char fields[1024], code[LEN_EXTCODE + 1], echotag[FIDO_AREATAG_LEN + 1], comment[256]
, *p, *tp; , *p, *tp;
...@@ -1792,8 +1792,8 @@ void alter_areas_bbs(FILE* afilein, FILE* afileout, FILE* nmfile ...@@ -1792,8 +1792,8 @@ void alter_areas_bbs(FILE* afilein, FILE* afileout, FILE* nmfile
fprintf(nmfile, "%s added.\r\n", echotag); fprintf(nmfile, "%s added.\r\n", echotag);
(*added)++; (*added)++;
} }
if (rescan && area_is_linked(areanum, &addr) && subnum_is_valid(&scfg, cfg.area[areanum].sub)) { if (rescan > 0 && area_is_linked(areanum, &addr) && subnum_is_valid(&scfg, cfg.area[areanum].sub)) {
ulong exported = export_echomail(scfg.sub[cfg.area[areanum].sub]->code, nodecfg, true); ulong exported = export_echomail(scfg.sub[cfg.area[areanum].sub]->code, nodecfg, rescan);
fprintf(nmfile, "%s rescanned and %lu messages exported.\r\n", echotag, exported); fprintf(nmfile, "%s rescanned and %lu messages exported.\r\n", echotag, exported);
} }
} }
...@@ -1904,7 +1904,7 @@ void add_areas_from_echolists(FILE* afileout, FILE* nmfile ...@@ -1904,7 +1904,7 @@ void add_areas_from_echolists(FILE* afileout, FILE* nmfile
/****************************************************************************** /******************************************************************************
Used by Area Manager to add/remove/change areas in the areas file Used by Area Manager to add/remove/change areas in the areas file
******************************************************************************/ ******************************************************************************/
void alter_areas(str_list_t add_area, str_list_t del_area, nodecfg_t* nodecfg, const char* to, bool rescan) void alter_areas(str_list_t add_area, str_list_t del_area, nodecfg_t* nodecfg, const char* to, uint32_t rescan)
{ {
FILE * nmfile, *afilein, *afileout; FILE * nmfile, *afilein, *afileout;
char outpath[MAX_PATH + 1]; char outpath[MAX_PATH + 1];
...@@ -2067,7 +2067,7 @@ bool alter_config(nodecfg_t* nodecfg, const char* key, const char* value) ...@@ -2067,7 +2067,7 @@ bool alter_config(nodecfg_t* nodecfg, const char* key, const char* value)
/****************************************************************************** /******************************************************************************
Used by Area Manager to process any '%' commands that come in via netmail Used by Area Manager to process any '%' commands that come in via netmail
******************************************************************************/ ******************************************************************************/
bool areamgr_command(char* instr, nodecfg_t* nodecfg, const char* to, bool rescan) bool areamgr_command(char* instr, nodecfg_t* nodecfg, const char* to, uint32_t rescan)
{ {
FILE * stream, *tmpf; FILE * stream, *tmpf;
char str[MAX_PATH + 1]; char str[MAX_PATH + 1];
...@@ -2247,25 +2247,39 @@ bool areamgr_command(char* instr, nodecfg_t* nodecfg, const char* to, bool resca ...@@ -2247,25 +2247,39 @@ bool areamgr_command(char* instr, nodecfg_t* nodecfg, const char* to, bool resca
return true; return true;
} }
// %RESCAN [R=<count>]
if (strnicmp(instr, "RESCAN R=", 9) == 0 && IS_DIGIT(instr[9])) {
rescan = strtol(instr + 9, NULL, 10);
*(instr + 6) = '\0';
}
if (stricmp(instr, "RESCAN") == 0) { if (stricmp(instr, "RESCAN") == 0) {
lprintf(LOG_INFO, "AreaMgr (for %s) Rescanning all areas", faddrtoa(&addr)); lprintf(LOG_INFO, "AreaMgr (for %s) Rescanning all areas", faddrtoa(&addr));
ulong exported = export_echomail(NULL, nodecfg, true); ulong exported = export_echomail(NULL, nodecfg, rescan ? rescan : ~0);
snprintf(str, sizeof str, "All connected areas have been rescanned and %lu messages exported.", exported); snprintf(str, sizeof str, "All connected areas have been rescanned and %lu messages exported.", exported);
create_netmail(to, /* msg: */ NULL, "Rescan Areas", str, /* dest: */ addr, /* src: */ NULL); create_netmail(to, /* msg: */ NULL, "Rescan Areas", str, /* dest: */ addr, /* src: */ NULL);
return true; return true;
} }
// %RESCAN <area-tag> [R=<count>]
if (strnicmp(instr, "RESCAN ", 7) == 0) { if (strnicmp(instr, "RESCAN ", 7) == 0) {
char* p = instr; char* p = instr + 7;
FIND_WHITESPACE(p);
SKIP_WHITESPACE(p); SKIP_WHITESPACE(p);
char* tp = p;
FIND_WHITESPACE(tp);
if (*tp != '\0') {
*tp = '\0';
++tp;
SKIP_WHITESPACE(tp);
if (strnicmp(tp, "R=", 2) == 0 && IS_DIGIT(tp[2]))
rescan = strtol(tp + 2, NULL, 10);
}
int subnum = find_linked_area(p, addr); int subnum = find_linked_area(p, addr);
if (subnum == SUB_NOT_FOUND) if (subnum == SUB_NOT_FOUND)
SAFEPRINTF(str, "Echo-tag '%s' not linked or not found.", p); SAFEPRINTF(str, "Echo-tag '%s' not linked or not found.", p);
else if (subnum == INVALID_SUB) else if (subnum == INVALID_SUB)
SAFEPRINTF(str, "Connected area '%s' is pass-through: cannot be rescanned", p); SAFEPRINTF(str, "Connected area '%s' is pass-through: cannot be rescanned", p);
else { else {
ulong exported = export_echomail(scfg.sub[subnum]->code, nodecfg, true); ulong exported = export_echomail(scfg.sub[subnum]->code, nodecfg, rescan ? rescan : ~0);
snprintf(str, sizeof str, "Connected area '%s' has been rescanned and %lu messages exported.", p, exported); snprintf(str, sizeof str, "Connected area '%s' has been rescanned and %lu messages exported.", p, exported);
} }
lprintf(LOG_INFO, "AreaMgr (for %s) %s", faddrtoa(&addr), str); lprintf(LOG_INFO, "AreaMgr (for %s) %s", faddrtoa(&addr), str);
...@@ -2351,7 +2365,7 @@ char* process_areamgr(fidoaddr_t addr, char* inbuf, const char* subj, const char ...@@ -2351,7 +2365,7 @@ char* process_areamgr(fidoaddr_t addr, char* inbuf, const char* subj, const char
char * p, *tp, action, cmds = 0; char * p, *tp, action, cmds = 0;
ulong l, m; ulong l, m;
str_list_t add_area, del_area; str_list_t add_area, del_area;
bool rescan = false; uint32_t rescan = 0;
bool list = false; bool list = false;
bool query = false; bool query = false;
...@@ -2369,12 +2383,14 @@ char* process_areamgr(fidoaddr_t addr, char* inbuf, const char* subj, const char ...@@ -2369,12 +2383,14 @@ char* process_areamgr(fidoaddr_t addr, char* inbuf, const char* subj, const char
while (*p != '\0') { while (*p != '\0') {
SKIP_WHITESPACE(p); SKIP_WHITESPACE(p);
if (stricmp(p, "-R") == 0 || strnicmp(p, "-R ", 3) == 0) if (stricmp(p, "-R") == 0 || strnicmp(p, "-R ", 3) == 0)
rescan = true; rescan = ~0;
if (stricmp(p, "-L") == 0 || strnicmp(p, "-L ", 3) == 0) { else if (strnicmp(p, "-R=", 3) == 0)
rescan = strtoul(p + 3, NULL, 10);
else if (stricmp(p, "-L") == 0 || strnicmp(p, "-L ", 3) == 0) {
list = true; list = true;
++cmds; ++cmds;
} }
if (stricmp(p, "-Q") == 0 || strnicmp(p, "-Q ", 3) == 0) { else if (stricmp(p, "-Q") == 0 || strnicmp(p, "-Q ", 3) == 0) {
query = true; query = true;
++cmds; ++cmds;
} }
...@@ -3014,7 +3030,7 @@ int mv(const char *insrc, const char *indest, bool copy) ...@@ -3014,7 +3030,7 @@ int mv(const char *insrc, const char *indest, bool copy)
/****************************************************************************/ /****************************************************************************/
/* Returns negative value on error */ /* Returns negative value on error */
/****************************************************************************/ /****************************************************************************/
long getlastmsg(uint subnum, uint32_t *ptr, /* unused: */ time_t *t) uint32_t getlastmsg(uint subnum, uint32_t *ptr, /* unused: */ time_t *t)
{ {
int i; int i;
smb_t smbfile; smb_t smbfile;
...@@ -4889,7 +4905,7 @@ static void write_export_ptr(int subnum, uint32_t ptr, const char* tag) ...@@ -4889,7 +4905,7 @@ static void write_export_ptr(int subnum, uint32_t ptr, const char* tag)
empty address as 'addr' designates that a rescan should be done for that empty address as 'addr' designates that a rescan should be done for that
address. address.
******************************************************************************/ ******************************************************************************/
ulong export_echomail(const char* sub_code, const nodecfg_t* nodecfg, bool rescan) ulong export_echomail(const char* sub_code, const nodecfg_t* nodecfg, uint32_t rescan)
{ {
char str[256], tear, cr; char str[256], tear, cr;
char* buf = NULL; char* buf = NULL;
...@@ -4900,7 +4916,7 @@ ulong export_echomail(const char* sub_code, const nodecfg_t* nodecfg, bool resca ...@@ -4900,7 +4916,7 @@ ulong export_echomail(const char* sub_code, const nodecfg_t* nodecfg, bool resca
unsigned area; unsigned area;
ulong f, l, m, exp, exported = 0; ulong f, l, m, exp, exported = 0;
uint32_t ptr, lastmsg, posts; uint32_t ptr, lastmsg, posts;
long msgs; uint32_t msgs;
smbmsg_t msg; smbmsg_t msg;
smbmsg_t orig_msg; smbmsg_t orig_msg;
fmsghdr_t hdr; fmsghdr_t hdr;
...@@ -4954,6 +4970,12 @@ ulong export_echomail(const char* sub_code, const nodecfg_t* nodecfg, bool resca ...@@ -4954,6 +4970,12 @@ ulong export_echomail(const char* sub_code, const nodecfg_t* nodecfg, bool resca
continue; continue;
} }
if (rescan > 0) {
if (msgs < rescan)
ptr = 0;
else
ptr = lastmsg - rescan;
}
post = NULL; post = NULL;
posts = loadmsgs(&smb, &post, ptr); posts = loadmsgs(&smb, &post, ptr);
...@@ -7048,7 +7070,7 @@ int main(int argc, char **argv) ...@@ -7048,7 +7070,7 @@ int main(int argc, char **argv)
} }
if (opt_export_echomail && !terminated) if (opt_export_echomail && !terminated)
export_echomail(sub_code, nodecfg, /* rescan: */ opt_ignore_msgptrs); export_echomail(sub_code, nodecfg, /* rescan: */ opt_ignore_msgptrs ? ~0 : 0);
if (opt_export_netmail && !terminated) if (opt_export_netmail && !terminated)
export_netmail(); export_netmail();
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "ini_file.h" #include "ini_file.h"
#define SBBSECHO_VERSION_MAJOR 3 #define SBBSECHO_VERSION_MAJOR 3
#define SBBSECHO_VERSION_MINOR 25 #define SBBSECHO_VERSION_MINOR 26
#define SBBSECHO_PRODUCT_CODE 0x12FF /* from http://ftsc.org/docs/ftscprod.013 */ #define SBBSECHO_PRODUCT_CODE 0x12FF /* from http://ftsc.org/docs/ftscprod.013 */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment