Newer
Older
/* Synchronet JavaScript "system" Object */
/* $Id$ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* 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. *
****************************************************************************/
#include "sbbs.h"
#include "js_request.h"
typedef struct {
scfg_t* cfg;
int nodefile;
int nodegets;
} js_system_private_t;
extern JSClass js_system_class;
/* System Object Properties */
enum {
SYS_PROP_NAME
,SYS_PROP_OP
,SYS_PROP_ID
,SYS_PROP_MISC
,SYS_PROP_PSNAME
,SYS_PROP_PSNUM
,SYS_PROP_INETADDR
,SYS_PROP_LOCATION
,SYS_PROP_TIMEZONE
,SYS_PROP_PWDAYS
,SYS_PROP_DELDAYS
,SYS_PROP_AUTODEL
,SYS_PROP_LASTUSER
,SYS_PROP_LASTUSERON
,SYS_PROP_FREEDISKSPACE
,SYS_PROP_FREEDISKSPACEK
,SYS_PROP_NODES
,SYS_PROP_LASTNODE
,SYS_PROP_NEW_PASS
,SYS_PROP_NEW_MAGIC
,SYS_PROP_NEW_LEVEL
,SYS_PROP_NEW_FLAGS1
,SYS_PROP_NEW_FLAGS2
,SYS_PROP_NEW_FLAGS3
,SYS_PROP_NEW_FLAGS4
,SYS_PROP_NEW_REST
,SYS_PROP_NEW_EXEMPT
,SYS_PROP_NEW_CDT
,SYS_PROP_NEW_MIN
,SYS_PROP_NEW_SHELL
,SYS_PROP_NEW_XEDIT
,SYS_PROP_NEW_MISC
,SYS_PROP_NEW_PROT
,SYS_PROP_NEW_EXPIRE
,SYS_PROP_NEW_UQ
,SYS_PROP_EXPIRED_LEVEL
,SYS_PROP_EXPIRED_FLAGS1
,SYS_PROP_EXPIRED_FLAGS2
,SYS_PROP_EXPIRED_FLAGS3
,SYS_PROP_EXPIRED_FLAGS4
,SYS_PROP_EXPIRED_REST
,SYS_PROP_EXPIRED_EXEMPT
/* directories */
,SYS_PROP_NODE_DIR
,SYS_PROP_CTRL_DIR
,SYS_PROP_DATA_DIR
,SYS_PROP_TEXT_DIR
,SYS_PROP_TEMP_DIR
,SYS_PROP_EXEC_DIR
,SYS_PROP_MODS_DIR
,SYS_PROP_LOGS_DIR
/* msclock() access */
,SYS_PROP_CLOCK
,SYS_PROP_CLOCK_PER_SEC
/* filenames */
,SYS_PROP_DEVNULL
,SYS_PROP_TEMP_PATH
/* last */
,SYS_PROP_LOCAL_HOSTNAME
static JSBool js_system_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
jsval idval;
ulong val;
js_system_private_t* sys;
if((sys = (js_system_private_t*)js_GetClassPrivate(cx,obj,&js_system_class))==NULL)
return JS_FALSE;
scfg_t* cfg = sys->cfg;
JS_IdToValue(cx, id, &idval);
tiny = JSVAL_TO_INT(idval);
#ifndef JSDOOR
*vp=UINT_TO_JSVAL(cfg->sys_misc);
break;
case SYS_PROP_PSNUM:
*vp = INT_TO_JSVAL(cfg->sys_psnum);
break;
case SYS_PROP_INETADDR:
break;
case SYS_PROP_LOCATION:
break;
case SYS_PROP_TIMEZONE:
sys_timezone(cfg);
*vp = INT_TO_JSVAL(cfg->sys_timezone);
break;
case SYS_PROP_NODES:
*vp = INT_TO_JSVAL(cfg->sys_nodes);
break;
case SYS_PROP_LASTNODE:
*vp = INT_TO_JSVAL(cfg->sys_lastnode);
break;
case SYS_PROP_PWDAYS:
*vp = INT_TO_JSVAL(cfg->sys_pwdays);
break;
case SYS_PROP_DELDAYS:
*vp = INT_TO_JSVAL(cfg->sys_deldays);
break;
case SYS_PROP_AUTODEL:
*vp = INT_TO_JSVAL(cfg->sys_autodel);
break;
case SYS_PROP_LASTUSER:
*vp = INT_TO_JSVAL(lastuser(cfg));
break;
#endif
case SYS_PROP_FREEDISKSPACEK:
rc=JS_SUSPENDREQUEST(cx);
if(tiny==SYS_PROP_FREEDISKSPACE)
val = getfreediskspace(cfg->temp_dir,0);
else
val = getfreediskspace(cfg->temp_dir,1024);
JS_RESUMEREQUEST(cx, rc);
Loading
Loading full blame...