From c2885baa918865250ad2138ca71b43c1e97bc1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Sat, 23 Jul 2022 11:04:02 +0200 Subject: [PATCH 1/3] Declare ext/snmp constants in stubs --- ext/snmp/php_snmp.h | 3 +- ext/snmp/snmp.c | 43 +--------- ext/snmp/snmp.stub.php | 170 ++++++++++++++++++++++++++++++++++++++++ ext/snmp/snmp_arginfo.h | 99 ++++++++++++++++++++++- 4 files changed, 273 insertions(+), 42 deletions(-) diff --git a/ext/snmp/php_snmp.h b/ext/snmp/php_snmp.h index 0615d6a3e9a0d..8e566a0f0ed7c 100644 --- a/ext/snmp/php_snmp.h +++ b/ext/snmp/php_snmp.h @@ -92,8 +92,7 @@ ZEND_END_MODULE_GLOBALS(snmp) #define SNMP_G(v) (snmp_globals.v) #endif -#define REGISTER_SNMP_CLASS_CONST_LONG(const_name, value) \ - zend_declare_class_constant_long(php_snmp_ce, const_name, sizeof(const_name)-1, (zend_long)value); +#define LONG_CONST(c) (zend_long) c; #else diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 84e618f28ad01..33e6da9a9a46e 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -31,7 +31,6 @@ #include "zend_exceptions.h" #include "zend_smart_string.h" #include "ext/spl/spl_exceptions.h" -#include "snmp_arginfo.h" #ifdef HAVE_SNMP @@ -78,6 +77,8 @@ extern netsnmp_log_handler *logh_head; #define SNMP_VALUE_PLAIN (1 << 0) #define SNMP_VALUE_OBJECT (1 << 1) +#include "snmp_arginfo.h" + typedef struct snmp_session php_snmp_session; #define PHP_SNMP_ADD_PROPERTIES(a, b) \ @@ -2052,47 +2053,11 @@ PHP_MINIT_FUNCTION(snmp) zend_hash_init(&php_snmp_properties, 0, NULL, free_php_snmp_properties, 1); PHP_SNMP_ADD_PROPERTIES(&php_snmp_properties, php_snmp_property_entries); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_SUFFIX", NETSNMP_OID_OUTPUT_SUFFIX, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_MODULE", NETSNMP_OID_OUTPUT_MODULE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_FULL", NETSNMP_OID_OUTPUT_FULL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NUMERIC", NETSNMP_OID_OUTPUT_NUMERIC, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_UCD", NETSNMP_OID_OUTPUT_UCD, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NONE", NETSNMP_OID_OUTPUT_NONE, CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("SNMP_VALUE_LIBRARY", SNMP_VALUE_LIBRARY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VALUE_PLAIN", SNMP_VALUE_PLAIN, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VALUE_OBJECT", SNMP_VALUE_OBJECT, CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("SNMP_BIT_STR", ASN_BIT_STR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OCTET_STR", ASN_OCTET_STR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OPAQUE", ASN_OPAQUE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_NULL", ASN_NULL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OBJECT_ID", ASN_OBJECT_ID, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_IPADDRESS", ASN_IPADDRESS, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_COUNTER", ASN_GAUGE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_UNSIGNED", ASN_UNSIGNED, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_TIMETICKS", ASN_TIMETICKS, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_UINTEGER", ASN_UINTEGER, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_INTEGER", ASN_INTEGER, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_COUNTER64", ASN_COUNTER64, CONST_CS | CONST_PERSISTENT); - - REGISTER_SNMP_CLASS_CONST_LONG("VERSION_1", SNMP_VERSION_1); - REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2c", SNMP_VERSION_2c); - REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2C", SNMP_VERSION_2c); - REGISTER_SNMP_CLASS_CONST_LONG("VERSION_3", SNMP_VERSION_3); - - REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_NOERROR", PHP_SNMP_ERRNO_NOERROR); - REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_ANY", PHP_SNMP_ERRNO_ANY); - REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_GENERIC", PHP_SNMP_ERRNO_GENERIC); - REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_TIMEOUT", PHP_SNMP_ERRNO_TIMEOUT); - REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_ERROR_IN_REPLY", PHP_SNMP_ERRNO_ERROR_IN_REPLY); - REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_OID_NOT_INCREASING", PHP_SNMP_ERRNO_OID_NOT_INCREASING); - REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_OID_PARSING_ERROR", PHP_SNMP_ERRNO_OID_PARSING_ERROR); - REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_MULTIPLE_SET_QUERIES", PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES); - /* Register SNMPException class */ php_snmp_exception_ce = register_class_SNMPException(spl_ce_RuntimeException); + register_snmp_symbols(module_number); + return SUCCESS; } /* }}} */ diff --git a/ext/snmp/snmp.stub.php b/ext/snmp/snmp.stub.php index 956af81d5991e..8df1355eb7881 100644 --- a/ext/snmp/snmp.stub.php +++ b/ext/snmp/snmp.stub.php @@ -2,6 +2,114 @@ /** @generate-class-entries */ +/** + * @var int + * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_SUFFIX) + */ +const SNMP_OID_OUTPUT_SUFFIX = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_MODULE) + */ +const SNMP_OID_OUTPUT_MODULE = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_FULL) + */ +const SNMP_OID_OUTPUT_FULL = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_NUMERIC) + */ +const SNMP_OID_OUTPUT_NUMERIC = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_UCD) + */ +const SNMP_OID_OUTPUT_UCD = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_NONE) + */ +const SNMP_OID_OUTPUT_NONE = UNKNOWN; + +/** + * @var int + * @cvalue LONG_CONST(SNMP_VALUE_LIBRARY) + */ +const SNMP_VALUE_LIBRARY = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(SNMP_VALUE_PLAIN) + */ +const SNMP_VALUE_PLAIN = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(SNMP_VALUE_OBJECT) + */ +const SNMP_VALUE_OBJECT = UNKNOWN; + +/** + * @var int + * @cvalue LONG_CONST(ASN_BIT_STR) + */ +const SNMP_BIT_STR = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_OCTET_STRLONG_CONST) + */ +const SNMP_OCTET_STR = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_OPAQUE) + */ +const SNMP_OPAQUE = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_NULL) + */ +const SNMP_NULL = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_OBJECT_ID) + */ +const SNMP_OBJECT_ID = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_IPADDRESS) + */ +const SNMP_IPADDRESS = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_GAUGE) + */ +const SNMP_COUNTER = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_UNSIGNED) + */ +const SNMP_UNSIGNED = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_TIMETICKS) + */ +const SNMP_TIMETICKS = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_UINTEGER) + */ +const SNMP_UINTEGER = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_INTEGER) + */ +const SNMP_INTEGER = UNKNOWN; +/** + * @var int + * @cvalue LONG_CONST(ASN_COUNTER64) + */ +const SNMP_COUNTER64 = UNKNOWN; + function snmpget(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): mixed {} function snmpgetnext(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): mixed {} @@ -75,6 +183,68 @@ function snmp_read_mib(string $filename): bool {} class SNMP { + /** + * @var int + * @cvalue LONG_CONST(SNMP_VERSION_1) + */ + public const VERSION_1 = UNKNOWN; + /** + * @var int + * @cvalue LONG_CONST(SNMP_VERSION_2c) + */ + public const VERSION_2c = UNKNOWN; + /** + * @var int + * @cvalue LONG_CONST(SNMP_VERSION_2c) + */ + public const VERSION_2C = UNKNOWN; + /** + * @var int + * @cvalue LONG_CONST(SNMP_VERSION_3) + */ + public const VERSION_3 = UNKNOWN; + + /** + * @var int + * @cvalue LONG_CONST(PHP_SNMP_ERRNO_NOERROR) + */ + public const ERRNO_NOERROR = UNKNOWN; + /** + * @var int + * @cvalue LONG_CONST(PHP_SNMP_ERRNO_ANY) + */ + public const ERRNO_ANY = UNKNOWN; + /** + * @var int + * @cvalue LONG_CONST(PHP_SNMP_ERRNO_GENERIC) + */ + public const ERRNO_GENERIC = UNKNOWN; + /** + * @var int + * @cvalue LONG_CONST(PHP_SNMP_ERRNO_TIMEOUT) + */ + public const ERRNO_TIMEOUT = UNKNOWN; + /** + * @var int + * @cvalue LONG_CONST(PHP_SNMP_ERRNO_ERROR_IN_REPLY) + */ + public const ERRNO_ERROR_IN_REPLY = UNKNOWN; + /** + * @var int + * @cvalue LONG_CONST(PHP_SNMP_ERRNO_OID_NOT_INCREASING) + */ + public const ERRNO_OID_NOT_INCREASING = UNKNOWN; + /** + * @var int + * @cvalue LONG_CONST(PHP_SNMP_ERRNO_OID_PARSING_ERROR) + */ + public const ERRNO_OID_PARSING_ERROR = UNKNOWN; + /** + * @var int + * @cvalue LONG_CONST(PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES) + */ + public const ERRNO_MULTIPLE_SET_QUERIES = UNKNOWN; + /** @readonly */ public array $info; public ?int $max_oids; diff --git a/ext/snmp/snmp_arginfo.h b/ext/snmp/snmp_arginfo.h index 7e3a2a26b2e6b..d1d83cd6c7058 100644 --- a/ext/snmp/snmp_arginfo.h +++ b/ext/snmp/snmp_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 75ba939cab1a18a8e1c2836e0c0bbab9d310ba2b */ + * Stub hash: 65439810ce75b738c6d9504aa176240ce2396143 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmpget, 0, 3, IS_MIXED, 0) ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0) @@ -244,6 +244,31 @@ static const zend_function_entry class_SNMPException_methods[] = { ZEND_FE_END }; +static void register_snmp_symbols(int module_number) +{ + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_SUFFIX", LONG_CONST(NETSNMP_OID_OUTPUT_SUFFIX), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_MODULE", LONG_CONST(NETSNMP_OID_OUTPUT_MODULE), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_FULL", LONG_CONST(NETSNMP_OID_OUTPUT_FULL), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NUMERIC", LONG_CONST(NETSNMP_OID_OUTPUT_NUMERIC), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_UCD", LONG_CONST(NETSNMP_OID_OUTPUT_UCD), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NONE", LONG_CONST(NETSNMP_OID_OUTPUT_NONE), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_VALUE_LIBRARY", LONG_CONST(SNMP_VALUE_LIBRARY), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_VALUE_PLAIN", LONG_CONST(SNMP_VALUE_PLAIN), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_VALUE_OBJECT", LONG_CONST(SNMP_VALUE_OBJECT), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_BIT_STR", LONG_CONST(ASN_BIT_STR), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OCTET_STR", LONG_CONST(ASN_OCTET_STRLONG_CONST), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OPAQUE", LONG_CONST(ASN_OPAQUE), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_NULL", LONG_CONST(ASN_NULL), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OBJECT_ID", LONG_CONST(ASN_OBJECT_ID), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_IPADDRESS", LONG_CONST(ASN_IPADDRESS), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_COUNTER", LONG_CONST(ASN_GAUGE), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_UNSIGNED", LONG_CONST(ASN_UNSIGNED), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_TIMETICKS", LONG_CONST(ASN_TIMETICKS), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_UINTEGER", LONG_CONST(ASN_UINTEGER), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_INTEGER", LONG_CONST(ASN_INTEGER), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_COUNTER64", LONG_CONST(ASN_COUNTER64), CONST_CS | CONST_PERSISTENT); +} + static zend_class_entry *register_class_SNMP(void) { zend_class_entry ce, *class_entry; @@ -251,6 +276,78 @@ static zend_class_entry *register_class_SNMP(void) INIT_CLASS_ENTRY(ce, "SNMP", class_SNMP_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); + zval const_VERSION_1_value; + ZVAL_LONG(&const_VERSION_1_value, LONG_CONST(SNMP_VERSION_1)); + zend_string *const_VERSION_1_name = zend_string_init_interned("VERSION_1", sizeof("VERSION_1") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_VERSION_1_name, &const_VERSION_1_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_VERSION_1_name); + + zval const_VERSION_2c_value; + ZVAL_LONG(&const_VERSION_2c_value, LONG_CONST(SNMP_VERSION_2c)); + zend_string *const_VERSION_2c_name = zend_string_init_interned("VERSION_2c", sizeof("VERSION_2c") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_VERSION_2c_name, &const_VERSION_2c_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_VERSION_2c_name); + + zval const_VERSION_2C_value; + ZVAL_LONG(&const_VERSION_2C_value, LONG_CONST(SNMP_VERSION_2c)); + zend_string *const_VERSION_2C_name = zend_string_init_interned("VERSION_2C", sizeof("VERSION_2C") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_VERSION_2C_name, &const_VERSION_2C_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_VERSION_2C_name); + + zval const_VERSION_3_value; + ZVAL_LONG(&const_VERSION_3_value, LONG_CONST(SNMP_VERSION_3)); + zend_string *const_VERSION_3_name = zend_string_init_interned("VERSION_3", sizeof("VERSION_3") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_VERSION_3_name, &const_VERSION_3_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_VERSION_3_name); + + zval const_ERRNO_NOERROR_value; + ZVAL_LONG(&const_ERRNO_NOERROR_value, LONG_CONST(PHP_SNMP_ERRNO_NOERROR)); + zend_string *const_ERRNO_NOERROR_name = zend_string_init_interned("ERRNO_NOERROR", sizeof("ERRNO_NOERROR") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_ERRNO_NOERROR_name, &const_ERRNO_NOERROR_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_ERRNO_NOERROR_name); + + zval const_ERRNO_ANY_value; + ZVAL_LONG(&const_ERRNO_ANY_value, LONG_CONST(PHP_SNMP_ERRNO_ANY)); + zend_string *const_ERRNO_ANY_name = zend_string_init_interned("ERRNO_ANY", sizeof("ERRNO_ANY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_ERRNO_ANY_name, &const_ERRNO_ANY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_ERRNO_ANY_name); + + zval const_ERRNO_GENERIC_value; + ZVAL_LONG(&const_ERRNO_GENERIC_value, LONG_CONST(PHP_SNMP_ERRNO_GENERIC)); + zend_string *const_ERRNO_GENERIC_name = zend_string_init_interned("ERRNO_GENERIC", sizeof("ERRNO_GENERIC") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_ERRNO_GENERIC_name, &const_ERRNO_GENERIC_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_ERRNO_GENERIC_name); + + zval const_ERRNO_TIMEOUT_value; + ZVAL_LONG(&const_ERRNO_TIMEOUT_value, LONG_CONST(PHP_SNMP_ERRNO_TIMEOUT)); + zend_string *const_ERRNO_TIMEOUT_name = zend_string_init_interned("ERRNO_TIMEOUT", sizeof("ERRNO_TIMEOUT") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_ERRNO_TIMEOUT_name, &const_ERRNO_TIMEOUT_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_ERRNO_TIMEOUT_name); + + zval const_ERRNO_ERROR_IN_REPLY_value; + ZVAL_LONG(&const_ERRNO_ERROR_IN_REPLY_value, LONG_CONST(PHP_SNMP_ERRNO_ERROR_IN_REPLY)); + zend_string *const_ERRNO_ERROR_IN_REPLY_name = zend_string_init_interned("ERRNO_ERROR_IN_REPLY", sizeof("ERRNO_ERROR_IN_REPLY") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_ERRNO_ERROR_IN_REPLY_name, &const_ERRNO_ERROR_IN_REPLY_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_ERRNO_ERROR_IN_REPLY_name); + + zval const_ERRNO_OID_NOT_INCREASING_value; + ZVAL_LONG(&const_ERRNO_OID_NOT_INCREASING_value, LONG_CONST(PHP_SNMP_ERRNO_OID_NOT_INCREASING)); + zend_string *const_ERRNO_OID_NOT_INCREASING_name = zend_string_init_interned("ERRNO_OID_NOT_INCREASING", sizeof("ERRNO_OID_NOT_INCREASING") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_ERRNO_OID_NOT_INCREASING_name, &const_ERRNO_OID_NOT_INCREASING_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_ERRNO_OID_NOT_INCREASING_name); + + zval const_ERRNO_OID_PARSING_ERROR_value; + ZVAL_LONG(&const_ERRNO_OID_PARSING_ERROR_value, LONG_CONST(PHP_SNMP_ERRNO_OID_PARSING_ERROR)); + zend_string *const_ERRNO_OID_PARSING_ERROR_name = zend_string_init_interned("ERRNO_OID_PARSING_ERROR", sizeof("ERRNO_OID_PARSING_ERROR") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_ERRNO_OID_PARSING_ERROR_name, &const_ERRNO_OID_PARSING_ERROR_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_ERRNO_OID_PARSING_ERROR_name); + + zval const_ERRNO_MULTIPLE_SET_QUERIES_value; + ZVAL_LONG(&const_ERRNO_MULTIPLE_SET_QUERIES_value, LONG_CONST(PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES)); + zend_string *const_ERRNO_MULTIPLE_SET_QUERIES_name = zend_string_init_interned("ERRNO_MULTIPLE_SET_QUERIES", sizeof("ERRNO_MULTIPLE_SET_QUERIES") - 1, 1); + zend_declare_class_constant_ex(class_entry, const_ERRNO_MULTIPLE_SET_QUERIES_name, &const_ERRNO_MULTIPLE_SET_QUERIES_value, ZEND_ACC_PUBLIC, NULL); + zend_string_release(const_ERRNO_MULTIPLE_SET_QUERIES_name); + zval property_info_default_value; ZVAL_UNDEF(&property_info_default_value); zend_string *property_info_name = zend_string_init("info", sizeof("info") - 1, 1); From e4a26cf9ac52fda182a075f1303544d56ff22281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 25 Jul 2022 13:32:58 +0200 Subject: [PATCH 2/3] Remove accidental semicolon and fix includes --- ext/snmp/php_snmp.h | 23 ++++++++++++++++++++++- ext/snmp/snmp.c | 25 ++----------------------- ext/snmp/snmp.stub.php | 2 +- ext/snmp/snmp_arginfo.h | 4 ++-- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ext/snmp/php_snmp.h b/ext/snmp/php_snmp.h index 8e566a0f0ed7c..935d028f2d684 100644 --- a/ext/snmp/php_snmp.h +++ b/ext/snmp/php_snmp.h @@ -92,7 +92,28 @@ ZEND_END_MODULE_GLOBALS(snmp) #define SNMP_G(v) (snmp_globals.v) #endif -#define LONG_CONST(c) (zend_long) c; +#define LONG_CONST(c) (zend_long) c + +#define SNMP_VALUE_LIBRARY (0 << 0) +#define SNMP_VALUE_PLAIN (1 << 0) +#define SNMP_VALUE_OBJECT (1 << 1) + +#define PHP_SNMP_ERRNO_NOERROR 0 +#define PHP_SNMP_ERRNO_GENERIC (1 << 1) +#define PHP_SNMP_ERRNO_TIMEOUT (1 << 2) +#define PHP_SNMP_ERRNO_ERROR_IN_REPLY (1 << 3) +#define PHP_SNMP_ERRNO_OID_NOT_INCREASING (1 << 4) +#define PHP_SNMP_ERRNO_OID_PARSING_ERROR (1 << 5) +#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES (1 << 6) +#define PHP_SNMP_ERRNO_ANY ( \ + PHP_SNMP_ERRNO_GENERIC | \ + PHP_SNMP_ERRNO_TIMEOUT | \ + PHP_SNMP_ERRNO_ERROR_IN_REPLY | \ + PHP_SNMP_ERRNO_OID_NOT_INCREASING | \ + PHP_SNMP_ERRNO_OID_PARSING_ERROR | \ + PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES | \ + PHP_SNMP_ERRNO_NOERROR \ + ) #else diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 33e6da9a9a46e..299d2d8fd08c8 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -62,6 +62,8 @@ #include #include +#include "snmp_arginfo.h" + /* For net-snmp prior to 5.4 */ #ifndef HAVE_SHUTDOWN_SNMP_LOGGING extern netsnmp_log_handler *logh_head; @@ -73,12 +75,6 @@ extern netsnmp_log_handler *logh_head; } #endif -#define SNMP_VALUE_LIBRARY (0 << 0) -#define SNMP_VALUE_PLAIN (1 << 0) -#define SNMP_VALUE_OBJECT (1 << 1) - -#include "snmp_arginfo.h" - typedef struct snmp_session php_snmp_session; #define PHP_SNMP_ADD_PROPERTIES(a, b) \ @@ -91,23 +87,6 @@ typedef struct snmp_session php_snmp_session; } \ } -#define PHP_SNMP_ERRNO_NOERROR 0 -#define PHP_SNMP_ERRNO_GENERIC (1 << 1) -#define PHP_SNMP_ERRNO_TIMEOUT (1 << 2) -#define PHP_SNMP_ERRNO_ERROR_IN_REPLY (1 << 3) -#define PHP_SNMP_ERRNO_OID_NOT_INCREASING (1 << 4) -#define PHP_SNMP_ERRNO_OID_PARSING_ERROR (1 << 5) -#define PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES (1 << 6) -#define PHP_SNMP_ERRNO_ANY ( \ - PHP_SNMP_ERRNO_GENERIC | \ - PHP_SNMP_ERRNO_TIMEOUT | \ - PHP_SNMP_ERRNO_ERROR_IN_REPLY | \ - PHP_SNMP_ERRNO_OID_NOT_INCREASING | \ - PHP_SNMP_ERRNO_OID_PARSING_ERROR | \ - PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES | \ - PHP_SNMP_ERRNO_NOERROR \ - ) - ZEND_DECLARE_MODULE_GLOBALS(snmp) static PHP_GINIT_FUNCTION(snmp); diff --git a/ext/snmp/snmp.stub.php b/ext/snmp/snmp.stub.php index 8df1355eb7881..903f91883d991 100644 --- a/ext/snmp/snmp.stub.php +++ b/ext/snmp/snmp.stub.php @@ -56,7 +56,7 @@ const SNMP_BIT_STR = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_OCTET_STRLONG_CONST) + * @cvalue LONG_CONST(ASN_OCTET_STR) */ const SNMP_OCTET_STR = UNKNOWN; /** diff --git a/ext/snmp/snmp_arginfo.h b/ext/snmp/snmp_arginfo.h index d1d83cd6c7058..30d2b0d5295a4 100644 --- a/ext/snmp/snmp_arginfo.h +++ b/ext/snmp/snmp_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 65439810ce75b738c6d9504aa176240ce2396143 */ + * Stub hash: f1f302268d2a409464db8e107742d8da499c1e60 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmpget, 0, 3, IS_MIXED, 0) ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0) @@ -256,7 +256,7 @@ static void register_snmp_symbols(int module_number) REGISTER_LONG_CONSTANT("SNMP_VALUE_PLAIN", LONG_CONST(SNMP_VALUE_PLAIN), CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SNMP_VALUE_OBJECT", LONG_CONST(SNMP_VALUE_OBJECT), CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SNMP_BIT_STR", LONG_CONST(ASN_BIT_STR), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OCTET_STR", LONG_CONST(ASN_OCTET_STRLONG_CONST), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OCTET_STR", LONG_CONST(ASN_OCTET_STR), CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SNMP_OPAQUE", LONG_CONST(ASN_OPAQUE), CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SNMP_NULL", LONG_CONST(ASN_NULL), CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SNMP_OBJECT_ID", LONG_CONST(ASN_OBJECT_ID), CONST_CS | CONST_PERSISTENT); From 477d4151ee67555af5772e97c4a1f86eea56f1e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 25 Jul 2022 17:35:12 +0200 Subject: [PATCH 3/3] Remove unnecessary LONG_CONST macro --- ext/snmp/php_snmp.h | 2 -- ext/snmp/snmp.stub.php | 66 +++++++++++++++++++-------------------- ext/snmp/snmp_arginfo.h | 68 ++++++++++++++++++++--------------------- 3 files changed, 67 insertions(+), 69 deletions(-) diff --git a/ext/snmp/php_snmp.h b/ext/snmp/php_snmp.h index 935d028f2d684..ce9849588b19e 100644 --- a/ext/snmp/php_snmp.h +++ b/ext/snmp/php_snmp.h @@ -92,8 +92,6 @@ ZEND_END_MODULE_GLOBALS(snmp) #define SNMP_G(v) (snmp_globals.v) #endif -#define LONG_CONST(c) (zend_long) c - #define SNMP_VALUE_LIBRARY (0 << 0) #define SNMP_VALUE_PLAIN (1 << 0) #define SNMP_VALUE_OBJECT (1 << 1) diff --git a/ext/snmp/snmp.stub.php b/ext/snmp/snmp.stub.php index 903f91883d991..175c3cdc6461e 100644 --- a/ext/snmp/snmp.stub.php +++ b/ext/snmp/snmp.stub.php @@ -4,109 +4,109 @@ /** * @var int - * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_SUFFIX) + * @cvalue NETSNMP_OID_OUTPUT_SUFFIX */ const SNMP_OID_OUTPUT_SUFFIX = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_MODULE) + * @cvalue NETSNMP_OID_OUTPUT_MODULE */ const SNMP_OID_OUTPUT_MODULE = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_FULL) + * @cvalue NETSNMP_OID_OUTPUT_FULL */ const SNMP_OID_OUTPUT_FULL = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_NUMERIC) + * @cvalue NETSNMP_OID_OUTPUT_NUMERIC */ const SNMP_OID_OUTPUT_NUMERIC = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_UCD) + * @cvalue NETSNMP_OID_OUTPUT_UCD */ const SNMP_OID_OUTPUT_UCD = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(NETSNMP_OID_OUTPUT_NONE) + * @cvalue NETSNMP_OID_OUTPUT_NONE */ const SNMP_OID_OUTPUT_NONE = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(SNMP_VALUE_LIBRARY) + * @cvalue SNMP_VALUE_LIBRARY */ const SNMP_VALUE_LIBRARY = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(SNMP_VALUE_PLAIN) + * @cvalue SNMP_VALUE_PLAIN */ const SNMP_VALUE_PLAIN = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(SNMP_VALUE_OBJECT) + * @cvalue SNMP_VALUE_OBJECT */ const SNMP_VALUE_OBJECT = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_BIT_STR) + * @cvalue ASN_BIT_STR */ const SNMP_BIT_STR = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_OCTET_STR) + * @cvalue ASN_OCTET_STR */ const SNMP_OCTET_STR = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_OPAQUE) + * @cvalue ASN_OPAQUE */ const SNMP_OPAQUE = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_NULL) + * @cvalue ASN_NULL */ const SNMP_NULL = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_OBJECT_ID) + * @cvalue ASN_OBJECT_ID */ const SNMP_OBJECT_ID = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_IPADDRESS) + * @cvalue ASN_IPADDRESS */ const SNMP_IPADDRESS = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_GAUGE) + * @cvalue ASN_GAUGE */ const SNMP_COUNTER = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_UNSIGNED) + * @cvalue ASN_UNSIGNED */ const SNMP_UNSIGNED = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_TIMETICKS) + * @cvalue ASN_TIMETICKS */ const SNMP_TIMETICKS = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_UINTEGER) + * @cvalue ASN_UINTEGER */ const SNMP_UINTEGER = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_INTEGER) + * @cvalue ASN_INTEGER */ const SNMP_INTEGER = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(ASN_COUNTER64) + * @cvalue ASN_COUNTER64 */ const SNMP_COUNTER64 = UNKNOWN; @@ -185,63 +185,63 @@ class SNMP { /** * @var int - * @cvalue LONG_CONST(SNMP_VERSION_1) + * @cvalue SNMP_VERSION_1 */ public const VERSION_1 = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(SNMP_VERSION_2c) + * @cvalue SNMP_VERSION_2c */ public const VERSION_2c = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(SNMP_VERSION_2c) + * @cvalue SNMP_VERSION_2c */ public const VERSION_2C = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(SNMP_VERSION_3) + * @cvalue SNMP_VERSION_3 */ public const VERSION_3 = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(PHP_SNMP_ERRNO_NOERROR) + * @cvalue PHP_SNMP_ERRNO_NOERROR */ public const ERRNO_NOERROR = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(PHP_SNMP_ERRNO_ANY) + * @cvalue PHP_SNMP_ERRNO_ANY */ public const ERRNO_ANY = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(PHP_SNMP_ERRNO_GENERIC) + * @cvalue PHP_SNMP_ERRNO_GENERIC */ public const ERRNO_GENERIC = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(PHP_SNMP_ERRNO_TIMEOUT) + * @cvalue PHP_SNMP_ERRNO_TIMEOUT */ public const ERRNO_TIMEOUT = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(PHP_SNMP_ERRNO_ERROR_IN_REPLY) + * @cvalue PHP_SNMP_ERRNO_ERROR_IN_REPLY */ public const ERRNO_ERROR_IN_REPLY = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(PHP_SNMP_ERRNO_OID_NOT_INCREASING) + * @cvalue PHP_SNMP_ERRNO_OID_NOT_INCREASING */ public const ERRNO_OID_NOT_INCREASING = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(PHP_SNMP_ERRNO_OID_PARSING_ERROR) + * @cvalue PHP_SNMP_ERRNO_OID_PARSING_ERROR */ public const ERRNO_OID_PARSING_ERROR = UNKNOWN; /** * @var int - * @cvalue LONG_CONST(PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES) + * @cvalue PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES */ public const ERRNO_MULTIPLE_SET_QUERIES = UNKNOWN; diff --git a/ext/snmp/snmp_arginfo.h b/ext/snmp/snmp_arginfo.h index 30d2b0d5295a4..ac5140a6e2cc2 100644 --- a/ext/snmp/snmp_arginfo.h +++ b/ext/snmp/snmp_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f1f302268d2a409464db8e107742d8da499c1e60 */ + * Stub hash: feff81a6d260b4c1c1d3f3acd11c564a5800e1c5 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmpget, 0, 3, IS_MIXED, 0) ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0) @@ -246,27 +246,27 @@ static const zend_function_entry class_SNMPException_methods[] = { static void register_snmp_symbols(int module_number) { - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_SUFFIX", LONG_CONST(NETSNMP_OID_OUTPUT_SUFFIX), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_MODULE", LONG_CONST(NETSNMP_OID_OUTPUT_MODULE), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_FULL", LONG_CONST(NETSNMP_OID_OUTPUT_FULL), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NUMERIC", LONG_CONST(NETSNMP_OID_OUTPUT_NUMERIC), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_UCD", LONG_CONST(NETSNMP_OID_OUTPUT_UCD), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NONE", LONG_CONST(NETSNMP_OID_OUTPUT_NONE), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VALUE_LIBRARY", LONG_CONST(SNMP_VALUE_LIBRARY), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VALUE_PLAIN", LONG_CONST(SNMP_VALUE_PLAIN), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_VALUE_OBJECT", LONG_CONST(SNMP_VALUE_OBJECT), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_BIT_STR", LONG_CONST(ASN_BIT_STR), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OCTET_STR", LONG_CONST(ASN_OCTET_STR), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OPAQUE", LONG_CONST(ASN_OPAQUE), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_NULL", LONG_CONST(ASN_NULL), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_OBJECT_ID", LONG_CONST(ASN_OBJECT_ID), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_IPADDRESS", LONG_CONST(ASN_IPADDRESS), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_COUNTER", LONG_CONST(ASN_GAUGE), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_UNSIGNED", LONG_CONST(ASN_UNSIGNED), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_TIMETICKS", LONG_CONST(ASN_TIMETICKS), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_UINTEGER", LONG_CONST(ASN_UINTEGER), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_INTEGER", LONG_CONST(ASN_INTEGER), CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SNMP_COUNTER64", LONG_CONST(ASN_COUNTER64), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_SUFFIX", NETSNMP_OID_OUTPUT_SUFFIX, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_MODULE", NETSNMP_OID_OUTPUT_MODULE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_FULL", NETSNMP_OID_OUTPUT_FULL, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NUMERIC", NETSNMP_OID_OUTPUT_NUMERIC, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_UCD", NETSNMP_OID_OUTPUT_UCD, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NONE", NETSNMP_OID_OUTPUT_NONE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_VALUE_LIBRARY", SNMP_VALUE_LIBRARY, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_VALUE_PLAIN", SNMP_VALUE_PLAIN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_VALUE_OBJECT", SNMP_VALUE_OBJECT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_BIT_STR", ASN_BIT_STR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OCTET_STR", ASN_OCTET_STR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OPAQUE", ASN_OPAQUE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_NULL", ASN_NULL, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_OBJECT_ID", ASN_OBJECT_ID, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_IPADDRESS", ASN_IPADDRESS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_COUNTER", ASN_GAUGE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_UNSIGNED", ASN_UNSIGNED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_TIMETICKS", ASN_TIMETICKS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_UINTEGER", ASN_UINTEGER, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_INTEGER", ASN_INTEGER, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SNMP_COUNTER64", ASN_COUNTER64, CONST_CS | CONST_PERSISTENT); } static zend_class_entry *register_class_SNMP(void) @@ -277,73 +277,73 @@ static zend_class_entry *register_class_SNMP(void) class_entry = zend_register_internal_class_ex(&ce, NULL); zval const_VERSION_1_value; - ZVAL_LONG(&const_VERSION_1_value, LONG_CONST(SNMP_VERSION_1)); + ZVAL_LONG(&const_VERSION_1_value, SNMP_VERSION_1); zend_string *const_VERSION_1_name = zend_string_init_interned("VERSION_1", sizeof("VERSION_1") - 1, 1); zend_declare_class_constant_ex(class_entry, const_VERSION_1_name, &const_VERSION_1_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_VERSION_1_name); zval const_VERSION_2c_value; - ZVAL_LONG(&const_VERSION_2c_value, LONG_CONST(SNMP_VERSION_2c)); + ZVAL_LONG(&const_VERSION_2c_value, SNMP_VERSION_2c); zend_string *const_VERSION_2c_name = zend_string_init_interned("VERSION_2c", sizeof("VERSION_2c") - 1, 1); zend_declare_class_constant_ex(class_entry, const_VERSION_2c_name, &const_VERSION_2c_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_VERSION_2c_name); zval const_VERSION_2C_value; - ZVAL_LONG(&const_VERSION_2C_value, LONG_CONST(SNMP_VERSION_2c)); + ZVAL_LONG(&const_VERSION_2C_value, SNMP_VERSION_2c); zend_string *const_VERSION_2C_name = zend_string_init_interned("VERSION_2C", sizeof("VERSION_2C") - 1, 1); zend_declare_class_constant_ex(class_entry, const_VERSION_2C_name, &const_VERSION_2C_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_VERSION_2C_name); zval const_VERSION_3_value; - ZVAL_LONG(&const_VERSION_3_value, LONG_CONST(SNMP_VERSION_3)); + ZVAL_LONG(&const_VERSION_3_value, SNMP_VERSION_3); zend_string *const_VERSION_3_name = zend_string_init_interned("VERSION_3", sizeof("VERSION_3") - 1, 1); zend_declare_class_constant_ex(class_entry, const_VERSION_3_name, &const_VERSION_3_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_VERSION_3_name); zval const_ERRNO_NOERROR_value; - ZVAL_LONG(&const_ERRNO_NOERROR_value, LONG_CONST(PHP_SNMP_ERRNO_NOERROR)); + ZVAL_LONG(&const_ERRNO_NOERROR_value, PHP_SNMP_ERRNO_NOERROR); zend_string *const_ERRNO_NOERROR_name = zend_string_init_interned("ERRNO_NOERROR", sizeof("ERRNO_NOERROR") - 1, 1); zend_declare_class_constant_ex(class_entry, const_ERRNO_NOERROR_name, &const_ERRNO_NOERROR_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_ERRNO_NOERROR_name); zval const_ERRNO_ANY_value; - ZVAL_LONG(&const_ERRNO_ANY_value, LONG_CONST(PHP_SNMP_ERRNO_ANY)); + ZVAL_LONG(&const_ERRNO_ANY_value, PHP_SNMP_ERRNO_ANY); zend_string *const_ERRNO_ANY_name = zend_string_init_interned("ERRNO_ANY", sizeof("ERRNO_ANY") - 1, 1); zend_declare_class_constant_ex(class_entry, const_ERRNO_ANY_name, &const_ERRNO_ANY_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_ERRNO_ANY_name); zval const_ERRNO_GENERIC_value; - ZVAL_LONG(&const_ERRNO_GENERIC_value, LONG_CONST(PHP_SNMP_ERRNO_GENERIC)); + ZVAL_LONG(&const_ERRNO_GENERIC_value, PHP_SNMP_ERRNO_GENERIC); zend_string *const_ERRNO_GENERIC_name = zend_string_init_interned("ERRNO_GENERIC", sizeof("ERRNO_GENERIC") - 1, 1); zend_declare_class_constant_ex(class_entry, const_ERRNO_GENERIC_name, &const_ERRNO_GENERIC_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_ERRNO_GENERIC_name); zval const_ERRNO_TIMEOUT_value; - ZVAL_LONG(&const_ERRNO_TIMEOUT_value, LONG_CONST(PHP_SNMP_ERRNO_TIMEOUT)); + ZVAL_LONG(&const_ERRNO_TIMEOUT_value, PHP_SNMP_ERRNO_TIMEOUT); zend_string *const_ERRNO_TIMEOUT_name = zend_string_init_interned("ERRNO_TIMEOUT", sizeof("ERRNO_TIMEOUT") - 1, 1); zend_declare_class_constant_ex(class_entry, const_ERRNO_TIMEOUT_name, &const_ERRNO_TIMEOUT_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_ERRNO_TIMEOUT_name); zval const_ERRNO_ERROR_IN_REPLY_value; - ZVAL_LONG(&const_ERRNO_ERROR_IN_REPLY_value, LONG_CONST(PHP_SNMP_ERRNO_ERROR_IN_REPLY)); + ZVAL_LONG(&const_ERRNO_ERROR_IN_REPLY_value, PHP_SNMP_ERRNO_ERROR_IN_REPLY); zend_string *const_ERRNO_ERROR_IN_REPLY_name = zend_string_init_interned("ERRNO_ERROR_IN_REPLY", sizeof("ERRNO_ERROR_IN_REPLY") - 1, 1); zend_declare_class_constant_ex(class_entry, const_ERRNO_ERROR_IN_REPLY_name, &const_ERRNO_ERROR_IN_REPLY_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_ERRNO_ERROR_IN_REPLY_name); zval const_ERRNO_OID_NOT_INCREASING_value; - ZVAL_LONG(&const_ERRNO_OID_NOT_INCREASING_value, LONG_CONST(PHP_SNMP_ERRNO_OID_NOT_INCREASING)); + ZVAL_LONG(&const_ERRNO_OID_NOT_INCREASING_value, PHP_SNMP_ERRNO_OID_NOT_INCREASING); zend_string *const_ERRNO_OID_NOT_INCREASING_name = zend_string_init_interned("ERRNO_OID_NOT_INCREASING", sizeof("ERRNO_OID_NOT_INCREASING") - 1, 1); zend_declare_class_constant_ex(class_entry, const_ERRNO_OID_NOT_INCREASING_name, &const_ERRNO_OID_NOT_INCREASING_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_ERRNO_OID_NOT_INCREASING_name); zval const_ERRNO_OID_PARSING_ERROR_value; - ZVAL_LONG(&const_ERRNO_OID_PARSING_ERROR_value, LONG_CONST(PHP_SNMP_ERRNO_OID_PARSING_ERROR)); + ZVAL_LONG(&const_ERRNO_OID_PARSING_ERROR_value, PHP_SNMP_ERRNO_OID_PARSING_ERROR); zend_string *const_ERRNO_OID_PARSING_ERROR_name = zend_string_init_interned("ERRNO_OID_PARSING_ERROR", sizeof("ERRNO_OID_PARSING_ERROR") - 1, 1); zend_declare_class_constant_ex(class_entry, const_ERRNO_OID_PARSING_ERROR_name, &const_ERRNO_OID_PARSING_ERROR_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_ERRNO_OID_PARSING_ERROR_name); zval const_ERRNO_MULTIPLE_SET_QUERIES_value; - ZVAL_LONG(&const_ERRNO_MULTIPLE_SET_QUERIES_value, LONG_CONST(PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES)); + ZVAL_LONG(&const_ERRNO_MULTIPLE_SET_QUERIES_value, PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES); zend_string *const_ERRNO_MULTIPLE_SET_QUERIES_name = zend_string_init_interned("ERRNO_MULTIPLE_SET_QUERIES", sizeof("ERRNO_MULTIPLE_SET_QUERIES") - 1, 1); zend_declare_class_constant_ex(class_entry, const_ERRNO_MULTIPLE_SET_QUERIES_name, &const_ERRNO_MULTIPLE_SET_QUERIES_value, ZEND_ACC_PUBLIC, NULL); zend_string_release(const_ERRNO_MULTIPLE_SET_QUERIES_name);