1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 16:23:14 +02:00

api: add info "pid" (WeeChat PID) (issue #850)

This commit is contained in:
Sébastien Helleu
2016-11-20 16:07:27 +01:00
parent d0c1df309e
commit 111f8245d8
21 changed files with 145 additions and 66 deletions
+24
View File
@@ -381,6 +381,27 @@ plugin_api_info_date_cb (const void *pointer, void *data,
return version_get_compilation_date ();
}
/*
* Returns WeeChat info "pid".
*/
const char *
plugin_api_info_pid_cb (const void *pointer, void *data,
const char *info_name,
const char *arguments)
{
static char value[32];
/* make C compiler happy */
(void) pointer;
(void) data;
(void) info_name;
(void) arguments;
snprintf (value, sizeof (value), "%d", (int)getpid ());
return value;
}
/*
* Returns WeeChat info "dir_separator".
*/
@@ -1830,6 +1851,9 @@ plugin_api_init ()
hook_info (NULL, "date",
N_("WeeChat compilation date"),
NULL, &plugin_api_info_date_cb, NULL, NULL);
hook_info (NULL, "pid",
N_("WeeChat PID (process ID)"),
NULL, &plugin_api_info_pid_cb, NULL, NULL);
hook_info (NULL, "dir_separator",
N_("directory separator"),
NULL, &plugin_api_info_dir_separator_cb, NULL, NULL);