cut PHP_VERSION_ID - we know API version now

Programming / Compilers / PHP - Boris Lytochkin [php.net] - 3 May 2013 10:22 UTC



###

diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index 756e531..eb2eab3 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -80,14 +80,6 @@
#include
#include

-#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;
@@ -497,9 +489,6 @@ 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;

@@ -508,11 +497,7 @@ 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;
@@ -1801,11 +1786,7 @@ 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;
}

@@ -1830,31 +1811,17 @@ 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:
@@ -2002,11 +1969,7 @@ 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;
@@ -2036,11 +1999,7 @@ 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) {
@@ -2052,11 +2011,7 @@ 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;
@@ -2083,11 +2038,7 @@ 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) {
@@ -2098,11 +2049,7 @@ 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;
@@ -2113,11 +2060,7 @@ 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 */
@@ -2127,11 +2070,7 @@ 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;
@@ -2144,11 +2083,7 @@ 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;
}
@@ -2168,11 +2103,7 @@ 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);

1c8befe cut PHP_VERSION_ID - we know API version now
ext/snmp/snmp.c | 69 -------------------------------------------------------
1 file changed, 69 deletions(-)

Upstream: github.com


  • Share