Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:4718 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47589 invoked by uid 1010); 7 Oct 2003 10:15:32 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 47565 invoked from network); 7 Oct 2003 10:15:32 -0000 Received: from unknown (HELO mx.thebrainroom.net) (65.200.24.98) by pb1.pair.com with SMTP; 7 Oct 2003 10:15:32 -0000 Received: by mx.thebrainroom.net (Postfix, from userid 517) id 514CD148808C; Tue, 7 Oct 2003 03:14:08 -0700 (PDT) Received: from zaneeb.thebrainroom.net (zaneeb.thebrainroom.net [82.133.1.138]) by mx.thebrainroom.net (Postfix) with ESMTP id BE4DF1488087; Tue, 7 Oct 2003 03:14:01 -0700 (PDT) Received: from titan (titan.thebrainroom.net [82.133.1.139]) by zaneeb.thebrainroom.net (8.11.6/8.11.6) with SMTP id h97AFOK15968; Tue, 7 Oct 2003 11:15:24 +0100 Message-ID: <016401c38cbb$e8d4a990$8b018552@titan> To: "netcat" , "PHP Development" References: <3F827CC1.5070405@abox.co.il> Date: Tue, 7 Oct 2003 11:15:18 +0100 Organization: The Brain Room Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.3790.0 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0 X-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,REFERENCES version=2.55 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) X-TBR-Filter: Virus scanned and defanged Subject: Re: [PHP-DEV] help request: passing return value From: wez@thebrainroom.com ("Wez Furlong") 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 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.