Using an existing extension in a custom extension
| From: | Fran�ois Lemaire | Date: | Tue, 06 Jan 2009 13:16:24 +0000 |
| Subject: | Using an existing extension in a custom extension | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-42500@lists.php.net to get a copy of this message | ||
Hello all,
here's what I'm trying to do: I'm writing a PHP extension in C and I'd like
to create a DOMDocument object in my C code that I could send back to my PHP
code. I have been trying many things, like:
#include "ext/dom/php_dom.h"
....
zval *doc;
MAKE_STD_ZVAL(doc);
object_init_ex(doc, dom_document_class_entry);
zval c_ret, constructor;
INIT_ZVAL(c_ret);
INIT_ZVAL(constructor);
ZVAL_STRING(&constructor, ZEND_CONSTRUCTOR_FUNC_NAME, 1);
call_user_function(NULL, &doc, &constructor, &c_ret, 0, NULL TSRMLS_CC);
It compiles, but when I call my function, it fails on object_init_ex (and
when I say it fails, it stops apache...). I've also tried things like:
zend_call_method(NULL, dom_document_class_entry,
dom_document_class_entry->constructor, ZEND_CONSTRUCTOR_FUNC_NAME,
strlen(ZEND_CONSTRUCTOR_FUNC_NAME), &doc, 2, "1.0", "UTF-8" TSRMLS_CC);
but it stills kill apache each time.
Does anyone know how to do this? Is this even feasible?
Regards,
François Lemaire