TechniqueUse the ZEND_FETCH_RESOURCE() macro: /* Completely useless function, example only */ PHP_FUNCTION(anyfetch) { zval **listid; type_of_resource *handle; YOURMODLS_FETCH(); if (ZEND_NUM_ARGS() != 1 zend_get_parameters_ex(1, &listid) == FAILURE) { WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(handle, type_of_resource *, listid, -1, "type_of_resource pointer", YOURMODG(le_YOURNAME)); RETURN_LONG(anyfetch(handle)); } CommentsThe ZEND_FETCH_RESOURCE() macro fetches the resource given by the third argument into the variable given by the first argument. It then typecasts that resource to the value given by the second argument with a resource identifier type of the sixth argument. The fourth and fifth arguments are for error-handling purposes. The fourth argument is what to return on error and the fifth argument is the name of the resource to be printed. |