}
-static switch_status_t sm_load_file(char *filename, sm_loadable_module_t **new_module)
+static switch_status_t sm_load_file(char *filename)
{
sm_loadable_module_t *module = NULL;
apr_dso_handle_t *dso = NULL;
assert(filename != NULL);
- *new_module = NULL;
status = apr_dso_load(&dso, filename, module_manager.pool);
while (loading) {
break;
}
- if ((module = switch_core_permanent_alloc(sizeof(sm_loadable_module_t))) == 0) {
+ if (!(module = (sm_loadable_module_t *) switch_core_permanent_alloc(sizeof(*module)))) {
err = "Could not allocate memory\n";
break;
}
module->module_interface = module_interface;
module->lib = dso;
- *new_module = module;
switch_core_hash_insert(module_manager.mod_hash, (char *) module->filename, (void *) module);
- for (mp = module_interface; mp; mp = mp->next) {
+ for (mp = module->module_interface; mp; mp = mp->next) {
switch_core_hash_insert(module_manager.load_hash, (char *)mp->name, (void *) mp);
}
switch_size_t len = 0;
char *path;
char *file;
- sm_loadable_module_t *new_module = NULL;
#ifdef WIN32
const char *ext = ".dll";
}
}
- return sm_load_file(path, &new_module);
+ return sm_load_file(path);
}
static switch_status_t load_modules(void)
}
}
+ if (argc > 4) {
+ int32 samps;
+ uint32_t pos = 0;
+ JS_ValueToInt32(cx, argv[4], &samps);
+ switch_core_file_seek(&fh, &pos, samps, SEEK_CUR);
+ }
+
memset(&fh, 0, sizeof(fh));
cb_state.extra = &fh;
cb_state.ret = BOOLEAN_TO_JSVAL( JS_FALSE );
char *app_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
char *app_arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
struct js_session *jss = JS_GetPrivate(cx, obj);
- jsrefcount saveDepth;
+ //jsrefcount saveDepth;
if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
if (application_interface->application_function) {
- saveDepth = JS_SuspendRequest(cx);
+ //saveDepth = JS_SuspendRequest(cx);
application_interface->application_function(jss->session, app_arg);
- JS_ResumeRequest(cx, saveDepth);
+ //JS_ResumeRequest(cx, saveDepth);
retval = JS_TRUE;
}
}
*/
#include "mod_spidermonkey.h"
-static const char modname[] = "DB";
+static const char modname[] = "CoreDB";
struct db_obj {
switch_memory_pool_t *pool;
{
struct db_obj *dbo = JS_GetPrivate(cx, obj);
*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-
- if (dbo->stmt) {
- int running = 1;
+ if (dbo->stmt) {
+ int running = 1;
while (running < 5000) {
int result = switch_core_db_step(dbo->stmt);
if (result == SQLITE_ROW) {
dbo->stmt = NULL;
}
- if (argc > 0) {
+ if (argc > 0) {
char *sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
-
- if(switch_core_db_prepare(dbo->db, sql, 0, &dbo->stmt, 0)) {
+ if(switch_core_db_prepare(dbo->db, sql, -1, &dbo->stmt, 0)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error %s\n", switch_core_db_errmsg(dbo->db));
} else {
*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
}
JSClass db_class = {
- "DB", JSCLASS_HAS_PRIVATE,
+ modname, JSCLASS_HAS_PRIVATE,
JS_PropertyStub, JS_PropertyStub, db_getProperty, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, db_destroy, NULL, NULL, NULL,
db_construct
};
-
-
-
-
-switch_status_t spidermonkey_load(JSContext *cx, JSObject *obj)
+switch_status_t db_load(JSContext *cx, JSObject *obj)
{
JS_InitClass(cx,
db_props,
db_methods
);
-
return SWITCH_STATUS_SUCCESS;
}
const sm_module_interface_t DB_module_interface = {
/*.name = */ modname,
- /*.spidermonkey_load*/ spidermonkey_load,
+ /*.spidermonkey_load*/ db_load,
/*.next*/ NULL
};