You are now ready to write a test script to
check that the extension works. Here’s a sample script that opens a file
test.txt, prints its contents to the standard output, and creates a copy of the
file as test.txt.new: (more…)
You are now ready to write a test script to
check that the extension works. Here’s a sample script that opens a file
test.txt, prints its contents to the standard output, and creates a copy of the
file as test.txt.new: (more…)
All macros have three forms:
one that accepts zvals, another one for zval *s, and finally one for zval **s.
The difference in their names is that the first has no suffix, the zval * has a
suffix of _P (as in one pointer), and the latter, zval **, has a suffix of _PP (two
pointers). (more…)
To remove a resource, you usually want to
use the following macro:
int zend_list_delete(int id)
The macro is passed the id of the resource, and returns either SUCCESS or
FAILURE. If the resource exists, prior to removing it from the Zend resource list,
it will call the registered destructor for the resource type. Therefore, in our
example, you don’t have to obtain the file pointer and fclose() it before remov-
ing the resource, but you can just go ahead and delete it.
Using this macro, we can now implement file_close(): (more…)
To access a resource, you need to use the fol-
lowing macro (see Table 15.6 for an explanation of its arguments):
ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id,
resource_type_name, resource_type); (more…)