Date: Sat Feb 21 22:36:45 CET 2004
User: Derick Rethans
Directory: php_srm
Log Message:
[2.00]
- Added framework for PHP 5 version of the extension
Modified files:
php_srm/.cvsignore (version: 1.2.2.1)
php_srm/config.m4 (version: 1.12.2.1)
php_srm/php_srm.h (version: 1.5.2.1)
php_srm/srm.c (version: 1.49.2.1)
Added files:
php_srm/class_srm.c (new version: 1.1.2.1)
php_srm/class_srm.h (new version: 1.1.2.1)
php_srm/srm_private.h (new version: 1.1.2.1)
[FILE: /php_srm/class_srm.c]
[FILE: /php_srm/class_srm.h]
[FILE: /php_srm/srm_private.h]
[FILE: /php_srm/.cvsignore]
--- php_srm/.cvsignore:1.2 Tue Feb 05 02:46:43 2002 GMT
+++ php_srm/.cvsignore Sat Feb 21 20:36:44 2004 GMT
@@ -1,7 +1,31 @@
+acinclude.m4
+aclocal.m4
+autom4te.cache
+build
+config.guess
+config.h
+config.h.in
+config.log
+config.nice
+config.status
+config.sub
+configure
+configure.in
.deps
-Makefile
-*.lo
-*.slo
+include
+install-sh
*.la
.libs
libs.mk
+libtool
+*.lo
+ltmain.sh
+Makefile
+Makefile.fragments
+Makefile.global
+Makefile.objects
+missing
+mkinstalldirs
+modules
+*.slo
+*.swp
[FILE: /php_srm/config.m4]
--- php_srm/config.m4:1.12 Fri Sep 19 15:38:47 2003 GMT
+++ php_srm/config.m4 Sat Feb 21 20:36:44 2004 GMT
@@ -1,5 +1,5 @@
dnl
-dnl $Id: cvstemp,v 1.12 2003/09/19 17:38:47 sniper Exp $
+dnl $Id: cvstemp,v 1.12.2.1 2004/02/21 21:36:44 derick Exp $
dnl
PHP_ARG_WITH(srm,for SRM support,
@@ -32,7 +32,7 @@
PHP_EVAL_LIBLINE($SRM_LIBLINE, SRM_SHARED_LIBADD)
PHP_EVAL_INCLINE($SRM_INCLINE)
- PHP_NEW_EXTENSION(srm, srm.c srm_util.c srm_session.c, $ext_shared)
+ PHP_NEW_EXTENSION(srm, class_srm.c srm.c srm_util.c srm_session.c, $ext_shared)
PHP_SUBST(SRM_SHARED_LIBADD)
AC_DEFINE(HAVE_SRM,1,[ ])
fi
[FILE: /php_srm/php_srm.h]
--- php_srm/php_srm.h:1.5 Fri Sep 19 15:38:47 2003 GMT
+++ php_srm/php_srm.h Sat Feb 21 20:36:44 2004 GMT
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cvstemp,v 1.5 2003/09/19 17:38:47 sniper Exp $ */
+/* $Id: cvstemp,v 1.5.2.1 2004/02/21 21:36:44 derick Exp $ */
#ifndef PHP_SRM_H
#define PHP_SRM_H
@@ -39,8 +39,6 @@
PHP_MINIT_FUNCTION(srm);
PHP_MSHUTDOWN_FUNCTION(srm);
PHP_MINFO_FUNCTION(srm);
-
-PHP_FUNCTION(srm_connect);
#ifdef ZTS
#define SRMG(v) TSRMG(srm_globals_id, zend_srm_globals *, v)
[FILE: /php_srm/srm.c]
--- php_srm/srm.c:1.49 Sun Sep 21 07:26:32 2003 GMT
+++ php_srm/srm.c Sat Feb 21 20:36:44 2004 GMT
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cvstemp,v 1.49 2003/09/21 09:26:32 sniper Exp $ */
+/* $Id: cvstemp,v 1.49.2.1 2004/02/21 21:36:44 derick Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -30,6 +30,7 @@
#include "ext/standard/info.h"
#include "ext/session/php_session.h"
#include "ext/standard/php_smart_str.h"
+#include "zend.h"
#include "SAPI.h"
#include "php_srm.h"
@@ -37,614 +38,24 @@
#include "srm_session.h"
#include "srm_logo.h"
+#include "class_srm.h"
+
#include <srm/srm_client.h>
#include <srm/srm_value.h>
#include <srm/srm_version.h> /* FIXME: SRM_API_VERSION should be fetched at runtime */
#include <sys/socket.h>
-/* Globals defined here to avoid including any header files in php_srm.h */
-ZEND_BEGIN_MODULE_GLOBALS(srm)
- srm_value *error_val;
-ZEND_END_MODULE_GLOBALS(srm)
-
-ZEND_DECLARE_MODULE_GLOBALS(srm)
-
-/* Function definitions */
-void php_srm_function_call_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
-zval php_srm_get_property_handler(zend_property_reference *property_reference);
-int php_srm_set_property_handler(zend_property_reference *property_reference, zval *value);
-
-void php_srmapp_function_call_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
-zval php_srmapp_get_property_handler(zend_property_reference *property_reference);
-int php_srmapp_set_property_handler(zend_property_reference *property_reference, zval *value);
-
+#if 0
static void _close_srm_connection(zend_rsrc_list_entry *rsrc TSRMLS_DC);
static void php_set_srm_error_message(srm_value *error_sval TSRMLS_DC);
+#endif
/* True global resources - no need for thread safety here */
static int le_srm;
-static zend_class_entry *srm_class_entry_ptr;
-static zend_class_entry *srmapp_class_entry_ptr;
-
-#define FETCH_CONN_ID(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \
- rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type);
-
-#define SRM_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \
- rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type);
-
-
-/* {{{ Helper functions for Object Overloading */
-/* {{{ get_properry_name (list, nr)
- Function that gets the n-th parameter from a list.
- This function does not check if that parameter really exists */
-static char* get_property_name (zend_llist* list, int parameter_nr)
-{
- zend_llist_element *e = list->head;
- zend_overloaded_element *oe;
- int i;
-
- for (i = 0; i < parameter_nr; i++) {
- e = e->next;
- }
- oe = (zend_overloaded_element *) e->data;
- if (Z_TYPE(oe->element) == IS_STRING) {
- return Z_STRVAL(oe->element);
- } else {
- return NULL;
- }
-}
-/* }}} */
-
-/* {{{ check_for_correct_handler (property_reference, conn_id)
- This function checks if a link is still active */
-static char* check_for_correct_handler (zend_property_reference *property_reference, zval*** conn_id TSRMLS_DC)
-{
- char *array_name;
- char *index;
- zval *object = property_reference->object;
- zval **tmp_id;
-
- /* Check for number of nested levels */
- if (property_reference->elements_list->count == 2) {
- /* Check for the propertyname "globals" */
- array_name = get_property_name (property_reference->elements_list, 0);
- if (array_name != NULL && strcmp (array_name, "globals") == 0) {
-
- /* Check for a valid string index */
- index = get_property_name (property_reference->elements_list, 1);
- if (index != NULL) {
-
- /* Check for valid connection */
- if (zend_hash_find(Z_OBJPROP_P(object), "conn_id", 8, (void **) &tmp_id) != FAILURE) {
- *conn_id = tmp_id;
- return index;
- } else {
- php_error (E_WARNING, "The member 'conn_id' of the SRM Object isn't a valid Connection Identifier");
- }
- } else {
- php_error (E_WARNING, "The index is not a string");
- }
- }
- }
- return NULL;
-}
-/* }}} */
-
-/* {{{ destroy_property_references (property_reference) */
-static void destroy_property_references (zend_property_reference *property_reference)
-{
- zend_llist_element *element;
- zend_overloaded_element *property;
-
- for (element = property_reference->elements_list->head; element != NULL; element = element->next) {
- property = (zend_overloaded_element *) element->data;
- zval_dtor(&property->element);
- }
-}
-/* }}} */
-/* }}} */
-
-
-/* {{{ Handlers for class SRM */
-/* {{{ php_srm_function_call_handler (IFP, property_reference)
- This function is called when $obj->function() is requested */
-void php_srm_function_call_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
-{
- zval ***args;
- zval *result;
- connect_data_t *connect_data;
- zend_overloaded_element *function_name = (zend_overloaded_element *) property_reference->elements_list->tail->data;
- srm_value *ret_val;
- zval *object;
- zval **conn_id;
- int argc = ZEND_NUM_ARGS();
- int i;
- SRM_LIST(params);
-
- /* Constructor */
- /* class 'SRM' */
- if (!strcmp(Z_STRVAL(function_name->element), "srm")) {
- PHP_FN(srm_connect)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- zval_dtor(&function_name->element);
- return;
- }
-
- /* Check if the connection property is correct */
- object = getThis();
- if (zend_hash_find(Z_OBJPROP_P(object), "conn_id", 8, (void **) &conn_id) == FAILURE) {
- php_error(E_WARNING, "The member 'conn_id' of the SRM Object isn't a valid Connection Identifier");
- zval_dtor(&function_name->element);
- RETURN_FALSE;
- }
-
- ret_val = srm_value_init();
- args = (zval ***) emalloc(argc * sizeof(zval **));
-
- if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
- efree(args);
- zval_dtor(&function_name->element);
- RETURN_FALSE;
- }
- ZEND_FETCH_RESOURCE(connect_data, connect_data_t *, conn_id, -1, "SRM link", le_srm);
-
- if (argc > 0) {
- SRM_LIST_INIT(params);
-
- for (i = 0; i < argc; i++) {
- SRM_LIST_ADD_SVAL(params, zval_to_srmval(*args[i]));
- }
- } else {
- params = NULL;
- }
-
- ret_val = srm_do_command(*connect_data, Z_STRVAL(function_name->element), params);
- /* FIX ME: FREE the list */
- efree(args);
-
- if (ret_val) {
- if (SRM_IS_ERROR(ret_val) && VALP_IS_STR(ret_val)) {
- php_set_srm_error_message(ret_val TSRMLS_CC);
- zval_dtor(&function_name->element);
- RETURN_FALSE;
- } else {
- result = srmval_to_zval(ret_val, 1 TSRMLS_CC);
- *return_value = *result;
-
- zval_dtor(&function_name->element);
- }
- } else {
- php_error (E_WARNING, "Communication error");
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ php_srm_get_property_handler (property_reference) */
-zval php_srm_get_property_handler(zend_property_reference *property_reference)
-{
- connect_data_t *connect_data;
- zval *result;
- srm_value *data;
- char *index;
- zval **conn_id;
- SRM_LIST(params)
- SRM_LIST(indices)
-
- TSRMLS_FETCH();
-
-#warning fixme: use efree
- result = malloc (sizeof(zval));
- index = check_for_correct_handler (property_reference, (zval ***) &conn_id TSRMLS_CC);
- ZVAL_NULL (result);
-
- if (index != NULL) {
- FETCH_CONN_ID(connect_data, connect_data_t *, conn_id, -1, "SRM link", le_srm);
- if (connect_data) {
- SRM_LIST_INIT(params);
- SRM_LIST_ADD(STR, params, "globals");
-
- SRM_LIST_INIT(indices);
- SRM_LIST_ADD(STR, indices, index);
- indices->ref_count++;
- SRM_LIST_ADD_LST(params, indices);
-
- data = srm_do_command(*connect_data, "get_data", params);
-
- srm_value_free(params);
- srm_value_free(indices);
-
- if (SRM_IS_ERROR(data)) {
- php_error(E_WARNING, "srm_data_retrieve() failed: %s", data->s_value);
- } else {
- result = srmval_to_zval (data, 1 TSRMLS_CC);
- }
- srm_value_free(data);
- } else {
- php_error (E_WARNING, "The connection data is not valid");
- }
- }
- destroy_property_references(property_reference);
-
- return *result;
-}
-/* }}} */
-
-/* {{{ php_srm_set_property_handler (property_reference, value) */
-int php_srm_set_property_handler(zend_property_reference *property_reference, zval *value)
-{
- connect_data_t *connect_data;
- srm_value *data, *ret_val;
- int ok = FALSE;
- char *index;
- zval **conn_id;
- SRM_LIST(params)
- SRM_LIST(indices)
-
- TSRMLS_FETCH();
-
- index = check_for_correct_handler (property_reference, (zval ***) &conn_id TSRMLS_CC);
-
- if (index != NULL) {
- FETCH_CONN_ID(connect_data, connect_data_t *, conn_id, -1, "SRM link", le_srm);
- if (connect_data) {
- SRM_LIST_INIT(params);
- SRM_LIST_ADD(STR, params, "globals");
-
- SRM_LIST_INIT(indices);
- SRM_LIST_ADD(STR, indices, index);
- indices->ref_count++;
- SRM_LIST_ADD_LST(params, indices);
-
- data = zval_to_srmval (value);
- SRM_LIST_ADD_SVAL(params, data);
-
- ret_val = srm_do_command(*connect_data, "set_data", params);
-
- srm_value_free(params);
- srm_value_free(indices);
- srm_value_free(data);
-
- if (SRM_IS_ERROR(ret_val)) {
- php_error(E_WARNING, "srm_data_store() failed: %s", ret_val->s_value);
- } else {
- ok = TRUE;
- }
- } else {
- php_error (E_WARNING, "The connection data is not valid");
- }
- }
-
- destroy_property_references(property_reference);
-
- return ok;
-}
-/* }}} */
-/* }}} */
-
-
-/* {{{ Handlers for class SRMApp */
-/* {{{ php_srmapp_ctor (IFP, property_reference TSRMLS_DC) */
-void php_srmapp_ctor (INTERNAL_FUNCTION_PARAMETERS, zend_overloaded_element *function_name_e)
-{
- zval *result;
- connect_data_t *connect_data;
- srm_value *ret_val;
- zval *srm_obj;
- zval **conn_id;
- char *srmapp;
- int srmapp_len;
- SRM_LIST(params);
-
- /* Check parameters */
- if (zend_parse_parameters (ZEND_NUM_ARGS() TSRMLS_CC, "os",
- &srm_obj, &srmapp, &srmapp_len) == FAILURE) {
-
- return;
- }
-
- /* Check if the connection property is correct */
- if (zend_hash_find(Z_OBJPROP_P(srm_obj), "conn_id", 8, (void **) &conn_id) == FAILURE) {
- php_error(E_WARNING, "The member 'conn_id' of the SRM Object does not exist");
- zval_dtor(&function_name_e->element);
- RETURN_FALSE;
- }
-
- /* Get connection data */
- ZEND_FETCH_RESOURCE(connect_data, connect_data_t *, conn_id, -1, "SRM link", le_srm);
-
- /* Build request */
- SRM_LIST_INIT(params);
- SRM_LIST_ADD(STR, params, srmapp);
-
- /* Do request */
- ret_val = srm_do_command(*connect_data, "start_banana", params);
-
- /* Handle return values */
- if (ret_val) {
- if (SRM_IS_ERROR(ret_val) && VALP_IS_STR(ret_val)) {
- php_set_srm_error_message(ret_val TSRMLS_CC);
- zval_dtor(&function_name_e->element);
- RETURN_FALSE;
- } else {
- result = srmval_to_zval(ret_val, 1 TSRMLS_CC);
-
- add_property_resource(getThis(), "conn_id", Z_LVAL_PP(conn_id));
- add_property_zval(getThis(), "handle", result);
- }
- } else {
- php_error (E_WARNING, "Communication error");
- RETURN_FALSE;
- }
- zval_dtor(&function_name_e->element);
- return;
-}
-/* }}} */
-
-/* {{{ php_srmapp_functioncall (IFP, function_name) */
-void php_srmapp_functioncall (INTERNAL_FUNCTION_PARAMETERS, zend_overloaded_element *function_name_e)
-{
- char *function_name = Z_STRVAL(function_name_e->element);
- int i;
- zval ***args;
- zval *obj;
- int argc;
- connect_data_t *connect_data;
- srm_value *ret_val;
- zval **conn_id;
- zval *result2;
- zval **handle;
- SRM_LIST(params);
-
- argc = ZEND_NUM_ARGS();
- obj = getThis();
-
- /* Get parameters */
- args = (zval ***)emalloc(argc * sizeof(zval **));
- if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
- efree(args);
- RETURN_FALSE;
- }
-
- /* Check if the connection property is correct */
- if (zend_hash_find(Z_OBJPROP_P(obj), "conn_id", 8, (void **) &conn_id) == FAILURE) {
- php_error(E_WARNING, "The member 'conn_id' of the SRM Object does not exist");
- zval_dtor(&function_name_e->element);
- efree(args);
- RETURN_FALSE;
- }
-
- /* Check if the handle is defined */
- if (zend_hash_find(Z_OBJPROP_P(obj), "handle", 7, (void **) &handle) == FAILURE) {
- php_error(E_WARNING, "The member 'handle' of the SRM Object does not exist");
- zval_dtor(&function_name_e->element);
- efree(args);
- RETURN_FALSE;
- }
-
- /* Get connection data */
- ZEND_FETCH_RESOURCE(connect_data, connect_data_t *, conn_id, -1, "SRM link", le_srm);
-
- /* Build request */
- SRM_LIST_INIT(params);
- SRM_LIST_ADD(STR, params, function_name);
- SRM_LIST_ADD(U32, params, Z_LVAL_PP(handle));
- if (argc > 0) {
- for (i = 0; i < argc; i++) {
- SRM_LIST_ADD_SVAL(params, zval_to_srmval (*args[i]));
- }
- }
-
- /* Do request */
- ret_val = srm_do_command(*connect_data, "banana_function_call", params);
- /* Handle return values */
- if (ret_val) {
- if (SRM_IS_ERROR(ret_val) && VALP_IS_STR(ret_val)) {
- php_set_srm_error_message(ret_val TSRMLS_CC);
- zval_dtor(&function_name_e->element);
- efree(args);
- RETURN_FALSE;
- } else {
- result2 = srmval_to_zval(ret_val, 1 TSRMLS_CC);
- *return_value = *result2;
- }
- } else {
- php_error (E_WARNING, "Communication error");
- zval_dtor(&function_name_e->element);
- efree(args);
- RETURN_FALSE;
- }
- zval_dtor(&function_name_e->element);
- efree(args);
- efree(result2);
- return;
-}
-/* }}} */
-
-/* {{{ php_srmapp_function_call_handler (IFP, property_reference)
- This function is called when $obj->function() is requested */
-void php_srmapp_function_call_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
-{
- zend_overloaded_element *function_name_e = (zend_overloaded_element *) property_reference->elements_list->tail->data;
- char *function_name = Z_STRVAL(function_name_e->element);
-
- /* Constructor */
- if ((strcmp(function_name, "srmapp") == 0)) {
- php_srmapp_ctor (INTERNAL_FUNCTION_PARAM_PASSTHRU, function_name_e);
- } else { /* Normal functions */
- php_srmapp_functioncall (INTERNAL_FUNCTION_PARAM_PASSTHRU, function_name_e);
- }
-}
-/* }}} */
-
-/* {{{ php_srmapp_set_property_handler (property_reference, value) */
-int php_srmapp_set_property_handler(zend_property_reference *property_reference, zval* value)
-{
- char *index = NULL;
- zval *object = property_reference->object;
- zval **tmp_id;
- connect_data_t *connect_data;
- srm_value *ret_val;
- zval **conn_id;
- zval **handle;
- srm_llist* params_ll;
- struct srm_value* params;
- int return_val = FALSE;
-
- TSRMLS_FETCH();
-
- /* Check for number of nested levels */
- if (property_reference->elements_list->count == 1) {
- /* Check for a valid string index */
- index = get_property_name (property_reference->elements_list, 0);
- if (index != NULL) {
-
- /* Check for valid connection */
- if (zend_hash_find(Z_OBJPROP_P(object), "conn_id", 8, (void **) &tmp_id) != FAILURE) {
- conn_id = tmp_id;
- } else {
- php_error (E_WARNING, "The member 'conn_id' of the SRM Object isn't a valid Connection Identifier");
- goto ret;
- }
- } else {
- php_error (E_WARNING, "The index is not a string");
- goto ret;
- }
- } else {
- php_error (E_WARNING, "Wrong indexing");
- goto ret;
- }
-
- /* Check if the handle is defined */
- if (zend_hash_find(Z_OBJPROP_P(object), "handle", 7, (void **) &handle) == FAILURE) {
- php_error(E_WARNING, "The member 'handle' of the SRM Object does not exist");
- goto ret;
- }
-
- /* Get connection data */
- SRM_FETCH_RESOURCE(connect_data, connect_data_t *, conn_id, -1, "SRM link", le_srm);
- if (!connect_data) {
- goto ret;
- }
-
- /* Build request */
- SRM_LIST_INIT(params);
- SRM_LIST_ADD(STR, params, strdup("banana_set"));
- SRM_LIST_ADD(U32, params, Z_LVAL_PP(handle));
- SRM_LIST_ADD(STR, params, index);
- SRM_LIST_ADD_SVAL(params, zval_to_srmval (value));
-
- /* Do request */
- ret_val = srm_do_command(*connect_data, "banana_function_call", params);
- /* Handle return values */
- if (ret_val) {
- if (SRM_IS_ERROR(ret_val) && VALP_IS_STR(ret_val)) {
- php_set_srm_error_message(ret_val TSRMLS_CC);
- } else {
- return_val = TRUE;
- }
- } else {
- php_error (E_WARNING, "Communication error");
- }
-
-ret:
- destroy_property_references(property_reference);
-
- return return_val;
-}
-/* }}} */
-
-/* {{{ php_srmapp_get_property_handler (property_reference) */
-zval php_srmapp_get_property_handler(zend_property_reference *property_reference)
-{
- char *index = NULL;
- zval *object = property_reference->object;
- zval **tmp_id;
- zval *res = NULL;
- connect_data_t *connect_data;
- srm_value *ret_val;
- zval **conn_id;
- zval **handle;
- srm_llist* params_ll;
- struct srm_value* params;
-
- TSRMLS_FETCH();
-
- /* Check for number of nested levels */
- if (property_reference->elements_list->count == 1) {
- /* Check for a valid string index */
- index = get_property_name (property_reference->elements_list, 0);
- if (index != NULL) {
-
- /* Check for valid connection */
- if (zend_hash_find(Z_OBJPROP_P(object), "conn_id", 8, (void **) &tmp_id) != FAILURE) {
- conn_id = tmp_id;
- } else {
- php_error (E_WARNING, "The member 'conn_id' of the SRM Object isn't a valid Connection Identifier");
- goto ret;
- }
- } else {
- php_error (E_WARNING, "The index is not a string");
- goto ret;
- }
- } else {
- php_error (E_WARNING, "Wrong indexing");
- goto ret;
- }
-
- /* Check if the handle is defined */
- if (zend_hash_find(Z_OBJPROP_P(object), "handle", 7, (void **) &handle) == FAILURE) {
- php_error(E_WARNING, "The member 'handle' of the SRM Object does not exist");
- goto ret;
- }
-
- /* Get connection data */
- SRM_FETCH_RESOURCE(connect_data, connect_data_t *, conn_id, -1, "SRM link", le_srm);
- if (!connect_data) {
- goto ret;
- }
-
- /* Build request */
- SRM_LIST_INIT(params);
- SRM_LIST_ADD(STR, params, strdup("banana_get"));
- SRM_LIST_ADD(U32, params, Z_LVAL_PP(handle));
- SRM_LIST_ADD(STR, params, index);
-
- /* Do request */
- ret_val = srm_do_command(*connect_data, "banana_function_call", params);
- /* Handle return values */
- if (ret_val) {
- if (SRM_IS_ERROR(ret_val) && VALP_IS_STR(ret_val)) {
- php_set_srm_error_message(ret_val TSRMLS_CC);
- } else {
- res = srmval_to_zval(ret_val, 1 TSRMLS_CC);
- }
- } else {
- php_error (E_WARNING, "Communication error");
- }
-
-ret:
- if (!res) {
- res = malloc (sizeof(zval));
- ZVAL_NULL (res);
- }
- destroy_property_references(property_reference);
- return *res;
-}
-/* }}} */
-/* }}} */
-
-/* {{{
-function_entry srm_object_methods[] = {
- PHP_FALIAS(connect, srm_connect, NULL)
- {NULL, NULL, NULL}
-};
-
-function_entry srm_functions[] = {
- {NULL, NULL, NULL}
-};
-}}} */
+zend_class_entry *srm_class_entry = NULL;
+zend_class_entry *srmapp_class_entry = NULL;
/* {{{ srm_module_entry */
zend_module_entry srm_module_entry = {
@@ -665,87 +76,38 @@
ZEND_GET_MODULE(srm)
#endif
-/* {{{ PHP_INI
- */
-/* Remove comments and fill if you need to have entries in php.ini
-PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("srm.value", "42", PHP_INI_ALL, OnUpdateInt, global_value, zend_srm_globals, srm_globals)
- STD_PHP_INI_ENTRY("srm.string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_srm_globals, srm_globals)
-PHP_INI_END()
-*/
-/* }}} */
-
-/* {{{ php_srm_init_globals
- */
-static void php_srm_init_globals(zend_srm_globals *srm_globals)
-{
- srm_globals->error_val = NULL;
-}
-/* }}} */
-
-/* {{{ php_srm_init_logo */
-static void php_srm_init_logo(void)
-{
- php_register_info_logo(SRM_INFO_LOGO_ID, "image/gif", srm_logo_data, sizeof(srm_logo_data));
-}
-/* }}} */
-
-/* {{{ php_register_srm_classes */
-static void php_register_srm_classes(TSRMLS_D)
-{
- zend_class_entry srm_class_entry;
- zend_class_entry srmapp_class_entry;
-
- INIT_OVERLOADED_CLASS_ENTRY(srm_class_entry, "srm", NULL,
- php_srm_function_call_handler,
- php_srm_get_property_handler,
- php_srm_set_property_handler);
- INIT_OVERLOADED_CLASS_ENTRY(srmapp_class_entry, "srmapp", NULL,
- php_srmapp_function_call_handler,
- php_srmapp_get_property_handler,
- php_srmapp_set_property_handler);
-
- srm_class_entry_ptr = zend_register_internal_class(&srm_class_entry TSRMLS_CC);
- srmapp_class_entry_ptr = zend_register_internal_class(&srmapp_class_entry TSRMLS_CC);
-}
-/* }}} */
-
-/* {{{ PHP module request handlers */
-/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(srm)
{
- ZEND_INIT_MODULE_GLOBALS(srm, php_srm_init_globals, NULL);
-
- /* If you have INI entries, uncomment these lines
- REGISTER_INI_ENTRIES();
- */
+ zend_class_entry srm;
+ zend_class_entry srm_app;
- le_srm = zend_register_list_destructors_ex(_close_srm_connection, NULL, "SRM link", module_number);
-
-#if HAVE_PHP_SESSION
- php_session_register_module(&ps_mod_srm);
+ INIT_CLASS_ENTRY(srm, "srm", srm_functions);
+ srm.create_object = srm_object_new;
+ srm_class_entry = zend_register_internal_class(&srm TSRMLS_CC);
+ srm_object_handlers.get_method = zend_get_std_object_handlers()->get_method;
+ srm_object_handlers.get_constructor = zend_get_std_object_handlers()->get_constructor;
+ srm_object_handlers.get_class_entry = zend_get_std_object_handlers()->get_class_entry;
+ srm_object_handlers.get_class_name = zend_get_std_object_handlers()->get_class_name;
+#if 0
+ INIT_CLASS_ENTRY(srmapp, "srmapp", srmapp_functions);
+ srmapp.create_object = srmapp_object_new;
+ srmapp_class_entry = zend_register_internal_class(&srmapp TSRMLS_CC);
+ srmapp_object_handlers.get_method = zend_get_std_object_handlers()->get_method;
+ srmapp_object_handlers.get_constructor = zend_get_std_object_handlers()->get_constructor;
+ srmapp_object_handlers.get_class_entry = zend_get_std_object_handlers()->get_class_entry;
+ srmapp_object_handlers.get_class_name = zend_get_std_object_handlers()->get_class_name;
#endif
+ php_register_info_logo(SRM_INFO_LOGO_ID, "image/gif", srm_logo_data, sizeof(srm_logo_data));
- php_srm_init_logo();
- php_register_srm_classes(TSRMLS_C);
-
return SUCCESS;
}
-/* }}} */
-/* {{{ PHP_MSHUTDOWN_FUNCTION */
PHP_MSHUTDOWN_FUNCTION(srm)
{
- /* uncomment this line if you have INI entries
- UNREGISTER_INI_ENTRIES();
- */
- php_unregister_info_logo (SRM_INFO_LOGO_ID);
-
return SUCCESS;
}
-/* }}} */
-
+
/* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(srm)
{
@@ -773,90 +135,6 @@
/* Remove comments if you have entries in php.ini
DISPLAY_INI_ENTRIES();
*/
-}
-/* }}} */
-/* }}} */
-
-static void php_set_srm_error_message(srm_value *error_sval TSRMLS_DC)
-{
- php_error (E_WARNING, SRMVALP_STR(error_sval));
- if (SRMG(error_val)) {
- srm_value_free (SRMG(error_val));
- }
-
- SRMG(error_val) = srm_value_duplicate (error_sval);
-}
-
-static void _close_srm_connection(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
- connect_data_t *connect_data = (connect_data_t *) rsrc->ptr;
-
- srm_disconnect(*connect_data);
- efree(connect_data);
-}
-
-/* {{{ proto resource srm_connect (string host [, int port])
- This function connects to the SRM deamon */
-PHP_FUNCTION(srm_connect)
-{
- struct srm_host_t hostinfo;
- char *host;
- int host_len;
- long port = 7777;
- connect_data_t *connect_data;
- srm_value *sret_val;
- int ret;
-
- /* Start session automatically. */
-// php_session_start(TSRMLS_C);
-
- /* Set defaults */
- hostinfo.host = NULL;
- hostinfo.port = 7777;
- hostinfo.family = AF_UNIX;
-
- /* Parse parameters */
- if (zend_parse_parameters (ZEND_NUM_ARGS() TSRMLS_CC, "s|l",
- &host, &host_len, &port) == FAILURE) {
- return;
- }
- hostinfo.host = host;
-
- /* If the host does not begin with '/', assume it's a TCP/IP socket */
- if (hostinfo.host[0] != '/') {
- hostinfo.family = AF_INET;
- } else {
- hostinfo.port = port;
- }
-#if 0
- /* If there is no session started, abort the connect */
- if (PS(id) == NULL) {
- php_error (E_ERROR,
- "There is no active session. Use session_start() before "
- "this call to srm_connect.");
- RETURN_FALSE;
- }
-
- /* Allocte connect_data struct, and copy the PHP SID */
- memcpy (connect_data->sess_key, PS(id), 32);
-#endif
- connect_data = ecalloc (sizeof (connect_data_t), 1);
- sret_val = srm_connect (hostinfo, 0, 0, connect_data);
-
- if (SRM_IS_ERROR (sret_val)) {
- if (hostinfo.host[0] == '/') {
- php_error (E_WARNING, "Couldn't connect to SRM on srm:%s", hostinfo.host);
- } else {
- php_error (E_WARNING, "Couldn't connect to SRM on srm://%s:%d", hostinfo.host, hostinfo.port);
- }
- efree (connect_data); /* Only free when not registering as resource */
- RETURN_FALSE;
- }
-
- ret = zend_list_insert(connect_data, le_srm);
- add_property_resource(getThis(), "conn_id", ret);
-
- RETURN_TRUE;
}
/* }}} */
Received on Sat Feb 21 22:36:50 2004
This archive was generated by hypermail 2.1.8 : Fri Jan 09 2009 - 16:00:03 CET