summaryrefslogtreecommitdiff
path: root/ext/snmp
diff options
context:
space:
mode:
Diffstat (limited to 'ext/snmp')
-rw-r--r--ext/snmp/snmp.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index 0ae140f7d1..9789638c66 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -80,6 +80,14 @@
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
+#if PHP_VERSION_ID < 50300
+#define Z_ADDREF_P(pz) pz->refcount++
+#define Z_ISREF_PP(oid) (PZVAL_IS_REF(*(oid)))
+#define Z_REFCOUNT_P(pz) pz->refcount
+#define Z_SET_REFCOUNT_P(pz, rc) pz->refcount = rc
+#define zend_parse_parameters_none() zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "")
+#endif
+
/* For net-snmp prior to 5.4 */
#ifndef HAVE_SHUTDOWN_SNMP_LOGGING
extern netsnmp_log_handler *logh_head;
@@ -489,6 +497,9 @@ static void php_snmp_object_free_storage(void *object TSRMLS_DC)
static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
+#if PHP_VERSION_ID < 50399
+ zval *tmp;
+#endif
zend_object_value retval;
php_snmp_object *intern;
@@ -497,7 +508,11 @@ static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS
memset(&intern->zo, 0, sizeof(php_snmp_object));
zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
+#if PHP_VERSION_ID < 50399
+ zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *));
+#else
object_properties_init(&intern->zo, class_type);
+#endif
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) php_snmp_object_free_storage, NULL TSRMLS_CC);
retval.handlers = (zend_object_handlers *) &php_snmp_object_handlers;
@@ -1760,7 +1775,11 @@ PHP_FUNCTION(snmp_read_mib)
char *filename;
int filename_len;
+#if PHP_VERSION_ID < 50399
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
+#else
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
+#endif
RETURN_FALSE;
}
@@ -1785,17 +1804,31 @@ PHP_METHOD(snmp, __construct)
long retries = SNMP_DEFAULT_RETRIES;
long version = SNMP_DEFAULT_VERSION;
int argc = ZEND_NUM_ARGS();
+#if PHP_VERSION_ID > 50300
zend_error_handling error_handling;
+#endif
snmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC);
+#if PHP_VERSION_ID > 50300
zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
+#else
+ php_set_error_handling(EH_THROW, zend_exception_get_default(TSRMLS_C) TSRMLS_CC);
+#endif
if (zend_parse_parameters(argc TSRMLS_CC, "lss|ll", &version, &a1, &a1_len, &a2, &a2_len, &timeout, &retries) == FAILURE) {
+#if PHP_VERSION_ID > 50300
zend_restore_error_handling(&error_handling TSRMLS_CC);
+#else
+ php_std_error_handling();
+#endif
return;
}
+#if PHP_VERSION_ID > 50300
zend_restore_error_handling(&error_handling TSRMLS_CC);
+#else
+ php_std_error_handling();
+#endif
switch(version) {
case SNMP_VERSION_1:
@@ -1943,7 +1976,11 @@ void php_snmp_add_property(HashTable *h, const char *name, size_t name_length, p
/* {{{ php_snmp_read_property(zval *object, zval *member, int type[, const zend_literal *key])
Generic object property reader */
+#if PHP_VERSION_ID < 50399
+zval *php_snmp_read_property(zval *object, zval *member, int type TSRMLS_DC)
+#else
zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC)
+#endif
{
zval tmp_member;
zval *retval;
@@ -1973,7 +2010,11 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_li
}
} else {
zend_object_handlers * std_hnd = zend_get_std_object_handlers();
+#if PHP_VERSION_ID < 50399
+ retval = std_hnd->read_property(object, member, type TSRMLS_CC);
+#else
retval = std_hnd->read_property(object, member, type, key TSRMLS_CC);
+#endif
}
if (member == &tmp_member) {
@@ -1985,7 +2026,11 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_li
/* {{{ php_snmp_write_property(zval *object, zval *member, zval *value[, const zend_literal *key])
Generic object property writer */
+#if PHP_VERSION_ID < 50399
+void php_snmp_write_property(zval *object, zval *member, zval *value TSRMLS_DC)
+#else
void php_snmp_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC)
+#endif
{
zval tmp_member;
php_snmp_object *obj;
@@ -2012,7 +2057,11 @@ void php_snmp_write_property(zval *object, zval *member, zval *value, const zend
}
} else {
zend_object_handlers * std_hnd = zend_get_std_object_handlers();
+#if PHP_VERSION_ID < 50399
+ std_hnd->write_property(object, member, value TSRMLS_CC);
+#else
std_hnd->write_property(object, member, value, key TSRMLS_CC);
+#endif
}
if (member == &tmp_member) {
@@ -2023,7 +2072,11 @@ void php_snmp_write_property(zval *object, zval *member, zval *value, const zend
/* {{{ php_snmp_has_property(zval *object, zval *member, int has_set_exists[, const zend_literal *key])
Generic object property checker */
+#if PHP_VERSION_ID < 50399
+static int php_snmp_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC)
+#else
static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, const zend_literal *key TSRMLS_DC)
+#endif
{
php_snmp_prop_handler *hnd;
int ret = 0;
@@ -2034,7 +2087,11 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists,
ret = 1;
break;
case 0: {
+#if PHP_VERSION_ID < 50399
+ zval *value = php_snmp_read_property(object, member, BP_VAR_IS TSRMLS_CC);
+#else
zval *value = php_snmp_read_property(object, member, BP_VAR_IS, key TSRMLS_CC);
+#endif
if (value != EG(uninitialized_zval_ptr)) {
ret = Z_TYPE_P(value) != IS_NULL? 1:0;
/* refcount is 0 */
@@ -2044,7 +2101,11 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists,
break;
}
default: {
+#if PHP_VERSION_ID < 50399
+ zval *value = php_snmp_read_property(object, member, BP_VAR_IS TSRMLS_CC);
+#else
zval *value = php_snmp_read_property(object, member, BP_VAR_IS, key TSRMLS_CC);
+#endif
if (value != EG(uninitialized_zval_ptr)) {
convert_to_boolean(value);
ret = Z_BVAL_P(value)? 1:0;
@@ -2057,7 +2118,11 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists,
}
} else {
zend_object_handlers * std_hnd = zend_get_std_object_handlers();
+#if PHP_VERSION_ID < 50399
+ ret = std_hnd->has_property(object, member, has_set_exists TSRMLS_CC);
+#else
ret = std_hnd->has_property(object, member, has_set_exists, key TSRMLS_CC);
+#endif
}
return ret;
}
@@ -2077,7 +2142,11 @@ static HashTable *php_snmp_get_properties(zval *object TSRMLS_DC)
ulong num_key;
obj = (php_snmp_object *)zend_objects_get_address(object TSRMLS_CC);
+#if PHP_VERSION_ID < 50399
+ props = obj->zo.properties;
+#else
props = zend_std_get_properties(object TSRMLS_CC);
+#endif
zend_hash_internal_pointer_reset_ex(&php_snmp_properties, &pos);
@@ -2456,20 +2525,26 @@ PHP_MINFO_FUNCTION(snmp)
/* {{{ snmp_module_deps[]
*/
+#if ZEND_MODULE_API_NO >= 20050922
static const zend_module_dep snmp_module_deps[] = {
#ifdef HAVE_SPL
ZEND_MOD_REQUIRED("spl")
#endif
ZEND_MOD_END
};
+#endif
/* }}} */
/* {{{ snmp_module_entry
*/
zend_module_entry snmp_module_entry = {
+#if ZEND_MODULE_API_NO >= 20050922
STANDARD_MODULE_HEADER_EX,
NULL,
snmp_module_deps,
+#else
+ STANDARD_MODULE_HEADER,
+#endif
"snmp",
snmp_functions,
PHP_MINIT(snmp),