...
 
Commits (6)
......@@ -4055,7 +4055,6 @@ js_resolve_ip(JSContext *cx, uintN argc, jsval *arglist)
hints.ai_socktype = SOCK_STREAM;
rc=JS_SUSPENDREQUEST(cx);
if((result=getaddrinfo(p, NULL, &hints, &res))!=0) {
lprintf(LOG_ERR, "!ERROR resolve_ip %s failed with error %d",p, result);
JS_RESUMEREQUEST(cx, rc);
free(p);
return JS_TRUE;
......
/* Synchronet JavaScript "system" Object */
// vi: tabstop=4
/* $Id: js_system.c,v 1.179 2020/03/31 18:32:34 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
......@@ -16,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -1148,9 +1133,13 @@ js_secondstr(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if(argc<1)
return(JS_TRUE);
if(!js_argc(cx, argc, 1))
return JS_FALSE;
if(JSVAL_NULL_OR_VOID(argv[0])) {
JS_ReportError(cx, "Invalid argument");
return JS_FALSE;
}
JS_ValueToInt32(cx,argv[0],&t);
sectostr(t,str);
if((js_str = JS_NewStringCopyZ(cx, str))==NULL)
......@@ -1677,11 +1666,13 @@ js_new_user(JSContext *cx, uintN argc, jsval *arglist)
return JS_FALSE;
scfg_t* cfg = sys->cfg;
if(argc<1 || JSVAL_NULL_OR_VOID(argv[0])) {
JS_ReportError(cx,"Missing or invalid argument");
if(!js_argc(cx, argc, 1))
return JS_FALSE;
}
if(JSVAL_NULL_OR_VOID(argv[0])) {
JS_ReportError(cx, "Invalid argument");
return JS_FALSE;
}
JSVALUE_TO_ASTRING(cx, argv[0], alias, LEN_ALIAS+2, NULL);
rc=JS_SUSPENDREQUEST(cx);
......@@ -1839,9 +1830,13 @@ js_popen(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(argc<1)
return(JS_TRUE);
if(!js_argc(cx, argc, 1))
return JS_FALSE;
if(JSVAL_NULL_OR_VOID(argv[0])) {
JS_ReportError(cx, "Invalid argument");
return JS_FALSE;
}
if((array=JS_NewArrayObject(cx,0,NULL))==NULL)
return(JS_FALSE);
......@@ -1934,9 +1929,13 @@ js_chkpid(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if(argc<1)
return(JS_TRUE);
if(!js_argc(cx, argc, 1))
return JS_FALSE;
if(JSVAL_NULL_OR_VOID(argv[0])) {
JS_ReportError(cx, "Invalid argument");
return JS_FALSE;
}
JS_ValueToInt32(cx,argv[0],&pid);
rc=JS_SUSPENDREQUEST(cx);
......@@ -1955,9 +1954,13 @@ js_killpid(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if(argc<1)
return(JS_TRUE);
if(!js_argc(cx, argc, 1))
return JS_FALSE;
if(JSVAL_NULL_OR_VOID(argv[0])) {
JS_ReportError(cx, "Invalid argument");
return JS_FALSE;
}
JS_ValueToInt32(cx,argv[0],&pid);
rc=JS_SUSPENDREQUEST(cx);
......@@ -1967,6 +1970,39 @@ js_killpid(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE);
}
static JSBool
js_text(JSContext *cx, uintN argc, jsval *arglist)
{
JSObject* obj=JS_THIS_OBJECT(cx, arglist);
jsval* argv=JS_ARGV(cx, arglist);
int32 i=0;
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if(!js_argc(cx, argc, 1))
return JS_FALSE;
if(JSVAL_NULL_OR_VOID(argv[0])) {
JS_ReportError(cx, "Invalid argument");
return JS_FALSE;
}
js_system_private_t* sys;
if((sys = (js_system_private_t*)js_GetClassPrivate(cx,obj,&js_system_class)) == NULL)
return JS_FALSE;
if(sys->cfg == NULL || sys->cfg->text == NULL)
return JS_TRUE;
if(!JS_ValueToECMAUint32(cx, argv[0], &i))
return JS_FALSE;
if(i > 0 && i <= TOTAL_TEXT) {
JSString* js_str = JS_NewStringCopyZ(cx, sys->cfg->text[i - 1]);
if(js_str==NULL)
return JS_FALSE;
JS_SET_RVAL(cx, arglist, STRING_TO_JSVAL(js_str));
}
return JS_TRUE;
}
static jsSyncMethodSpec js_system_functions[] = {
#ifndef JSDOOR
......@@ -2097,6 +2133,10 @@ static jsSyncMethodSpec js_system_functions[] = {
"returns <i>true</i> on success")
,315
},
{"text", js_text, 1, JSTYPE_STRING, JSDOCSTR("number")
,JSDOCSTR("returns specified text string from text.dat (like <tt>bbs.text()</tt>) or returns <i>null</i> upon error")
,31802
},
{0}
};
......
/* Synchronet class (sbbs_t) definition and exported function prototypes */
// vi: tabstop=4
/* $Id: sbbs.h,v 1.583 2020/08/17 00:48:28 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
......@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -477,7 +463,7 @@ public:
char *text[TOTAL_TEXT]; /* Text from ctrl\text.dat */
char *text_sav[TOTAL_TEXT]; /* Text from ctrl\text.dat */
char dszlog[127]; /* DSZLOG enviornment variable */
char dszlog[127]; /* DSZLOG environment variable */
int keybuftop,keybufbot; /* Keyboard input buffer pointers (for ungetkey) */
char keybuf[KEY_BUFSIZE]; /* Keyboard input buffer */
size_t keybuf_space(void);
......@@ -1041,7 +1027,6 @@ public:
,ulong misc);
bool exec_xtrn(uint xtrnnum); /* Executes online external program */
bool user_event(user_event_t); /* Executes user event(s) */
char xtrn_access(uint xnum); /* Does useron have access to xtrn? */
void moduserdat(uint xtrnnum);
const char* xtrn_dropdir(const xtrn_t*, char* buf, size_t);
......
......@@ -1725,7 +1725,11 @@ static BOOL ar_exp(scfg_t* cfg, uchar **ptrptr, user_t* user, client_t* client)
#endif
break;
case AR_DOS:
result=not;
#if defined(_WIN32) || (defined(__linux__) && defined(USE_DOSEMU)) || defined(__FreeBSD__)
result=!not;
#else
result=not;
#endif
break;
case AR_WIN32:
#ifndef _WIN32
......