Skip to content

Commit

Permalink
refactor: remove header file php5to7.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Timandes committed Jan 23, 2019
1 parent fb3fae2 commit 2e66bd0
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 92 deletions.
1 change: 0 additions & 1 deletion package.xml
Expand Up @@ -62,7 +62,6 @@ Bugs:
<file role='src' name='php_zookeeper_session.h'/>
<file role='src' name='zoo_lock.c'/>
<file role='src' name='zoo_lock.h'/>
<file role='src' name='php5to7.h'/>
<file role='src' name='php_zookeeper_exceptions.c'/>
<file role='src' name='php_zookeeper_exceptions.h'/>
<file role='src' name='php_zookeeper_callback.c'/>
Expand Down
41 changes: 0 additions & 41 deletions php5to7.h

This file was deleted.

43 changes: 22 additions & 21 deletions php_zookeeper.c
Expand Up @@ -45,7 +45,6 @@
#include <ext/standard/php_smart_string.h>
#endif

#include "php5to7.h"
#include "php_zookeeper.h"
#include "php_zookeeper_private.h"
#include "php_zookeeper_session.h"
Expand All @@ -71,6 +70,8 @@
return; \
} \

#define Z_ZK_P(zv) php_zk_fetch_object(Z_OBJ_P((zv)))

/****************************************
Structures and definitions
****************************************/
Expand Down Expand Up @@ -183,7 +184,7 @@ static void php_zookeeper_connect_impl(INTERNAL_FUNCTION_PARAMETERS, char *host,
Connects to a zookeeper host */
static PHP_METHOD(Zookeeper, connect)
{
strsize_t host_len;
size_t host_len;
char *host;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
Expand All @@ -203,7 +204,7 @@ static PHP_METHOD(Zookeeper, connect)
static PHP_METHOD(Zookeeper, __construct)
{
zval *object = getThis();
strsize_t host_len = 0;
size_t host_len = 0;
char *host = NULL;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
Expand All @@ -230,7 +231,7 @@ static PHP_METHOD(Zookeeper, __construct)
static PHP_METHOD(Zookeeper, create)
{
char *path, *value = NULL;
strsize_t path_len, value_len;
size_t path_len, value_len;
zval *acl_info = NULL;
long flags = 0;
char *realpath;
Expand Down Expand Up @@ -267,7 +268,7 @@ static PHP_METHOD(Zookeeper, create)
return;
}

PHP5TO7_RETVAL_STRING(realpath);
RETVAL_STRING(realpath);
efree(realpath);
}
/* }}} */
Expand All @@ -277,7 +278,7 @@ static PHP_METHOD(Zookeeper, create)
static PHP_METHOD(Zookeeper, delete)
{
char *path;
strsize_t path_len;
size_t path_len;
long version = -1;
int status = ZOK;

Expand Down Expand Up @@ -305,7 +306,7 @@ static PHP_METHOD(Zookeeper, delete)
static PHP_METHOD(Zookeeper, getChildren)
{
char *path;
strsize_t path_len;
size_t path_len;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
php_cb_data_t *cb_data = NULL;
Expand Down Expand Up @@ -334,7 +335,7 @@ static PHP_METHOD(Zookeeper, getChildren)

array_init(return_value);
for (i = 0; i < strings.count; i++) {
php5to7_add_next_index_string(return_value, strings.data[i]);
add_next_index_string(return_value, strings.data[i]);
}
deallocate_String_vector(&strings);
}
Expand All @@ -345,7 +346,7 @@ static PHP_METHOD(Zookeeper, getChildren)
static PHP_METHOD(Zookeeper, get)
{
char *path;
strsize_t path_len;
size_t path_len;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
zval *stat_info = NULL;
Expand Down Expand Up @@ -425,7 +426,7 @@ static PHP_METHOD(Zookeeper, get)
RETURN_NULL();
}

PHP5TO7_RETVAL_STRINGL(buffer, length);
RETVAL_STRINGL(buffer, length);
efree(buffer);
}
/* }}} */
Expand All @@ -435,7 +436,7 @@ static PHP_METHOD(Zookeeper, get)
static PHP_METHOD(Zookeeper, exists)
{
char *path;
strsize_t path_len;
size_t path_len;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
php_cb_data_t *cb_data = NULL;
Expand Down Expand Up @@ -475,7 +476,7 @@ static PHP_METHOD(Zookeeper, exists)
static PHP_METHOD(Zookeeper, set)
{
char *path, *value = NULL;
strsize_t path_len, value_len;
size_t path_len, value_len;
long version = -1;
zval *stat_info = NULL;
struct Stat stat, *stat_ptr = NULL;
Expand Down Expand Up @@ -529,7 +530,7 @@ static PHP_METHOD(Zookeeper, getClientId)
cid = zoo_client_id(i_obj->zk);
array_init(return_value);
add_next_index_long(return_value, cid->client_id);
php5to7_add_next_index_string(return_value, (char *)cid->passwd);
add_next_index_string(return_value, (char *)cid->passwd);
}
/* }}} */

Expand All @@ -538,7 +539,7 @@ static PHP_METHOD(Zookeeper, getClientId)
static PHP_METHOD(Zookeeper, getAcl)
{
char *path;
strsize_t path_len;
size_t path_len;
int status = ZOK;
struct ACL_vector aclv;
struct Stat stat;
Expand Down Expand Up @@ -580,7 +581,7 @@ static PHP_METHOD(Zookeeper, getAcl)
static PHP_METHOD(Zookeeper, setAcl)
{
char *path;
strsize_t path_len;
size_t path_len;
long version;
zval *acl_info;
struct ACL_vector aclv;
Expand Down Expand Up @@ -691,7 +692,7 @@ static PHP_METHOD(Zookeeper, setDeterministicConnOrder)
static PHP_METHOD(Zookeeper, addAuth)
{
char *scheme, *cert;
strsize_t scheme_len, cert_len;
size_t scheme_len, cert_len;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
int status = ZOK;
Expand Down Expand Up @@ -924,7 +925,7 @@ static inline void php_zk_dispatch_one(php_cb_data_t *cb_data, int type, int sta

ZVAL_LONG(&params[0], type);
ZVAL_LONG(&params[1], state);
PHP5TO7_ZVAL_STRING(&params[2], (char *)path);
ZVAL_STRING(&params[2], (char *)path);

cb_data->fci.retval = &retval;
#else
Expand All @@ -940,7 +941,7 @@ static inline void php_zk_dispatch_one(php_cb_data_t *cb_data, int type, int sta

ZVAL_LONG(z_type, type);
ZVAL_LONG(z_state, state);
PHP5TO7_ZVAL_STRING(z_path, (char *)path);
ZVAL_STRING(z_path, (char *)path);

params[0] = &z_type;
params[1] = &z_state;
Expand Down Expand Up @@ -1268,9 +1269,9 @@ static void php_aclv_to_array(const struct ACL_vector *aclv, zval *array)
MAKE_STD_ZVAL(entry);
#endif
array_init(entry);
add_assoc_long_ex(entry, PHP5TO7_STRS("perms"), aclv->data[i].perms);
php5to7_add_assoc_string_ex(entry, PHP5TO7_STRS("scheme"), aclv->data[i].id.scheme);
php5to7_add_assoc_string_ex(entry, PHP5TO7_STRS("id"), aclv->data[i].id.id);
add_assoc_long_ex(entry, ZEND_STRL("perms"), aclv->data[i].perms);
add_assoc_string_ex(entry, ZEND_STRL("scheme"), aclv->data[i].id.scheme);
add_assoc_string_ex(entry, ZEND_STRL("id"), aclv->data[i].id.id);
add_next_index_zval(array, entry);
}
}
Expand Down
13 changes: 6 additions & 7 deletions php_zookeeper_config_class.c
Expand Up @@ -20,7 +20,6 @@

#include <php.h>

#include "php5to7.h"
#include "php_zookeeper_class.h"
#include "php_zookeeper_exceptions.h"
#include "php_zookeeper_config_class.h"
Expand Down Expand Up @@ -110,7 +109,7 @@ static PHP_METHOD(ZookeeperConfig, get)
RETURN_NULL();
}

PHP5TO7_RETVAL_STRINGL(buffer, length);
RETVAL_STRINGL(buffer, length);
efree(buffer);
}
/* }}} */
Expand All @@ -121,7 +120,7 @@ static PHP_METHOD(ZookeeperConfig, get)
static PHP_METHOD(ZookeeperConfig, set)
{
char *members;
strsize_t members_len;
size_t members_len;
int64_t version = -1;
zval *stat_info_p = NULL;

Expand All @@ -140,7 +139,7 @@ static PHP_METHOD(ZookeeperConfig, set)
static PHP_METHOD(ZookeeperConfig, add)
{
char *members;
strsize_t members_len;
size_t members_len;
int64_t version = -1;
zval *stat_info_p = NULL;

Expand All @@ -159,7 +158,7 @@ static PHP_METHOD(ZookeeperConfig, add)
static PHP_METHOD(ZookeeperConfig, remove)
{
char *members;
strsize_t members_len;
size_t members_len;
int64_t version = -1;
zval *stat_info_p = NULL;

Expand Down Expand Up @@ -233,7 +232,7 @@ void php_zk_config_register(TSRMLS_D)
zend_class_entry ce;

INIT_CLASS_ENTRY(ce, "ZookeeperConfig", zookeeper_config_class_methods);
php_zk_config_ce = php5to7_register_internal_class_ex(&ce, NULL);
php_zk_config_ce = zend_register_internal_class_ex(&ce, NULL);
php_zk_config_ce->create_object = php_zk_config_new;

memcpy(&php_zk_conf_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
Expand Down Expand Up @@ -296,6 +295,6 @@ static void php_zookeeper_config_reconfig_impl(INTERNAL_FUNCTION_PARAMETERS, con
RETURN_NULL();
}

PHP5TO7_RETVAL_STRINGL(buffer, buffer_len);
RETVAL_STRINGL(buffer, buffer_len);
efree(buffer);
}
15 changes: 7 additions & 8 deletions php_zookeeper_exceptions.c
Expand Up @@ -21,7 +21,6 @@
#include "TSRM.h"
#endif

#include "php5to7.h"
#include "php_zookeeper.h"
#include "php_zookeeper_exceptions.h"

Expand All @@ -40,25 +39,25 @@ void php_zk_register_exceptions(TSRMLS_D)
zend_class_entry ce;

INIT_CLASS_ENTRY(ce, "ZookeeperException", NULL);
zk_base_exception = php5to7_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C));
zk_base_exception = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C));

INIT_CLASS_ENTRY(ce, "ZookeeperOperationTimeoutException", NULL);
zk_optimeout_exception = php5to7_register_internal_class_ex(&ce, zk_base_exception);
zk_optimeout_exception = zend_register_internal_class_ex(&ce, zk_base_exception);

INIT_CLASS_ENTRY(ce, "ZookeeperConnectionException", NULL);
zk_connection_exception = php5to7_register_internal_class_ex(&ce, zk_base_exception);
zk_connection_exception = zend_register_internal_class_ex(&ce, zk_base_exception);

INIT_CLASS_ENTRY(ce, "ZookeeperMarshallingException", NULL);
zk_marshalling_exception = php5to7_register_internal_class_ex(&ce, zk_base_exception);
zk_marshalling_exception = zend_register_internal_class_ex(&ce, zk_base_exception);

INIT_CLASS_ENTRY(ce, "ZookeeperAuthenticationException", NULL);
zk_auth_exception = php5to7_register_internal_class_ex(&ce, zk_base_exception);
zk_auth_exception = zend_register_internal_class_ex(&ce, zk_base_exception);

INIT_CLASS_ENTRY(ce, "ZookeeperSessionException", NULL);
zk_session_exception = php5to7_register_internal_class_ex(&ce, zk_base_exception);
zk_session_exception = zend_register_internal_class_ex(&ce, zk_base_exception);

INIT_CLASS_ENTRY(ce, "ZookeeperNoNodeException", NULL);
zk_nonode_exception = php5to7_register_internal_class_ex(&ce, zk_base_exception);
zk_nonode_exception = zend_register_internal_class_ex(&ce, zk_base_exception);
}

zend_class_entry * php_zk_get_exception_with_message(zend_class_entry *ce, char *message TSRMLS_DC)
Expand Down
1 change: 0 additions & 1 deletion php_zookeeper_session.c
Expand Up @@ -21,7 +21,6 @@

#include "SAPI.h"

#include "php5to7.h"
#include "php_zookeeper.h"
#include "php_zookeeper_private.h"
#include "php_zookeeper_session.h"
Expand Down
25 changes: 12 additions & 13 deletions php_zookeeper_stat.c
Expand Up @@ -15,7 +15,6 @@
*/
#include <php.h>

#include "php5to7.h"
#include "php_zookeeper_stat.h"

void php_stat_to_array(const struct Stat *stat, zval *array)
Expand All @@ -30,15 +29,15 @@ void php_stat_to_array(const struct Stat *stat, zval *array)
array_init(array);
}

add_assoc_double_ex(array, PHP5TO7_STRS("czxid"), stat->czxid);
add_assoc_double_ex(array, PHP5TO7_STRS("mzxid"), stat->mzxid);
add_assoc_double_ex(array, PHP5TO7_STRS("ctime"), stat->ctime);
add_assoc_double_ex(array, PHP5TO7_STRS("mtime"), stat->mtime);
add_assoc_long_ex(array, PHP5TO7_STRS("version"), stat->version);
add_assoc_long_ex(array, PHP5TO7_STRS("cversion"), stat->cversion);
add_assoc_long_ex(array, PHP5TO7_STRS("aversion"), stat->aversion);
add_assoc_double_ex(array, PHP5TO7_STRS("ephemeralOwner"), stat->ephemeralOwner);
add_assoc_long_ex(array, PHP5TO7_STRS("dataLength"), stat->dataLength);
add_assoc_long_ex(array, PHP5TO7_STRS("numChildren"), stat->numChildren);
add_assoc_double_ex(array, PHP5TO7_STRS("pzxid"), stat->pzxid);
}
add_assoc_double_ex(array, ZEND_STRL("czxid"), stat->czxid);
add_assoc_double_ex(array, ZEND_STRL("mzxid"), stat->mzxid);
add_assoc_double_ex(array, ZEND_STRL("ctime"), stat->ctime);
add_assoc_double_ex(array, ZEND_STRL("mtime"), stat->mtime);
add_assoc_long_ex(array, ZEND_STRL("version"), stat->version);
add_assoc_long_ex(array, ZEND_STRL("cversion"), stat->cversion);
add_assoc_long_ex(array, ZEND_STRL("aversion"), stat->aversion);
add_assoc_double_ex(array, ZEND_STRL("ephemeralOwner"), stat->ephemeralOwner);
add_assoc_long_ex(array, ZEND_STRL("dataLength"), stat->dataLength);
add_assoc_long_ex(array, ZEND_STRL("numChildren"), stat->numChildren);
add_assoc_double_ex(array, ZEND_STRL("pzxid"), stat->pzxid);
}

0 comments on commit 2e66bd0

Please sign in to comment.