summaryrefslogtreecommitdiff
path: root/ext/interbase/ibase_blobs.c
diff options
context:
space:
mode:
authorGabriel Caruso <carusogabriel34@gmail.com>2018-02-18 10:12:12 -0300
committerJoe Watkins <krakjoe@php.net>2018-02-19 08:33:18 +0100
commita6b2223220f65d06e43dc176d534cfd3347118f2 (patch)
tree9ca2bbddc833f29ad47e6d35d6d0715131a6cef5 /ext/interbase/ibase_blobs.c
parent7566416d9d0117b14daf2ac0ed95039674027f64 (diff)
downloadphp-git-a6b2223220f65d06e43dc176d534cfd3347118f2.tar.gz
Refactoring duplicated ZPP with a switch
Diffstat (limited to 'ext/interbase/ibase_blobs.c')
-rw-r--r--ext/interbase/ibase_blobs.c64
1 files changed, 19 insertions, 45 deletions
diff --git a/ext/interbase/ibase_blobs.c b/ext/interbase/ibase_blobs.c
index a329d5dfd0..7898fd6c82 100644
--- a/ext/interbase/ibase_blobs.c
+++ b/ext/interbase/ibase_blobs.c
@@ -30,6 +30,22 @@
#define BLOB_CLOSE 1
#define BLOB_CANCEL 2
+#define PARSE_PARAMETERS \
+ switch (ZEND_NUM_ARGS()) { \
+ default: \
+ WRONG_PARAM_COUNT; \
+ case 1: \
+ if (FAILURE == zend_parse_parameters(1, "s", &blob_id, &blob_id_len)) { \
+ RETURN_FALSE; \
+ } \
+ break; \
+ case 2: \
+ if (FAILURE == zend_parse_parameters(2, "rs", &link, &blob_id, &blob_id_len)) { \
+ RETURN_FALSE; \
+ } \
+ break; \
+ } \
+
static int le_blob;
static void _php_ibase_free_blob(zend_resource *rsrc) /* {{{ */
@@ -242,21 +258,7 @@ PHP_FUNCTION(ibase_blob_open)
ibase_blob *ib_blob;
RESET_ERRMSG;
-
- switch (ZEND_NUM_ARGS()) {
- default:
- WRONG_PARAM_COUNT;
- case 1:
- if (FAILURE == zend_parse_parameters(1, "s", &blob_id, &blob_id_len)) {
- RETURN_FALSE;
- }
- break;
- case 2:
- if (FAILURE == zend_parse_parameters(2, "rs", &link, &blob_id, &blob_id_len)) {
- RETURN_FALSE;
- }
- break;
- }
+ PARSE_PARAMETERS;
PHP_IBASE_LINK_TRANS(link, ib_link, trans);
@@ -405,21 +407,7 @@ PHP_FUNCTION(ibase_blob_info)
IBASE_BLOBINFO bl_info;
RESET_ERRMSG;
-
- switch (ZEND_NUM_ARGS()) {
- default:
- WRONG_PARAM_COUNT;
- case 1:
- if (FAILURE == zend_parse_parameters(1, "s", &blob_id, &blob_id_len)) {
- RETURN_FALSE;
- }
- break;
- case 2:
- if (FAILURE == zend_parse_parameters(2, "rs", &link, &blob_id, &blob_id_len)) {
- RETURN_FALSE;
- }
- break;
- }
+ PARSE_PARAMETERS;
PHP_IBASE_LINK_TRANS(link, ib_link, trans);
@@ -482,21 +470,7 @@ PHP_FUNCTION(ibase_blob_echo)
unsigned short seg_len;
RESET_ERRMSG;
-
- switch (ZEND_NUM_ARGS()) {
- default:
- WRONG_PARAM_COUNT;
- case 1:
- if (FAILURE == zend_parse_parameters(1, "s", &blob_id, &blob_id_len)) {
- RETURN_FALSE;
- }
- break;
- case 2:
- if (FAILURE == zend_parse_parameters(2, "rs", &link, &blob_id, &blob_id_len)) {
- RETURN_FALSE;
- }
- break;
- }
+ PARSE_PARAMETERS;
PHP_IBASE_LINK_TRANS(link, ib_link, trans);