I write a php extension.
How can I user Zend API do that?
where can I find some doc about file_handle->handle ?
ZEND_API zend_op_array *(*org_compile_file)(zend_file_handle *file_handle,
int type TSRMLS_DC);
ZEND_API zend_op_array *sead_compile_file(zend_file_handle *file_handle,
int type TSRMLS_DC)
{
php_stream *stream;
char *data_decode;
int data_decode_len;
/* ... */
/* Zend API Begin: This unsuccessful */
php_stream *tmpstream;
if ((tmpstream = php_stream_fopen_tmpfile()) == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create
temporary file. Check permissions in temporary files directory.");
php_stream_close(stream);
return org_compile_file(file_handle, type TSRMLS_CC);
}
numbytes = php_stream_write(tmpstream, data_decode, data_decode_len);
if (numbytes != data_decode_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes
written, possibly out of free disk space", numbytes, data_decode_len);
numbytes = -1;
}
php_stream_rewind(tmpstream);
/* Zend API End */
/* C Begin: This is OK */
FILE *tmpstream;
tmpstream = `tmpfile()`;
fwrite(data_decode, data_decode_len, 1, tmpstream);
rewind(tmpstream);
/* C End */
file_handle->handle.fp = tmpstream;
file_handle->type = ZEND_HANDLE_FP;
file_handle->opened_path = expand_filepath(file_handle->filename, `NULL`
TSRMLS_CC);
return org_compile_file(file_handle, type TSRMLS_CC);
}