Skip to content
Snippets Groups Projects
Commit 5da26eca authored by rswindell's avatar rswindell
Browse files

MsgBase.open() would not, could not, actually create a message base.

It would create 3 0-byte files (*.shd, *.sdt, *.sid), but more is actually
needed for a message base to be "created" (i.e. a call to smb_create()).
So, MsgBase.open() now uses smb_open_sub() rather than smb_open() to initialize
theSMB  status fields with the proper default values (based on the sysop
configuration) and calls smb_crate() if the header file is empty.
Yes, normally, SCFG creates message bases, but it shouldn't have to
(e.g. a fresh install on *nix, doesn't actually start with any files in
data/subs) and now that we have JavaScript-based message lister/readers, we
really needed this support.
parent 7b71fb6f
No related branches found
No related tags found
No related merge requests found
...@@ -86,6 +86,13 @@ js_open(JSContext *cx, uintN argc, jsval *arglist) ...@@ -86,6 +86,13 @@ js_open(JSContext *cx, uintN argc, jsval *arglist)
JSObject *obj=JS_THIS_OBJECT(cx, arglist); JSObject *obj=JS_THIS_OBJECT(cx, arglist);
private_t* p; private_t* p;
jsrefcount rc; jsrefcount rc;
scfg_t* scfg;
scfg = JS_GetRuntimePrivate(JS_GetRuntime(cx));
if(scfg == NULL) {
JS_ReportError(cx, "JS_GetRuntimePrivate returned NULL");
return JS_FALSE;
}
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) { if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE; return JS_FALSE;
...@@ -101,10 +108,16 @@ js_open(JSContext *cx, uintN argc, jsval *arglist) ...@@ -101,10 +108,16 @@ js_open(JSContext *cx, uintN argc, jsval *arglist)
} }
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
if((p->smb_result=smb_open(&(p->smb)))!=SMB_SUCCESS) { if((p->smb_result = smb_open_sub(scfg, &(p->smb), p->smb.subnum)) != SMB_SUCCESS) {
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
return JS_TRUE; return JS_TRUE;
} }
if(filelength(fileno(p->smb.shd_fp)) < 1) { /* MsgBase doesn't exist yet, create it */
if((p->smb_result = smb_create(&(p->smb))) != SMB_SUCCESS) {
JS_RESUMEREQUEST(cx, rc);
return JS_TRUE;
}
}
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
JS_SET_RVAL(cx, arglist, JSVAL_TRUE); JS_SET_RVAL(cx, arglist, JSVAL_TRUE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment