1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-13 05:43:37 -04:00

[event] union for const/non-const void *

This commit is contained in:
Witold Filipczyk 2022-01-30 19:19:20 +01:00
parent feac3151f3
commit cba95b2b30
13 changed files with 47 additions and 44 deletions

View File

@ -87,10 +87,10 @@ static enum evhook_status bookmark_change_hook(va_list ap, void *data);
static enum evhook_status bookmark_write_hook(va_list ap, void *data);
struct event_hook_info bookmark_hooks[] = {
{ C_("bookmark-delete"), 0, bookmark_change_hook, NULL },
{ C_("bookmark-move"), 0, bookmark_change_hook, NULL },
{ C_("bookmark-update"), 0, bookmark_change_hook, NULL },
{ C_("periodic-saving"), 0, bookmark_write_hook, NULL },
{ C_("bookmark-delete"), 0, bookmark_change_hook, {NULL} },
{ C_("bookmark-move"), 0, bookmark_change_hook, {NULL} },
{ C_("bookmark-update"), 0, bookmark_change_hook, {NULL} },
{ C_("periodic-saving"), 0, bookmark_write_hook, {NULL} },
NULL_EVENT_HOOK_INFO,
};

View File

@ -39,7 +39,7 @@ goto_url_history_write_hook(va_list ap, void *data)
}
static struct event_hook_info goto_url_history_hooks[] = {
{ "periodic-saving", 0, goto_url_history_write_hook, NULL },
{ "periodic-saving", 0, goto_url_history_write_hook, {NULL} },
NULL_EVENT_HOOK_INFO,
};

View File

@ -425,7 +425,7 @@ global_history_write_hook(va_list ap, void *data)
}
struct event_hook_info global_history_hooks[] = {
{ "periodic-saving", 0, global_history_write_hook, NULL },
{ "periodic-saving", 0, global_history_write_hook, {NULL} },
NULL_EVENT_HOOK_INFO,
};

View File

@ -289,7 +289,7 @@ register_event_hooks(struct event_hook_info *hooks)
if (id == EVENT_NONE) continue;
register_event_hook(id, hooks[i].callback, hooks[i].priority,
hooks[i].data);
hooks[i].adata);
}
}

View File

@ -79,10 +79,13 @@ struct event_hook_info {
const char *name;
int priority;
event_hook_T callback;
void *data;
union {
const void *data;
void *adata;
};
};
#define NULL_EVENT_HOOK_INFO { NULL, 0, NULL, NULL }
#define NULL_EVENT_HOOK_INFO { NULL, 0, NULL, {NULL} }
void register_event_hooks(struct event_hook_info *hooks);
void unregister_event_hooks(struct event_hook_info *hooks);

View File

@ -339,7 +339,7 @@ goto_url_hook(va_list ap, void *data)
}
struct event_hook_info uri_rewrite_hooks[] = {
{ "goto-url", -1, goto_url_hook },
{ "goto-url", -1, goto_url_hook, {NULL} },
NULL_EVENT_HOOK_INFO
};

View File

@ -184,10 +184,10 @@ script_hook_quit(va_list ap, void *data)
}
struct event_hook_info guile_scripting_hooks[] = {
{ "goto-url", 0, script_hook_goto_url, NULL },
{ "follow-url", 0, script_hook_follow_url, NULL },
{ "pre-format-html", 0, script_hook_pre_format_html, NULL },
{ "get-proxy", 0, script_hook_get_proxy, NULL },
{ "quit", 0, script_hook_quit, NULL },
{ "goto-url", 0, script_hook_goto_url, {NULL} },
{ "follow-url", 0, script_hook_follow_url, {NULL} },
{ "pre-format-html", 0, script_hook_pre_format_html, {NULL} },
{ "get-proxy", 0, script_hook_get_proxy, {NULL} },
{ "quit", 0, script_hook_quit, {NULL} },
NULL_EVENT_HOOK_INFO,
};

View File

@ -235,12 +235,12 @@ script_hook_quit(va_list ap, void *data)
}
struct event_hook_info lua_scripting_hooks[] = {
{ "goto-url", 0, script_hook_goto_url, NULL },
{ "follow-url", 0, script_hook_follow_url, NULL },
{ "pre-format-html", 0, script_hook_pre_format_html, NULL },
{ "get-proxy", 0, script_hook_get_proxy, NULL },
{ "quit", 0, script_hook_quit, NULL },
{ "dialog-lua-console", 0, dialog_lua_console, NULL },
{ "free-history", 0, free_lua_console_history, NULL },
{ "goto-url", 0, script_hook_goto_url, {NULL} },
{ "follow-url", 0, script_hook_follow_url, {NULL} },
{ "pre-format-html", 0, script_hook_pre_format_html, {NULL} },
{ "get-proxy", 0, script_hook_get_proxy, {NULL} },
{ "quit", 0, script_hook_quit, {NULL} },
{ "dialog-lua-console", 0, dialog_lua_console, {NULL} },
{ "free-history", 0, free_lua_console_history, {NULL} },
NULL_EVENT_HOOK_INFO,
};

View File

@ -237,10 +237,10 @@ script_hook_quit(va_list ap, void *data)
}
struct event_hook_info perl_scripting_hooks[] = {
{ "goto-url", 0, script_hook_goto_url, NULL },
{ "follow-url", 0, script_hook_follow_url, NULL },
{ "pre-format-html", 0, script_hook_pre_format_html, NULL },
{ "get-proxy", 0, script_hook_get_proxy, NULL },
{ "quit", 0, script_hook_quit, NULL },
{ "goto-url", 0, script_hook_goto_url, {NULL} },
{ "follow-url", 0, script_hook_follow_url, {NULL} },
{ "pre-format-html", 0, script_hook_pre_format_html, {NULL} },
{ "get-proxy", 0, script_hook_get_proxy, {NULL} },
{ "quit", 0, script_hook_quit, {NULL} },
NULL_EVENT_HOOK_INFO,
};

View File

@ -144,7 +144,7 @@ script_hook_pre_format_html(va_list ap, void *data)
struct fragment *fragment = get_cache_fragment(cached);
char *url = struri(cached->uri);
int codepage = get_codepage(cached->head);
char *method = "pre_format_html_hook";
const char *method = "pre_format_html_hook";
struct session *saved_python_ses = python_ses;
PyObject *result = NULL;
int success = 0;
@ -264,7 +264,7 @@ script_hook_get_proxy(va_list ap, void *data)
{
char **proxy = va_arg(ap, char **);
char *url = va_arg(ap, char *);
char *method = "proxy_for_hook";
const char *method = "proxy_for_hook";
PyObject *result;
evhook_use_params(proxy && url);
@ -288,7 +288,7 @@ script_hook_get_proxy(va_list ap, void *data)
static enum evhook_status
script_hook_quit(va_list ap, void *data)
{
char *method = "quit_hook";
const char *method = "quit_hook";
PyObject *result;
if (!python_hooks || !PyObject_HasAttrString(python_hooks, method))
@ -303,10 +303,10 @@ script_hook_quit(va_list ap, void *data)
}
struct event_hook_info python_scripting_hooks[] = {
{ "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 },
{ "get-proxy", 0, script_hook_get_proxy, NULL },
{ "quit", 0, script_hook_quit, 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} },
{ "get-proxy", 0, script_hook_get_proxy, {NULL} },
{ "quit", 0, script_hook_quit, {NULL} },
NULL_EVENT_HOOK_INFO,
};

View File

@ -247,11 +247,11 @@ script_hook_quit(va_list ap, void *data)
}
struct event_hook_info ruby_scripting_hooks[] = {
{ "goto-url", 0, script_hook_goto_url, NULL },
{ "follow-url", 0, script_hook_follow_url, NULL },
{ "pre-format-html", 0, script_hook_pre_format_html, NULL },
{ "get-proxy", 0, script_hook_get_proxy, NULL },
{ "quit", 0, script_hook_quit, NULL },
{ "goto-url", 0, script_hook_goto_url, {NULL} },
{ "follow-url", 0, script_hook_follow_url, {NULL} },
{ "pre-format-html", 0, script_hook_pre_format_html, {NULL} },
{ "get-proxy", 0, script_hook_get_proxy, {NULL} },
{ "quit", 0, script_hook_quit, {NULL} },
NULL_EVENT_HOOK_INFO,
};

View File

@ -102,9 +102,9 @@ end:
}
struct event_hook_info smjs_scripting_hooks[] = {
{ "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 },
{ "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,
};

View File

@ -2010,7 +2010,7 @@ search_history_write_hook(va_list ap, void *data)
}
static struct event_hook_info search_history_hooks[] = {
{ "periodic-saving", 0, search_history_write_hook, NULL },
{ "periodic-saving", 0, search_history_write_hook, {NULL} },
NULL_EVENT_HOOK_INFO,
};