Commit 5a192c0e authored by rswindell's avatar rswindell

2 more configurable loadable modules:

- external programs section (default: "xtrn_sec")
- logon list (default: "logonlist")

This ties the Baja XTRN_SECTION and USERLIST_LOGONS functions and the
JS bbs.xtrn_sec() and bbs.list_logons() methods to the loadable modules (if
configured) automatically without the exec_bin hackery in *.src.

Also, allow the xtrn section argument to be passed to the JS/C++ method to
go directly to a specific xtrn program section.

The bbs.list_logons() can also accept an argument to pass to the module
(e.g. "-y" for yesterday's logons).
parent c58b969e
......@@ -2049,6 +2049,8 @@ js_qwk_sec(JSContext *cx, uintN argc, jsval *arglist)
static JSBool
js_xtrn_sec(JSContext *cx, uintN argc, jsval *arglist)
{
jsval *argv=JS_ARGV(cx, arglist);
char* section = "";
sbbs_t* sbbs;
jsrefcount rc;
......@@ -2056,9 +2058,11 @@ js_xtrn_sec(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(argc > 0) {
JSVALUE_TO_ASTRING(cx, argv[0], section, LEN_CODE + 1, NULL);
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->xtrn_sec();
sbbs->xtrn_sec(section);
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
......@@ -2496,6 +2500,8 @@ js_change_user(JSContext *cx, uintN argc, jsval *arglist)
static JSBool
js_logonlist(JSContext *cx, uintN argc, jsval *arglist)
{
jsval *argv=JS_ARGV(cx, arglist);
char* args="";
sbbs_t* sbbs;
jsrefcount rc;
......@@ -2504,8 +2510,11 @@ js_logonlist(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(argc > 0) {
JSVALUE_TO_ASTRING(cx, argv[0], args, LEN_CMD, NULL);
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->logonlist();
sbbs->logonlist(args);
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
......@@ -4192,8 +4201,8 @@ static jsSyncMethodSpec js_bbs_functions[] = {
,JSDOCSTR("enter the text files section")
,310
},
{"xtrn_sec", js_xtrn_sec, 0, JSTYPE_VOID, JSDOCSTR("")
,JSDOCSTR("enter the external programs section")
{"xtrn_sec", js_xtrn_sec, 0, JSTYPE_VOID, JSDOCSTR("[section]")
,JSDOCSTR("enter the external programs section (or go directly to the specified <i>section</i>)")
,310
},
{"xfer_policy", js_xfer_policy, 0, JSTYPE_VOID, JSDOCSTR("")
......@@ -4280,8 +4289,8 @@ static jsSyncMethodSpec js_bbs_functions[] = {
,JSDOCSTR("change to a different user")
,310
},
{"list_logons", js_logonlist, 0, JSTYPE_VOID, JSDOCSTR("")
,JSDOCSTR("display the logon list")
{"list_logons", js_logonlist, 0, JSTYPE_VOID, JSDOCSTR("[arguments]")
,JSDOCSTR("display the logon list (optionally passing arguments to the logon list module)")
,310
},
{"read_mail", js_readmail, 0, JSTYPE_VOID, JSDOCSTR("[which=<tt>MAIL_YOUR</tt>] [,user_number=<i>current</i>] [,loadmail_mode=<tt>0</tt>]")
......
......@@ -599,7 +599,7 @@ public:
void xfer_prot_menu(enum XFER_TYPE);
void node_stats(uint node_num);
void sys_stats(void);
void logonlist(void);
void logonlist(const char* args = "");
bool spy(uint node_num);
void reset_logon_vars(void);
......@@ -972,7 +972,7 @@ public:
long xtrn_mode;
/* xtrn_sec.cpp */
int xtrn_sec(void); /* The external program section */
int xtrn_sec(const char* section = ""); /* The external program section */
void xtrndat(const char* name, const char* dropdir, uchar type, ulong tleft
,ulong misc);
bool exec_xtrn(uint xtrnnum); /* Executes online external program */
......
......@@ -596,6 +596,7 @@ typedef struct
char sync_mod[LEN_MODNAME+1]; /* Synchronization module */
char expire_mod[LEN_MODNAME+1]; /* User expiration module */
char textsec_mod[LEN_MODNAME+1]; /* Text section module */
char xtrnsec_mod[LEN_MODNAME+1]; /* External Program section module */
char automsg_mod[LEN_MODNAME+1]; /* Auto-message module */
char readmail_mod[LEN_CMD+1]; /* Reading mail module */
char scanposts_mod[LEN_CMD+1]; /* Scanning posts (in a single sub) module */
......@@ -604,6 +605,7 @@ typedef struct
char nodelist_mod[LEN_CMD+1];
char whosonline_mod[LEN_CMD+1];
char privatemsg_mod[LEN_CMD+1];
char logonlist_mod[LEN_CMD+1];
char scfg_cmd[LEN_CMD+1]; /* SCFG command line - unused! */
uchar smb_retry_time; /* Seconds to retry on SMBs */
uint16_t sec_warn; /* Seconds before inactivity warning */
......
......@@ -309,9 +309,10 @@ BOOL read_main_cfg(scfg_t* cfg, char* error)
if(!cfg->textsec_mod[0]) SAFECOPY(cfg->textsec_mod,"text_sec");
get_str(cfg->automsg_mod,instream);
if(!cfg->automsg_mod[0]) SAFECOPY(cfg->automsg_mod,"automsg");
get_str(cfg->xtrnsec_mod,instream);
if(!cfg->xtrnsec_mod[0]) SAFECOPY(cfg->xtrnsec_mod,"xtrn_sec");
get_int(c, instream);
for(i=0;i<21;i++) /* unused - initialized to NULL */
for(i=0;i<17;i++) /* unused - initialized to NULL */
get_int(n,instream);
get_str(cfg->nodelist_mod,instream);
if(cfg->nodelist_mod[0] == '\xff')
......@@ -322,7 +323,10 @@ BOOL read_main_cfg(scfg_t* cfg, char* error)
get_str(cfg->privatemsg_mod,instream);
if(cfg->privatemsg_mod[0] == '\xff')
SAFECOPY(cfg->privatemsg_mod, "privatemsg");
for(i=0;i<158;i++) /* unused - initialized to 0xff */
get_str(cfg->logonlist_mod,instream);
if(cfg->logonlist_mod[0] == '\xff')
SAFECOPY(cfg->logonlist_mod, "logonlist");
for(i=0;i<126;i++) /* unused - initialized to 0xff */
get_int(n,instream);
get_int(cfg->user_backup_level,instream);
......
......@@ -273,15 +273,18 @@ BOOL DLLCALL write_main_cfg(scfg_t* cfg, int backup_level)
put_str(cfg->scansubs_mod, stream);
put_str(cfg->listmsgs_mod, stream);
put_str(cfg->textsec_mod,stream);
put_str(cfg->automsg_mod,stream);
put_str(cfg->xtrnsec_mod,stream);
n=0;
for(i=0;i<26;i++)
for(i=0;i<17;i++)
put_int(n,stream);
put_str(cfg->nodelist_mod, stream);
put_str(cfg->whosonline_mod, stream);
put_str(cfg->privatemsg_mod, stream);
put_str(cfg->logonlist_mod, stream);
n=0xffff;
for(i=0;i<158;i++)
for(i=0;i<126;i++)
put_int(n,stream);
put_int(cfg->user_backup_level,stream);
......
......@@ -1033,11 +1033,16 @@ void sbbs_t::sys_stats(void)
bprintf(text[StatsFeedbacksToday],ultoac(stats.ftoday,tmp));
}
void sbbs_t::logonlist(void)
void sbbs_t::logonlist(const char* args)
{
char str[MAX_PATH+1];
sprintf(str,"%slogon.lst", cfg.data_dir);
if(cfg.logonlist_mod[0] != '\0') {
SAFEPRINTF2(str, "%s %s", cfg.logonlist_mod, args);
exec_bin(str, &main_csi);
return;
}
SAFEPRINTF(str,"%slogon.lst", cfg.data_dir);
if(flength(str)<1) {
bputs("\r\n\r\n");
bputs(text[NoOneHasLoggedOnToday]);
......
......@@ -41,13 +41,18 @@
/* This is the external programs (doors) section of the bbs */
/* Return 1 if no externals available, 0 otherwise. */
/****************************************************************************/
int sbbs_t::xtrn_sec()
int sbbs_t::xtrn_sec(const char* section)
{
char str[MAX_PATH+1];
int xsec;
uint i,j,k,*usrxtrn,usrxtrns,*usrxsec,usrxsecs;
long l;
if(cfg.xtrnsec_mod[0] != '\0') {
SAFEPRINTF2(str, "%s %s", cfg.xtrnsec_mod, section);
return exec_bin(str, &main_csi);
}
if(useron.rest&FLAG('X')) {
bputs(text[R_ExternalPrograms]);
return(1);
......
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