Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:970 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53242 invoked from network); 19 Apr 2003 07:19:52 -0000 Received: from unknown (HELO ns1.xprowler.com) (64.246.18.33) by pb1.pair.com with SMTP; 19 Apr 2003 07:19:52 -0000 Received: from Marshall (ppp-66-73-176-242.dsl.sfldmi.ameritech.net [66.73.176.242]) (authenticated (0 bits)) by ns1.xprowler.com (8.11.6/8.11.6) with ESMTP id h3J7in218301 for ; Sat, 19 Apr 2003 03:44:50 -0400 Message-ID: <001a01c30644$2c0f5150$6501a8c0@Marshall> To: Date: Sat, 19 Apr 2003 03:20:34 -0400 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.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Subject: Sharing resources between modules From: marshall@magpcss.com ("Marshall A. Greenblatt") Hi guys, a quick question: Is it possible for one module to retrieve the resource structure registered by another module? For instance, assume that we have two loaded PHP modules, `php_a.so' and `php_b.so'. A script calls a PHP function defined in `php_a.so'. That function creates a structure, calls zend_register_resource(), and returns the resource ID. That same script then calls a PHP function defined in `php_b.so' that accepts the resource ID as a parameter. Would it be possible for the function in `php_b.so' to retrieve the structure associated with the resource ID registered in `php_a.so'? My thinking is that something like the following (semi-psudocode) should work: In the `php_a.so' function, which creates the resource: zval *myzvalp; mystruct *mystructp = emalloc(sizeof(mystruct)); MAKE_STD_ZVAL(myzvalp); zend_register_resource(myzvalp, mystructp, "my structure"); RETURN_RESOURCE(myzvalp); In the `php_b.so' function, which retrieves the resource: int res_type; mystruct *mystructp; zval *myzvalp; [ get myzvalp from the parameter list ] res_type = zend_fetch_list_dtor_id("my structure"); mystructp = (mystruct*)zend_fetch_resource(&myzvalp TSRMLS_CC, -1, "my structure", NULL, 1, res_type); if(mystructp) { [ mystructp should be the same as allocated in `php_a.so' ] } However, I see the `TSRMLS_CC' value in the zend_fetch_resource() call and this makes me wonder if zend_fetch_resource() is using something specific to the current module. Also, I'm guessing at the use of the zend_fetch_list_dtor_id() function, so any suggestions about a more appropriate way to do this (or a pointer to code where this is currently being done) would be appreciated. Thanks, Marshall