Commit 2937264d authored by deuce's avatar deuce
Browse files

Add new "jsdoor" binary which has no dependencies on libsbbs.so or the ctrl

directory.  This is the beginnings of the ability to write a door in JS for
all BBSes, not just Synchronet (door kit pending).

This requires moving js_CreateCommonObjects() into main.cpp, which requires
constifying the name parameter to js_CreateClientObject() due to C++ being
more paranoid about using a string literal as a char * parameter
(warning fix).
parent c71db2d8
......@@ -106,6 +106,7 @@ CFLAGS += $(JS_CFLAGS) $(CRYPT_CFLAGS) $(UIFC-MT_CFLAGS) $(XPDEV-MT_CFLAGS) $(SM
CFLAGS += -I../comio
vpath %.c ../comio
OBJS += $(MTOBJODIR)$(DIRSEP)comio_nix$(OFILE)
JSDOOR_OBJS += $(MTOBJODIR)$(DIRSEP)comio_nix$(OFILE)
LDFLAGS += $(UIFC-MT_LDFLAGS) $(XPDEV-MT_LDFLAGS) $(SMBLIB_LDFLAGS) $(CIOLIB-MT_LDFLAGS) $(JS_LDFLAGS) $(CRYPT_LDFLAGS)
# Monolithic Synchronet executable Build Rule
......@@ -198,6 +199,11 @@ $(MAKEUSER): $(MAKEUSER_OBJS)
@echo Linking $@
$(QUIET)$(CC) $(CONSOLE_LDFLAGS) -o $@ $(MAKEUSER_OBJS) $(XPDEV_LIBS)
# JSDOOR
$(JSDOOR): $(JSDOOR_OBJS) $(SBBS)
@echo Linking $@
$(QUIET)$(CXX) $(LDFLAGS) $(MT_LDFLAGS) -o $@ $(JSDOOR_OBJS) $(JS_LIBS) $(CRYPT_LIBS) $(UIFC-MT_LIBS) $(CIOLIB-MT_LIBS) $(SMBLIB_LIBS) $(XPDEV-MT_LIBS)
# JSEXEC
$(JSEXEC): $(JSEXEC_OBJS) $(SBBS)
@echo Linking $@
......
......@@ -170,7 +170,7 @@ static JSClass js_client_class = {
};
JSObject* DLLCALL js_CreateClientObject(JSContext* cx, JSObject* parent
,char* name, client_t* client, SOCKET sock)
,const char* name, client_t* client, SOCKET sock)
{
JSObject* obj;
......
......@@ -4301,89 +4301,4 @@ BOOL DLLCALL js_CreateGlobalObject(JSContext* cx, scfg_t* cfg, jsSyncMethodSpec*
return(TRUE);
}
BOOL DLLCALL js_CreateCommonObjects(JSContext* js_cx
,scfg_t* cfg /* common */
,scfg_t* node_cfg /* node-specific */
,jsSyncMethodSpec* methods /* global */
,time_t uptime /* system */
,char* host_name /* system */
,char* socklib_desc /* system */
,js_callback_t* cb /* js */
,js_startup_t* js_startup /* js */
,client_t* client /* client */
,SOCKET client_socket /* client */
,js_server_props_t* props /* server */
,JSObject** glob
)
{
BOOL success=FALSE;
if(node_cfg==NULL)
node_cfg=cfg;
/* Global Object */
if(!js_CreateGlobalObject(js_cx, cfg, methods, js_startup, glob))
return(FALSE);
do {
/* System Object */
if(js_CreateSystemObject(js_cx, *glob, node_cfg, uptime, host_name, socklib_desc)==NULL)
break;
/* Internal JS Object */
if(cb!=NULL
&& js_CreateInternalJsObject(js_cx, *glob, cb, js_startup)==NULL)
break;
/* Client Object */
if(client!=NULL
&& js_CreateClientObject(js_cx, *glob, "client", client, client_socket)==NULL)
break;
/* Server */
if(props!=NULL
&& js_CreateServerObject(js_cx, *glob, props)==NULL)
break;
/* Socket Class */
if(js_CreateSocketClass(js_cx, *glob)==NULL)
break;
/* Queue Class */
if(js_CreateQueueClass(js_cx, *glob)==NULL)
break;
/* MsgBase Class */
if(js_CreateMsgBaseClass(js_cx, *glob, cfg)==NULL)
break;
/* File Class */
if(js_CreateFileClass(js_cx, *glob)==NULL)
break;
/* User class */
if(js_CreateUserClass(js_cx, *glob, cfg)==NULL)
break;
/* COM Class */
if(js_CreateCOMClass(js_cx, *glob)==NULL)
break;
/* CryptContext Class */
if(js_CreateCryptContextClass(js_cx, *glob)==NULL)
break;
/* Area Objects */
if(!js_CreateUserObjects(js_cx, *glob, cfg, /* user: */NULL, client, /* html_index_fname: */NULL, /* subscan: */NULL))
break;
success=TRUE;
} while(0);
if(!success)
JS_RemoveObjectRoot(js_cx, glob);
return(success);
}
#endif /* JAVSCRIPT */
This diff is collapsed.
......@@ -1249,6 +1249,91 @@ void sbbs_t::js_create_user_objects(void)
JS_ENDREQUEST(js_cx);
}
extern "C" BOOL DLLCALL js_CreateCommonObjects(JSContext* js_cx
,scfg_t* cfg /* common */
,scfg_t* node_cfg /* node-specific */
,jsSyncMethodSpec* methods /* global */
,time_t uptime /* system */
,char* host_name /* system */
,char* socklib_desc /* system */
,js_callback_t* cb /* js */
,js_startup_t* js_startup /* js */
,client_t* client /* client */
,SOCKET client_socket /* client */
,js_server_props_t* props /* server */
,JSObject** glob
)
{
BOOL success=FALSE;
if(node_cfg==NULL)
node_cfg=cfg;
/* Global Object */
if(!js_CreateGlobalObject(js_cx, cfg, methods, js_startup, glob))
return(FALSE);
do {
/* System Object */
if(js_CreateSystemObject(js_cx, *glob, node_cfg, uptime, host_name, socklib_desc)==NULL)
break;
/* Internal JS Object */
if(cb!=NULL
&& js_CreateInternalJsObject(js_cx, *glob, cb, js_startup)==NULL)
break;
/* Client Object */
if(client!=NULL
&& js_CreateClientObject(js_cx, *glob, "client", client, client_socket)==NULL)
break;
/* Server */
if(props!=NULL
&& js_CreateServerObject(js_cx, *glob, props)==NULL)
break;
/* Socket Class */
if(js_CreateSocketClass(js_cx, *glob)==NULL)
break;
/* Queue Class */
if(js_CreateQueueClass(js_cx, *glob)==NULL)
break;
/* MsgBase Class */
if(js_CreateMsgBaseClass(js_cx, *glob, cfg)==NULL)
break;
/* File Class */
if(js_CreateFileClass(js_cx, *glob)==NULL)
break;
/* User class */
if(js_CreateUserClass(js_cx, *glob, cfg)==NULL)
break;
/* COM Class */
if(js_CreateCOMClass(js_cx, *glob)==NULL)
break;
/* CryptContext Class */
if(js_CreateCryptContextClass(js_cx, *glob)==NULL)
break;
/* Area Objects */
if(!js_CreateUserObjects(js_cx, *glob, cfg, /* user: */NULL, client, /* html_index_fname: */NULL, /* subscan: */NULL))
break;
success=TRUE;
} while(0);
if(!success)
JS_RemoveObjectRoot(js_cx, glob);
return(success);
}
#endif /* JAVASCRIPT */
static BYTE* telnet_interpret(sbbs_t* sbbs, BYTE* inbuf, int inlen,
......
......@@ -238,6 +238,43 @@ JSEXEC_OBJS = \
$(MTOBJODIR)$(DIRSEP)js_uifc$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_conio$(OFILE)
JSDOOR_OBJS = \
$(MTOBJODIR)$(DIRSEP)ars$(OFILE) \
$(MTOBJODIR)$(DIRSEP)base64$(OFILE) \
$(MTOBJODIR)$(DIRSEP)date_str$(OFILE) \
$(MTOBJODIR)$(DIRSEP)dat_rec$(OFILE) \
$(MTOBJODIR)$(DIRSEP)jsdoor$(OFILE) \
$(MTOBJODIR)$(DIRSEP)jsdebug$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_uifc$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_conio$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_request$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_socket$(OFILE) \
$(MTOBJODIR)$(DIRSEP)comio$(OFILE)\
$(MTOBJODIR)$(DIRSEP)js_client$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_com$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_cryptcon$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_global$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_rtpool$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_sprintf$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_file$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_internal$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_queue$(OFILE) \
$(MTOBJODIR)$(DIRSEP)js_server$(OFILE) \
$(MTOBJODIR)$(DIRSEP)nopen$(OFILE) \
$(MTOBJODIR)$(DIRSEP)str_util$(OFILE) \
$(MTOBJODIR)$(DIRSEP)sockopts$(OFILE)\
$(MTOBJODIR)$(DIRSEP)ssl$(OFILE)\
$(MTOBJODIR)$(DIRSEP)load_cfg$(OFILE)\
$(MTOBJODIR)$(DIRSEP)readtext$(OFILE)\
$(MTOBJODIR)$(DIRSEP)text_defaults$(OFILE)\
$(MTOBJODIR)$(DIRSEP)scfgsave$(OFILE)\
$(MTOBJODIR)$(DIRSEP)scfglib1$(OFILE)\
$(MTOBJODIR)$(DIRSEP)scfglib2$(OFILE)\
$(MTOBJODIR)$(DIRSEP)wordwrap$(OFILE)\
$(MTOBJODIR)$(DIRSEP)userdat$(OFILE)\
$(MTOBJODIR)$(DIRSEP)uucode$(OFILE)\
$(MTOBJODIR)$(DIRSEP)yenc$(OFILE)\
SEXYZ_OBJS = \
$(MTOBJODIR)$(DIRSEP)sexyz$(OFILE) \
$(MTOBJODIR)$(DIRSEP)xmodem$(OFILE) \
......
......@@ -1166,6 +1166,20 @@ extern "C" {
DLLEXPORT JSBool DLLCALL js_DefineConstIntegers(JSContext* cx, JSObject* obj, jsConstIntSpec*, int flags);
DLLEXPORT JSBool DLLCALL js_CreateArrayOfStrings(JSContext* cx, JSObject* parent
,const char* name, char* str[], unsigned flags);
DLLEXPORT BOOL DLLCALL js_CreateCommonObjects(JSContext* cx
,scfg_t* cfg /* common */
,scfg_t* node_cfg /* node-specific */
,jsSyncMethodSpec* methods /* global */
,time_t uptime /* system */
,char* host_name /* system */
,char* socklib_desc /* system */
,js_callback_t* /* js */
,js_startup_t* /* js */
,client_t* client /* client */
,SOCKET client_socket /* client */
,js_server_props_t* props /* server */
,JSObject** glob
);
/* js_server.c */
DLLEXPORT JSObject* DLLCALL js_CreateServerObject(JSContext* cx, JSObject* parent
......@@ -1182,20 +1196,6 @@ extern "C" {
} global_private_t;
DLLEXPORT BOOL DLLCALL js_argc(JSContext *cx, unsigned argc, unsigned min);
DLLEXPORT BOOL DLLCALL js_CreateGlobalObject(JSContext* cx, scfg_t* cfg, jsSyncMethodSpec* methods, js_startup_t*, JSObject**);
DLLEXPORT BOOL DLLCALL js_CreateCommonObjects(JSContext* cx
,scfg_t* cfg /* common */
,scfg_t* node_cfg /* node-specific */
,jsSyncMethodSpec* methods /* global */
,time_t uptime /* system */
,char* host_name /* system */
,char* socklib_desc /* system */
,js_callback_t* /* js */
,js_startup_t* /* js */
,client_t* client /* client */
,SOCKET client_socket /* client */
,js_server_props_t* props /* server */
,JSObject** glob
);
/* js_internal.c */
DLLEXPORT JSObject* DLLCALL js_CreateInternalJsObject(JSContext*, JSObject* parent, js_callback_t*, js_startup_t*);
......@@ -1212,7 +1212,7 @@ extern "C" {
/* js_client.c */
DLLEXPORT JSObject* DLLCALL js_CreateClientObject(JSContext* cx, JSObject* parent
,char* name, client_t* client, SOCKET sock);
,const char* name, client_t* client, SOCKET sock);
/* js_user.c */
DLLEXPORT JSObject* DLLCALL js_CreateUserClass(JSContext* cx, JSObject* parent, scfg_t* cfg);
DLLEXPORT JSObject* DLLCALL js_CreateUserObject(JSContext* cx, JSObject* parent, scfg_t* cfg
......
......@@ -14,6 +14,7 @@ SERVICES = $(LIBODIR)$(DIRSEP)$(LIBPREFIX)services$(SOFILE)
SBBSCON = $(EXEODIR)$(DIRSEP)sbbs$(EXEFILE)
SBBSMONO = $(EXEODIR)$(DIRSEP)sbbsmono$(EXEFILE)
JSEXEC = $(EXEODIR)$(DIRSEP)jsexec$(EXEFILE)
JSDOOR = $(EXEODIR)$(DIRSEP)jsdoor$(EXEFILE)
NODE = $(EXEODIR)$(DIRSEP)node$(EXEFILE)
BAJA = $(EXEODIR)$(DIRSEP)baja$(EXEFILE)
UNBAJA = $(EXEODIR)$(DIRSEP)unbaja$(EXEFILE)
......@@ -50,7 +51,7 @@ all: dlls utils console
console: $(JS_DEPS) xpdev-mt smblib \
$(MTOBJODIR) $(LIBODIR) $(EXEODIR) \
dlls \
$(SBBSCON) $(JSEXEC)
$(SBBSCON) $(JSEXEC) ${JSDOOR}
utils: smblib xpdev-mt xpdev ciolib-mt uifc-mt \
$(LIBODIR) $(OBJODIR) $(MTOBJODIR) $(EXEODIR) \
......@@ -77,6 +78,7 @@ $(SERVICES):
$(SBBSCON): $(XPDEV-MT_LIB) $(SMBLIB)
$(SBBSMONO): $(XPDEV-MT_LIB) $(SMBLIB)
$(JSEXEC): $(XPDEV-MT_LIB) $(SMBLIB)
$(JSDOOR): $(XPDEV-MT_LIB)
$(NODE): $(XPDEV_LIB)
$(BAJA): $(XPDEV_LIB) $(SMBLIB)
$(UNBAJA): $(XPDEV_LIB)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment