Skip to content

Commit

Permalink
remove shutup operator, ANSI C comments, iniArr renamed to ini_arr
Browse files Browse the repository at this point in the history
  • Loading branch information
pinepain committed Jan 12, 2013
1 parent 579b965 commit cc626d9
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 73 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ before_script:
- sh -c "cd rabbitmq-c && git submodule init && git submodule update"
- sh -c "cd rabbitmq-c && autoreconf -i && ./configure && make && sudo make install"
- sh -c "phpize && ./configure && make"
# - sudo rabbitmqctl set_vm_memory_high_watermark 0.01

script:
- sh -c "make test | tee result.txt"
- sh test-report.sh

notifications:
email:
- pinepain@gmail.com
# - lstrojny@php.net
# - bkw@codingforce.com
- lstrojny@php.net
- bkw@codingforce.com
31 changes: 14 additions & 17 deletions amqp_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,11 @@ PHP_METHOD(amqp_connection_class, __construct)
zval *id;
amqp_connection_object *connection;

zval* iniArr = NULL;
zval* ini_arr = NULL;
zval** zdata;

// double ini_amqp_timeout;
// double ini_amqp_read_timeout;

/* Parse out the method parameters */
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|a", &id, amqp_connection_class_entry, &iniArr) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|a", &id, amqp_connection_class_entry, &ini_arr) == FAILURE) {
return;
}

Expand All @@ -487,7 +484,7 @@ PHP_METHOD(amqp_connection_class, __construct)

/* Pull the login out of the $params array */
zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "login", sizeof("login"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "login", sizeof("login"), (void*)&zdata)) {
convert_to_string(*zdata);
}
/* Validate the given login */
Expand All @@ -505,7 +502,7 @@ PHP_METHOD(amqp_connection_class, __construct)

/* Pull the password out of the $params array */
zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF(iniArr), "password", sizeof("password"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF(ini_arr), "password", sizeof("password"), (void*)&zdata)) {
convert_to_string(*zdata);
}
/* Validate the given password */
Expand All @@ -522,7 +519,7 @@ PHP_METHOD(amqp_connection_class, __construct)

/* Pull the host out of the $params array */
zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF(iniArr), "host", sizeof("host"), (void *)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF(ini_arr), "host", sizeof("host"), (void *)&zdata)) {
convert_to_string(*zdata);
}
/* Validate the given host */
Expand All @@ -539,7 +536,7 @@ PHP_METHOD(amqp_connection_class, __construct)

/* Pull the vhost out of the $params array */
zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "vhost", sizeof("vhost"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "vhost", sizeof("vhost"), (void*)&zdata)) {
convert_to_string(*zdata);
}
/* Validate the given vhost */
Expand All @@ -556,27 +553,27 @@ PHP_METHOD(amqp_connection_class, __construct)

connection->port = INI_INT("amqp.port");

if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "port", sizeof("port"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "port", sizeof("port"), (void*)&zdata)) {
convert_to_long(*zdata);
connection->port = (size_t)Z_LVAL_PP(zdata);
}

connection->read_timeout = INI_FLT("amqp.read_timeout");

if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "read_timeout", sizeof("read_timeout"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "read_timeout", sizeof("read_timeout"), (void*)&zdata)) {
convert_to_double(*zdata);
if (Z_DVAL_PP(zdata) < 0) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'read_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
} else {
connection->read_timeout = Z_DVAL_PP(zdata);
}

if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "timeout", sizeof("timeout"), (void*)&zdata)) {
// 'read_timeout' takes preccedande on 'timeout' but users have to know this
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "timeout", sizeof("timeout"), (void*)&zdata)) {
/* 'read_timeout' takes precedence on 'timeout' but users have to know this */
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter 'timeout' is deprecated, 'read_timeout' used instead");
}

} else if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "timeout", sizeof("timeout"), (void*)&zdata)) {
} else if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "timeout", sizeof("timeout"), (void*)&zdata)) {

php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "Parameter 'timeout' is deprecated; use 'read_timeout' instead");

Expand Down Expand Up @@ -604,7 +601,7 @@ PHP_METHOD(amqp_connection_class, __construct)

connection->write_timeout = INI_FLT("amqp.write_timeout");

if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "write_timeout", sizeof("write_timeout"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "write_timeout", sizeof("write_timeout"), (void*)&zdata)) {
convert_to_double(*zdata);
if (Z_DVAL_PP(zdata) < 0) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'write_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
Expand Down Expand Up @@ -1087,8 +1084,8 @@ PHP_METHOD(amqp_connection_class, setVhost)
}
/* }}} */

// @deprecated
/* {{{ proto amqp::getTimeout()
@deprecated
get the timeout */
PHP_METHOD(amqp_connection_class, getTimeout)
{
Expand All @@ -1110,8 +1107,8 @@ PHP_METHOD(amqp_connection_class, getTimeout)
}
/* }}} */

// @deprecated
/* {{{ proto amqp::setTimeout(double timeout)
@deprecated
set the timeout */
PHP_METHOD(amqp_connection_class, setTimeout)
{
Expand Down
32 changes: 16 additions & 16 deletions amqp_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ zend_object_value amqp_exchange_ctor(zend_class_entry *ce TSRMLS_DC)

memset(exchange, 0, sizeof(amqp_exchange_object));

// Initialize the arguments array:
/* Initialize the arguments array: */
MAKE_STD_ZVAL(exchange->arguments);
array_init(exchange->arguments);

Expand Down Expand Up @@ -585,7 +585,7 @@ publish into Exchange
PHP_METHOD(amqp_exchange_class, publish)
{
zval *id;
zval *iniArr = NULL;
zval *ini_arr = NULL;
zval** zdata;
amqp_exchange_object *exchange;
amqp_channel_object *channel;
Expand All @@ -610,7 +610,7 @@ PHP_METHOD(amqp_exchange_class, publish)
amqp_bytes_t abt0, abt1, abt2;


if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|sla", &id, amqp_exchange_class_entry, &msg, &msg_len, &key_name, &key_len, &flags, &iniArr) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|sla", &id, amqp_exchange_class_entry, &msg, &msg_len, &key_name, &key_len, &flags, &ini_arr) == FAILURE) {
return;
}

Expand All @@ -624,7 +624,7 @@ PHP_METHOD(amqp_exchange_class, publish)
props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG;

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "content_type", sizeof("content_type"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "content_type", sizeof("content_type"), (void*)&zdata)) {
convert_to_string(*zdata);
}
if (zdata && strlen(Z_STRVAL_PP(zdata)) > 0) {
Expand All @@ -634,7 +634,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "content_encoding", sizeof("content_encoding"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "content_encoding", sizeof("content_encoding"), (void*)&zdata)) {
convert_to_string(*zdata);
}
if (zdata && strlen(Z_STRVAL_PP(zdata)) > 0) {
Expand All @@ -643,7 +643,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "message_id", sizeof("message_id"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "message_id", sizeof("message_id"), (void*)&zdata)) {
convert_to_string(*zdata);
}
if (zdata && strlen(Z_STRVAL_PP(zdata)) > 0) {
Expand All @@ -652,7 +652,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "user_id", sizeof("user_id"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "user_id", sizeof("user_id"), (void*)&zdata)) {
convert_to_string(*zdata);
}
if (zdata && strlen(Z_STRVAL_PP(zdata)) > 0) {
Expand All @@ -661,7 +661,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "app_id", sizeof("app_id"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "app_id", sizeof("app_id"), (void*)&zdata)) {
convert_to_string(*zdata);
}
if (zdata && strlen(Z_STRVAL_PP(zdata)) > 0) {
Expand All @@ -670,7 +670,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "delivery_mode", sizeof("delivery_mode"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "delivery_mode", sizeof("delivery_mode"), (void*)&zdata)) {
convert_to_long(*zdata);
}
if (zdata) {
Expand All @@ -679,7 +679,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "priority", sizeof("priority"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "priority", sizeof("priority"), (void*)&zdata)) {
convert_to_long(*zdata);
}
if (zdata) {
Expand All @@ -688,7 +688,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "timestamp", sizeof("timestamp"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "timestamp", sizeof("timestamp"), (void*)&zdata)) {
convert_to_long(*zdata);
}
if (zdata) {
Expand All @@ -697,7 +697,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "expiration", sizeof("expiration"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "expiration", sizeof("expiration"), (void*)&zdata)) {
convert_to_string(*zdata);
}
if (zdata && strlen(Z_STRVAL_PP(zdata)) > 0) {
Expand All @@ -706,7 +706,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "type", sizeof("type"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "type", sizeof("type"), (void*)&zdata)) {
convert_to_string(*zdata);
}
if (zdata && strlen(Z_STRVAL_PP(zdata)) > 0) {
Expand All @@ -715,7 +715,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "reply_to", sizeof("reply_to"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "reply_to", sizeof("reply_to"), (void*)&zdata)) {
convert_to_string(*zdata);
}
if (zdata && strlen(Z_STRVAL_PP(zdata)) > 0) {
Expand All @@ -724,7 +724,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF (iniArr), "correlation_id", sizeof("correlation_id"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "correlation_id", sizeof("correlation_id"), (void*)&zdata)) {
convert_to_string(*zdata);
}
if (zdata && strlen(Z_STRVAL_PP(zdata)) > 0) {
Expand All @@ -733,7 +733,7 @@ PHP_METHOD(amqp_exchange_class, publish)
}

zdata = NULL;
if (iniArr && SUCCESS == zend_hash_find(HASH_OF(iniArr), "headers", sizeof("headers"), (void*)&zdata)) {
if (ini_arr && SUCCESS == zend_hash_find(HASH_OF(ini_arr), "headers", sizeof("headers"), (void*)&zdata)) {
HashTable *headers;
HashPosition pos;

Expand Down
2 changes: 1 addition & 1 deletion amqp_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ zend_object_value amqp_queue_ctor(zend_class_entry *ce TSRMLS_DC)
zend_object_std_init(&queue->zo, ce TSRMLS_CC);
AMQP_OBJECT_PROPERTIES_INIT(queue->zo, ce);

// Initialize the arguments array:
/* Initialize the arguments array: */
MAKE_STD_ZVAL(queue->arguments);
array_init(queue->arguments);

Expand Down
1 change: 0 additions & 1 deletion php_amqp.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ extern zend_class_entry *amqp_exception_class_entry,
#endif

extern int le_amqp_connection_resource;
// ZEND_DECLARE_MODULE_GLOBALS(amqp)

typedef struct _amqp_channel_object {
zend_object zo;
Expand Down
1 change: 1 addition & 0 deletions tests/amqpchannel_var_dump.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ AMQPChannel var_dump
if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
print "skip";
}
?>
--FILE--
<?php
$cnn = new AMQPConnection();
Expand Down
3 changes: 2 additions & 1 deletion tests/amqpconnection_setReadTimeout_out_of_range.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
AMQPConnection setReadTimeout float
AMQPConnection setReadTimeout out of range
--SKIPIF--
<?php if (!extension_loaded("amqp")) print "skip"; ?>
--FILE--
Expand All @@ -12,6 +12,7 @@ try {
echo PHP_EOL;
echo $e->getMessage();
}
?>
--EXPECT--
AMQPConnectionException
Parameter 'read_timeout' must be greater than or equal to zero.
2 changes: 1 addition & 1 deletion tests/amqpconnection_setReadTimeout_string.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
AMQPConnection setReadTimeout float
AMQPConnection setReadTimeout string
--SKIPIF--
<?php if (!extension_loaded("amqp")) print "skip"; ?>
--FILE--
Expand Down
17 changes: 12 additions & 5 deletions tests/amqpconnection_setTimeout_float.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ AMQPConnection setTimeout float
--FILE--
<?php
$cnn = new AMQPConnection();
@$cnn->setTimeout(.34);
var_dump(@$cnn->getTimeout());
@$cnn->setTimeout(4.7e-2);
var_dump(@$cnn->getTimeout());?>
--EXPECT--
$cnn->setTimeout(.34);
var_dump($cnn->getTimeout());
$cnn->setTimeout(4.7e-2);
var_dump($cnn->getTimeout());?>
--EXPECTF--
%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3

%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
float(0.34)

%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5

%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6
float(0.047)
9 changes: 6 additions & 3 deletions tests/amqpconnection_setTimeout_int.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ AMQPConnection setTimeout int
--FILE--
<?php
$cnn = new AMQPConnection();
@$cnn->setTimeout(3);
var_dump(@$cnn->getTimeout());
$cnn->setTimeout(3);
var_dump($cnn->getTimeout());
?>
--EXPECT--
--EXPECTF--
%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3

%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
float(3)
7 changes: 4 additions & 3 deletions tests/amqpconnection_setTimeout_out_of_range.phpt
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
--TEST--
AMQPConnection setTimeout float
AMQPConnection setTimeout out of range
--SKIPIF--
<?php if (!extension_loaded("amqp")) print "skip"; ?>
--FILE--
<?php
$cnn = new AMQPConnection();
try {
@$cnn->setTimeout(-1);
$cnn->setTimeout(-1);
} catch (Exception $e) {
echo get_class($e);
echo PHP_EOL;
echo $e->getMessage();
}
?>
--EXPECT--
--EXPECTF--
%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 4
AMQPConnectionException
Parameter 'timeout' must be greater than or equal to zero.
Loading

0 comments on commit cc626d9

Please sign in to comment.