From 091a13c85528714c085a7e729e2d24fe360c84b7 Mon Sep 17 00:00:00 2001 From: Thai Pham Date: Wed, 14 Jun 2017 07:48:23 +1000 Subject: [PATCH 1/3] Support sd_notify --- php_systemd.h | 1 + systemd.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) 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..b4bedf0 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 sd_notify(unset_envinronment, state); +} From 0eb3741e4cf0b1c138a590ca3abc8aa74acedab3 Mon Sep 17 00:00:00 2001 From: Thai Pham Date: Wed, 14 Jun 2017 07:53:39 +1000 Subject: [PATCH 2/3] Fix a typo --- systemd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd.c b/systemd.c index b4bedf0..bc3ca6e 100644 --- a/systemd.c +++ b/systemd.c @@ -77,5 +77,5 @@ PHP_FUNCTION(sd_notify) RETURN_FALSE; } - return sd_notify(unset_envinronment, state); + return sd_notify(unset_environment, state); } From 16138be65a559ce8f5b0c856cd442c406f6e70f6 Mon Sep 17 00:00:00 2001 From: Thai Pham Date: Wed, 14 Jun 2017 07:58:01 +1000 Subject: [PATCH 3/3] Use RETURN_LONG --- systemd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd.c b/systemd.c index bc3ca6e..e925532 100644 --- a/systemd.c +++ b/systemd.c @@ -77,5 +77,5 @@ PHP_FUNCTION(sd_notify) RETURN_FALSE; } - return sd_notify(unset_environment, state); + RETURN_LONG(sd_notify(unset_environment, state)); }