1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Factor smjs_do_file out of smjs_load_hooks.

This commit is contained in:
Miciah Dashiel Butler Masters 2005-12-29 13:27:12 +00:00 committed by Miciah Dashiel Butler Masters
parent 9d4893e384
commit cb506ea412

View File

@ -69,32 +69,39 @@ reported:
static JSRuntime *smjs_rt;
static void
smjs_load_hooks(void)
smjs_do_file(unsigned char *path)
{
jsval rval;
struct string script;
unsigned char *path;
assert(smjs_ctx);
if (!init_string(&script)) return;
if (elinks_home) {
path = straconcat(elinks_home, SMJS_HOOKS_FILENAME, NULL);
} else {
path = stracpy(CONFDIR "/" SMJS_HOOKS_FILENAME);
}
if (add_file_to_string(&script, path)
&& JS_FALSE == JS_EvaluateScript(smjs_ctx,
JS_GetGlobalObject(smjs_ctx),
script.source, script.length, path, 1, &rval))
alert_smjs_error("error loading default script file");
mem_free(path);
done_string(&script);
}
static void
smjs_load_hooks(void)
{
unsigned char *path;
assert(smjs_ctx);
if (elinks_home) {
path = straconcat(elinks_home, SMJS_HOOKS_FILENAME, NULL);
} else {
path = stracpy(CONFDIR "/" SMJS_HOOKS_FILENAME);
}
smjs_do_file(path);
mem_free(path);
}
void
init_smjs(struct module *module)
{