Newer
Older
/* Synchronet JavaScript "bbs" Object */
/****************************************************************************
* @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 *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#include "sbbs.h"
#include "js_request.h"
#ifdef JAVASCRIPT
/*****************************/
/* BBS Object Properites */
/*****************************/
enum {
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
BBS_PROP_SYS_STATUS
, BBS_PROP_STARTUP_OPT
, BBS_PROP_ANSWER_TIME
, BBS_PROP_LOGON_TIME
, BBS_PROP_START_TIME
, BBS_PROP_NS_TIME
, BBS_PROP_LAST_NS_TIME
, BBS_PROP_ONLINE
, BBS_PROP_TIMELEFT
, BBS_PROP_EVENT_TIME
, BBS_PROP_EVENT_CODE
, BBS_PROP_FIRST_NODE
, BBS_PROP_LAST_NODE
, BBS_PROP_NODE_NUM
, BBS_PROP_NODE_SETTINGS
, BBS_PROP_NODE_STATUS
, BBS_PROP_NODE_ERRORS
, BBS_PROP_NODE_ACTION
, BBS_PROP_NODE_USERON
, BBS_PROP_NODE_CONNECTION
, BBS_PROP_NODE_MISC
, BBS_PROP_NODE_AUX
, BBS_PROP_NODE_EXTAUX
, BBS_PROP_NODE_VAL_USER
, BBS_PROP_LOGON_ULB
, BBS_PROP_LOGON_DLB
, BBS_PROP_LOGON_ULS
, BBS_PROP_LOGON_DLS
, BBS_PROP_LOGON_POSTS
, BBS_PROP_LOGON_EMAILS
, BBS_PROP_LOGON_FBACKS
, BBS_PROP_POSTS_READ
, BBS_PROP_MENU_DIR
, BBS_PROP_MENU_FILE
, BBS_PROP_MAIN_CMDS
, BBS_PROP_FILE_CMDS
, BBS_PROP_CURGRP
, BBS_PROP_CURSUB
, BBS_PROP_CURSUB_CODE
, BBS_PROP_CURLIB
, BBS_PROP_CURDIR
, BBS_PROP_CURDIR_CODE
, BBS_PROP_CONNECTION /* READ ONLY */
, BBS_PROP_RLOGIN_NAME
, BBS_PROP_RLOGIN_PASS
, BBS_PROP_RLOGIN_TERM
, BBS_PROP_CLIENT_NAME
, BBS_PROP_ERRORLEVEL /* READ ONLY */
/* READ ONLY */
, BBS_PROP_SMB_GROUP
, BBS_PROP_SMB_GROUP_DESC
, BBS_PROP_SMB_GROUP_NUM
, BBS_PROP_SMB_SUB
, BBS_PROP_SMB_SUB_DESC
, BBS_PROP_SMB_SUB_CODE
, BBS_PROP_SMB_SUB_NUM
, BBS_PROP_SMB_ATTR
, BBS_PROP_SMB_LAST_MSG
, BBS_PROP_SMB_TOTAL_MSGS
, BBS_PROP_SMB_MSGS
, BBS_PROP_SMB_CURMSG // writable
/* READ ONLY */
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
, BBS_PROP_MSG_TO
, BBS_PROP_MSG_TO_EXT
, BBS_PROP_MSG_TO_NET
, BBS_PROP_MSG_TO_AGENT
, BBS_PROP_MSG_FROM
, BBS_PROP_MSG_FROM_EXT
, BBS_PROP_MSG_FROM_NET
, BBS_PROP_MSG_FROM_BBSID
, BBS_PROP_MSG_FROM_AGENT
, BBS_PROP_MSG_REPLYTO
, BBS_PROP_MSG_REPLYTO_EXT
, BBS_PROP_MSG_REPLYTO_NET
, BBS_PROP_MSG_REPLYTO_AGENT
, BBS_PROP_MSG_SUBJECT
, BBS_PROP_MSG_DATE
, BBS_PROP_MSG_TIMEZONE
, BBS_PROP_MSG_DATE_IMPORTED
, BBS_PROP_MSG_ATTR
, BBS_PROP_MSG_AUXATTR
, BBS_PROP_MSG_NETATTR
, BBS_PROP_MSG_OFFSET
, BBS_PROP_MSG_NUMBER // writable
, BBS_PROP_MSG_EXPIRATION
, BBS_PROP_MSG_FORWARDED
, BBS_PROP_MSG_THREAD_ID
, BBS_PROP_MSG_THREAD_BACK
, BBS_PROP_MSG_THREAD_NEXT
, BBS_PROP_MSG_THREAD_FIRST
, BBS_PROP_MSG_ID
, BBS_PROP_MSG_REPLY_ID
, BBS_PROP_MSG_DELIVERY_ATTEMPTS
, BBS_PROP_MSGHDR_TOS
/* READ ONLY */
, BBS_PROP_DOWNLOAD_CPS
, BBS_PROP_BATCH_UPLOAD_TOTAL
, BBS_PROP_BATCH_DNLOAD_TOTAL
, BBS_PROP_FILE_NAME
, BBS_PROP_FILE_DESC
, BBS_PROP_FILE_DIR
, BBS_PROP_FILE_ATTR
, BBS_PROP_FILE_DATE
, BBS_PROP_FILE_SIZE
, BBS_PROP_FILE_CREDITS
, BBS_PROP_FILE_ULER
, BBS_PROP_FILE_DATE_ULED
, BBS_PROP_FILE_DATE_DLED
, BBS_PROP_FILE_TIMES_DLED
, BBS_PROP_COMMAND_STR
#ifdef BUILD_JSDOCS
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
static const char* bbs_prop_desc[] = {
"System status bit-flags (see <tt>SS_*</tt> in <tt>sbbsdefs.js</tt> for bit definitions)"
, "Startup options bit-flags (see <tt>BBS_OPT_*</tt> in <tt>sbbsdefs.js</tt> for bit definitions)"
, "Answer time, in <i>time_t</i> format"
, "Logon time, in <i>time_t</i> format"
, "Time from which user's time left is calculated, in <i>time_t</i> format"
, "Current file new-scan time, in <i>time_t</i> format"
, "Previous file new-scan time, in <i>time_t</i> format"
, "Online (see <tt>ON_*</tt> in <tt>sbbsdefs.js</tt> for valid values)"
, "Time left (in seconds)"
, "Time of next exclusive event (in <i>time_t</i> format), or 0 if none"
, "Internal code of next exclusive event"
, "First node number (of this instance of Synchronet)"
, "Last node number (of this instance of Synchronet)"
, "Current node number"
, "Current node settings bit-flags (see <tt>NM_*</tt> in <tt>sbbsdefs.js</tt> for bit definitions)"
, "Current node status value (see <tt>nodedefs.js</tt> for valid values)"
, "Current node error counter"
, "Current node action (see <tt>nodedefs.js</tt> for valid values)"
, "Current node user number (<i>useron</i> value)"
, "Current node connection type (see <tt>nodedefs.js</tt> for valid values)"
, "Current node misc value (see <tt>nodedefs.js</tt> for valid values)"
, "Current node aux value"
, "Current node extended aux (<i>extaux</i>) value"
, "Validation feedback user for this node (or 0 for no validation feedback required)"
, "Bytes uploaded during this session"
, "Bytes downloaded during this session"
, "Files uploaded during this session"
, "Files downloaded during this session"
, "Messages posted during this session"
, "E-mails sent during this session"
, "Feedback messages sent during this session"
, "Messages read during this session"
, "Menu subdirectory (overrides default)"
, "Menu file (overrides default)"
, "Total main menu commands received from user during this session"
, "Total file menu commands received from user during this session"
, "Current message group"
, "Current message sub-board"
, "Current message sub-board internal code"
, "Current file library"
, "Current file directory"
, "Current file directory internal code"
, "Remote connection type"
, "Login name given during RLogin negotiation"
, "Password specified during RLogin negotiation"
, "Terminal specified during RLogin negotiation"
, "Client name"
, "Error level returned from last executed external program"
, "Message group name of message being read"
, "Message group description of message being read"
, "Message group number of message being read"
, "Sub-board name of message being read"
, "Sub-board description of message being read"
, "Sub-board internal code of message being read"
, "Sub-board number of message being read"
, "Message base attributes"
, "Highest message number in message base"
, "Total number of messages in message base"
, "Number of messages loaded from message base"
, "Current message number in message base"
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
, "Message recipient name"
, "Message recipient extension"
, "Message recipient network address"
, "Message recipient agent type"
, "Message sender name"
, "Message sender extension"
, "Message sender network address"
, "Message sender BBS ID"
, "Message sender agent type"
, "Message reply-to name"
, "Message reply-to extension"
, "Message reply-to network address"
, "Message reply-to agent type"
, "Message subject"
, "Message date/time"
, "Message time zone"
, "Message date/time imported"
, "Message attributes"
, "Message auxiliary attributes"
, "Message network attributes"
, "Message header offset"
, "Message number (unique, monotonically incrementing)"
, "Message expiration"
, "Message forwarded"
, "Message thread identifier (0 if unknown)"
, "Message thread, back message number"
, "Message thread, next message number"
, "Message thread, message number of first reply to this message"
, "Message identifier"
, "Message replied-to identifier"
, "Message delivery attempt counter"
, "Message header displayed at top-of-screen"
, "File name"
, "File description"
, "File directory (number)"
, "File attribute flags"
, "File date"
, "File size (in bytes)"
, "File credit value"
, "File uploader (user name)"
, "File upload date"
, "File last-download date"
, "File download count"
, "Most recent file download rate (in characters/bytes per second)"
, "Number of files in batch upload queue"
, "Number of files in batch download queue"
, "Current command shell/module <i>command string</i> value"
, NULL
};
extern JSClass js_bbs_class; // defined later
static sbbs_t *js_GetPrivate(JSContext *cx, JSObject *obj)
return (sbbs_t *)js_GetClassPrivate(cx, obj, &js_bbs_class);
static JSBool js_bbs_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
jsval idval;
char tmp[128];
const char* p = NULL;
const char* nulstr = "";
uint32 val = 0;
jsint tiny;
sbbs_t* sbbs;
jsrefcount rc;
if ((sbbs = js_GetPrivate(cx, obj)) == NULL)
JS_IdToValue(cx, id, &idval);
tiny = JSVAL_TO_INT(idval);
val = sbbs->sys_status;
break;
case BBS_PROP_STARTUP_OPT:
val = sbbs->startup->options;
break;
case BBS_PROP_ANSWER_TIME:
val = (uint32)sbbs->answertime;
break;
case BBS_PROP_LOGON_TIME:
val = (uint32)sbbs->logontime;
case BBS_PROP_START_TIME:
val = (uint32)sbbs->starttime;
val = (uint32)sbbs->ns_time;
break;
case BBS_PROP_LAST_NS_TIME:
val = (uint32)sbbs->last_ns_time;
rc = JS_SUSPENDREQUEST(cx);
val = sbbs->gettimeleft(false);
JS_RESUMEREQUEST(cx, rc);
case BBS_PROP_EVENT_TIME:
val = (uint32)sbbs->event_time;
break;
case BBS_PROP_EVENT_CODE:
break;
case BBS_PROP_FIRST_NODE:
val = sbbs->startup->first_node;
break;
case BBS_PROP_LAST_NODE:
val = sbbs->startup->last_node;
break;
val = sbbs->cfg.node_num;
val = sbbs->cfg.node_misc;
val = sbbs->thisnode.status;
val = sbbs->thisnode.errors;
val = sbbs->thisnode.useron;
val = sbbs->thisnode.connection;
val = sbbs->thisnode.misc;
val = sbbs->thisnode.aux;
val = sbbs->thisnode.extaux;
case BBS_PROP_NODE_VAL_USER:
val = sbbs->cfg.valuser;
break;
case BBS_PROP_LOGON_ULB:
val = (uint32_t)sbbs->logon_ulb; // TODO: fix for > 4GB!
break;
case BBS_PROP_LOGON_DLB:
val = (uint32_t)sbbs->logon_dlb; // TODO: fix for > 4GB!
break;
case BBS_PROP_LOGON_ULS:
val = (uint32_t)sbbs->logon_uls; // TODO: fix for > 4GB!
break;
case BBS_PROP_LOGON_DLS:
val = (uint32_t)sbbs->logon_dls; // TODO: fix for > 4GB!
break;
case BBS_PROP_LOGON_POSTS:
val = sbbs->logon_posts;
break;
case BBS_PROP_LOGON_EMAILS:
val = sbbs->logon_emails;
break;
case BBS_PROP_LOGON_FBACKS:
val = sbbs->logon_fbacks;
break;
case BBS_PROP_POSTS_READ:
val = sbbs->posts_read;
break;
case BBS_PROP_MENU_DIR:
val = sbbs->main_cmds;
val = sbbs->xfer_cmds;
case BBS_PROP_CURGRP:
break;
case BBS_PROP_CURSUB:
if (sbbs->curgrp < sbbs->usrgrps)
val = sbbs->cursub[sbbs->curgrp];
case BBS_PROP_CURSUB_CODE:
if (sbbs->subnum_is_valid(sbbs->cursubnum))
p = sbbs->cfg.sub[sbbs->cursubnum]->code;
else
case BBS_PROP_CURLIB:
break;
case BBS_PROP_CURDIR:
if (sbbs->curlib < sbbs->usrlibs)
val = sbbs->curdir[sbbs->curlib];
case BBS_PROP_CURDIR_CODE:
if (sbbs->dirnum_is_valid(sbbs->curdirnum))
p = sbbs->cfg.dir[sbbs->curdirnum]->code;
else
p = sbbs->rlogin_name;
case BBS_PROP_RLOGIN_PASS:
p = sbbs->rlogin_pass;
case BBS_PROP_RLOGIN_TERM:
p = sbbs->rlogin_term;
p = sbbs->client_name;
case BBS_PROP_ERRORLEVEL:
val = sbbs->errorlevel;
break;
/* Currently Open Message Base (sbbs.smb) */
case BBS_PROP_SMB_GROUP:
if (!subnum_is_valid(&sbbs->cfg, sbbs->smb.subnum))
p = nulstr;
else
p = sbbs->cfg.grp[sbbs->cfg.sub[sbbs->smb.subnum]->grp]->sname;
break;
case BBS_PROP_SMB_GROUP_DESC:
if (!subnum_is_valid(&sbbs->cfg, sbbs->smb.subnum))
p = nulstr;
else
p = sbbs->cfg.grp[sbbs->cfg.sub[sbbs->smb.subnum]->grp]->lname;
break;
case BBS_PROP_SMB_GROUP_NUM:
if (sbbs->subnum_is_valid(sbbs->smb.subnum)) {

Rob Swindell
committed
int ugrp;
for (ugrp = 0; ugrp < sbbs->usrgrps; ugrp++)
if (sbbs->usrgrp[ugrp] == sbbs->cfg.sub[sbbs->smb.subnum]->grp)
break;
}
break;
case BBS_PROP_SMB_SUB:
if (!subnum_is_valid(&sbbs->cfg, sbbs->smb.subnum))
p = nulstr;
else
p = sbbs->cfg.sub[sbbs->smb.subnum]->sname;
break;
case BBS_PROP_SMB_SUB_DESC:
if (!subnum_is_valid(&sbbs->cfg, sbbs->smb.subnum))
p = nulstr;
else
p = sbbs->cfg.sub[sbbs->smb.subnum]->lname;
break;
case BBS_PROP_SMB_SUB_CODE:
if (!subnum_is_valid(&sbbs->cfg, sbbs->smb.subnum))
p = nulstr;
else
p = sbbs->cfg.sub[sbbs->smb.subnum]->code;
break;
case BBS_PROP_SMB_SUB_NUM:
if (sbbs->usrsubs && sbbs->subnum_is_valid(sbbs->smb.subnum)) {

Rob Swindell
committed
int ugrp;
for (ugrp = 0; ugrp < sbbs->usrgrps; ugrp++)
if (sbbs->usrgrp[ugrp] == sbbs->cfg.sub[sbbs->smb.subnum]->grp)
break;

Rob Swindell
committed
int usub;
for (usub = 0; usub < sbbs->usrsubs[ugrp]; usub++)
if (sbbs->usrsub[ugrp][usub] == sbbs->smb.subnum)
break;
}
break;
case BBS_PROP_SMB_ATTR:
val = sbbs->smb.status.attr;
break;
case BBS_PROP_SMB_LAST_MSG:
val = sbbs->smb.status.last_msg;
break;
case BBS_PROP_SMB_TOTAL_MSGS:
val = sbbs->smb.status.total_msgs;
break;
case BBS_PROP_SMB_MSGS:
break;
case BBS_PROP_SMB_CURMSG:
val = sbbs->smb.curmsg;
/* Currently Displayed Message Header (sbbs.current_msg) */
case BBS_PROP_MSG_TO:
if (sbbs->current_msg_to == NULL)
p = nulstr;
else
p = sbbs->current_msg_to;
break;
case BBS_PROP_MSG_TO_EXT:
if (sbbs->current_msg == NULL || sbbs->current_msg->to_ext == NULL)
p = nulstr;
else
p = sbbs->current_msg->to_ext;
break;
case BBS_PROP_MSG_TO_NET:
if (sbbs->current_msg == NULL || sbbs->current_msg->to_net.type == NET_NONE)
p = nulstr;
else
p = smb_netaddrstr(&sbbs->current_msg->to_net, tmp);
break;
case BBS_PROP_MSG_TO_AGENT:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->to_agent;
break;
case BBS_PROP_MSG_FROM:
if (sbbs->current_msg_from == NULL)
p = nulstr;
else
p = sbbs->current_msg_from;
break;
case BBS_PROP_MSG_FROM_EXT:
if (sbbs->current_msg == NULL || sbbs->current_msg->from_ext == NULL)
p = nulstr;
else
p = sbbs->current_msg->from_ext;
break;
case BBS_PROP_MSG_FROM_NET:
if (sbbs->current_msg == NULL || sbbs->current_msg->from_net.type == NET_NONE)
p = nulstr;
else
p = smb_netaddrstr(&sbbs->current_msg->from_net, tmp);
break;
if (sbbs->current_msg == NULL || sbbs->current_msg->ftn_bbsid == NULL)
p = nulstr;
else // Should we return only the last ID of the QWKnet route here?
p = sbbs->current_msg->ftn_bbsid;
break;
case BBS_PROP_MSG_FROM_AGENT:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->from_agent;
break;
case BBS_PROP_MSG_REPLYTO:
if (sbbs->current_msg == NULL || sbbs->current_msg->replyto == NULL)
p = nulstr;
else
p = sbbs->current_msg->replyto;
break;
case BBS_PROP_MSG_REPLYTO_EXT:
if (sbbs->current_msg == NULL || sbbs->current_msg->replyto_ext == NULL)
p = nulstr;
else
p = sbbs->current_msg->replyto_ext;
break;
case BBS_PROP_MSG_REPLYTO_NET:
if (sbbs->current_msg == NULL || sbbs->current_msg->replyto_net.type == NET_NONE)
p = nulstr;
else
p = smb_netaddrstr(&sbbs->current_msg->replyto_net, tmp);
break;
case BBS_PROP_MSG_REPLYTO_AGENT:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->replyto_agent;
break;
case BBS_PROP_MSG_SUBJECT:
if (sbbs->current_msg_subj == NULL)
p = nulstr;
else
p = sbbs->current_msg_subj;
break;
case BBS_PROP_MSG_DATE:
if (sbbs->current_msg != NULL)
val = (uint32)smb_time(sbbs->current_msg->hdr.when_written);
break;
case BBS_PROP_MSG_TIMEZONE:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.when_written.zone;
break;
case BBS_PROP_MSG_DATE_IMPORTED:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.when_imported.time;
break;
case BBS_PROP_MSG_ATTR:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.attr;
break;
case BBS_PROP_MSG_AUXATTR:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.auxattr;
break;
case BBS_PROP_MSG_NETATTR:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.netattr;
break;
case BBS_PROP_MSG_OFFSET:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->idx_offset;
break;
case BBS_PROP_MSG_NUMBER:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.number;
val = sbbs->current_msg_number;
break;
case BBS_PROP_MSG_EXPIRATION:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->expiration;
break;
case BBS_PROP_MSG_FORWARDED:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->forwarded;
break;
case BBS_PROP_MSG_THREAD_ID:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.thread_id;
break;
case BBS_PROP_MSG_THREAD_BACK:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.thread_back;
break;
case BBS_PROP_MSG_THREAD_NEXT:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.thread_next;
break;
case BBS_PROP_MSG_THREAD_FIRST:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.thread_first;
break;
case BBS_PROP_MSG_DELIVERY_ATTEMPTS:
if (sbbs->current_msg != NULL)
val = sbbs->current_msg->hdr.delivery_attempts;
break;
case BBS_PROP_MSG_ID:
if (sbbs->current_msg == NULL || sbbs->current_msg->id == NULL)
p = nulstr;
p = sbbs->current_msg->id;
break;
case BBS_PROP_MSG_REPLY_ID:
if (sbbs->current_msg == NULL || sbbs->current_msg->reply_id == NULL)
p = nulstr;
p = sbbs->current_msg->reply_id;
case BBS_PROP_MSGHDR_TOS:
val = sbbs->msghdr_tos;
break;
/* Currently Displayed File (sbbs.current_file) */
case BBS_PROP_FILE_NAME:
if (sbbs->current_file == NULL)
p = nulstr;
p = sbbs->current_file->name;
break;
case BBS_PROP_FILE_DESC:
if (sbbs->current_file == NULL)
p = nulstr;
p = sbbs->current_file->desc;
break;
case BBS_PROP_FILE_ULER:
if (sbbs->current_file == NULL)
p = nulstr;
p = sbbs->current_file->from;
break;
case BBS_PROP_FILE_DATE:
if (sbbs->current_file == NULL)
p = nulstr;
val = (uint32)sbbs->current_file->time;
break;
case BBS_PROP_FILE_DATE_ULED:
if (sbbs->current_file == NULL)
p = nulstr;
val = sbbs->current_file->hdr.when_imported.time;
break;
case BBS_PROP_FILE_DATE_DLED:
if (sbbs->current_file == NULL)
p = nulstr;
val = sbbs->current_file->hdr.last_downloaded;
break;
case BBS_PROP_FILE_TIMES_DLED:
if (sbbs->current_file == NULL)
p = nulstr;
val = sbbs->current_file->hdr.times_downloaded;
break;
case BBS_PROP_FILE_SIZE:
if (sbbs->current_file == NULL)
p = nulstr;
else // TODO: fix for 64-bit file sizes
val = (uint32)sbbs->current_file->size;
break;
case BBS_PROP_FILE_CREDITS:
if (sbbs->current_file == NULL)
p = nulstr;
val = (uint32_t)sbbs->current_file->cost; // TODO (cost is now 64-bit)
if (sbbs->current_file == NULL)
p = nulstr;
val = sbbs->current_file->dir;
break;
case BBS_PROP_FILE_ATTR:
if (sbbs->current_file == NULL)
p = nulstr;
val = sbbs->current_file->hdr.attr;
case BBS_PROP_DOWNLOAD_CPS:
val = sbbs->cur_cps;
break;
case BBS_PROP_BATCH_UPLOAD_TOTAL:
val = sbbs->batup_total();
break;
case BBS_PROP_BATCH_DNLOAD_TOTAL:
val = sbbs->batdn_total();
case BBS_PROP_COMMAND_STR:
p = sbbs->main_csi.str;
break;
if (p != NULL) {
JSString* js_str = JS_NewStringCopyZ(cx, p);
if (js_str == NULL)
*vp = STRING_TO_JSVAL(js_str);
} else
*vp = UINT_TO_JSVAL(val);
static JSBool js_bbs_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
jsval idval;
char* p = NULL;
uint32 val = 0;
jsint tiny;
JSString* js_str;
sbbs_t* sbbs;
if ((sbbs = js_GetPrivate(cx, obj)) == NULL)
JS_IdToValue(cx, id, &idval);
tiny = JSVAL_TO_INT(idval);
if (JSVAL_IS_NUMBER(*vp) || JSVAL_IS_BOOLEAN(*vp)) {
if (!JS_ValueToECMAUint32(cx, *vp, &val))
else if (JSVAL_IS_STRING(*vp)) {
if ((js_str = JS_ValueToString(cx, *vp)) == NULL)
HANDLE_PENDING(cx, p);
sbbs->sys_status = val;
break;
case BBS_PROP_STARTUP_OPT:
sbbs->startup->options = val;
break;
case BBS_PROP_ANSWER_TIME:
sbbs->answertime = val;
break;
case BBS_PROP_LOGON_TIME:
sbbs->logontime = val;
case BBS_PROP_START_TIME:
sbbs->starttime = val;
break;
case BBS_PROP_LAST_NS_TIME:
sbbs->last_ns_time = val;
sbbs->cfg.node_misc = val;
sbbs->action = (uchar)val;
case BBS_PROP_NODE_VAL_USER:
sbbs->cfg.valuser = (ushort)val;
break;
case BBS_PROP_LOGON_ULB:
sbbs->logon_ulb = val;
break;
case BBS_PROP_LOGON_DLB:
sbbs->logon_dlb = val;
break;
case BBS_PROP_LOGON_ULS:
sbbs->logon_uls = val;
break;
case BBS_PROP_LOGON_DLS:
sbbs->logon_dls = val;
break;
case BBS_PROP_LOGON_POSTS:
sbbs->logon_posts = val;
break;
case BBS_PROP_LOGON_EMAILS:
sbbs->logon_emails = val;
case BBS_PROP_LOGON_FBACKS:
sbbs->logon_fbacks = val;
sbbs->posts_read = val;
if (p != NULL)
SAFECOPY(sbbs->menu_dir, p);
if (p != NULL)
SAFECOPY(sbbs->menu_file, p);
sbbs->main_cmds = val;
sbbs->xfer_cmds = val;
case BBS_PROP_SMB_CURMSG:
sbbs->smb.curmsg = val;
break;
case BBS_PROP_MSG_NUMBER:
sbbs->current_msg_number = val;
break;
case BBS_PROP_CURGRP:
if (p != NULL) { /* set by name */

Rob Swindell
committed
int i;
for (i = 0; i < sbbs->usrgrps; i++)
if (!stricmp(sbbs->cfg.grp[sbbs->usrgrp[i]]->sname, p))
break;
if (i < sbbs->usrgrps)
sbbs->curgrp = i;
break;
}
if ((int)val < sbbs->cfg.total_grps && (int)val < sbbs->usrgrps)
sbbs->curgrp = val;
break;
case BBS_PROP_CURSUB:
case BBS_PROP_CURSUB_CODE:
if (p != NULL) { /* set by code */
for (int i = 0; i < sbbs->usrgrps; i++)
for (int j = 0; j < sbbs->usrsubs[i]; j++)
if (!stricmp(sbbs->cfg.sub[sbbs->usrsub[i][j]]->code, p)) {
sbbs->curgrp = i;
sbbs->cursub[i] = j;
}
break;
}
if (sbbs->curgrp < sbbs->cfg.total_grps && (int)val < sbbs->usrsubs[sbbs->curgrp])
sbbs->cursub[sbbs->curgrp] = val;
break;
case BBS_PROP_CURLIB:
if (p != NULL) { /* set by name */

Rob Swindell
committed
int i;
for (i = 0; i < sbbs->usrlibs; i++)
if (!stricmp(sbbs->cfg.lib[sbbs->usrlib[i]]->sname, p))
break;
if (i < sbbs->usrlibs)
sbbs->curlib = i;
break;
}
if ((int)val < sbbs->cfg.total_libs && (int)val < sbbs->usrlibs)
sbbs->curlib = val;
break;
case BBS_PROP_CURDIR:
case BBS_PROP_CURDIR_CODE:
if (p != NULL) { /* set by code */
for (int i = 0; i < sbbs->usrlibs; i++)
for (int j = 0; j < sbbs->usrdirs[i]; j++)
if (!stricmp(sbbs->cfg.dir[sbbs->usrdir[i][j]]->code, p)) {
sbbs->curlib = i;
sbbs->curdir[i] = j;
}
break;
}
if (sbbs->curlib < sbbs->cfg.total_libs && (int)val < sbbs->usrdirs[sbbs->curlib])
sbbs->curdir[sbbs->curlib] = val;
if (p != NULL)
SAFECOPY(sbbs->rlogin_name, p);
case BBS_PROP_RLOGIN_PASS:
if (p != NULL)
SAFECOPY(sbbs->rlogin_pass, p);
case BBS_PROP_RLOGIN_TERM:
if (p != NULL)
SAFECOPY(sbbs->rlogin_term, p);
if (p != NULL)
SAFECOPY(sbbs->client_name, p);
case BBS_PROP_COMMAND_STR:
strlcpy(sbbs->main_csi.str, p, 1024);
break;
if (sbbs->usrgrps)
sbbs->cursubnum = sbbs->usrsub[sbbs->curgrp][sbbs->cursub[sbbs->curgrp]]; /* Used for ARS */
sbbs->cursubnum = INVALID_SUB;
if (sbbs->usrlibs)
sbbs->curdirnum = sbbs->usrdir[sbbs->curlib][sbbs->curdir[sbbs->curlib]]; /* Used for ARS */
sbbs->curdirnum = INVALID_DIR;