diff --git a/php_systemd.h b/php_systemd.h index 2e2f2e6..a83da3a 100644 --- a/php_systemd.h +++ b/php_systemd.h @@ -4,6 +4,7 @@ #define PHP_SYSTEMD_EXTNAME "systemd" PHP_FUNCTION(sd_journal_send); +PHP_FUNCTION(sd_notify); extern zend_module_entry systemd_module_entry; #define phpext_systemd_ptr &systemd_module_entry diff --git a/systemd.c b/systemd.c index 9479556..e925532 100644 --- a/systemd.c +++ b/systemd.c @@ -3,10 +3,12 @@ #endif #include "php.h" #include "php_systemd.h" +#include #include zend_function_entry systemd_functions[] = { PHP_FE(sd_journal_send, NULL) + PHP_FE(sd_notify, NULL) {NULL, NULL, NULL} // Sentinel }; @@ -63,3 +65,17 @@ PHP_FUNCTION(sd_journal_send) RETURN_TRUE; } + +PHP_FUNCTION(sd_notify) +{ + int unset_environment; + char *state; + int state_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", + &unset_environment, &state, &state_len) != SUCCESS) { + RETURN_FALSE; + } + + RETURN_LONG(sd_notify(unset_environment, state)); +}