summaryrefslogtreecommitdiff
path: root/ext/snmp
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-04-19 20:05:16 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-04-20 10:38:41 +0200
commit4815be44db6b7a73cabfa872dc17d7e1574e1930 (patch)
tree1acf5fda7957d12814f73654ef1e3b149ba39bc2 /ext/snmp
parent8e9bc90004f09a0d67fdac393a8f3fca904be397 (diff)
downloadphp-git-4815be44db6b7a73cabfa872dc17d7e1574e1930.tar.gz
Generate function entries from stubs
Converts ext/pcntl, ext/simplexml, ext/snmp, ext/soap, ext/sqlite3. Closes GH-5421
Diffstat (limited to 'ext/snmp')
-rw-r--r--ext/snmp/php_snmp.h36
-rw-r--r--ext/snmp/snmp.c72
-rw-r--r--ext/snmp/snmp.stub.php2
-rw-r--r--ext/snmp/snmp_arginfo.h76
4 files changed, 89 insertions, 97 deletions
diff --git a/ext/snmp/php_snmp.h b/ext/snmp/php_snmp.h
index 45c8ae3d0f..25eb67f35a 100644
--- a/ext/snmp/php_snmp.h
+++ b/ext/snmp/php_snmp.h
@@ -44,42 +44,6 @@ PHP_MINIT_FUNCTION(snmp);
PHP_MSHUTDOWN_FUNCTION(snmp);
PHP_MINFO_FUNCTION(snmp);
-PHP_FUNCTION(snmpget);
-PHP_FUNCTION(snmpgetnext);
-PHP_FUNCTION(snmpwalk);
-PHP_FUNCTION(snmprealwalk);
-PHP_FUNCTION(snmpset);
-PHP_FUNCTION(snmp_get_quick_print);
-PHP_FUNCTION(snmp_set_quick_print);
-PHP_FUNCTION(snmp_set_enum_print);
-PHP_FUNCTION(snmp_set_oid_output_format);
-
-PHP_FUNCTION(snmp2_get);
-PHP_FUNCTION(snmp2_getnext);
-PHP_FUNCTION(snmp2_walk);
-PHP_FUNCTION(snmp2_real_walk);
-PHP_FUNCTION(snmp2_set);
-
-PHP_FUNCTION(snmp3_get);
-PHP_FUNCTION(snmp3_getnext);
-PHP_FUNCTION(snmp3_walk);
-PHP_FUNCTION(snmp3_real_walk);
-PHP_FUNCTION(snmp3_set);
-
-PHP_FUNCTION(snmp_set_valueretrieval);
-PHP_FUNCTION(snmp_get_valueretrieval);
-
-PHP_FUNCTION(snmp_read_mib);
-
-PHP_METHOD(SNMP, setSecurity);
-PHP_METHOD(SNMP, close);
-PHP_METHOD(SNMP, get);
-PHP_METHOD(SNMP, getnext);
-PHP_METHOD(SNMP, walk);
-PHP_METHOD(SNMP, set);
-PHP_METHOD(SNMP, getErrno);
-PHP_METHOD(SNMP, getError);
-
typedef struct _php_snmp_object {
struct snmp_session *session;
int max_oids;
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index 6c720e2b17..8464e74aad 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -136,40 +136,6 @@ struct objid_query {
snmpobjarg *vars;
};
-/* {{{ snmp_functions[]
- */
-static const zend_function_entry snmp_functions[] = {
- PHP_FE(snmpget, arginfo_snmpget)
- PHP_FE(snmpgetnext, arginfo_snmpgetnext)
- PHP_FE(snmpwalk, arginfo_snmpwalk)
- PHP_FE(snmprealwalk, arginfo_snmprealwalk)
- PHP_FALIAS(snmpwalkoid, snmprealwalk, arginfo_snmpwalkoid)
- PHP_FE(snmpset, arginfo_snmpset)
- PHP_FE(snmp_get_quick_print, arginfo_snmp_get_quick_print)
- PHP_FE(snmp_set_quick_print, arginfo_snmp_set_quick_print)
- PHP_FE(snmp_set_enum_print, arginfo_snmp_set_enum_print)
- PHP_FE(snmp_set_oid_output_format, arginfo_snmp_set_oid_output_format)
- PHP_FALIAS(snmp_set_oid_numeric_print, snmp_set_oid_output_format, arginfo_snmp_set_oid_numeric_print)
-
- PHP_FE(snmp2_get, arginfo_snmp2_get)
- PHP_FE(snmp2_getnext, arginfo_snmp2_getnext)
- PHP_FE(snmp2_walk, arginfo_snmp2_walk)
- PHP_FE(snmp2_real_walk, arginfo_snmp2_real_walk)
- PHP_FE(snmp2_set, arginfo_snmp2_set)
-
- PHP_FE(snmp3_get, arginfo_snmp3_get)
- PHP_FE(snmp3_getnext, arginfo_snmp3_getnext)
- PHP_FE(snmp3_walk, arginfo_snmp3_walk)
- PHP_FE(snmp3_real_walk, arginfo_snmp3_real_walk)
- PHP_FE(snmp3_set, arginfo_snmp3_set)
- PHP_FE(snmp_set_valueretrieval, arginfo_snmp_set_valueretrieval)
- PHP_FE(snmp_get_valueretrieval, arginfo_snmp_get_valueretrieval)
-
- PHP_FE(snmp_read_mib, arginfo_snmp_read_mib)
- PHP_FE_END
-};
-/* }}} */
-
/* query an agent with GET method */
#define SNMP_CMD_GET (1<<0)
/* query an agent with GETNEXT method */
@@ -1517,7 +1483,7 @@ PHP_FUNCTION(snmp_read_mib)
/* {{{ proto SNMP::__construct(int version, string hostname, string community|securityName [, int timeout [, int retries]])
Creates a new SNMP session to specified host. */
-PHP_METHOD(snmp, __construct)
+PHP_METHOD(SNMP, __construct)
{
php_snmp_object *snmp_object;
zval *object = ZEND_THIS;
@@ -1564,7 +1530,7 @@ PHP_METHOD(snmp, __construct)
/* {{{ proto bool SNMP::close()
Close SNMP session */
-PHP_METHOD(snmp, close)
+PHP_METHOD(SNMP, close)
{
php_snmp_object *snmp_object;
zval *object = ZEND_THIS;
@@ -1583,7 +1549,7 @@ PHP_METHOD(snmp, close)
/* {{{ proto mixed SNMP::get(mixed object_id [, bool preserve_keys])
Fetch a SNMP object returning scalar for single OID and array of oid->value pairs for multi OID request */
-PHP_METHOD(snmp, get)
+PHP_METHOD(SNMP, get)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GET, (-1));
}
@@ -1591,7 +1557,7 @@ PHP_METHOD(snmp, get)
/* {{{ proto mixed SNMP::getnext(mixed object_id)
Fetch a SNMP object returning scalar for single OID and array of oid->value pairs for multi OID request */
-PHP_METHOD(snmp, getnext)
+PHP_METHOD(SNMP, getnext)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GETNEXT, (-1));
}
@@ -1599,7 +1565,7 @@ PHP_METHOD(snmp, getnext)
/* {{{ proto mixed SNMP::walk(mixed object_id [, bool $suffix_as_key = FALSE [, int $max_repetitions [, int $non_repeaters]])
Return all objects including their respective object id within the specified one as array of oid->value pairs */
-PHP_METHOD(snmp, walk)
+PHP_METHOD(SNMP, walk)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_WALK, (-1));
}
@@ -1607,7 +1573,7 @@ PHP_METHOD(snmp, walk)
/* {{{ proto bool SNMP::set(mixed object_id, mixed type, mixed value)
Set the value of a SNMP object */
-PHP_METHOD(snmp, set)
+PHP_METHOD(SNMP, set)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, (-1));
}
@@ -1615,7 +1581,7 @@ PHP_METHOD(snmp, set)
/* {{{ proto bool SNMP::setSecurity(string sec_level, [ string auth_protocol, string auth_passphrase [, string priv_protocol, string priv_passphrase [, string contextName [, string contextEngineID]]]])
Set SNMPv3 security-related session parameters */
-PHP_METHOD(snmp, setSecurity)
+PHP_METHOD(SNMP, setSecurity)
{
php_snmp_object *snmp_object;
zval *object = ZEND_THIS;
@@ -1640,7 +1606,7 @@ PHP_METHOD(snmp, setSecurity)
/* {{{ proto int SNMP::getErrno()
Get last error code number */
-PHP_METHOD(snmp, getErrno)
+PHP_METHOD(SNMP, getErrno)
{
php_snmp_object *snmp_object;
zval *object = ZEND_THIS;
@@ -1658,7 +1624,7 @@ PHP_METHOD(snmp, getErrno)
/* {{{ proto int SNMP::getError()
Get last error message */
-PHP_METHOD(snmp, getError)
+PHP_METHOD(SNMP, getError)
{
php_snmp_object *snmp_object;
zval *object = ZEND_THIS;
@@ -1979,22 +1945,6 @@ static void free_php_snmp_properties(zval *el) /* {{{ */
}
/* }}} */
-/* {{{ php_snmp_class_methods[] */
-static const zend_function_entry php_snmp_class_methods[] = {
- PHP_ME(snmp, __construct, arginfo_class_SNMP___construct, ZEND_ACC_PUBLIC)
- PHP_ME(snmp, close, arginfo_class_SNMP_close, ZEND_ACC_PUBLIC)
- PHP_ME(snmp, setSecurity, arginfo_class_SNMP_setSecurity, ZEND_ACC_PUBLIC)
-
- PHP_ME(snmp, get, arginfo_class_SNMP_get, ZEND_ACC_PUBLIC)
- PHP_ME(snmp, getnext, arginfo_class_SNMP_getnext, ZEND_ACC_PUBLIC)
- PHP_ME(snmp, walk, arginfo_class_SNMP_walk, ZEND_ACC_PUBLIC)
- PHP_ME(snmp, set, arginfo_class_SNMP_set, ZEND_ACC_PUBLIC)
- PHP_ME(snmp, getErrno, arginfo_class_SNMP_getErrno, ZEND_ACC_PUBLIC)
- PHP_ME(snmp, getError, arginfo_class_SNMP_getError, ZEND_ACC_PUBLIC)
-
- PHP_FE_END
-};
-
#define PHP_SNMP_PROPERTY_ENTRY_RECORD(name) \
{ "" #name "", sizeof("" #name "") - 1, php_snmp_read_##name, php_snmp_write_##name }
@@ -2042,7 +1992,7 @@ PHP_MINIT_FUNCTION(snmp)
php_snmp_object_handlers.get_gc = php_snmp_get_gc;
/* Register SNMP Class */
- INIT_CLASS_ENTRY(ce, "SNMP", php_snmp_class_methods);
+ INIT_CLASS_ENTRY(ce, "SNMP", class_SNMP_methods);
ce.create_object = php_snmp_object_new;
php_snmp_object_handlers.offset = XtOffsetOf(php_snmp_object, zo);
php_snmp_object_handlers.clone_obj = NULL;
@@ -2137,7 +2087,7 @@ zend_module_entry snmp_module_entry = {
NULL,
snmp_module_deps,
"snmp",
- snmp_functions,
+ ext_functions,
PHP_MINIT(snmp),
PHP_MSHUTDOWN(snmp),
NULL,
diff --git a/ext/snmp/snmp.stub.php b/ext/snmp/snmp.stub.php
index bee2b39318..06632b602d 100644
--- a/ext/snmp/snmp.stub.php
+++ b/ext/snmp/snmp.stub.php
@@ -1,5 +1,7 @@
<?php
+/** @generate-function-entries */
+
/** @param array|string $object_id */
function snmpget(string $host, string $community, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {}
diff --git a/ext/snmp/snmp_arginfo.h b/ext/snmp/snmp_arginfo.h
index 487304f113..ed907a7dbd 100644
--- a/ext/snmp/snmp_arginfo.h
+++ b/ext/snmp/snmp_arginfo.h
@@ -144,3 +144,79 @@ ZEND_END_ARG_INFO()
#define arginfo_class_SNMP_getErrno arginfo_class_SNMP_close
#define arginfo_class_SNMP_getError arginfo_class_SNMP_close
+
+
+ZEND_FUNCTION(snmpget);
+ZEND_FUNCTION(snmpgetnext);
+ZEND_FUNCTION(snmpwalk);
+ZEND_FUNCTION(snmprealwalk);
+ZEND_FUNCTION(snmpset);
+ZEND_FUNCTION(snmp_get_quick_print);
+ZEND_FUNCTION(snmp_set_quick_print);
+ZEND_FUNCTION(snmp_set_enum_print);
+ZEND_FUNCTION(snmp_set_oid_output_format);
+ZEND_FUNCTION(snmp2_get);
+ZEND_FUNCTION(snmp2_getnext);
+ZEND_FUNCTION(snmp2_walk);
+ZEND_FUNCTION(snmp2_real_walk);
+ZEND_FUNCTION(snmp2_set);
+ZEND_FUNCTION(snmp3_get);
+ZEND_FUNCTION(snmp3_getnext);
+ZEND_FUNCTION(snmp3_walk);
+ZEND_FUNCTION(snmp3_real_walk);
+ZEND_FUNCTION(snmp3_set);
+ZEND_FUNCTION(snmp_set_valueretrieval);
+ZEND_FUNCTION(snmp_get_valueretrieval);
+ZEND_FUNCTION(snmp_read_mib);
+ZEND_METHOD(SNMP, __construct);
+ZEND_METHOD(SNMP, close);
+ZEND_METHOD(SNMP, setSecurity);
+ZEND_METHOD(SNMP, get);
+ZEND_METHOD(SNMP, getnext);
+ZEND_METHOD(SNMP, walk);
+ZEND_METHOD(SNMP, set);
+ZEND_METHOD(SNMP, getErrno);
+ZEND_METHOD(SNMP, getError);
+
+
+static const zend_function_entry ext_functions[] = {
+ ZEND_FE(snmpget, arginfo_snmpget)
+ ZEND_FE(snmpgetnext, arginfo_snmpgetnext)
+ ZEND_FE(snmpwalk, arginfo_snmpwalk)
+ ZEND_FE(snmprealwalk, arginfo_snmprealwalk)
+ ZEND_FALIAS(snmpwalkoid, snmprealwalk, arginfo_snmpwalkoid)
+ ZEND_FE(snmpset, arginfo_snmpset)
+ ZEND_FE(snmp_get_quick_print, arginfo_snmp_get_quick_print)
+ ZEND_FE(snmp_set_quick_print, arginfo_snmp_set_quick_print)
+ ZEND_FE(snmp_set_enum_print, arginfo_snmp_set_enum_print)
+ ZEND_FE(snmp_set_oid_output_format, arginfo_snmp_set_oid_output_format)
+ ZEND_FALIAS(snmp_set_oid_numeric_print, snmp_set_oid_output_format, arginfo_snmp_set_oid_numeric_print)
+ ZEND_FE(snmp2_get, arginfo_snmp2_get)
+ ZEND_FE(snmp2_getnext, arginfo_snmp2_getnext)
+ ZEND_FE(snmp2_walk, arginfo_snmp2_walk)
+ ZEND_FE(snmp2_real_walk, arginfo_snmp2_real_walk)
+ ZEND_FE(snmp2_set, arginfo_snmp2_set)
+ ZEND_FE(snmp3_get, arginfo_snmp3_get)
+ ZEND_FE(snmp3_getnext, arginfo_snmp3_getnext)
+ ZEND_FE(snmp3_walk, arginfo_snmp3_walk)
+ ZEND_FE(snmp3_real_walk, arginfo_snmp3_real_walk)
+ ZEND_FE(snmp3_set, arginfo_snmp3_set)
+ ZEND_FE(snmp_set_valueretrieval, arginfo_snmp_set_valueretrieval)
+ ZEND_FE(snmp_get_valueretrieval, arginfo_snmp_get_valueretrieval)
+ ZEND_FE(snmp_read_mib, arginfo_snmp_read_mib)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_SNMP_methods[] = {
+ ZEND_ME(SNMP, __construct, arginfo_class_SNMP___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(SNMP, close, arginfo_class_SNMP_close, ZEND_ACC_PUBLIC)
+ ZEND_ME(SNMP, setSecurity, arginfo_class_SNMP_setSecurity, ZEND_ACC_PUBLIC)
+ ZEND_ME(SNMP, get, arginfo_class_SNMP_get, ZEND_ACC_PUBLIC)
+ ZEND_ME(SNMP, getnext, arginfo_class_SNMP_getnext, ZEND_ACC_PUBLIC)
+ ZEND_ME(SNMP, walk, arginfo_class_SNMP_walk, ZEND_ACC_PUBLIC)
+ ZEND_ME(SNMP, set, arginfo_class_SNMP_set, ZEND_ACC_PUBLIC)
+ ZEND_ME(SNMP, getErrno, arginfo_class_SNMP_getErrno, ZEND_ACC_PUBLIC)
+ ZEND_ME(SNMP, getError, arginfo_class_SNMP_getError, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};