PHP_FUNCTION (or ZEND_FUNCTION - they are the same)
includes the function paramters; one of those is:

zval *return_value;

which already contains an allocated zval (set to NULL).

If you want to change this in one of your own functions, you could
do something like this:

int f1(zval *return_value, ...)
{
    ... change the return_value here ...
   return SUCCESS;
}

PHP_FUNCTION(my_func)
{
    if (f1(return_value) == SUCCESS) {
        /* it worked */
        return;
    } else {
        /* it didn't work */
        php_error(....)
    }
}

Also take a look in Zend/zend.h at the definitions for
INTERNAL_FUNCTION_PARAMETERS and
INTERNAL_FUNCTION_PARAM_PASSTHRU
which can be used in you own function declarations to handle
the php function paramters.

Hope that helps,

--Wez.

PS: You're welcome to join the PHP Extension Community Library,
or PECL, on [EMAIL PROTECTED]

----- Original Message ----- 
From: "netcat" <[EMAIL PROTECTED]>
To: "PHP Development" <[EMAIL PROTECTED]>
Sent: Tuesday, October 07, 2003 9:43 AM
Subject: [PHP-DEV] help request: passing return value


> Hi internals.
> 
> [background]
> I'm newbie here and with php extensions.
> Working on php extension.
> It should give access to librep.
> I have very little experience with C.
> 
> [problem]
> 
> zval f1(some_args) {
>   zval r;
>   ...
>   return r;
> }
> 
> /* f1 can return many different types */
> 
> ZEND_FUNCTION(f2) {
>   /* working on some_args here */
>   ...
>   ...
>   /* here i need to return what
>   f1(some_args) returns */
> }
> 
> What's the best way to pass the result ?
> Any macro that would ?
> [tried]
> 
> To look at another modules.
> 
> Make f1 be (zval *) and
> "*return_value=*rep_data_converter(result);"
> in f2.
> Since zval is not very simple structure - it doesn't work.

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

Reply via email to