1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
This commit is contained in:
Kalle Olavi Niemitalo 2006-02-12 23:15:59 +02:00 committed by Kalle Olavi Niemitalo
commit e7dfe6d5da

View File

@ -22,7 +22,7 @@
static enum evhook_status
script_hook_goto_url(va_list ap, void *data)
script_hook_url(va_list ap, void *data)
{
unsigned char **url = va_arg(ap, unsigned char **);
struct session *ses = va_arg(ap, struct session *);
@ -35,40 +35,7 @@ script_hook_goto_url(va_list ap, void *data)
args[0] = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, *url));
if (JS_TRUE == smjs_invoke_elinks_object_method("goto_url_hook",
args, 1, &rval)) {
if (JSVAL_IS_BOOLEAN(rval)) {
if (JS_FALSE == JSVAL_TO_BOOLEAN(rval))
ret = EVENT_HOOK_STATUS_LAST;
} else {
JSString *jsstr = JS_ValueToString(smjs_ctx, rval);
unsigned char *str = JS_GetStringBytes(jsstr);
mem_free_set(url, stracpy(str));
}
}
smjs_ses = NULL;
return ret;
}
static enum evhook_status
script_hook_follow_url(va_list ap, void *data)
{
unsigned char **url = va_arg(ap, unsigned char **);
struct session *ses = va_arg(ap, struct session *);
enum evhook_status ret = EVENT_HOOK_STATUS_NEXT;
jsval args[1], rval;
if (*url == NULL) return EVENT_HOOK_STATUS_NEXT;
smjs_ses = ses;
args[0] = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, *url));
if (JS_TRUE == smjs_invoke_elinks_object_method("follow_url_hook",
args, 1, &rval)) {
if (JS_TRUE == smjs_invoke_elinks_object_method(data, args, 1, &rval)) {
if (JSVAL_IS_BOOLEAN(rval)) {
if (JS_FALSE == JSVAL_TO_BOOLEAN(rval))
ret = EVENT_HOOK_STATUS_LAST;
@ -123,8 +90,8 @@ end:
}
struct event_hook_info smjs_scripting_hooks[] = {
{ "goto-url", 0, script_hook_goto_url, NULL },
{ "follow-url", 0, script_hook_follow_url, NULL },
{ "goto-url", 0, script_hook_url, "goto_url_hook" },
{ "follow-url", 0, script_hook_url, "follow_url_hook" },
{ "pre-format-html", 0, script_hook_pre_format_html, NULL },
NULL_EVENT_HOOK_INFO,