diff options
author | James Booth <boothj5@gmail.com> | 2016-06-23 00:36:26 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-06-23 00:36:26 +0100 |
commit | 1e37b755fe4030586b6994c397ddc855a659af43 (patch) | |
tree | 17d705b3578a7d9870992d7a59f51ffd8f37186e | |
parent | c6288d89f9682ee090f5776956cc2e6e8e6889bc (diff) | |
download | profani-tty-1e37b755fe4030586b6994c397ddc855a659af43.tar.gz |
Add macro for C plugins register_timed
-rw-r--r-- | src/plugins/c_api.c | 9 | ||||
-rw-r--r-- | src/plugins/profapi.c | 2 | ||||
-rw-r--r-- | src/plugins/profapi.h | 3 | ||||
-rw-r--r-- | src/plugins/python_api.c | 9 |
4 files changed, 15 insertions, 8 deletions
diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index 726f7d45..97d2e2f8 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -85,7 +85,7 @@ c_api_register_command(const char *filename, const char *command_name, int min_a void(*callback)(char **args)) { char *plugin_name = _c_plugin_name(filename); - log_debug("FILENAME : %s", plugin_name); + log_debug("Register command %s for %s", command_name, plugin_name); CommandWrapper *wrapper = malloc(sizeof(CommandWrapper)); wrapper->func = callback; @@ -94,8 +94,11 @@ c_api_register_command(const char *filename, const char *command_name, int min_a } static void -c_api_register_timed(void(*callback)(void), int interval_seconds) +c_api_register_timed(const char *filename, void(*callback)(void), int interval_seconds) { + char *plugin_name = _c_plugin_name(filename); + log_debug("Register timed for %s", plugin_name); + TimedWrapper *wrapper = malloc(sizeof(TimedWrapper)); wrapper->func = callback; api_register_timed(wrapper, interval_seconds, c_timed_callback); @@ -303,7 +306,7 @@ c_api_init(void) prof_cons_show_themed = c_api_cons_show_themed; prof_cons_bad_cmd_usage = c_api_cons_bad_cmd_usage; _prof_register_command = c_api_register_command; - prof_register_timed = c_api_register_timed; + _prof_register_timed = c_api_register_timed; prof_completer_add = c_api_completer_add; prof_completer_remove = c_api_completer_remove; prof_completer_clear = c_api_completer_clear; diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c index 9c352343..33967613 100644 --- a/src/plugins/profapi.c +++ b/src/plugins/profapi.c @@ -46,7 +46,7 @@ void (*_prof_register_command)(const char *filename, const char *command_name, i const char **synopsis, const char *description, const char *arguments[][2], const char **examples, void(*callback)(char **args)) = NULL; -void (*prof_register_timed)(void(*callback)(void), int interval_seconds) = NULL; +void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds) = NULL; void (*prof_completer_add)(const char *key, char **items) = NULL; void (*prof_completer_remove)(const char *key, char **items) = NULL; diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h index d25944c3..697e9598 100644 --- a/src/plugins/profapi.h +++ b/src/plugins/profapi.h @@ -36,6 +36,7 @@ #define PROF_API_H #define prof_register_command(command_name, min_args, max_args, synopsis, description, arguments, examples, callback) _prof_register_command(__FILE__, command_name, min_args, max_args, synopsis, description, arguments, examples, callback) +#define prof_register_timed(callback, interval_seconds) _prof_register_timed(__FILE__, callback, interval_seconds) typedef char* PROF_WIN_TAG; @@ -48,7 +49,7 @@ void (*_prof_register_command)(const char *filename, const char *command_name, i const char **synopsis, const char *description, const char *arguments[][2], const char **examples, void(*callback)(char **args)); -void (*prof_register_timed)(void(*callback)(void), int interval_seconds); +void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds); void (*prof_completer_add)(const char *key, char **items); void (*prof_completer_remove)(const char *key, char **items); diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index e0222e8d..a5c5d73c 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -119,6 +119,9 @@ python_api_register_command(PyObject *self, PyObject *args) return Py_BuildValue(""); } + char *plugin_name = _python_plugin_name(); + log_debug("Register command %s for %s", command_name, plugin_name); + if (p_callback && PyCallable_Check(p_callback)) { Py_ssize_t len = PyList_Size(synopsis); const char *c_synopsis[len == 0 ? 0 : len+1]; @@ -161,9 +164,6 @@ python_api_register_command(PyObject *self, PyObject *args) } c_examples[len] = NULL; - char *plugin_name = _python_plugin_name(); - log_debug("FILENAME : %s", plugin_name); - allow_python_threads(); api_register_command(command_name, min_args, max_args, c_synopsis, description, c_arguments, c_examples, p_callback, python_command_callback); @@ -176,6 +176,9 @@ python_api_register_command(PyObject *self, PyObject *args) static PyObject * python_api_register_timed(PyObject *self, PyObject *args) { + char *plugin_name = _python_plugin_name(); + log_debug("Register timed for %s", plugin_name); + PyObject *p_callback = NULL; int interval_seconds = 0; |