Hy,
i've attached my patch, it's not perfect and it's not complete.. the codebase is a little bit awful and my code isn't much better ;) , however - now it works with php 5.2.1 and spread 4.0. (only worked on connecting + sending spread messages, the rest of the code i didn't touched, so i don't know if every feature is working correctly..)

ng
siml
ps.: sorry for my bad englisch - i'm an austrian student :)


Tijnema ! schrieb:
On 5/3/07, Tretter Simon <[EMAIL PROTECTED]> wrote:
submitting a patch for a php extension in pecl tree (spread)
i made a patch for php5.2 and spread 4.0


You don't need a CVS account for submitting one patch, send it to this
list and someone will submit the patch.

Tijnema


diff -r1.17 php_spread.c
121,125c121,127
<       PHP_ME_MAPPING(connect,         spread_connect,         NULL)
<       PHP_ME_MAPPING(disconnect,      spread_disconnect,      NULL)
<       PHP_ME_MAPPING(join,            spread_join,            NULL)
<       PHP_ME_MAPPING(receive,         spread_receive,         NULL)
<       {NULL, NULL, NULL}
---
>       PHP_ME_MAPPING(connect,         spread_connect,         NULL,   0)
>       PHP_ME_MAPPING(disconnect,      spread_disconnect,      NULL,   0)
>       PHP_ME_MAPPING(join,            spread_join,            NULL,   0)
>       PHP_ME_MAPPING(receive,         spread_receive,         NULL,   0)
>       PHP_ME_MAPPING(multicast,       multicast,       NULL,   0)
>         PHP_ME_MAPPING(multicast2,       spread_multicast,       NULL,   0)
>       {NULL, NULL, NULL, 0}
308c310
<               php_error_docref(E_WARNING, "Failed to connect to spread daemon (%s) using private_name (%s), error returned was: %d", spread_name, private_name, retval);
---
>               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to connect to spread daemon (%s) using private_name (%s), error returned was: %d", spread_name, private_name, retval);
365a368
> 
407,409c410
<             } else {
<                 RETURN_FALSE;
<             }
---
>             } 
488c489
<       zval *group = NULL;
---
>       zval **group = NULL;
490c491
<       char *message = NULL;
---
>       zval **message = NULL;
496a498,499
> 
> #ifndef ZEND_ENGINE_2
503a507,508
> #endif
> 
511,513c516,549
<       default_mbox = SpG(default_conn);
<       ZEND_FETCH_RESOURCE(mbox, int *, tmp, -1, "Spread-FD", le_conn);
<       if(Z_TYPE_P(group) == IS_STRING) {
---
> 
> 
> #ifdef ZEND_ENGINE_2
>         zval *this = getThis();
>       if (this) {
>                       ze_spread_object *obj = spread_fetch_object(this);
>               if (ZEND_NUM_ARGS() > 2) {
>                       WRONG_PARAM_COUNT;
>               }
> 
>               if(zend_get_parameters_ex(2, &group, &message) == FAILURE) {
>                         return;
>                 }
>               else
>               {
>                          SEPARATE_ZVAL(group)
>                          SEPARATE_ZVAL(message)
>                          convert_to_string_ex(message);
>               }
> 
>               mbox = obj->mbox;
>         } else
> #endif
>       {
>               default_mbox = SpG(default_conn);
>               ZEND_FETCH_RESOURCE(mbox, int *, tmp, -1, "Spread-FD", le_conn);
>       }
> 
>         if (!mbox) {
>               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", "Resource or mailbox connection invalid.");
>               RETURN_FALSE;
>       }
> 
>       if((*group)->type == IS_STRING) {
515,517c551,553
<               convert_to_string_ex(&group);
<               tmpgrp = estrndup(group->value.str.val,group->value.str.len);
<               if (sperrno = (SP_multicast(*mbox, service_type, tmpgrp, mess_type, message_len, message) <0))
---
>               convert_to_string_ex(group);
>               tmpgrp = estrndup((*group)->value.str.val,(*group)->value.str.len);
>               if (sperrno = (SP_multicast(*mbox, service_type, tmpgrp, mess_type, (*message)->value.str.len, (*message)->value.str.val) <0))
519c555
<                       zend_error(E_WARNING, "SP_mulicast error(%d)", sperrno);
---
>                       zend_error(E_WARNING, "SP_multicast error(%d)", sperrno);
522c558,559
<               RETURN_LONG(sperrno);
---
>               // strange behaviour, SP_multicast (spread 4.0) always returns 0 in the case of no errors, so we return the length of our string ;)
>               RETURN_LONG((*message)->value.str.len);
524c561
<       if(Z_TYPE_P(group) == IS_ARRAY) {
---
>         if((*group)->type == IS_ARRAY) {
529,530c566,567
<               zend_hash_internal_pointer_reset_ex(group->value.ht, &pos);
<               while(zend_hash_get_current_data_ex(group->value.ht, (void **) &tmp, &pos) == SUCCESS && n < 100) 
---
>               zend_hash_internal_pointer_reset_ex((*group)->value.ht, &pos);
>               while(zend_hash_get_current_data_ex((*group)->value.ht, (void **) &tmp, &pos) == SUCCESS && n < 100) 
535c572
<                       zend_hash_move_forward_ex(group->value.ht, &pos);
---
>                       zend_hash_move_forward_ex((*group)->value.ht, &pos);
539c576
<                                               message_len, message) <0))
---
>                                               (*message)->value.str.len, (*message)->value.str.val) <0))
546c583
<               fprintf(stderr, "type is %d\n", Z_TYPE_P(group));
---
>                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", "SP_Multicast: expect groups to an array of strings or a string (got: %d)",(*group)->type);
646c683
<               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", "SP_Join: expect groups to an array of strings or a string");
---
>               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", "SP_Join: expect groups to an array of strings or a string (got: %d)",Z_TYPE_P(group));


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to