Skip to content
Snippets Groups Projects
js_bbs.cpp 91.1 KiB
Newer Older
	if(dirnum>=sbbs->cfg.total_dirs) {
		JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(0));
		return(JS_TRUE);
	}

	for(uintN i=1;i<argc;i++) {
		if(JSVAL_IS_NUMBER(argv[i])) {
			if(!JS_ValueToInt32(cx,argv[i],&mode))
				return JS_FALSE;
		}
		else if(JSVAL_IS_STRING(argv[i])) {
			js_str = JS_ValueToString(cx, argv[i]);
deuce's avatar
deuce committed
			JSSTRING_TO_MSTRING(cx, js_str, fspec, NULL);
			if(fspec==NULL)
				return JS_FALSE;
	JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(sbbs->listfileinfo(dirnum,padfname(fspec,buf),mode)));
deuce's avatar
deuce committed
	if(fspec != def)
		free(fspec);
js_postmsg(JSContext *cx, uintN argc, jsval *arglist)
	jsval *argv=JS_ARGV(cx, arglist);
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
	if((sbbs=js_GetContextPrivate(cx))==NULL)
	subnum=get_subnum(cx,sbbs,argv,argc,0);
	if(subnum>=sbbs->cfg.total_subs) 	// invalid sub-board
		if(JSVAL_IS_NUMBER(argv[n])) {
			if(!JS_ValueToInt32(cx,argv[n],&mode))
				return JS_FALSE;
		}
		else if(JSVAL_IS_OBJECT(argv[n])) {
			if((hdrobj=JSVAL_TO_OBJECT(argv[n]))==NULL)
				return(JS_TRUE);
			remsg=&msg;
			if(!js_ParseMsgHeaderObject(cx,hdrobj,remsg))
	JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->postmsg(subnum,remsg,mode)));
js_msgscan_cfg(JSContext *cx, uintN argc, jsval *arglist)
	jsval *argv=JS_ARGV(cx, arglist);
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
	if(argc && JSVAL_IS_NUMBER(argv[0])) {
		if(!JS_ValueToInt32(cx,argv[0],&mode))
			return JS_FALSE;
	}
js_msgscan_ptrs(JSContext *cx, uintN argc, jsval *arglist)
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
js_msgscan_reinit(JSContext *cx, uintN argc, jsval *arglist)
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
	for(uint i=0;i<sbbs->cfg.total_subs;i++) {
		sbbs->subscan[i].ptr=sbbs->subscan[i].sav_ptr;
		sbbs->subscan[i].last=sbbs->subscan[i].sav_last; 
	}
	sbbs->bputs(sbbs->text[MsgPtrsInitialized]);
js_scansubs(JSContext *cx, uintN argc, jsval *arglist)
	jsval *argv=JS_ARGV(cx, arglist);
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
		if(JSVAL_IS_NUMBER(argv[i])) {
			if(!JS_ValueToInt32(cx,argv[i],&mode))
				return JS_FALSE;
		}
		else if(JSVAL_IS_BOOLEAN(argv[i]))
			all=JSVAL_TO_BOOLEAN(argv[i]);
	}

	if(all)
		sbbs->scanallsubs(mode);
	else
		sbbs->scansubs(mode);
js_scandirs(JSContext *cx, uintN argc, jsval *arglist)
	jsval *argv=JS_ARGV(cx, arglist);
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
		if(JSVAL_IS_NUMBER(argv[i])) {
			if(!JS_ValueToInt32(cx,argv[i],&mode))
				return JS_FALSE;
		}
		else if(JSVAL_IS_BOOLEAN(argv[i]))
			all=JSVAL_TO_BOOLEAN(argv[i]);
	}

	if(all)
		sbbs->scanalldirs(mode);
	else
		sbbs->scandirs(mode);
js_scanposts(JSContext *cx, uintN argc, jsval *arglist)
	jsval *argv=JS_ARGV(cx, arglist);
deuce's avatar
deuce committed
	const char	*def="";
	char*		find=(char *)def;
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
	subnum=get_subnum(cx,sbbs,argv,argc,0);

	if(subnum>=sbbs->cfg.total_subs) {	// invalid sub-board
		JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
		if(JSVAL_IS_NUMBER(argv[i])) {
			if(!JS_ValueToInt32(cx,argv[i],&mode))
				return JS_FALSE;
		}
deuce's avatar
deuce committed
		else if(JSVAL_IS_STRING(argv[i]) && find==def) {
			JSVALUE_TO_MSTRING(cx, argv[i], find, NULL);
			if(find==NULL)
				return JS_FALSE;
		}
	JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->scanposts(subnum,mode,find)==0));
deuce's avatar
deuce committed
	if(find != def)
		free(find);
js_listmsgs(JSContext *cx, uintN argc, jsval *arglist)
	jsval *argv=JS_ARGV(cx, arglist);
deuce's avatar
deuce committed
	const char	*def="";
	char*		find=(char *)def;
	uint		subnum;
	sbbs_t*		sbbs;
	uintN		argn=0;
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
	JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(0));
	subnum=get_subnum(cx,sbbs,argv,argc,argn++);

	if(subnum>=sbbs->cfg.total_subs) 	// invalid sub-board
		return(JS_TRUE);

	if(argc > argn && JSVAL_IS_NUMBER(argv[argn])) {
		if(!JS_ValueToInt32(cx,argv[argn++],&mode))
			return JS_FALSE;
	}
	if(argc > argn && JSVAL_IS_NUMBER(argv[argn])) {
		if(!JS_ValueToInt32(cx,argv[argn++],&start))
			return JS_FALSE;
	}
deuce's avatar
deuce committed
	if(argc > argn && JSVAL_IS_STRING(argv[argn])) {
		JSVALUE_TO_MSTRING(cx, argv[argn++], find, NULL);
		if(find==NULL)
			return JS_FALSE;
	}
	JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(sbbs->listsub(subnum,mode,start,find)));
deuce's avatar
deuce committed
	if(find != def)
		free(find);
js_getnstime(JSContext *cx, uintN argc, jsval *arglist)
	jsval *argv=JS_ARGV(cx, arglist);
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_NULL);
	if((sbbs=js_GetContextPrivate(cx))==NULL)
	if(argc && JSVAL_IS_NUMBER(argv[0])) {
		if(!JS_ValueToInt32(cx,argv[0],(int32*)&t))
			return JS_FALSE;
	}
deuce's avatar
deuce committed
	if(sbbs->inputnstime(&t)==true) {
		JS_SET_RVAL(cx, arglist,DOUBLE_TO_JSVAL((double)t));
js_select_shell(JSContext *cx, uintN argc, jsval *arglist)
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
	JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->select_shell()));
js_select_editor(JSContext *cx, uintN argc, jsval *arglist)
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
	JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->select_editor()));
js_get_time_left(JSContext *cx, uintN argc, jsval *arglist)
deuce's avatar
deuce committed
	jsrefcount	rc;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
	JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(sbbs->gettimeleft()));
js_chk_ar(JSContext *cx, uintN argc, jsval *arglist)
	jsval *argv=JS_ARGV(cx, arglist);
deuce's avatar
deuce committed
	char		*p;
	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((sbbs=js_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);
deuce's avatar
deuce committed
	JSVALUE_TO_MSTRING(cx, argv[0], p, NULL);
deuce's avatar
deuce committed
	if(p==NULL)
		return JS_FALSE;

	rc=JS_SUSPENDREQUEST(cx);
deuce's avatar
deuce committed
	ar = arstr(NULL,p,&sbbs->cfg);
deuce's avatar
deuce committed
	free(p);
	JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->chk_ar(ar,&sbbs->useron,&sbbs->client)));

	if(ar!=NULL && ar!=nular)
		free(ar);
	JS_RESUMEREQUEST(cx, rc);

	return JS_TRUE;
}

static jsSyncMethodSpec js_bbs_functions[] = {
rswindell's avatar
rswindell committed
	{"atcode",			js_atcode,			1,	JSTYPE_STRING,	JSDOCSTR("code_string")
rswindell's avatar
rswindell committed
	,JSDOCSTR("returns @-code value, specified <i>code</i> string does not include @ character delimiters")
rswindell's avatar
rswindell committed
	/* text.dat */
rswindell's avatar
rswindell committed
	{"text",			js_text,			1,	JSTYPE_STRING,	JSDOCSTR("line_number")
rswindell's avatar
rswindell committed
	,JSDOCSTR("returns specified text string from text.dat")
rswindell's avatar
rswindell committed
	{"replace_text",	js_replace_text,	2,	JSTYPE_BOOLEAN,	JSDOCSTR("line_number, string text")
rswindell's avatar
rswindell committed
	,JSDOCSTR("replaces specified text string in memory")
rswindell's avatar
rswindell committed
	{"revert_text",		js_revert_text,		1,	JSTYPE_BOOLEAN,	JSDOCSTR("[line_number=<i>all</i>]")
rswindell's avatar
rswindell committed
	,JSDOCSTR("reverts specified text string to original text string; "
rswindell's avatar
rswindell committed
		"if <i>line_number</i> unspecified, reverts all text lines")
rswindell's avatar
rswindell committed
	{"load_text",		js_load_text,		1,	JSTYPE_BOOLEAN,	JSDOCSTR("base_filename")
	,JSDOCSTR("load an alternate text.dat from ctrl directory, automatically appends '.dat' to basefilename")
rswindell's avatar
rswindell committed
	/* procedures */
	{"newuser",			js_newuser,			0,	JSTYPE_VOID,	JSDOCSTR("")
rswindell's avatar
rswindell committed
	,JSDOCSTR("interactive new user procedure")
rswindell's avatar
rswindell committed
	{"login",			js_login,			2,	JSTYPE_BOOLEAN,	JSDOCSTR("user_name, password_prompt")
	,JSDOCSTR("login with <i>user_name</i>, displaying <i>password_prompt</i> for password (if required)")
	{"logon",			js_logon,			0,	JSTYPE_BOOLEAN,	JSDOCSTR("")
rswindell's avatar
rswindell committed
	,JSDOCSTR("interactive logon procedure")
	{"logoff",			js_logoff,			1,	JSTYPE_VOID,	JSDOCSTR("[prompt=<i>true</i>]")
	,JSDOCSTR("interactive logoff procedure, pass <i>false</i> for <i>prompt</i> argument to avoid yes/no prompt")
	,315
	{"logout",			js_logout,			0,	JSTYPE_VOID,	JSDOCSTR("")
rswindell's avatar
rswindell committed
	,JSDOCSTR("non-interactive logout procedure")
	{"hangup",			js_hangup,			0,	JSTYPE_VOID,	JSDOCSTR("")
rswindell's avatar
rswindell committed
	,JSDOCSTR("hangup (disconnect) immediately")
	{"node_sync",		js_nodesync,		0,	JSTYPE_ALIAS },
	{"nodesync",		js_nodesync,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("synchronize with node database, checks for messages, interruption, etc. (AKA node_sync)")
	{"auto_msg",		js_automsg,			0,	JSTYPE_VOID,	JSDOCSTR("")
rswindell's avatar
rswindell committed
	,JSDOCSTR("read/create system's auto-message")
	{"time_bank",		js_time_bank,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("enter the time banking system")
	{"qwk_sec",			js_qwk_sec,			0,	JSTYPE_VOID,	JSDOCSTR("")
rswindell's avatar
rswindell committed
	,JSDOCSTR("enter the QWK message packet upload/download/config section")
	{"text_sec",		js_text_sec,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("enter the text files section")
	{"xtrn_sec",		js_xtrn_sec,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("enter the external programs section")
	{"xfer_policy",		js_xfer_policy,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("display the file transfer policy")
	{"batch_menu",		js_batchmenu,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("enter the batch file transfer menu")
	{"batch_download",	js_batchdownload,	0,	JSTYPE_BOOLEAN,	JSDOCSTR("")
rswindell's avatar
rswindell committed
	,JSDOCSTR("start a batch download")
rswindell's avatar
rswindell committed
	{"batch_add_list",	js_batchaddlist,	1,	JSTYPE_VOID,	JSDOCSTR("list_filename")
	,JSDOCSTR("add file list to batch download queue")
	{"send_file",		js_sendfile,		1,	JSTYPE_BOOLEAN,	JSDOCSTR("filename [,protocol]")
	,JSDOCSTR("send specified filename (complete path) to user via user-prompted "
		"(or optionally specified) protocol")
	,314
	{"receive_file",	js_recvfile,		1,	JSTYPE_BOOLEAN,	JSDOCSTR("filename [,protocol]")
	,JSDOCSTR("received specified filename (complete path) frome user via user-prompted "
		"(or optionally specified) protocol")
	,314
	{"temp_xfer",		js_temp_xfer,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("enter the temporary file tranfer menu")
	{"user_sync",		js_user_sync,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("read the current user data from the database")
	{"user_config",		js_user_config,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("enter the user settings configuration menu")
	{"sys_info",		js_sys_info,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("display system information")
rswindell's avatar
rswindell committed
	{"sub_info",		js_sub_info,		1,	JSTYPE_VOID,	JSDOCSTR("[sub-board=<i>current</i>]")
rswindell's avatar
rswindell committed
	,JSDOCSTR("display message sub-board information (current <i>sub-board</i>, if unspecified)")
rswindell's avatar
rswindell committed
	{"dir_info",		js_dir_info,		0,	JSTYPE_VOID,	JSDOCSTR("[directory=<i>current</i>]")
rswindell's avatar
rswindell committed
	,JSDOCSTR("display file directory information (current <i>directory</i>, if unspecified)")
	{"user_info",		js_user_info,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("display current user information")
	{"ver",				js_ver,				0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("display software version information")
	{"sys_stats",		js_sys_stats,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("display system statistics")
rswindell's avatar
rswindell committed
	{"node_stats",		js_node_stats,		0,	JSTYPE_VOID,	JSDOCSTR("[node_number=<i>current</i>]")
	,JSDOCSTR("display current (or specified) node statistics")
rswindell's avatar
rswindell committed
	{"list_users",		js_userlist,		0,	JSTYPE_VOID,	JSDOCSTR("[mode=<tt>UL_ALL</tt>]")
	,JSDOCSTR("display user list"
	"(see <tt>UL_*</tt> in <tt>sbbsdefs.js</tt> for valid <i>mode</i> values)")
rswindell's avatar
rswindell committed
	{"edit_user",		js_useredit,		0,	JSTYPE_VOID,	JSDOCSTR("[user_number=<i>current</i>]")
	,JSDOCSTR("enter the user editor")
	{"change_user",		js_change_user,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("change to a different user")
	{"list_logons",		js_logonlist,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("display the logon list")
rswindell's avatar
rswindell committed
	{"read_mail",		js_readmail,		0,	JSTYPE_VOID,	JSDOCSTR("[which=<tt>MAIL_YOUR</tt>] [,user_number=<i>current</i>]")
	,JSDOCSTR("read private e-mail"
	"(see <tt>MAIL_*</tt> in <tt>sbbsdefs.js</tt> for valid <i>which</i> values)")
rswindell's avatar
rswindell committed
	{"email",			js_email,			1,	JSTYPE_BOOLEAN,	JSDOCSTR("to_user_number [,mode=<tt>WM_EMAIL</tt>] [,top=<i>none</i>] [,subject=<i>none</i>]")
	,JSDOCSTR("send private e-mail to a local user")
rswindell's avatar
rswindell committed
	{"netmail",			js_netmail,			1,	JSTYPE_BOOLEAN,	JSDOCSTR("address [,mode=<tt>WM_NONE</tt>] [,subject=<i>none</i>]")
	,JSDOCSTR("send private netmail")
	{"bulk_mail",		js_bulkmail,		0,	JSTYPE_VOID,	JSDOCSTR("[ars]")
rswindell's avatar
rswindell committed
	,JSDOCSTR("send bulk private e-mail, if <i>ars</i> not specified, prompt for destination users")
rswindell's avatar
rswindell committed
	{"upload_file",		js_upload_file,		1,	JSTYPE_BOOLEAN,	JSDOCSTR("[directory=<i>current</i>]")
rswindell's avatar
rswindell committed
	,JSDOCSTR("upload file to file directory specified by number or internal code")
rswindell's avatar
rswindell committed
	{"bulk_upload",		js_bulkupload,		1,	JSTYPE_BOOLEAN,	JSDOCSTR("[directory=<i>current</i>]")
rswindell's avatar
rswindell committed
	,JSDOCSTR("add files (already in local storage path) to file directory "
		"specified by number or internal code")
rswindell's avatar
rswindell committed
	{"resort_dir",		js_resort_dir,		1,	JSTYPE_BOOLEAN,	JSDOCSTR("[directory=<i>current</i>]")
rswindell's avatar
rswindell committed
	,JSDOCSTR("re-sort the file directory specified by number or internal code)")
	{"list_files",		js_listfiles,		1,	JSTYPE_NUMBER,	JSDOCSTR("[directory=<i>current</i>] [,filespec=<tt>\"*.*\"</tt> or search_string] [,mode=<tt>FL_NONE</tt>]")
rswindell's avatar
rswindell committed
	,JSDOCSTR("list files in the specified file directory, "
		"optionally specifying a file specification (wildcards) or a description search string, "
		"and <i>mode</i> (bitfield)")
rswindell's avatar
rswindell committed
	{"list_file_info",	js_listfileinfo,	1,	JSTYPE_NUMBER,	JSDOCSTR("[directory=<i>current</i>] [,filespec=<tt>\"*.*\"</tt>] [,mode=<tt>FI_INFO</tt>]")
	,JSDOCSTR("list extended file information for files in the specified file directory")
rswindell's avatar
rswindell committed
	{"post_msg",		js_postmsg,			1,	JSTYPE_BOOLEAN,	JSDOCSTR("[sub-board=<i>current</i>] [,mode=<tt>WM_MODE</tt>] [,object reply_header]")
rswindell's avatar
rswindell committed
	,JSDOCSTR("post a message in the specified message sub-board (number or internal code) "
		"with optinal <i>mode</i> (bitfield)<br>"
		"If <i>reply_header</i> is specified (a header object returned from <i>MsgBase.get_msg_header()</i>), that header "
		"will be used for the in-reply-to header fields (this argument added in v3.13)")
	,313
rswindell's avatar
rswindell committed
	{"cfg_msg_scan",	js_msgscan_cfg,		0,	JSTYPE_VOID,	JSDOCSTR("[type=<tt>SCAN_CFG_NEW</tt>]")
	,JSDOCSTR("configure message scan "
		"(<i>type</i> is either <tt>SCAN_CFG_NEW</tt> or <tt>SCAN_CFG_TOYOU</tt>)")
	{"cfg_msg_ptrs",	js_msgscan_ptrs,	0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("change message scan pointer values")
	{"reinit_msg_ptrs",	js_msgscan_reinit,	0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("re-initialize new message scan pointers")
rswindell's avatar
rswindell committed
	{"scan_subs",		js_scansubs,		0,	JSTYPE_VOID,	JSDOCSTR("[mode=<tt>SCAN_NEW</tt>] [,all=<tt>false</tt>]")
	,JSDOCSTR("scan sub-boards for messages")
rswindell's avatar
rswindell committed
	{"scan_dirs",		js_scandirs,		0,	JSTYPE_VOID,	JSDOCSTR("[mode=<tt>FL_NONE</tt>] [,all=<tt>false</tt>]")
	,JSDOCSTR("scan directories for files")
	{"scan_posts",		js_scanposts,		1,	JSTYPE_ALIAS },
	{"scan_msgs",		js_scanposts,		1,	JSTYPE_BOOLEAN,	JSDOCSTR("[sub-board=<i>current</i>] [,mode=<tt>SCAN_READ</tt>] [,string find]")
	,JSDOCSTR("scan messages in the specified message sub-board (number or internal code), "
		"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>] [,string find]")
	,JSDOCSTR("list messages in the specified message sub-board (number or internal code), "
		"optionally search for 'find' string, returns number of messages listed")
rswindell's avatar
rswindell committed
	/* menuing */
	{"menu",			js_menu,			1,	JSTYPE_VOID,	JSDOCSTR("base_filename")
rswindell's avatar
rswindell committed
	,JSDOCSTR("display a menu file from the text/menu directory")
rswindell's avatar
rswindell committed
	{"log_key",			js_logkey,			1,	JSTYPE_BOOLEAN,	JSDOCSTR("key [,comma=<tt>false</tt>]")
	,JSDOCSTR("log key to node.log (comma optional)")
	{"log_str",			js_logstr,			1,	JSTYPE_BOOLEAN,	JSDOCSTR("text")
	,JSDOCSTR("log string to node.log")
rswindell's avatar
rswindell committed
	/* users */
	{"finduser",		js_finduser,		1,	JSTYPE_NUMBER,	JSDOCSTR("username_or_number")
rswindell's avatar
rswindell committed
	,JSDOCSTR("find user name (partial name support), interactive")
	{"trashcan",		js_trashcan,		2,	JSTYPE_BOOLEAN,	JSDOCSTR("base_filename, search_string")
	,JSDOCSTR("search file for psuedo-regexp (search string) in trashcan file (text/base_filename.can)")
rswindell's avatar
rswindell committed
	/* xtrn programs/modules */
rswindell's avatar
rswindell committed
	{"exec",			js_exec,			2,	JSTYPE_NUMBER,	JSDOCSTR("cmdline [,mode=<tt>EX_NONE</tt>] [,string startup_dir]")
	,JSDOCSTR("execute a program, optionally changing current directory to <i>startup_dir</i> "
	"(see <tt>EX_*</tt> in <tt>sbbsdefs.js</tt> for valid <i>mode</i> bits)")
	{"exec_xtrn",		js_exec_xtrn,		1,	JSTYPE_BOOLEAN,	JSDOCSTR("xtrn_number_or_code")
rswindell's avatar
rswindell committed
	,JSDOCSTR("execute external program by number or internal code")
rswindell's avatar
rswindell committed
	{"user_event",		js_user_event,		1,	JSTYPE_BOOLEAN,	JSDOCSTR("event_type")
	,JSDOCSTR("execute user event by event type "
	"(see <tt>EVENT_*</tt> in <tt>sbbsdefs.js</tt> for valid values)")
rswindell's avatar
rswindell committed
	{"telnet_gate",		js_telnet_gate,		1,	JSTYPE_VOID,	JSDOCSTR("address [,mode=<tt>TG_NONE</tt>]")
	,JSDOCSTR("external telnet/rlogin gateway (see <tt>TG_*</tt> in <tt>sbbsdefs.js</tt> for valid <i>mode</i> bits)")
rswindell's avatar
rswindell committed
	/* security */
	{"check_syspass",	js_chksyspass,		0,	JSTYPE_BOOLEAN,	JSDOCSTR("")
	,JSDOCSTR("prompt for and verify system password")
rswindell's avatar
rswindell committed
	{"good_password",	js_chkpass,			1,	JSTYPE_STRING,	JSDOCSTR("password")
rswindell's avatar
rswindell committed
	,JSDOCSTR("check if requested user password meets minimum password requirements "
		"(length, uniqueness, etc.)")
rswindell's avatar
rswindell committed
	/* chat/node stuff */
	{"page_sysop",		js_pagesysop,		0,	JSTYPE_BOOLEAN,	JSDOCSTR("")
	,JSDOCSTR("page the sysop for chat, returns <i>false</i> if the sysop could not be paged")
	{"page_guru",		js_pageguru,		0,	JSTYPE_BOOLEAN,	JSDOCSTR("")
	,JSDOCSTR("page the guru for chat")
	{"multinode_chat",	js_multinode_chat,	0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("enter multi-node chat")
	{"private_message",	js_private_message,	0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("use the private inter-node message prompt")
	{"private_chat",	js_private_chat,	0,	JSTYPE_VOID,	JSDOCSTR("[local=<i>false</i>]")
	,JSDOCSTR("enter private inter-node chat, or local sysop chat (if <i>local</i>=<i>true</i>)")
	{"get_node_message",js_get_node_message,0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("receive and display an inter-node message")
rswindell's avatar
rswindell committed
	{"put_node_message",js_put_node_message,2,	JSTYPE_BOOLEAN,	JSDOCSTR("node_number, text")
	,JSDOCSTR("send an inter-node message")
rswindell's avatar
rswindell committed
	{"get_telegram",	js_get_telegram,	1,	JSTYPE_VOID,	JSDOCSTR("[user_number=<i>current</i>]")
	,JSDOCSTR("receive and display waiting telegrams for specified (or current) user")
rswindell's avatar
rswindell committed
	{"put_telegram",	js_put_telegram,	2,	JSTYPE_BOOLEAN,	JSDOCSTR("user_number, text")
	,JSDOCSTR("send a telegram to a user")
	{"list_nodes",		js_nodelist,		0,	JSTYPE_VOID,	JSDOCSTR("")
	,JSDOCSTR("list all nodes")
	{"whos_online",		js_whos_online,		0,	JSTYPE_VOID,	JSDOCSTR("")
rswindell's avatar
rswindell committed
	,JSDOCSTR("list active nodes only (who's online)")
	{"spy",				js_spy,				1,	JSTYPE_VOID,	JSDOCSTR("node_number")
	,JSDOCSTR("spy on a node")
rswindell's avatar
rswindell committed
	{"cmdstr",			js_cmdstr,			1,	JSTYPE_STRING,	JSDOCSTR("command_string [,string fpath=<tt>\"\"</tt>] [,string fspec=<tt>\"\"</tt>]")
rswindell's avatar
rswindell committed
	,JSDOCSTR("return expanded command string using Synchronet command-line specifiers")
	{"get_filespec",	js_getfilespec,		0,	JSTYPE_STRING,	JSDOCSTR("")	
rswindell's avatar
rswindell committed
	,JSDOCSTR("returns a file specification input by the user (optionally with wildcards)")
rswindell's avatar
rswindell committed
	{"get_newscantime",	js_getnstime,		1,	JSTYPE_NUMBER,	JSDOCSTR("time=<i>current</i>")
	,JSDOCSTR("confirm or change a new-scan time, returns the new new-scan time value (<i>time_t</i> format)")
	{"select_shell",	js_select_shell,	0,	JSTYPE_BOOLEAN,	JSDOCSTR("")
rswindell's avatar
rswindell committed
	,JSDOCSTR("prompt user to select a new command shell")
	{"select_editor",	js_select_editor,	0,	JSTYPE_BOOLEAN,	JSDOCSTR("")
rswindell's avatar
rswindell committed
	,JSDOCSTR("prompt user to select a new external message editor")
	{"get_time_left",	js_get_time_left,	0,	JSTYPE_NUMBER,	JSDOCSTR("")
	,JSDOCSTR("check the user's available remaining time online and return the value, in seconds<br>"
	"This method will inform (and disconnect) the user when they are out of time")
	{"compare_ars",		js_chk_ar,			1,	JSTYPE_BOOLEAN,	JSDOCSTR("string ars")
	,JSDOCSTR("verify the current user online meets the specified Access Requirements String")
	,315
	},		
static JSBool js_bbs_resolve(JSContext *cx, JSObject *obj, jsid id)
{
	char*			name=NULL;
deuce's avatar
deuce committed
	JSBool			ret;
deuce's avatar
deuce committed
	if(id != JSID_VOID && id != JSID_EMPTY) {
		jsval idval;
		
		JS_IdToValue(cx, id, &idval);
deuce's avatar
deuce committed
		if(JSVAL_IS_STRING(idval)) {
			JSSTRING_TO_MSTRING(cx, JSVAL_TO_STRING(idval), name, NULL);
			HANDLE_PENDING(cx);
		}
deuce's avatar
deuce committed
	}
deuce's avatar
deuce committed
	ret=js_SyncResolve(cx, obj, name, js_bbs_properties, js_bbs_functions, NULL, 0);
	if(name)
		free(name);
	return ret;
}

static JSBool js_bbs_enumerate(JSContext *cx, JSObject *obj)
{
deuce's avatar
deuce committed
	return(js_bbs_resolve(cx, obj, JSID_VOID));

static JSClass js_bbs_class = {
     "BBS"					/* name			*/
    ,0						/* flags		*/
	,JS_PropertyStub		/* addProperty	*/
	,JS_PropertyStub		/* delProperty	*/
	,js_bbs_get				/* getProperty	*/
	,js_bbs_set				/* setProperty	*/
	,js_bbs_enumerate		/* enumerate	*/
	,js_bbs_resolve			/* resolve		*/
	,JS_ConvertStub			/* convert		*/
	,JS_FinalizeStub		/* finalize		*/
};

JSObject* js_CreateBbsObject(JSContext* cx, JSObject* parent)
{
	JSObject* obj;
	obj = JS_DefineObject(cx, parent, "bbs", &js_bbs_class, NULL
		,JSPROP_ENUMERATE|JSPROP_READONLY);

	if(obj==NULL)
		return(NULL);

	if((mods=JS_DefineObject(cx, obj, "mods", NULL, NULL ,JSPROP_ENUMERATE))==NULL)
		return(NULL);

	js_DescribeSyncObject(cx,mods,"Global repository for 3rd party modifications",312);
	js_DescribeSyncObject(cx,obj,"Controls the Telnet/SSH/RLogin BBS experience",310);
	js_CreateArrayOfStrings(cx, obj, "_property_desc_list", bbs_prop_desc, JSPROP_READONLY);
#endif

#endif	/* JAVSCRIPT */