Hello again,
Well, two books (Advanced PHP Programming [very good] & Building Custom PHP
Extensions [not so good]) and a bit of experimentation later, I have
narrowed my problem down to the following:
If I call php_stream_opendir from within an exposed function it works fine
but dies with the segfault as earlier described when I try to call it from a
helper function. For example:
PHP_FUNCTION(tmpl_reload)
{
if (ZEND_NUM_ARGS() != 0) {
WRONG_PARAM_COUNT;
}
php_stream *base_dir = NULL;
php_stream_context *context = NULL;
if (TMPL_G(template_dir) != NULL)
base_dir = php_stream_opendir (TMPL_G(template_dir),
ENFORCE_SAFE_MODE|REPORT_ERRORS, context);
if (base_dir)
{
RETURN_BOOL (1);
}
else
{
RETURN_BOOL (0);
}
}
This function works fine and always returns true/1, however:
int do_reload ()
{
// My declares
php_stream *base_dir = NULL;
php_stream_context *context = NULL;
int count = 0;
// Zend declares
TSRMLS_FETCH();
// Start from scratch
TMPL_G(tmpl_loaded) = 0;
if (TMPL_G(template_dir) != NULL)
base_dir = php_stream_opendir (TMPL_G(template_dir),
ENFORCE_SAFE_MODE|REPORT_ERRORS, context);
TMPL_G(tmpl_dir_valid) = (base_dir) ? 1 : 0;
return 1;
}
Causes a segfault. So, my question is as follows - is there a specific way
to declare helper functions so that they have whatever is available to the
module functions so that I can avoid this segfault?
Regards,
Mikey
"What are you doing with that cat dear, it looks half dead!" - Mrs
Schroedinger