Commit 828dea3f authored by rswindell's avatar rswindell
Browse files

Call the listmsgs_mod (List msgs module) when the bbs.list_msgs() method

is called without a "mode" specified. This uses the new default SCAN_INDEX
mode. If you need the old behavior (does not invoke the listmsgs_mod), specify
a different mode value (e.g. SCAN_READ). All of the mode values (other than
SCAN_INDEX) will not start the list message module, but rather use the internal
C++ logic.
This provides an intuitive way to actually invoke the list messages module
from JS without hard-coding bbs.exec("?module") into a cmd shell, for example.
parent 68947da2
......@@ -3929,7 +3929,7 @@ js_listmsgs(JSContext *cx, uintN argc, jsval *arglist)
jsval *argv=JS_ARGV(cx, arglist);
const char *def="";
char* find=(char *)def;
uint32 mode=0;
uint32 mode=SCAN_INDEX;
uint32 start=0;
uint subnum;
sbbs_t* sbbs;
......@@ -4377,7 +4377,7 @@ static jsSyncMethodSpec js_bbs_functions[] = {
"optionally search for 'find' string (AKA scan_posts)")
{"list_msgs", js_listmsgs, 1, JSTYPE_NUMBER, JSDOCSTR("[sub-board=<i>current</i>] [,mode=<tt>SCAN_READ</tt>] [,message_number=<tt>0</tt>] [,find]")
{"list_msgs", js_listmsgs, 1, JSTYPE_NUMBER, JSDOCSTR("[sub-board=<i>current</i>] [,mode=<tt>SCAN_INDEX</tt>] [,message_number=<tt>0</tt>] [,find]")
,JSDOCSTR("list messages in the specified message sub-board (number or internal code), "
"optionally search for 'find' string, returns number of messages listed")
......@@ -64,7 +64,7 @@ long sbbs_t::listmsgs(uint subnum, long mode, post_t *post, long start, long pos
smbmsg_t msg;
long listed=0;
for(long i = start; i<posts && !msgabort(); i++) {
if(mode&SCAN_NEW && post[i].idx.number<=subscan[subnum].ptr)
......@@ -1615,6 +1615,13 @@ long sbbs_t::listsub(uint subnum, long mode, long start, const char* search)
long lp_mode = LP_BYSELF;
post_t *post;
if((mode&SCAN_INDEX) && cfg.listmsgs_mod[0]) {
char cmdline[256];
safe_snprintf(cmdline, sizeof(cmdline), "%s %s %ld", cfg.listmsgs_mod, cfg.sub[subnum]->code, mode);
return exec_bin(cmdline, &main_csi);
if((i=smb_stack(&smb,SMB_STACK_PUSH))!=0) {
......@@ -894,6 +894,7 @@ enum XFER_TYPE { /* Values for type in xfer_prot_select() */
#define SCAN_MSGSONLY (1<<6) /* Do not do a new file scan even if the
* user enabled Automatic New File Scan */
#define SCAN_POLLS (1<<7) /* Scan for polls (only) */
#define SCAN_INDEX (1<<8) // List the msg index or exec listmsgs_mod
/* Bits in misc of chan_t */
#define CHAN_PW (1<<0) /* Can be password protected */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment