Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:4721 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97850 invoked by uid 1010); 7 Oct 2003 12:38:20 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 97826 invoked from network); 7 Oct 2003 12:38:19 -0000 Received: from unknown (HELO mail.sites-secure.com) (213.189.34.71) by pb1.pair.com with SMTP; 7 Oct 2003 12:38:19 -0000 Received: by mail.sites-secure.com (CommuniGate Pro PIPE 3.5.9) with PIPE id 31179323; Tue, 07 Oct 2003 13:45:13 +0200 Received: from [192.117.106.24] (account ilya@up.co.il HELO abox.co.il) by mail.sites-secure.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 31179320 for internals@lists.php.net; Tue, 07 Oct 2003 13:45:07 +0200 Message-ID: <3F82B497.7030202@abox.co.il> Date: Tue, 07 Oct 2003 14:41:59 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3; MultiZilla v1.3.1 (a)) Gecko/20030917 X-Accept-Language: en-us, en, he, ru MIME-Version: 1.0 To: PHP Development References: <3F827CC1.5070405@abox.co.il> <016401c38cbb$e8d4a990$8b018552@titan> In-Reply-To: <016401c38cbb$e8d4a990$8b018552@titan> X-Enigmail-Version: 0.76.7.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-DoalSignature: rot-4 (smtp) Subject: Re: [PHP-DEV] help request: passing return value From: netcat@abox.co.il (netcat) Wez Furlong wrote: >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(....) > } >} > > > Thanks a lot, it seems to work. >Also take a look in Zend/zend.h at the definitions for >INTERNAL_FUNCTION_PARAMETERS and >INTERNAL_FUNCTION_PARAM_PASSTHRU > > I will. Thanks again. >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 pecl-dev@lists.php.net > >----- Original Message ----- >From: "netcat" >To: "PHP Development" >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. >> >> > > > -- NetCat ------------------------------------------------------ SPAM-Free 10mb Free email + Antivirus + POP3 + more... Get it at http://www.doal.co.il:81/free/?c=all-spam