Permalink
Browse files

Just a bit more code shuffling happening here.

  • Loading branch information...
1 parent 239c2b1 commit 117bfca2c7ed1efde1dda5abbc4d7951cef39b1c @nrk committed Oct 23, 2013
Showing with 78 additions and 75 deletions.
  1. +8 −1 php_phpiredis.h
  2. +70 −74 phpiredis.c
View
@@ -1,5 +1,12 @@
#ifndef PHP_PHPIREDIS_H
-#define PHP_PHPIREDIS_H 1
+#define PHP_PHPIREDIS_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
#define PHP_PHPIREDIS_VERSION "1.0.0"
#define PHP_PHPIREDIS_EXTNAME "phpiredis"
View
@@ -1,69 +1,26 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include "hiredis/hiredis.h"
-#include "php.h"
-#include "php_ini.h"
#include "php_phpiredis.h"
-#include "ext/standard/head.h"
-#include "ext/standard/info.h"
#include "php_phpiredis_struct.h"
-static zend_function_entry phpiredis_functions[] = {
- PHP_FE(phpiredis_connect, NULL)
- PHP_FE(phpiredis_pconnect, NULL)
- PHP_FE(phpiredis_disconnect, NULL)
- PHP_FE(phpiredis_command, NULL)
- PHP_FE(phpiredis_command_bs, NULL)
- PHP_FE(phpiredis_multi_command, NULL)
- PHP_FE(phpiredis_multi_command_bs, NULL)
- PHP_FE(phpiredis_format_command, NULL)
- PHP_FE(phpiredis_reader_create, NULL)
- PHP_FE(phpiredis_reader_reset, NULL)
- PHP_FE(phpiredis_reader_feed, NULL)
- PHP_FE(phpiredis_reader_get_state, NULL)
- PHP_FE(phpiredis_reader_get_error, NULL)
- PHP_FE(phpiredis_reader_get_reply, NULL)
- PHP_FE(phpiredis_reader_destroy, NULL)
- PHP_FE(phpiredis_reader_set_error_handler, NULL)
- PHP_FE(phpiredis_reader_set_status_handler, NULL)
- {NULL, NULL, NULL}
-};
-
-zend_module_entry phpiredis_module_entry = {
-#if ZEND_MODULE_API_NO >= 20010901
- STANDARD_MODULE_HEADER,
-#endif
- PHP_PHPIREDIS_EXTNAME,
- phpiredis_functions,
- PHP_MINIT(phpiredis),
- NULL,
- NULL,
- NULL,
- NULL,
-#if ZEND_MODULE_API_NO >= 20010901
- PHP_PHPIREDIS_VERSION,
-#endif
- STANDARD_MODULE_PROPERTIES
-};
-
-#ifdef COMPILE_DL_PHPIREDIS
-ZEND_GET_MODULE(phpiredis)
-#endif
+#include "ext/standard/head.h"
+#include "ext/standard/info.h"
#define PHPIREDIS_CONNECTION_NAME "phpredis connection"
#define PHPIREDIS_PERSISTENT_CONNECTION_NAME "phpredis connection persistent"
#define PHPIREDIS_READER_NAME "phpredis reader"
-static
-void convert_redis_to_php(phpiredis_reader* reader, zval* return_value, redisReply* reply);
+int le_redis_reader_context;
+int le_redis_context;
+int le_redis_persistent_context;
typedef struct callback {
zval *function;
} callback;
static
+void convert_redis_to_php(phpiredis_reader* reader, zval* return_value, redisReply* reply);
+
+static
void s_destroy_connection(phpiredis_connection *connection TSRMLS_DC)
{
if (connection) {
@@ -110,29 +67,6 @@ void php_redis_reader_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
}
}
-int le_redis_reader_context;
-int le_redis_context;
-int le_redis_persistent_context;
-
-PHP_MINIT_FUNCTION(phpiredis)
-{
- le_redis_context = zend_register_list_destructors_ex(php_redis_connection_dtor, NULL, PHPIREDIS_CONNECTION_NAME, module_number);
- le_redis_persistent_context = zend_register_list_destructors_ex(NULL, php_redis_connection_dtor, PHPIREDIS_PERSISTENT_CONNECTION_NAME, module_number);
- le_redis_reader_context = zend_register_list_destructors_ex(php_redis_reader_dtor, NULL, PHPIREDIS_READER_NAME, module_number);
-
- REGISTER_LONG_CONSTANT("PHPIREDIS_READER_STATE_INCOMPLETE", PHPIREDIS_READER_STATE_INCOMPLETE, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("PHPIREDIS_READER_STATE_COMPLETE", PHPIREDIS_READER_STATE_COMPLETE, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("PHPIREDIS_READER_STATE_ERROR", PHPIREDIS_READER_STATE_ERROR, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_STRING", REDIS_REPLY_STRING, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_ARRAY", REDIS_REPLY_ARRAY, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_INTEGER", REDIS_REPLY_INTEGER, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_NIL", REDIS_REPLY_NIL, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_STATUS", REDIS_REPLY_STATUS, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_ERROR", REDIS_REPLY_ERROR, CONST_PERSISTENT|CONST_CS);
-
- return SUCCESS;
-}
-
static
phpiredis_connection *s_create_connection (const char *ip, int port, zend_bool is_persistent)
{
@@ -870,3 +804,65 @@ PHP_FUNCTION(phpiredis_reader_get_state)
ZVAL_LONG(return_value, PHPIREDIS_READER_STATE_INCOMPLETE);
}
}
+
+
+PHP_MINIT_FUNCTION(phpiredis)
+{
+ le_redis_context = zend_register_list_destructors_ex(php_redis_connection_dtor, NULL, PHPIREDIS_CONNECTION_NAME, module_number);
+ le_redis_persistent_context = zend_register_list_destructors_ex(NULL, php_redis_connection_dtor, PHPIREDIS_PERSISTENT_CONNECTION_NAME, module_number);
+ le_redis_reader_context = zend_register_list_destructors_ex(php_redis_reader_dtor, NULL, PHPIREDIS_READER_NAME, module_number);
+
+ REGISTER_LONG_CONSTANT("PHPIREDIS_READER_STATE_INCOMPLETE", PHPIREDIS_READER_STATE_INCOMPLETE, CONST_PERSISTENT|CONST_CS);
+ REGISTER_LONG_CONSTANT("PHPIREDIS_READER_STATE_COMPLETE", PHPIREDIS_READER_STATE_COMPLETE, CONST_PERSISTENT|CONST_CS);
+ REGISTER_LONG_CONSTANT("PHPIREDIS_READER_STATE_ERROR", PHPIREDIS_READER_STATE_ERROR, CONST_PERSISTENT|CONST_CS);
+ REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_STRING", REDIS_REPLY_STRING, CONST_PERSISTENT|CONST_CS);
+ REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_ARRAY", REDIS_REPLY_ARRAY, CONST_PERSISTENT|CONST_CS);
+ REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_INTEGER", REDIS_REPLY_INTEGER, CONST_PERSISTENT|CONST_CS);
+ REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_NIL", REDIS_REPLY_NIL, CONST_PERSISTENT|CONST_CS);
+ REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_STATUS", REDIS_REPLY_STATUS, CONST_PERSISTENT|CONST_CS);
+ REGISTER_LONG_CONSTANT("PHPIREDIS_REPLY_ERROR", REDIS_REPLY_ERROR, CONST_PERSISTENT|CONST_CS);
+
+ return SUCCESS;
+}
+
+static zend_function_entry phpiredis_functions[] = {
+ PHP_FE(phpiredis_connect, NULL)
+ PHP_FE(phpiredis_pconnect, NULL)
+ PHP_FE(phpiredis_disconnect, NULL)
+ PHP_FE(phpiredis_command, NULL)
+ PHP_FE(phpiredis_command_bs, NULL)
+ PHP_FE(phpiredis_multi_command, NULL)
+ PHP_FE(phpiredis_multi_command_bs, NULL)
+ PHP_FE(phpiredis_format_command, NULL)
+ PHP_FE(phpiredis_reader_create, NULL)
+ PHP_FE(phpiredis_reader_reset, NULL)
+ PHP_FE(phpiredis_reader_feed, NULL)
+ PHP_FE(phpiredis_reader_get_state, NULL)
+ PHP_FE(phpiredis_reader_get_error, NULL)
+ PHP_FE(phpiredis_reader_get_reply, NULL)
+ PHP_FE(phpiredis_reader_destroy, NULL)
+ PHP_FE(phpiredis_reader_set_error_handler, NULL)
+ PHP_FE(phpiredis_reader_set_status_handler, NULL)
+ {NULL, NULL, NULL}
+};
+
+zend_module_entry phpiredis_module_entry = {
+#if ZEND_MODULE_API_NO >= 20010901
+ STANDARD_MODULE_HEADER,
+#endif
+ PHP_PHPIREDIS_EXTNAME,
+ phpiredis_functions,
+ PHP_MINIT(phpiredis),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+#if ZEND_MODULE_API_NO >= 20010901
+ PHP_PHPIREDIS_VERSION,
+#endif
+ STANDARD_MODULE_PROPERTIES
+};
+
+#ifdef COMPILE_DL_PHPIREDIS
+ZEND_GET_MODULE(phpiredis)
+#endif

0 comments on commit 117bfca

Please sign in to comment.