mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
Merge branch 'resource-api' of https://github.com/laruence/php-src
This commit is contained in:
commit
6fe8dce671
118
Zend/zend_list.c
118
Zend/zend_list.c
@ -89,77 +89,91 @@ ZEND_API int zend_list_close(zend_resource *res)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
ZEND_API zend_resource* zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type)
|
||||
ZEND_API zend_resource* zend_register_resource(void *rsrc_pointer, int rsrc_type)
|
||||
{
|
||||
zval *zv;
|
||||
|
||||
zv = zend_list_insert(rsrc_pointer, rsrc_type);
|
||||
|
||||
if (rsrc_result) {
|
||||
ZVAL_COPY_VALUE(rsrc_result, zv);
|
||||
return Z_RES_P(rsrc_result);
|
||||
} else {
|
||||
return Z_RES_P(zv);
|
||||
}
|
||||
return Z_RES_P(zv);
|
||||
}
|
||||
|
||||
ZEND_API void *zend_fetch_resource(zval *passed_id, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...)
|
||||
ZEND_API void *zend_fetch_resource2(zend_resource *res, const char *resource_type_name, int resource_type1, int resource_type2)
|
||||
{
|
||||
int actual_resource_type;
|
||||
// void *resource;
|
||||
va_list resource_types;
|
||||
int i;
|
||||
zend_resource *res;
|
||||
const char *space;
|
||||
const char *class_name;
|
||||
|
||||
if (default_id==-1) { /* use id */
|
||||
if (!passed_id) {
|
||||
if (resource_type_name) {
|
||||
class_name = get_active_class_name(&space);
|
||||
zend_error(E_WARNING, "%s%s%s(): no %s resource supplied", class_name, space, get_active_function_name(), resource_type_name);
|
||||
}
|
||||
return NULL;
|
||||
} else if (Z_TYPE_P(passed_id) != IS_RESOURCE) {
|
||||
if (resource_type_name) {
|
||||
class_name = get_active_class_name(&space);
|
||||
zend_error(E_WARNING, "%s%s%s(): supplied argument is not a valid %s resource", class_name, space, get_active_function_name(), resource_type_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
passed_id = zend_hash_index_find(&EG(regular_list), default_id);
|
||||
if (!passed_id) {
|
||||
if (resource_type_name) {
|
||||
class_name = get_active_class_name(&space);
|
||||
zend_error(E_WARNING, "%s%s%s(): %d is not a valid %s resource", class_name, space, get_active_function_name(), default_id, resource_type_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (resource_type1 == res->type) {
|
||||
return res->ptr;
|
||||
}
|
||||
res = Z_RES_P(passed_id);
|
||||
actual_resource_type = res->type;
|
||||
|
||||
va_start(resource_types, num_resource_types);
|
||||
for (i=0; i<num_resource_types; i++) {
|
||||
if (actual_resource_type == va_arg(resource_types, int)) {
|
||||
va_end(resource_types);
|
||||
if (found_resource_type) {
|
||||
*found_resource_type = actual_resource_type;
|
||||
}
|
||||
return res->ptr;
|
||||
}
|
||||
if (resource_type2 == res->type) {
|
||||
return res->ptr;
|
||||
}
|
||||
va_end(resource_types);
|
||||
|
||||
if (resource_type_name) {
|
||||
class_name = get_active_class_name(&space);
|
||||
const char *space;
|
||||
const char *class_name = get_active_class_name(&space);
|
||||
zend_error(E_WARNING, "%s%s%s(): supplied resource is not a valid %s resource", class_name, space, get_active_function_name(), resource_type_name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZEND_API void *zend_fetch_resource(zend_resource *res, const char *resource_type_name, int resource_type)
|
||||
{
|
||||
if (resource_type == res->type) {
|
||||
return res->ptr;
|
||||
}
|
||||
|
||||
if (resource_type_name) {
|
||||
const char *space;
|
||||
const char *class_name = get_active_class_name(&space);
|
||||
zend_error(E_WARNING, "%s%s%s(): supplied resource is not a valid %s resource", class_name, space, get_active_function_name(), resource_type_name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZEND_API void *zend_fetch_resource_ex(zval *res, const char *resource_type_name, int resource_type)
|
||||
{
|
||||
const char *space, *class_name;
|
||||
if (res == NULL) {
|
||||
if (resource_type_name) {
|
||||
class_name = get_active_class_name(&space);
|
||||
zend_error(E_WARNING, "%s%s%s(): no %s resource supplied", class_name, space, get_active_function_name(), resource_type_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (Z_TYPE_P(res) != IS_RESOURCE) {
|
||||
if (resource_type_name) {
|
||||
class_name = get_active_class_name(&space);
|
||||
zend_error(E_WARNING, "%s%s%s(): supplied argument is not a valid %s resource", class_name, space, get_active_function_name(), resource_type_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return zend_fetch_resource(Z_RES_P(res), resource_type_name, resource_type);
|
||||
}
|
||||
|
||||
ZEND_API void *zend_fetch_resource2_ex(zval *res, const char *resource_type_name, int resource_type1, int resource_type2)
|
||||
{
|
||||
const char *space, *class_name;
|
||||
if (res == NULL) {
|
||||
if (resource_type_name) {
|
||||
class_name = get_active_class_name(&space);
|
||||
zend_error(E_WARNING, "%s%s%s(): no %s resource supplied", class_name, space, get_active_function_name(), resource_type_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (Z_TYPE_P(res) != IS_RESOURCE) {
|
||||
if (resource_type_name) {
|
||||
class_name = get_active_class_name(&space);
|
||||
zend_error(E_WARNING, "%s%s%s(): supplied argument is not a valid %s resource", class_name, space, get_active_function_name(), resource_type_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return zend_fetch_resource2(Z_RES_P(res), resource_type_name, resource_type1, resource_type2);
|
||||
}
|
||||
|
||||
void list_entry_destructor(zval *zv)
|
||||
{
|
||||
zend_resource *res = Z_RES_P(zv);
|
||||
|
@ -59,40 +59,17 @@ ZEND_API int zend_list_free(zend_resource *res);
|
||||
ZEND_API int zend_list_delete(zend_resource *res);
|
||||
ZEND_API int zend_list_close(zend_resource *res);
|
||||
|
||||
ZEND_API zend_resource *zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type);
|
||||
ZEND_API void *zend_fetch_resource(zval *passed_id, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...);
|
||||
ZEND_API zend_resource *zend_register_resource(void *rsrc_pointer, int rsrc_type);
|
||||
ZEND_API void *zend_fetch_resource(zend_resource *res, const char *resource_type_name, int resource_type);
|
||||
ZEND_API void *zend_fetch_resource2(zend_resource *res, const char *resource_type_name, int resource_type, int resource_type2);
|
||||
ZEND_API void *zend_fetch_resource_ex(zval *res, const char *resource_type_name, int resource_type);
|
||||
ZEND_API void *zend_fetch_resource2_ex(zval *res, const char *resource_type_name, int resource_type, int resource_type2);
|
||||
|
||||
ZEND_API const char *zend_rsrc_list_get_rsrc_type(zend_resource *res);
|
||||
ZEND_API int zend_fetch_list_dtor_id(const char *type_name);
|
||||
|
||||
extern ZEND_API int le_index_ptr; /* list entry type for index pointers */
|
||||
|
||||
#define ZEND_VERIFY_RESOURCE(rsrc) \
|
||||
if (!rsrc) { \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
#define ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \
|
||||
rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 1, resource_type); \
|
||||
ZEND_VERIFY_RESOURCE(rsrc);
|
||||
|
||||
#define ZEND_FETCH_RESOURCE_NO_RETURN(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \
|
||||
(rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 1, resource_type))
|
||||
|
||||
#define ZEND_FETCH_RESOURCE2(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1, resource_type2) \
|
||||
rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2); \
|
||||
ZEND_VERIFY_RESOURCE(rsrc);
|
||||
|
||||
#define ZEND_FETCH_RESOURCE2_NO_RETURN(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1, resource_type2) \
|
||||
(rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2))
|
||||
|
||||
#define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type) \
|
||||
zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type);
|
||||
|
||||
#define ZEND_GET_RESOURCE_TYPE_ID(le_id, le_type_name) \
|
||||
if (le_id == 0) { \
|
||||
le_id = zend_fetch_list_dtor_id(le_type_name); \
|
||||
}
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif
|
||||
|
@ -230,7 +230,7 @@ void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
|
||||
}
|
||||
|
||||
if (!Z_ISUNDEF(ch->handlers->std_err)) {
|
||||
stream = zend_fetch_resource(&ch->handlers->std_err, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
|
||||
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->std_err, NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
if (stream == NULL) {
|
||||
if (reporterror) {
|
||||
php_error_docref(NULL, E_WARNING, "CURLOPT_STDERR resource has gone away, resetting to stderr");
|
||||
@ -242,7 +242,7 @@ void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
|
||||
}
|
||||
}
|
||||
if (ch->handlers->read && !Z_ISUNDEF(ch->handlers->read->stream)) {
|
||||
stream = zend_fetch_resource(&ch->handlers->read->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
|
||||
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->read->stream, NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
if (stream == NULL) {
|
||||
if (reporterror) {
|
||||
php_error_docref(NULL, E_WARNING, "CURLOPT_INFILE resource has gone away, resetting to default");
|
||||
@ -256,7 +256,7 @@ void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
|
||||
}
|
||||
}
|
||||
if (ch->handlers->write_header && !Z_ISUNDEF(ch->handlers->write_header->stream)) {
|
||||
stream = zend_fetch_resource(&ch->handlers->write_header->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
|
||||
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->write_header->stream, NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
if (stream == NULL) {
|
||||
if (reporterror) {
|
||||
php_error_docref(NULL, E_WARNING, "CURLOPT_WRITEHEADER resource has gone away, resetting to default");
|
||||
@ -270,7 +270,7 @@ void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
|
||||
}
|
||||
}
|
||||
if (ch->handlers->write && !Z_ISUNDEF(ch->handlers->write->stream)) {
|
||||
stream = zend_fetch_resource(&ch->handlers->write->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
|
||||
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->write->stream, NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
if (stream == NULL) {
|
||||
if (reporterror) {
|
||||
php_error_docref(NULL, E_WARNING, "CURLOPT_FILE resource has gone away, resetting to default");
|
||||
@ -1896,7 +1896,7 @@ PHP_FUNCTION(curl_init)
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, ch, le_curl);
|
||||
ZVAL_RES(return_value, zend_register_resource(ch, le_curl));
|
||||
ch->res = Z_RES_P(return_value);
|
||||
}
|
||||
/* }}} */
|
||||
@ -1913,7 +1913,9 @@ PHP_FUNCTION(curl_copy_handle)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
cp = curl_easy_duphandle(ch->cp);
|
||||
if (!cp) {
|
||||
@ -1994,7 +1996,7 @@ PHP_FUNCTION(curl_copy_handle)
|
||||
/* Keep track of cloned copies to avoid invoking curl destructors for every clone */
|
||||
ch->clone++;
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, dupch, le_curl);
|
||||
ZVAL_RES(return_value, zend_register_resource(dupch, le_curl));
|
||||
dupch->res = Z_RES_P(return_value);
|
||||
}
|
||||
/* }}} */
|
||||
@ -2279,11 +2281,10 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
case CURLOPT_STDERR:
|
||||
case CURLOPT_WRITEHEADER: {
|
||||
FILE *fp = NULL;
|
||||
int type;
|
||||
php_stream *what = NULL;
|
||||
|
||||
if (Z_TYPE_P(zvalue) != IS_NULL) {
|
||||
what = zend_fetch_resource(zvalue, -1, "File-Handle", &type, 1, php_file_le_stream(), php_file_le_pstream());
|
||||
what = (php_stream *)zend_fetch_resource2_ex(zvalue, "File-Handle", php_file_le_stream(), php_file_le_pstream());
|
||||
if (!what) {
|
||||
return FAILURE;
|
||||
}
|
||||
@ -2719,9 +2720,8 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
|
||||
case CURLOPT_SHARE:
|
||||
{
|
||||
php_curlsh *sh = NULL;
|
||||
ZEND_FETCH_RESOURCE_NO_RETURN(sh, php_curlsh *, zvalue, -1, le_curl_share_handle_name, le_curl_share_handle);
|
||||
if (sh) {
|
||||
php_curlsh *sh;
|
||||
if ((sh = (php_curlsh *)zend_fetch_resource_ex(zvalue, le_curl_share_handle_name, le_curl_share_handle))) {
|
||||
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
|
||||
}
|
||||
}
|
||||
@ -2765,7 +2765,9 @@ PHP_FUNCTION(curl_setopt)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (options <= 0 && options != CURLOPT_SAFE_UPLOAD) {
|
||||
php_error_docref(NULL, E_WARNING, "Invalid curl configuration option");
|
||||
@ -2793,7 +2795,9 @@ PHP_FUNCTION(curl_setopt_array)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(arr), option, string_key, entry) {
|
||||
if (string_key) {
|
||||
@ -2837,7 +2841,9 @@ PHP_FUNCTION(curl_exec)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
_php_curl_verify_handlers(ch, 1);
|
||||
|
||||
@ -2853,7 +2859,7 @@ PHP_FUNCTION(curl_exec)
|
||||
|
||||
if (!Z_ISUNDEF(ch->handlers->std_err)) {
|
||||
php_stream *stream;
|
||||
stream = zend_fetch_resource(&ch->handlers->std_err, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
|
||||
stream = (php_stream*)zend_fetch_resource2_ex(&ch->handlers->std_err, NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
if (stream) {
|
||||
php_stream_flush(stream);
|
||||
}
|
||||
@ -2892,7 +2898,9 @@ PHP_FUNCTION(curl_getinfo)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ZEND_NUM_ARGS() < 2) {
|
||||
char *s_code;
|
||||
@ -3097,7 +3105,9 @@ PHP_FUNCTION(curl_error)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ch->err.str[CURL_ERROR_SIZE] = 0;
|
||||
RETURN_STRING(ch->err.str);
|
||||
@ -3115,7 +3125,9 @@ PHP_FUNCTION(curl_errno)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(ch->err.no);
|
||||
}
|
||||
@ -3132,7 +3144,9 @@ PHP_FUNCTION(curl_close)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ch->in_callback) {
|
||||
php_error_docref(NULL, E_WARNING, "Attempt to close cURL handle from a callback");
|
||||
@ -3308,7 +3322,9 @@ PHP_FUNCTION(curl_reset)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ch->in_callback) {
|
||||
php_error_docref(NULL, E_WARNING, "Attempt to reset cURL handle from a callback");
|
||||
@ -3336,7 +3352,9 @@ PHP_FUNCTION(curl_escape)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((res = curl_easy_escape(ch->cp, str, str_len))) {
|
||||
RETVAL_STRING(res);
|
||||
@ -3361,7 +3379,9 @@ PHP_FUNCTION(curl_unescape)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((out = curl_easy_unescape(ch->cp, str, str_len, &out_len))) {
|
||||
RETVAL_STRINGL(out, out_len);
|
||||
@ -3386,7 +3406,9 @@ PHP_FUNCTION(curl_pause)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(curl_easy_pause(ch->cp, bitmask));
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ PHP_FUNCTION(curl_multi_init)
|
||||
|
||||
zend_llist_init(&mh->easyh, sizeof(zval), _php_curl_multi_cleanup_list, 0);
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, mh, le_curl_multi_handle);
|
||||
RETURN_RES(zend_register_resource(mh, le_curl_multi_handle));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -82,8 +82,13 @@ PHP_FUNCTION(curl_multi_add_handle)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, z_ch, -1, le_curl_name, le_curl);
|
||||
if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(z_ch), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
_php_curl_cleanup_handle(ch);
|
||||
|
||||
@ -104,13 +109,10 @@ void _php_curl_multi_cleanup_list(void *data) /* {{{ */
|
||||
if (!z_ch) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Z_RES_P(z_ch)->ptr == NULL) {
|
||||
if (!Z_RES_P(z_ch)->ptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
ch = zend_fetch_resource(z_ch, -1, le_curl_name, NULL, 1, le_curl);
|
||||
if (!ch) {
|
||||
if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(z_ch), le_curl_name, le_curl)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -140,8 +142,13 @@ PHP_FUNCTION(curl_multi_remove_handle)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, z_ch, -1, le_curl_name, le_curl);
|
||||
if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(z_ch), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETVAL_LONG((zend_long)curl_multi_remove_handle(mh->multi, ch->cp));
|
||||
zend_llist_del_element(&mh->easyh, &z_ch, (int (*)(void *, void *))curl_compare_resources);
|
||||
@ -176,7 +183,9 @@ PHP_FUNCTION(curl_multi_select)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
|
||||
if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
_make_timeval_struct(&to, timeout);
|
||||
|
||||
@ -206,17 +215,22 @@ PHP_FUNCTION(curl_multi_exec)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
|
||||
if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
{
|
||||
zend_llist_position pos;
|
||||
php_curl *ch;
|
||||
zval *pz_ch;
|
||||
|
||||
for(pz_ch = (zval *)zend_llist_get_first_ex(&mh->easyh, &pos); pz_ch;
|
||||
for (pz_ch = (zval *)zend_llist_get_first_ex(&mh->easyh, &pos); pz_ch;
|
||||
pz_ch = (zval *)zend_llist_get_next_ex(&mh->easyh, &pos)) {
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, pz_ch, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(pz_ch), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
_php_curl_verify_handlers(ch, 1);
|
||||
}
|
||||
}
|
||||
@ -241,7 +255,9 @@ PHP_FUNCTION(curl_multi_getcontent)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, z_ch, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(z_ch), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ch->handlers->write->method == PHP_CURL_RETURN) {
|
||||
if (!ch->handlers->write->buf.s) {
|
||||
@ -269,7 +285,9 @@ PHP_FUNCTION(curl_multi_info_read)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
|
||||
if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
tmp_msg = curl_multi_info_read(mh->multi, &queued_msgs);
|
||||
if (tmp_msg == NULL) {
|
||||
@ -294,7 +312,9 @@ PHP_FUNCTION(curl_multi_info_read)
|
||||
for(pz_ch = (zval *)zend_llist_get_first_ex(&mh->easyh, &pos); pz_ch;
|
||||
pz_ch = (zval *)zend_llist_get_next_ex(&mh->easyh, &pos)) {
|
||||
|
||||
ZEND_FETCH_RESOURCE(ch, php_curl *, pz_ch, -1, le_curl_name, le_curl);
|
||||
if ((ch = (php_curl *)zend_fetch_resource(Z_RES_P(pz_ch), le_curl_name, le_curl)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (ch->cp == tmp_msg->easy_handle) {
|
||||
|
||||
/* we are adding a reference to the underlying php_curl
|
||||
@ -329,7 +349,9 @@ PHP_FUNCTION(curl_multi_close)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
|
||||
if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zend_list_close(Z_RES_P(z_mh));
|
||||
}
|
||||
@ -347,7 +369,7 @@ void _php_curl_multi_close(zend_resource *rsrc) /* {{{ */
|
||||
pz_ch = (zval *)zend_llist_get_next_ex(&mh->easyh, &pos)) {
|
||||
/* ptr is NULL means it already be freed */
|
||||
if (Z_RES_P(pz_ch)->ptr) {
|
||||
ch = (php_curl *) zend_fetch_resource(pz_ch, -1, le_curl_name, NULL, 1, le_curl);
|
||||
ch = (php_curl *) zend_fetch_resource(Z_RES_P(pz_ch), le_curl_name, le_curl);
|
||||
_php_curl_verify_handlers(ch, 0);
|
||||
}
|
||||
}
|
||||
@ -424,7 +446,9 @@ PHP_FUNCTION(curl_multi_setopt)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
|
||||
if ((mh = (php_curlm *)zend_fetch_resource(Z_RES_P(z_mh), le_curl_multi_handle_name, le_curl_multi_handle)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!_php_curl_multi_setopt(mh, options, zvalue, return_value)) {
|
||||
RETURN_TRUE;
|
||||
|
@ -46,7 +46,7 @@ PHP_FUNCTION(curl_share_init)
|
||||
|
||||
sh->share = curl_share_init();
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, sh, le_curl_share_handle);
|
||||
RETURN_RES(zend_register_resource(sh, le_curl_share_handle));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -61,7 +61,10 @@ PHP_FUNCTION(curl_share_close)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(sh, php_curlsh *, z_sh, -1, le_curl_share_handle_name, le_curl_share_handle);
|
||||
if ((sh = (php_curlsh *)zend_fetch_resource(Z_RES_P(z_sh), le_curl_share_handle_name, le_curl_share_handle)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zend_list_close(Z_RES_P(z_sh));
|
||||
}
|
||||
/* }}} */
|
||||
@ -103,7 +106,9 @@ PHP_FUNCTION(curl_share_setopt)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(sh, php_curlsh *, zid, -1, le_curl_share_handle_name, le_curl_share_handle);
|
||||
if ((sh = (php_curlsh *)zend_fetch_resource(Z_RES_P(zid), le_curl_share_handle_name, le_curl_share_handle)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!_php_curl_share_setopt(sh, options, zvalue, return_value)) {
|
||||
RETURN_TRUE;
|
||||
|
@ -277,7 +277,9 @@ static size_t php_dba_make_key(zval *key, char **key_str, char **key_free)
|
||||
|
||||
|
||||
#define DBA_FETCH_RESOURCE(info, id) \
|
||||
ZEND_FETCH_RESOURCE2(info, dba_info *, id, -1, "DBA identifier", le_db, le_pdb);
|
||||
if ((info = (dba_info *)zend_fetch_resource2(Z_RES_P(id), "DBA identifier", le_db, le_pdb)) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
#define DBA_ID_GET2 DBA_ID_PARS; DBA_GET2; DBA_FETCH_RESOURCE(info, id)
|
||||
#define DBA_ID_GET2_3 DBA_ID_PARS; DBA_GET2_3; DBA_FETCH_RESOURCE(info, id)
|
||||
@ -951,7 +953,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, info, (persistent ? le_pdb : le_db));
|
||||
RETVAL_RES(zend_register_resource(info, (persistent ? le_pdb : le_db)));
|
||||
FREENOW;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -338,14 +338,14 @@ PHP_MINFO_FUNCTION(enchant)
|
||||
/* }}} */
|
||||
|
||||
#define PHP_ENCHANT_GET_BROKER \
|
||||
ZEND_FETCH_RESOURCE(pbroker, enchant_broker *, broker, -1, "enchant_broker", le_enchant_broker); \
|
||||
pbroker = (enchant_broker *)zend_fetch_resource(Z_RES_P(broker), "enchant_broker", le_enchant_broker); \
|
||||
if (!pbroker || !pbroker->pbroker) { \
|
||||
php_error_docref(NULL, E_WARNING, "%s", "Resource broker invalid"); \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
#define PHP_ENCHANT_GET_DICT \
|
||||
ZEND_FETCH_RESOURCE(pdict, enchant_dict *, dict, -1, "enchant_dict", le_enchant_dict); \
|
||||
pdict = (enchant_dict *)zend_fetch_resource(Z_RES_P(dict), "enchant_dict", le_enchant_dict); \
|
||||
if (!pdict || !pdict->pdict) { \
|
||||
php_error_docref(NULL, E_WARNING, "%s", "Invalid dictionary resource."); \
|
||||
RETURN_FALSE; \
|
||||
@ -369,7 +369,8 @@ PHP_FUNCTION(enchant_broker_init)
|
||||
broker->pbroker = pbroker;
|
||||
broker->dict = NULL;
|
||||
broker->dictcnt = 0;
|
||||
broker->rsrc = ZEND_REGISTER_RESOURCE(return_value, broker, le_enchant_broker);
|
||||
broker->rsrc = zend_register_resource(broker, le_enchant_broker);
|
||||
RETURN_RES(broker->rsrc);
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@ -566,8 +567,9 @@ PHP_FUNCTION(enchant_broker_request_dict)
|
||||
dict->pdict = d;
|
||||
pbroker->dict[pos] = dict;
|
||||
|
||||
dict->rsrc = ZEND_REGISTER_RESOURCE(return_value, dict, le_enchant_dict);
|
||||
dict->rsrc = zend_register_resource(dict, le_enchant_dict);
|
||||
pbroker->rsrc->gc.refcount++;
|
||||
RETURN_RES(dict->rsrc);
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@ -616,8 +618,9 @@ PHP_FUNCTION(enchant_broker_request_pwl_dict)
|
||||
dict->pdict = d;
|
||||
pbroker->dict[pos] = dict;
|
||||
|
||||
dict->rsrc = ZEND_REGISTER_RESOURCE(return_value, dict, le_enchant_dict);
|
||||
dict->rsrc = zend_register_resource(dict, le_enchant_dict);
|
||||
pbroker->rsrc->gc.refcount++;
|
||||
RETURN_RES(dict->rsrc);
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ PHP_FUNCTION(finfo_open)
|
||||
if (object) {
|
||||
FILEINFO_REGISTER_OBJECT(object, finfo);
|
||||
} else {
|
||||
ZEND_REGISTER_RESOURCE(return_value, finfo, le_fileinfo);
|
||||
RETURN_RES(zend_register_resource(finfo, le_fileinfo));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -370,7 +370,10 @@ PHP_FUNCTION(finfo_close)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zfinfo) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(finfo, php_fileinfo *, zfinfo, -1, "file_info", le_fileinfo);
|
||||
|
||||
if ((finfo = (php_fileinfo *)zend_fetch_resource(Z_RES_P(zfinfo), "file_info", le_fileinfo)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zend_list_close(Z_RES_P(zfinfo));
|
||||
|
||||
@ -396,7 +399,9 @@ PHP_FUNCTION(finfo_set_flags)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &zfinfo, &options) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(finfo, php_fileinfo *, zfinfo, -1, "file_info", le_fileinfo);
|
||||
if ((finfo = (php_fileinfo *)zend_fetch_resource(Z_RES_P(zfinfo), "file_info", le_fileinfo)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
FINFO_SET_OPTION(finfo->magic, options)
|
||||
@ -461,7 +466,9 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|lr", &zfinfo, &buffer, &buffer_len, &options, &zcontext) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(finfo, php_fileinfo *, zfinfo, -1, "file_info", le_fileinfo);
|
||||
if ((finfo = (php_fileinfo *)zend_fetch_resource(Z_RES_P(zfinfo), "file_info", le_fileinfo)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
magic = finfo->magic;
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,7 @@ PHP_FUNCTION(ftp_connect)
|
||||
ftp->use_ssl = 0;
|
||||
#endif
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, ftp, le_ftpbuf);
|
||||
RETURN_RES(zend_register_resource(ftp, le_ftpbuf));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -402,7 +402,7 @@ PHP_FUNCTION(ftp_ssl_connect)
|
||||
/* enable ssl */
|
||||
ftp->use_ssl = 1;
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, ftp, le_ftpbuf);
|
||||
RETURN_RES(zend_register_resource(ftp, le_ftpbuf));
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
@ -420,7 +420,9 @@ PHP_FUNCTION(ftp_login)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* log in */
|
||||
if (!ftp_login(ftp, user, pass)) {
|
||||
@ -444,7 +446,9 @@ PHP_FUNCTION(ftp_pwd)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!(pwd = ftp_pwd(ftp))) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
@ -466,7 +470,9 @@ PHP_FUNCTION(ftp_cdup)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!ftp_cdup(ftp)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
@ -490,7 +496,9 @@ PHP_FUNCTION(ftp_chdir)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* change directories */
|
||||
if (!ftp_chdir(ftp, dir)) {
|
||||
@ -515,7 +523,9 @@ PHP_FUNCTION(ftp_exec)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* execute serverside command */
|
||||
if (!ftp_exec(ftp, cmd)) {
|
||||
@ -540,7 +550,9 @@ PHP_FUNCTION(ftp_raw)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* execute arbitrary ftp command */
|
||||
ftp_raw(ftp, cmd, return_value);
|
||||
@ -561,7 +573,9 @@ PHP_FUNCTION(ftp_mkdir)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* create directorie */
|
||||
if (NULL == (tmp = ftp_mkdir(ftp, dir))) {
|
||||
@ -586,7 +600,9 @@ PHP_FUNCTION(ftp_rmdir)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* remove directorie */
|
||||
if (!ftp_rmdir(ftp, dir)) {
|
||||
@ -612,7 +628,9 @@ PHP_FUNCTION(ftp_chmod)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!ftp_chmod(ftp, mode, filename, filename_len)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
@ -636,7 +654,9 @@ PHP_FUNCTION(ftp_alloc)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ret = ftp_alloc(ftp, size, zresponse ? &response : NULL);
|
||||
if (response) {
|
||||
@ -665,7 +685,9 @@ PHP_FUNCTION(ftp_nlist)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* get list of files */
|
||||
if (NULL == (nlist = ftp_nlist(ftp, dir))) {
|
||||
@ -694,7 +716,9 @@ PHP_FUNCTION(ftp_rawlist)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* get raw directory listing */
|
||||
if (NULL == (llist = ftp_list(ftp, dir, recursive))) {
|
||||
@ -721,7 +745,9 @@ PHP_FUNCTION(ftp_systype)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (NULL == (syst = ftp_syst(ftp))) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
@ -748,8 +774,10 @@ PHP_FUNCTION(ftp_fget)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
php_stream_from_zval(stream, z_file);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
php_stream_from_res(stream, Z_RES_P(z_file));
|
||||
XTYPE(xtype, mode);
|
||||
|
||||
/* ignore autoresume if autoseek is switched off */
|
||||
@ -792,8 +820,10 @@ PHP_FUNCTION(ftp_nb_fget)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
php_stream_from_zval(stream, z_file);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
php_stream_from_res(stream, Z_RES_P(z_file));
|
||||
XTYPE(xtype, mode);
|
||||
|
||||
/* ignore autoresume if autoseek is switched off */
|
||||
@ -836,7 +866,9 @@ PHP_FUNCTION(ftp_pasv)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!ftp_pasv(ftp, pasv ? 1 : 0)) {
|
||||
RETURN_FALSE;
|
||||
@ -862,7 +894,9 @@ PHP_FUNCTION(ftp_get)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
XTYPE(xtype, mode);
|
||||
|
||||
/* ignore autoresume if autoseek is switched off */
|
||||
@ -926,7 +960,9 @@ PHP_FUNCTION(ftp_nb_get)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
XTYPE(xtype, mode);
|
||||
|
||||
/* ignore autoresume if autoseek is switched off */
|
||||
@ -992,7 +1028,9 @@ PHP_FUNCTION(ftp_nb_continue)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!ftp->nb) {
|
||||
php_error_docref(NULL, E_WARNING, "no nbronous transfer to continue.");
|
||||
@ -1034,7 +1072,9 @@ PHP_FUNCTION(ftp_fput)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
php_stream_from_zval(stream, z_file);
|
||||
XTYPE(xtype, mode);
|
||||
|
||||
@ -1082,8 +1122,10 @@ PHP_FUNCTION(ftp_nb_fput)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
php_stream_from_zval(stream, z_file);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
php_stream_from_res(stream, Z_RES_P(z_file));
|
||||
XTYPE(xtype, mode);
|
||||
|
||||
/* ignore autoresume if autoseek is switched off */
|
||||
@ -1134,7 +1176,9 @@ PHP_FUNCTION(ftp_put)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
XTYPE(xtype, mode);
|
||||
|
||||
if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", REPORT_ERRORS, NULL))) {
|
||||
@ -1187,7 +1231,9 @@ PHP_FUNCTION(ftp_nb_put)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
XTYPE(xtype, mode);
|
||||
|
||||
if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", REPORT_ERRORS, NULL))) {
|
||||
@ -1244,7 +1290,9 @@ PHP_FUNCTION(ftp_size)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* get file size */
|
||||
RETURN_LONG(ftp_size(ftp, file));
|
||||
@ -1264,7 +1312,9 @@ PHP_FUNCTION(ftp_mdtm)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* get file mod time */
|
||||
RETURN_LONG(ftp_mdtm(ftp, file));
|
||||
@ -1284,7 +1334,9 @@ PHP_FUNCTION(ftp_rename)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* rename the file */
|
||||
if (!ftp_rename(ftp, src, dest)) {
|
||||
@ -1309,7 +1361,9 @@ PHP_FUNCTION(ftp_delete)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* delete the file */
|
||||
if (!ftp_delete(ftp, file)) {
|
||||
@ -1334,7 +1388,9 @@ PHP_FUNCTION(ftp_site)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* send the site command */
|
||||
if (!ftp_site(ftp, cmd)) {
|
||||
@ -1357,7 +1413,9 @@ PHP_FUNCTION(ftp_close)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ftp_quit(ftp);
|
||||
|
||||
@ -1377,7 +1435,9 @@ PHP_FUNCTION(ftp_set_option)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch (option) {
|
||||
case PHP_FTP_OPT_TIMEOUT_SEC:
|
||||
@ -1422,7 +1482,9 @@ PHP_FUNCTION(ftp_get_option)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
|
||||
if ((ftp = (ftpbuf_t *)zend_fetch_resource(Z_RES_P(z_ftp), le_ftpbuf_name, le_ftpbuf)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch (option) {
|
||||
case PHP_FTP_OPT_TIMEOUT_SEC:
|
||||
|
373
ext/gd/gd.c
373
ext/gd/gd.c
@ -1538,7 +1538,9 @@ PHP_FUNCTION(imagesetstyle)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* copy the style values in the stylearr */
|
||||
stylearr = safe_emalloc(sizeof(int), zend_hash_num_elements(HASH_OF(styles)), 0);
|
||||
@ -1577,7 +1579,7 @@ PHP_FUNCTION(imagecreatetruecolor)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
|
||||
RETURN_RES(zend_register_resource(im, le_gd));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1592,7 +1594,9 @@ PHP_FUNCTION(imageistruecolor)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_BOOL(im->trueColor);
|
||||
}
|
||||
@ -1611,7 +1615,9 @@ PHP_FUNCTION(imagetruecolortopalette)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ncolors <= 0) {
|
||||
php_error_docref(NULL, E_WARNING, "Number of colors has to be greater than zero");
|
||||
@ -1634,7 +1640,9 @@ PHP_FUNCTION(imagepalettetotruecolor)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (gdImagePaletteToTrueColor(im) == 0) {
|
||||
RETURN_FALSE;
|
||||
@ -1656,8 +1664,12 @@ PHP_FUNCTION(imagecolormatch)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im1, gdImagePtr, IM1, -1, "Image", le_gd);
|
||||
ZEND_FETCH_RESOURCE(im2, gdImagePtr, IM2, -1, "Image", le_gd);
|
||||
if ((im1 = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM1), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if ((im2 = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM2), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
result = gdImageColorMatch(im1, im2);
|
||||
switch (result) {
|
||||
@ -1695,7 +1707,9 @@ PHP_FUNCTION(imagesetthickness)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageSetThickness(im, thick);
|
||||
|
||||
@ -1715,7 +1729,9 @@ PHP_FUNCTION(imagefilledellipse)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageFilledEllipse(im, cx, cy, w, h, color);
|
||||
|
||||
@ -1736,7 +1752,9 @@ PHP_FUNCTION(imagefilledarc)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
e = E;
|
||||
if (e < 0) {
|
||||
@ -1766,7 +1784,10 @@ PHP_FUNCTION(imagealphablending)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageAlphaBlending(im, blend);
|
||||
|
||||
RETURN_TRUE;
|
||||
@ -1785,7 +1806,10 @@ PHP_FUNCTION(imagesavealpha)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageSaveAlpha(im, save);
|
||||
|
||||
RETURN_TRUE;
|
||||
@ -1804,7 +1828,10 @@ PHP_FUNCTION(imagelayereffect)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageAlphaBlending(im, effect);
|
||||
|
||||
RETURN_TRUE;
|
||||
@ -1824,7 +1851,10 @@ PHP_FUNCTION(imagecolorallocatealpha)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ct = gdImageColorAllocateAlpha(im, red, green, blue, alpha);
|
||||
if (ct < 0) {
|
||||
RETURN_FALSE;
|
||||
@ -1845,7 +1875,9 @@ PHP_FUNCTION(imagecolorresolvealpha)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(gdImageColorResolveAlpha(im, red, green, blue, alpha));
|
||||
}
|
||||
@ -1863,7 +1895,9 @@ PHP_FUNCTION(imagecolorclosestalpha)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(gdImageColorClosestAlpha(im, red, green, blue, alpha));
|
||||
}
|
||||
@ -1881,7 +1915,9 @@ PHP_FUNCTION(imagecolorexactalpha)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(gdImageColorExactAlpha(im, red, green, blue, alpha));
|
||||
}
|
||||
@ -1900,8 +1936,13 @@ PHP_FUNCTION(imagecopyresampled)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
srcX = SX;
|
||||
srcY = SY;
|
||||
@ -2003,7 +2044,7 @@ clean:
|
||||
if (!im) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
|
||||
RETURN_RES(zend_register_resource(im, le_gd));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -2062,7 +2103,7 @@ PHP_FUNCTION(imagegrabscreen)
|
||||
if (!im) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
|
||||
RETURN_RES(zend_register_resource(im, le_gd));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -2082,12 +2123,14 @@ PHP_FUNCTION(imagerotate)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
im_dst = gdImageRotateInterpolated(im_src, (const float)degrees, color);
|
||||
|
||||
if (im_dst != NULL) {
|
||||
ZEND_REGISTER_RESOURCE(return_value, im_dst, le_gd);
|
||||
RETURN_RES(zend_register_resource(im_dst, le_gd));
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@ -2105,8 +2148,13 @@ PHP_FUNCTION(imagesettile)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
ZEND_FETCH_RESOURCE(tile, gdImagePtr, TILE, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((tile = (gdImagePtr)zend_fetch_resource(Z_RES_P(TILE), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageSetTile(im, tile);
|
||||
|
||||
@ -2125,8 +2173,13 @@ PHP_FUNCTION(imagesetbrush)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
ZEND_FETCH_RESOURCE(tile, gdImagePtr, TILE, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((tile = (gdImagePtr)zend_fetch_resource(Z_RES_P(TILE), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageSetBrush(im, tile);
|
||||
|
||||
@ -2156,7 +2209,7 @@ PHP_FUNCTION(imagecreate)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
|
||||
RETURN_RES(zend_register_resource(im, le_gd));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -2333,7 +2386,7 @@ PHP_FUNCTION(imagecreatefromstring)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
|
||||
RETURN_RES(zend_register_resource(im, le_gd));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -2443,7 +2496,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
|
||||
|
||||
/* register_im: */
|
||||
if (im) {
|
||||
ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
|
||||
RETVAL_RES(zend_register_resource(im, le_gd));
|
||||
php_stream_close(stream);
|
||||
return;
|
||||
}
|
||||
@ -2566,7 +2619,9 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(imgind), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
fn = file;
|
||||
@ -2780,7 +2835,9 @@ PHP_FUNCTION(imagedestroy)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zend_list_close(Z_RES_P(IM));
|
||||
|
||||
@ -2802,7 +2859,9 @@ PHP_FUNCTION(imagecolorallocate)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ct = gdImageColorAllocate(im, red, green, blue);
|
||||
if (ct < 0) {
|
||||
@ -2823,8 +2882,13 @@ PHP_FUNCTION(imagepalettecopy)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(dst, gdImagePtr, dstim, -1, "Image", le_gd);
|
||||
ZEND_FETCH_RESOURCE(src, gdImagePtr, srcim, -1, "Image", le_gd);
|
||||
if ((dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(dstim), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((src = (gdImagePtr)zend_fetch_resource(Z_RES_P(srcim), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImagePaletteCopy(dst, src);
|
||||
}
|
||||
@ -2842,7 +2906,9 @@ PHP_FUNCTION(imagecolorat)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (gdImageTrueColor(im)) {
|
||||
if (im->tpixels && gdImageBoundsSafe(im, x, y)) {
|
||||
@ -2874,7 +2940,9 @@ PHP_FUNCTION(imagecolorclosest)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(gdImageColorClosest(im, red, green, blue));
|
||||
}
|
||||
@ -2892,7 +2960,9 @@ PHP_FUNCTION(imagecolorclosesthwb)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(gdImageColorClosestHWB(im, red, green, blue));
|
||||
}
|
||||
@ -2911,7 +2981,9 @@ PHP_FUNCTION(imagecolordeallocate)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* We can return right away for a truecolor image as deallocating colours is meaningless here */
|
||||
if (gdImageTrueColor(im)) {
|
||||
@ -2942,7 +3014,9 @@ PHP_FUNCTION(imagecolorresolve)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(gdImageColorResolve(im, red, green, blue));
|
||||
}
|
||||
@ -2960,7 +3034,9 @@ PHP_FUNCTION(imagecolorexact)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(gdImageColorExact(im, red, green, blue));
|
||||
}
|
||||
@ -2979,7 +3055,9 @@ PHP_FUNCTION(imagecolorset)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
col = color;
|
||||
|
||||
@ -3007,7 +3085,9 @@ PHP_FUNCTION(imagecolorsforindex)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
col = index;
|
||||
|
||||
@ -3038,7 +3118,9 @@ PHP_FUNCTION(imagegammacorrect)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (gdImageTrueColor(im)) {
|
||||
int x, y, c;
|
||||
@ -3080,7 +3162,10 @@ PHP_FUNCTION(imagesetpixel)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageSetPixel(im, x, y, col);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@ -3098,7 +3183,9 @@ PHP_FUNCTION(imageline)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GD_BUNDLED
|
||||
if (im->antialias) {
|
||||
@ -3124,7 +3211,10 @@ PHP_FUNCTION(imagedashedline)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageDashedLine(im, x1, y1, x2, y2, col);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@ -3142,7 +3232,10 @@ PHP_FUNCTION(imagerectangle)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageRectangle(im, x1, y1, x2, y2, col);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@ -3160,7 +3253,9 @@ PHP_FUNCTION(imagefilledrectangle)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
gdImageFilledRectangle(im, x1, y1, x2, y2, col);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@ -3179,7 +3274,9 @@ PHP_FUNCTION(imagearc)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
e = E;
|
||||
if (e < 0) {
|
||||
@ -3208,7 +3305,9 @@ PHP_FUNCTION(imageellipse)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageEllipse(im, cx, cy, w, h, color);
|
||||
RETURN_TRUE;
|
||||
@ -3227,7 +3326,10 @@ PHP_FUNCTION(imagefilltoborder)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageFillToBorder(im, x, y, border, col);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@ -3245,7 +3347,10 @@ PHP_FUNCTION(imagefill)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gdImageFill(im, x, y, col);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@ -3262,7 +3367,9 @@ PHP_FUNCTION(imagecolorstotal)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(gdImageColorsTotal(im));
|
||||
}
|
||||
@ -3281,7 +3388,9 @@ PHP_FUNCTION(imagecolortransparent)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
gdImageColorTransparent(im, COL);
|
||||
@ -3304,7 +3413,9 @@ PHP_FUNCTION(imageinterlace)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
gdImageInterlace(im, INT);
|
||||
@ -3331,7 +3442,9 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
npoints = NPOINTS;
|
||||
col = COL;
|
||||
@ -3510,7 +3623,9 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
col = COL;
|
||||
|
||||
@ -3601,8 +3716,13 @@ PHP_FUNCTION(imagecopy)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
|
||||
if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
srcX = SX;
|
||||
srcY = SY;
|
||||
@ -3629,8 +3749,13 @@ PHP_FUNCTION(imagecopymerge)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
|
||||
if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
srcX = SX;
|
||||
srcY = SY;
|
||||
@ -3658,8 +3783,13 @@ PHP_FUNCTION(imagecopymergegray)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
|
||||
if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
srcX = SX;
|
||||
srcY = SY;
|
||||
@ -3687,8 +3817,13 @@ PHP_FUNCTION(imagecopyresized)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd);
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
srcX = SX;
|
||||
srcY = SY;
|
||||
@ -3720,7 +3855,9 @@ PHP_FUNCTION(imagesx)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(gdImageSX(im));
|
||||
}
|
||||
@ -3737,7 +3874,9 @@ PHP_FUNCTION(imagesy)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(gdImageSY(im));
|
||||
}
|
||||
@ -3811,7 +3950,9 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
|
||||
} else if (zend_parse_parameters(argc, "rddlllss|a", &IM, &ptsize, &angle, &x, &y, &col, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* convert angle to radians */
|
||||
@ -3928,7 +4069,7 @@ PHP_FUNCTION(imagepsloadfont)
|
||||
|
||||
font = (int *) emalloc(sizeof(int));
|
||||
*font = f_ind;
|
||||
ZEND_REGISTER_RESOURCE(return_value, font, le_ps_font);
|
||||
RETURN_RES(zend_register_resource(font, le_gd));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -3996,7 +4137,10 @@ PHP_FUNCTION(imagepsfreefont)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
|
||||
if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zend_list_close(Z_RES_P(fnt));
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@ -4015,7 +4159,9 @@ PHP_FUNCTION(imagepsencodefont)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
|
||||
if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((enc_vector = T1_LoadEncoding(enc)) == NULL) {
|
||||
php_error_docref(NULL, E_WARNING, "Couldn't load encoding vector from %s", enc);
|
||||
@ -4047,7 +4193,9 @@ PHP_FUNCTION(imagepsextendfont)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
|
||||
if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
T1_DeleteAllSizes(*f_ind);
|
||||
|
||||
@ -4076,7 +4224,9 @@ PHP_FUNCTION(imagepsslantfont)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
|
||||
if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (T1_SlantFont(*f_ind, slt) != 0) {
|
||||
RETURN_FALSE;
|
||||
@ -4116,8 +4266,12 @@ PHP_FUNCTION(imagepstext)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(bg_img, gdImagePtr, img, -1, "Image", le_gd);
|
||||
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
|
||||
if ((bg_img = (gdImagePtr)zend_fetch_resource(Z_RES_P(img), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* Ensure that the provided colors are valid */
|
||||
if (_fg < 0 || (!gdImageTrueColor(bg_img) && _fg > gdImageColorsTotal(bg_img))) {
|
||||
@ -4257,7 +4411,9 @@ PHP_FUNCTION(imagepsbbox)
|
||||
per_char = add_width || angle ? 1 : 0;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font);
|
||||
if ((f_ind = (int *)zend_fetch_resource(Z_RES_P(fnt), "Type 1 font", le_ps_font)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
#define max(a, b) (a > b ? a : b)
|
||||
#define min(a, b) (a < b ? a : b)
|
||||
@ -4589,8 +4745,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
if (zend_parse_parameters(1, "r", &SIM) == FAILURE) { \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd); \
|
||||
if (im_src == NULL) { \
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
@ -4626,7 +4781,9 @@ static void php_image_filter_brightness(INTERNAL_FUNCTION_PARAMETERS)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (im_src == NULL) {
|
||||
RETURN_FALSE;
|
||||
@ -4649,7 +4806,9 @@ static void php_image_filter_contrast(INTERNAL_FUNCTION_PARAMETERS)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (im_src == NULL) {
|
||||
RETURN_FALSE;
|
||||
@ -4673,7 +4832,9 @@ static void php_image_filter_colorize(INTERNAL_FUNCTION_PARAMETERS)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (im_src == NULL) {
|
||||
RETURN_FALSE;
|
||||
@ -4752,7 +4913,9 @@ static void php_image_filter_smooth(INTERNAL_FUNCTION_PARAMETERS)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (im_src == NULL) {
|
||||
RETURN_FALSE;
|
||||
@ -4776,7 +4939,9 @@ static void php_image_filter_pixelate(INTERNAL_FUNCTION_PARAMETERS)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (im == NULL) {
|
||||
RETURN_FALSE;
|
||||
@ -4840,7 +5005,9 @@ PHP_FUNCTION(imageconvolution)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd);
|
||||
if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
nelem = zend_hash_num_elements(Z_ARRVAL_P(hash_matrix));
|
||||
if (nelem != 3) {
|
||||
@ -4888,7 +5055,9 @@ PHP_FUNCTION(imageflip)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case GD_FLIP_VERTICAL:
|
||||
@ -4925,7 +5094,9 @@ PHP_FUNCTION(imageantialias)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
gdImageAntialias(im, alias);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@ -4947,7 +5118,9 @@ PHP_FUNCTION(imagecrop)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((tmp = zend_hash_str_find(HASH_OF(z_rect), "x", sizeof("x") -1)) != NULL) {
|
||||
rect.x = zval_get_long(tmp);
|
||||
@ -4982,7 +5155,7 @@ PHP_FUNCTION(imagecrop)
|
||||
if (im_crop == NULL) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
ZEND_REGISTER_RESOURCE(return_value, im_crop, le_gd);
|
||||
RETURN_RES(zend_register_resource(im_crop, le_gd));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -5002,7 +5175,9 @@ PHP_FUNCTION(imagecropauto)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case -1:
|
||||
@ -5030,7 +5205,7 @@ PHP_FUNCTION(imagecropauto)
|
||||
if (im_crop == NULL) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
ZEND_REGISTER_RESOURCE(return_value, im_crop, le_gd);
|
||||
RETURN_RES(zend_register_resource(im_crop, le_gd));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -5051,7 +5226,9 @@ PHP_FUNCTION(imagescale)
|
||||
}
|
||||
method = tmp_m;
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (tmp_h < 0) {
|
||||
/* preserve ratio */
|
||||
@ -5074,7 +5251,7 @@ PHP_FUNCTION(imagescale)
|
||||
if (im_scaled == NULL) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
ZEND_REGISTER_RESOURCE(return_value, im_scaled, le_gd);
|
||||
RETURN_RES(zend_register_resource(im_scaled, le_gd));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -5099,7 +5276,9 @@ PHP_FUNCTION(imageaffine)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(src, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((src = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_affine))) != 6) {
|
||||
php_error_docref(NULL, E_WARNING, "Affine array must have six elements");
|
||||
@ -5169,7 +5348,7 @@ PHP_FUNCTION(imageaffine)
|
||||
if (dst == NULL) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
ZEND_REGISTER_RESOURCE(return_value, dst, le_gd);
|
||||
RETURN_RES(zend_register_resource(dst, le_gd));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -5334,7 +5513,9 @@ PHP_FUNCTION(imagesetinterpolation)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (method == -1) {
|
||||
method = GD_BILINEAR_FIXED;
|
||||
|
@ -103,7 +103,9 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", phpi_get_le_gd());
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(imgind), "Image", phpi_get_le_gd())) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
q = quality; /* or colorindex for foreground of BW images (defaults to black) */
|
||||
|
@ -386,7 +386,7 @@ PHP_FUNCTION(hash_init)
|
||||
hash->key = (unsigned char *) K;
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, hash, php_hash_le_hash);
|
||||
RETURN_RES(zend_register_resource(hash, php_hash_le_hash));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -403,7 +403,9 @@ PHP_FUNCTION(hash_update)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
|
||||
if ((hash = (php_hash_data *)zend_fetch_resource(Z_RES_P(zhash), PHP_HASH_RESNAME, php_hash_le_hash)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
hash->ops->hash_update(hash->context, (unsigned char *) data, data_len);
|
||||
|
||||
@ -424,7 +426,10 @@ PHP_FUNCTION(hash_update_stream)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
|
||||
if ((hash = (php_hash_data *)zend_fetch_resource(Z_RES_P(zhash), PHP_HASH_RESNAME, php_hash_le_hash)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
php_stream_from_zval(stream, zstream);
|
||||
|
||||
while (length) {
|
||||
@ -463,7 +468,9 @@ PHP_FUNCTION(hash_update_file)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
|
||||
if ((hash = (php_hash_data *)zend_fetch_resource(Z_RES_P(zhash), PHP_HASH_RESNAME, php_hash_le_hash)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
context = php_stream_context_from_zval(zcontext, 0);
|
||||
|
||||
stream = php_stream_open_wrapper_ex(filename, "rb", REPORT_ERRORS, NULL, context);
|
||||
@ -495,7 +502,9 @@ PHP_FUNCTION(hash_final)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
|
||||
if ((hash = (php_hash_data *)zend_fetch_resource(Z_RES_P(zhash), PHP_HASH_RESNAME, php_hash_le_hash)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
digest_len = hash->ops->digest_size;
|
||||
digest = zend_string_alloc(digest_len, 0);
|
||||
@ -558,7 +567,9 @@ PHP_FUNCTION(hash_copy)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
|
||||
if ((hash = (php_hash_data *)zend_fetch_resource(Z_RES_P(zhash), PHP_HASH_RESNAME, php_hash_le_hash)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
context = emalloc(hash->ops->context_size);
|
||||
@ -578,7 +589,7 @@ PHP_FUNCTION(hash_copy)
|
||||
if (hash->key) {
|
||||
memcpy(copy_hash->key, hash->key, hash->ops->block_size);
|
||||
}
|
||||
ZEND_REGISTER_RESOURCE(return_value, copy_hash, php_hash_le_hash);
|
||||
RETURN_RES(zend_register_resource(copy_hash, php_hash_le_hash));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -1245,7 +1245,7 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
|
||||
imap_le_struct->imap_stream = imap_stream;
|
||||
imap_le_struct->flags = cl_flags;
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, imap_le_struct, le_imap);
|
||||
RETURN_RES(zend_register_resource(imap_le_struct, le_imap));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1272,7 +1272,9 @@ PHP_FUNCTION(imap_reopen)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (options) {
|
||||
flags = options;
|
||||
@ -1341,7 +1343,9 @@ PHP_FUNCTION(imap_append)
|
||||
}
|
||||
|
||||
zend_string_free(regex);
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
INIT (&st, mail_string, (void *) message->val, message->len);
|
||||
|
||||
@ -1364,7 +1368,9 @@ PHP_FUNCTION(imap_num_msg)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(imap_le_struct->imap_stream->nmsgs);
|
||||
}
|
||||
@ -1381,7 +1387,9 @@ PHP_FUNCTION(imap_ping)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_BOOL(mail_ping(imap_le_struct->imap_stream));
|
||||
}
|
||||
@ -1398,7 +1406,9 @@ PHP_FUNCTION(imap_num_recent)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(imap_le_struct->imap_stream->recent);
|
||||
}
|
||||
@ -1417,7 +1427,9 @@ PHP_FUNCTION(imap_get_quota)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
IMAPG(quota_return) = &return_value;
|
||||
@ -1444,7 +1456,9 @@ PHP_FUNCTION(imap_get_quotaroot)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
IMAPG(quota_return) = &return_value;
|
||||
@ -1473,7 +1487,9 @@ PHP_FUNCTION(imap_set_quota)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
limits.text.data = (unsigned char*)"STORAGE";
|
||||
limits.text.size = mailbox_size;
|
||||
@ -1495,7 +1511,9 @@ PHP_FUNCTION(imap_setacl)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_BOOL(imap_setacl(imap_le_struct->imap_stream, mailbox->val, id->val, rights->val));
|
||||
}
|
||||
@ -1513,7 +1531,9 @@ PHP_FUNCTION(imap_getacl)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* initializing the special array for the return values */
|
||||
array_init(return_value);
|
||||
@ -1544,7 +1564,9 @@ PHP_FUNCTION(imap_expunge)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
mail_expunge (imap_le_struct->imap_stream);
|
||||
|
||||
@ -1569,7 +1591,9 @@ PHP_FUNCTION(imap_gc)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
mail_gc(imap_le_struct->imap_stream, flags);
|
||||
|
||||
@ -1590,7 +1614,9 @@ PHP_FUNCTION(imap_close)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (argc == 2) {
|
||||
flags = options;
|
||||
@ -1630,7 +1656,9 @@ PHP_FUNCTION(imap_headers)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* Initialize return array */
|
||||
array_init(return_value);
|
||||
@ -1685,7 +1713,9 @@ PHP_FUNCTION(imap_body)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((argc == 3) && (flags & FT_UID)) {
|
||||
/* This should be cached; if it causes an extra RTT to the
|
||||
@ -1723,7 +1753,9 @@ PHP_FUNCTION(imap_mail_copy)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (mail_copy_full(imap_le_struct->imap_stream, seq->val, folder->val, (argc == 4 ? options : NIL)) == T) {
|
||||
RETURN_TRUE;
|
||||
@ -1747,7 +1779,9 @@ PHP_FUNCTION(imap_mail_move)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (mail_copy_full(imap_le_struct->imap_stream, seq->val, folder->val, (argc == 4 ? (options | CP_MOVE) : CP_MOVE)) == T) {
|
||||
RETURN_TRUE;
|
||||
@ -1769,7 +1803,9 @@ PHP_FUNCTION(imap_createmailbox)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (mail_create(imap_le_struct->imap_stream, folder->val) == T) {
|
||||
RETURN_TRUE;
|
||||
@ -1791,7 +1827,9 @@ PHP_FUNCTION(imap_renamemailbox)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (mail_rename(imap_le_struct->imap_stream, old_mailbox->val, new_mailbox->val) == T) {
|
||||
RETURN_TRUE;
|
||||
@ -1813,7 +1851,9 @@ PHP_FUNCTION(imap_deletemailbox)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (mail_delete(imap_le_struct->imap_stream, folder->val) == T) {
|
||||
RETURN_TRUE;
|
||||
@ -1836,7 +1876,9 @@ PHP_FUNCTION(imap_list)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* set flag for normal, old mailbox list */
|
||||
IMAPG(folderlist_style) = FLIST_ARRAY;
|
||||
@ -1874,7 +1916,9 @@ PHP_FUNCTION(imap_list_full)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* set flag for new, improved array of objects mailbox list */
|
||||
IMAPG(folderlist_style) = FLIST_OBJECT;
|
||||
@ -1921,7 +1965,9 @@ PHP_FUNCTION(imap_listscan)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
IMAPG(imap_folders) = NIL;
|
||||
mail_scan(imap_le_struct->imap_stream, ref->val, pat->val, content->val);
|
||||
@ -1953,7 +1999,9 @@ PHP_FUNCTION(imap_check)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (mail_ping (imap_le_struct->imap_stream) == NIL) {
|
||||
RETURN_FALSE;
|
||||
@ -1986,7 +2034,9 @@ PHP_FUNCTION(imap_delete)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
convert_to_string_ex(sequence);
|
||||
|
||||
@ -2008,7 +2058,9 @@ PHP_FUNCTION(imap_undelete)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
convert_to_string_ex(sequence);
|
||||
|
||||
@ -2034,7 +2086,9 @@ PHP_FUNCTION(imap_headerinfo)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
if (fromlength < 0 || fromlength > MAILTMPLEN) {
|
||||
@ -2139,7 +2193,9 @@ PHP_FUNCTION(imap_lsub)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* set flag for normal, old mailbox list */
|
||||
IMAPG(folderlist_style) = FLIST_ARRAY;
|
||||
@ -2176,7 +2232,9 @@ PHP_FUNCTION(imap_lsub_full)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* set flag for new, improved array of objects list */
|
||||
IMAPG(folderlist_style) = FLIST_OBJECT;
|
||||
@ -2222,7 +2280,9 @@ PHP_FUNCTION(imap_subscribe)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (mail_subscribe(imap_le_struct->imap_stream, folder->val) == T) {
|
||||
RETURN_TRUE;
|
||||
@ -2244,7 +2304,9 @@ PHP_FUNCTION(imap_unsubscribe)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (mail_unsubscribe(imap_le_struct->imap_stream, folder->val) == T) {
|
||||
RETURN_TRUE;
|
||||
@ -2273,7 +2335,9 @@ PHP_FUNCTION(imap_fetchstructure)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (msgno < 1) {
|
||||
RETURN_FALSE;
|
||||
@ -2323,7 +2387,9 @@ PHP_FUNCTION(imap_fetchbody)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (argc < 4 || !(flags & FT_UID)) {
|
||||
/* only perform the check if the msgno is a message number and not a UID */
|
||||
@ -2363,7 +2429,9 @@ PHP_FUNCTION(imap_fetchmime)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (argc < 4 || !(flags & FT_UID)) {
|
||||
/* only perform the check if the msgno is a message number and not a UID */
|
||||
@ -2396,7 +2464,9 @@ PHP_FUNCTION(imap_savebody)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_ptr, pils *, stream, -1, "imap", le_imap);
|
||||
if ((imap_ptr = (pils *)zend_fetch_resource(Z_RES_P(stream), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!imap_ptr) {
|
||||
RETURN_FALSE;
|
||||
@ -2539,7 +2609,9 @@ PHP_FUNCTION(imap_mailboxmsginfo)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* Initialize return object */
|
||||
object_init(return_value);
|
||||
@ -3024,7 +3096,9 @@ PHP_FUNCTION(imap_setflag_full)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
mail_setflag_full(imap_le_struct->imap_stream, sequence->val, flag->val, (flags ? flags : NIL));
|
||||
RETURN_TRUE;
|
||||
@ -3045,7 +3119,9 @@ PHP_FUNCTION(imap_clearflag_full)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
mail_clearflag_full(imap_le_struct->imap_stream, sequence->val, flag->val, (argc == 4 ? flags : NIL));
|
||||
RETURN_TRUE;
|
||||
@ -3070,7 +3146,9 @@ PHP_FUNCTION(imap_sort)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (pgm > SORTSIZE) {
|
||||
php_error_docref(NULL, E_WARNING, "Unrecognized sort criteria");
|
||||
@ -3129,7 +3207,9 @@ PHP_FUNCTION(imap_fetchheader)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((argc == 3) && (flags & FT_UID)) {
|
||||
/* This should be cached; if it causes an extra RTT to the
|
||||
@ -3159,7 +3239,9 @@ PHP_FUNCTION(imap_uid)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
msgindex = msgno;
|
||||
if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) {
|
||||
@ -3183,7 +3265,9 @@ PHP_FUNCTION(imap_msgno)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(mail_msgno(imap_le_struct->imap_stream, msgno));
|
||||
}
|
||||
@ -3202,7 +3286,9 @@ PHP_FUNCTION(imap_status)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
object_init(return_value);
|
||||
|
||||
@ -3245,7 +3331,9 @@ PHP_FUNCTION(imap_bodystruct)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!msg || msg < 1 || (unsigned) msg > imap_le_struct->imap_stream->nmsgs) {
|
||||
php_error_docref(NULL, E_WARNING, "Bad message number");
|
||||
@ -3361,7 +3449,9 @@ PHP_FUNCTION(imap_fetch_overview)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
@ -4050,7 +4140,9 @@ PHP_FUNCTION(imap_search)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
search_criteria = estrndup(criteria->val, criteria->len);
|
||||
|
||||
@ -4651,7 +4743,9 @@ PHP_FUNCTION(imap_thread)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
|
||||
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
pgm = mail_criteria(criteria);
|
||||
top = mail_thread(imap_le_struct->imap_stream, "REFERENCES", NIL, pgm, flags);
|
||||
|
212
ext/ldap/ldap.c
212
ext/ldap/ldap.c
@ -362,7 +362,7 @@ PHP_FUNCTION(ldap_connect)
|
||||
#endif
|
||||
LDAPG(num_links)++;
|
||||
ld->link = ldap;
|
||||
ZEND_REGISTER_RESOURCE(return_value, ld, le_link);
|
||||
RETURN_RES(zend_register_resource(ld, le_link));
|
||||
}
|
||||
|
||||
}
|
||||
@ -419,7 +419,9 @@ PHP_FUNCTION(ldap_bind)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ldap_bind_dn != NULL && memchr(ldap_bind_dn, '\0', ldap_bind_dnlen) != NULL) {
|
||||
_set_lderrno(ld->link, LDAP_INVALID_CREDENTIALS);
|
||||
@ -547,7 +549,9 @@ PHP_FUNCTION(ldap_sasl_bind)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ctx = _php_sasl_setdefs(ld->link, sasl_mech, sasl_realm, sasl_authc_id, passwd, sasl_authz_id);
|
||||
|
||||
@ -578,7 +582,9 @@ PHP_FUNCTION(ldap_unbind)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zend_list_close(Z_RES_P(link));
|
||||
RETURN_TRUE;
|
||||
@ -724,7 +730,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
|
||||
for (i=0; i<nlinks; i++) {
|
||||
entry = zend_hash_get_current_data(Z_ARRVAL_P(link));
|
||||
|
||||
ld = (ldap_linkdata *) zend_fetch_resource(entry, -1, "ldap link", NULL, 1, le_link);
|
||||
ld = (ldap_linkdata *) zend_fetch_resource_ex(entry, "ldap link", le_link);
|
||||
if (ld == NULL) {
|
||||
ret = 0;
|
||||
goto cleanup_parallel;
|
||||
@ -763,7 +769,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
|
||||
rcs[i] = ldap_result(lds[i]->link, LDAP_RES_ANY, 1 /* LDAP_MSG_ALL */, NULL, &ldap_res);
|
||||
}
|
||||
if (rcs[i] != -1) {
|
||||
ZEND_REGISTER_RESOURCE(&resource, ldap_res, le_result);
|
||||
ZVAL_RES(&resource, zend_register_resource(ldap_res, le_result));
|
||||
add_next_index_zval(return_value, &resource);
|
||||
} else {
|
||||
add_next_index_bool(return_value, 0);
|
||||
@ -782,7 +788,7 @@ cleanup_parallel:
|
||||
ldap_base_dn = Z_STRVAL_P(base_dn);
|
||||
}
|
||||
|
||||
ld = (ldap_linkdata *) zend_fetch_resource(link, -1, "ldap link", NULL, 1, le_link);
|
||||
ld = (ldap_linkdata *) zend_fetch_resource_ex(link, "ldap link", le_link);
|
||||
if (ld == NULL) {
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
@ -814,7 +820,7 @@ cleanup_parallel:
|
||||
}
|
||||
#endif
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, ldap_res, le_result);
|
||||
RETVAL_RES(zend_register_resource(ldap_res, le_result));
|
||||
}
|
||||
}
|
||||
|
||||
@ -867,7 +873,9 @@ PHP_FUNCTION(ldap_free_result)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, result, -1, "ldap result", le_result);
|
||||
if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zend_list_close(Z_RES_P(result)); /* Delete list entry */
|
||||
RETVAL_TRUE;
|
||||
@ -886,8 +894,13 @@ PHP_FUNCTION(ldap_count_entries)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, result, -1, "ldap result", le_result);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(ldap_count_entries(ld->link, ldap_result));
|
||||
}
|
||||
@ -906,14 +919,19 @@ PHP_FUNCTION(ldap_first_entry)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, result, -1, "ldap result", le_result);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((entry = ldap_first_entry(ld->link, ldap_result)) == NULL) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
resultentry = emalloc(sizeof(ldap_resultentry));
|
||||
ZEND_REGISTER_RESOURCE(return_value, resultentry, le_result_entry);
|
||||
RETVAL_RES(zend_register_resource(resultentry, le_result_entry));
|
||||
ZVAL_COPY(&resultentry->res, result);
|
||||
resultentry->data = entry;
|
||||
resultentry->ber = NULL;
|
||||
@ -934,14 +952,18 @@ PHP_FUNCTION(ldap_next_entry)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((entry_next = ldap_next_entry(ld->link, resultentry->data)) == NULL) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
resultentry_next = emalloc(sizeof(ldap_resultentry));
|
||||
ZEND_REGISTER_RESOURCE(return_value, resultentry_next, le_result_entry);
|
||||
RETVAL_RES(zend_register_resource(resultentry_next, le_result_entry));
|
||||
ZVAL_COPY(&resultentry_next->res, &resultentry->res);
|
||||
resultentry_next->data = entry_next;
|
||||
resultentry_next->ber = NULL;
|
||||
@ -969,8 +991,12 @@ PHP_FUNCTION(ldap_get_entries)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, result, -1, "ldap result", le_result);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ldap = ld->link;
|
||||
num_entries = ldap_count_entries(ldap, ldap_result);
|
||||
@ -1056,8 +1082,13 @@ PHP_FUNCTION(ldap_first_attribute)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((attribute = ldap_first_attribute(ld->link, resultentry->data, &resultentry->ber)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
@ -1084,8 +1115,13 @@ PHP_FUNCTION(ldap_next_attribute)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (resultentry->ber == NULL) {
|
||||
php_error_docref(NULL, E_WARNING, "called before calling ldap_first_attribute() or no attributes found in result entry");
|
||||
@ -1126,8 +1162,13 @@ PHP_FUNCTION(ldap_get_attributes)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
num_attrib = 0;
|
||||
@ -1179,8 +1220,13 @@ PHP_FUNCTION(ldap_get_values_len)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((ldap_value_len = ldap_get_values_len(ld->link, resultentry->data, attr)) == NULL) {
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get the value(s) of attribute %s", ldap_err2string(_get_lderrno(ld->link)));
|
||||
@ -1213,8 +1259,13 @@ PHP_FUNCTION(ldap_get_dn)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
text = ldap_get_dn(ld->link, resultentry->data);
|
||||
if (text != NULL) {
|
||||
@ -1309,7 +1360,9 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
num_attribs = zend_hash_num_elements(Z_ARRVAL_P(entry));
|
||||
ldap_mods = safe_emalloc((num_attribs+1), sizeof(LDAPMod *), 0);
|
||||
@ -1460,7 +1513,9 @@ PHP_FUNCTION(ldap_delete)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((rc = ldap_delete_s(ld->link, dn)) != LDAP_SUCCESS) {
|
||||
php_error_docref(NULL, E_WARNING, "Delete: %s", ldap_err2string(rc));
|
||||
@ -1557,7 +1612,9 @@ PHP_FUNCTION(ldap_modify_batch)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* perform validation */
|
||||
{
|
||||
@ -1821,7 +1878,9 @@ PHP_FUNCTION(ldap_errno)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(_get_lderrno(ld->link));
|
||||
}
|
||||
@ -1853,7 +1912,9 @@ PHP_FUNCTION(ldap_error)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ld_errno = _get_lderrno(ld->link);
|
||||
|
||||
@ -1875,7 +1936,9 @@ PHP_FUNCTION(ldap_compare)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
errno = ldap_compare_s(ld->link, dn, attr, value);
|
||||
|
||||
@ -1908,7 +1971,9 @@ PHP_FUNCTION(ldap_sort)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((le = zend_hash_index_find_ptr(&EG(regular_list), Z_RES_HANDLE_P(result))) == NULL || le->type != le_result) {
|
||||
php_error_docref(NULL, E_WARNING, "Supplied resource is not a valid ldap result resource");
|
||||
@ -1937,7 +2002,9 @@ PHP_FUNCTION(ldap_get_option)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch (option) {
|
||||
/* options with int value */
|
||||
@ -2045,7 +2112,9 @@ PHP_FUNCTION(ldap_set_option)
|
||||
if (Z_TYPE_P(link) == IS_NULL) {
|
||||
ldap = NULL;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource_ex(link, "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
ldap = ld->link;
|
||||
}
|
||||
|
||||
@ -2212,8 +2281,13 @@ PHP_FUNCTION(ldap_parse_result)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, result, -1, "ldap result", le_result);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
rc = ldap_parse_result(ld->link, ldap_result, &lerrcode,
|
||||
myargcount > 3 ? &lmatcheddn : NULL,
|
||||
@ -2277,14 +2351,19 @@ PHP_FUNCTION(ldap_first_reference)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, result, -1, "ldap result", le_result);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((entry = ldap_first_reference(ld->link, ldap_result)) == NULL) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
resultentry = emalloc(sizeof(ldap_resultentry));
|
||||
ZEND_REGISTER_RESOURCE(return_value, resultentry, le_result_entry);
|
||||
RETVAL_RES(zend_register_resource(resultentry, le_result_entry));
|
||||
ZVAL_COPY(&resultentry->res, result);
|
||||
resultentry->data = entry;
|
||||
resultentry->ber = NULL;
|
||||
@ -2305,14 +2384,19 @@ PHP_FUNCTION(ldap_next_reference)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((entry_next = ldap_next_reference(ld->link, resultentry->data)) == NULL) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
resultentry_next = emalloc(sizeof(ldap_resultentry));
|
||||
ZEND_REGISTER_RESOURCE(return_value, resultentry_next, le_result_entry);
|
||||
RETVAL_RES(zend_register_resource(resultentry_next, le_result_entry));
|
||||
ZVAL_COPY(&resultentry_next->res, &resultentry->res);
|
||||
resultentry_next->data = entry_next;
|
||||
resultentry_next->ber = NULL;
|
||||
@ -2334,8 +2418,13 @@ PHP_FUNCTION(ldap_parse_reference)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ldap_parse_reference(ld->link, resultentry->data, &lreferrals, NULL /* &serverctrls */, 0) != LDAP_SUCCESS) {
|
||||
RETURN_FALSE;
|
||||
@ -2371,7 +2460,9 @@ PHP_FUNCTION(ldap_rename)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (newparent_len == 0) {
|
||||
newparent = NULL;
|
||||
@ -2408,7 +2499,9 @@ PHP_FUNCTION(ldap_start_tls)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (((rc = ldap_set_option(ld->link, LDAP_OPT_PROTOCOL_VERSION, &protocol)) != LDAP_SUCCESS) ||
|
||||
((rc = ldap_start_tls_s(ld->link, NULL, NULL)) != LDAP_SUCCESS)
|
||||
@ -2434,7 +2527,7 @@ int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgi
|
||||
zval cb_retval;
|
||||
zval *cb_link = (zval *) params;
|
||||
|
||||
ld = (ldap_linkdata *) zend_fetch_resource(cb_link, -1, "ldap link", NULL, 1, le_link);
|
||||
ld = (ldap_linkdata *) zend_fetch_resource_ex(cb_link, "ldap link", le_link);
|
||||
|
||||
/* link exists and callback set? */
|
||||
if (ld == NULL || Z_ISUNDEF(ld->rebindproc)) {
|
||||
@ -2470,7 +2563,9 @@ PHP_FUNCTION(ldap_set_rebind_proc)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (Z_TYPE_P(callback) == IS_STRING && Z_STRLEN_P(callback) == 0) {
|
||||
/* unregister rebind procedure */
|
||||
@ -2656,7 +2751,9 @@ PHP_FUNCTION(ldap_control_paged_result)
|
||||
if (Z_TYPE_P(link) == IS_NULL) {
|
||||
ldap = NULL;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource_ex(link, "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
ldap = ld->link;
|
||||
}
|
||||
|
||||
@ -2743,8 +2840,13 @@ PHP_FUNCTION(ldap_control_paged_result_response)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
|
||||
ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, result, -1, "ldap result", le_result);
|
||||
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
rc = ldap_parse_result(ld->link,
|
||||
ldap_result,
|
||||
|
@ -341,7 +341,9 @@ typedef enum {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &mcryptind) == FAILURE) { \
|
||||
return; \
|
||||
} \
|
||||
ZEND_FETCH_RESOURCE (pm, php_mcrypt *, mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
if ((pm = (php_mcrypt *)zend_fetch_resource(Z_RES_P(mcryptind), "MCrypt", le_mcrypt)) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
#define MCRYPT_GET_MODE_DIR_ARGS(DIRECTORY) \
|
||||
char *dir = NULL; \
|
||||
@ -533,7 +535,7 @@ PHP_FUNCTION(mcrypt_module_open)
|
||||
pm = emalloc(sizeof(php_mcrypt));
|
||||
pm->td = td;
|
||||
pm->init = 0;
|
||||
ZEND_REGISTER_RESOURCE(return_value, pm, le_mcrypt);
|
||||
RETURN_RES(zend_register_resource(pm, le_mcrypt));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -554,7 +556,9 @@ PHP_FUNCTION(mcrypt_generic_init)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(pm, php_mcrypt *, mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
if ((pm = (php_mcrypt *)zend_fetch_resource(Z_RES_P(mcryptind), "MCrypt", le_mcrypt)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
max_key_size = mcrypt_enc_get_key_size(pm->td);
|
||||
iv_size = mcrypt_enc_get_iv_size(pm->td);
|
||||
@ -629,7 +633,9 @@ PHP_FUNCTION(mcrypt_generic)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(pm, php_mcrypt *, mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
if ((pm = (php_mcrypt *)zend_fetch_resource(Z_RES_P(mcryptind), "MCrypt", le_mcrypt)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
PHP_MCRYPT_INIT_CHECK
|
||||
|
||||
if (data_len == 0) {
|
||||
@ -674,7 +680,9 @@ PHP_FUNCTION(mdecrypt_generic)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(pm, php_mcrypt * , mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
if ((pm = (php_mcrypt *)zend_fetch_resource(Z_RES_P(mcryptind), "MCrypt", le_mcrypt)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
PHP_MCRYPT_INIT_CHECK
|
||||
|
||||
if (data_len == 0) {
|
||||
|
@ -543,9 +543,7 @@ static MYSQLND *mysql_convert_zv_to_mysqlnd(zval *zv)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mysql = zend_fetch_resource(zv, -1, "MySQL-Link", NULL, 2, le_link, le_plink);
|
||||
|
||||
if (!mysql) {
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(zv), "MySQL-Link", le_link, le_plink))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -966,7 +964,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ZEND_REGISTER_RESOURCE(return_value, mysql, le_plink);
|
||||
ZVAL_RES(return_value, zend_register_resource(mysql, le_plink));
|
||||
} else { /* non persistent */
|
||||
zend_resource *index_ptr;
|
||||
zval new_index_ptr;
|
||||
@ -1051,7 +1049,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
|
||||
mysql_options(mysql->conn, MYSQL_OPT_LOCAL_INFILE, (char *)&MySG(allow_local_infile));
|
||||
|
||||
/* add it to the list */
|
||||
ZEND_REGISTER_RESOURCE(return_value, mysql, le_link);
|
||||
ZVAL_RES(return_value, zend_register_resource(mysql, le_link));
|
||||
|
||||
/* add it to the hash */
|
||||
ZVAL_NEW_RES(&new_index_ptr, -1, Z_RES_P(return_value), le_index_ptr);
|
||||
@ -1111,9 +1109,17 @@ PHP_FUNCTION(mysql_close)
|
||||
}
|
||||
|
||||
if (mysql_link) {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, NULL, MySG(default_link)? MySG(default_link)->handle : -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!MySG(default_link)) {
|
||||
zend_fetch_resource2_ex(NULL, "MySQL-Link", le_link, le_plink); /* trigger a warning to be consistent */
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(MySG(default_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
res = mysql_link ? Z_RES_P(mysql_link) : MySG(default_link);
|
||||
@ -1158,7 +1164,9 @@ PHP_FUNCTION(mysql_select_db)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (php_mysql_select_db(mysql, db)) {
|
||||
@ -1199,7 +1207,9 @@ PHP_FUNCTION(mysql_get_host_info)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_STRING((char *)mysql_get_host_info(mysql->conn));
|
||||
@ -1222,7 +1232,9 @@ PHP_FUNCTION(mysql_get_proto_info)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_LONG(mysql_get_proto_info(mysql->conn));
|
||||
@ -1245,7 +1257,9 @@ PHP_FUNCTION(mysql_get_server_info)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_STRING((char *)mysql_get_server_info(mysql->conn));
|
||||
@ -1269,7 +1283,9 @@ PHP_FUNCTION(mysql_info)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((str = (char *)mysql_info(mysql->conn))) {
|
||||
@ -1296,7 +1312,9 @@ PHP_FUNCTION(mysql_thread_id)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_LONG((zend_long) mysql_thread_id(mysql->conn));
|
||||
@ -1325,7 +1343,9 @@ PHP_FUNCTION(mysql_stat)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PHPMY_UNBUFFERED_QUERY_CHECK();
|
||||
@ -1358,7 +1378,9 @@ PHP_FUNCTION(mysql_client_encoding)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_STRING((char *)mysql_character_set_name(mysql->conn));
|
||||
@ -1385,7 +1407,9 @@ PHP_FUNCTION(mysql_set_charset)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mysql_set_character_set(mysql->conn, csname)) {
|
||||
@ -1417,7 +1441,9 @@ PHP_FUNCTION(mysql_create_db)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PHPMY_UNBUFFERED_QUERY_CHECK();
|
||||
@ -1448,10 +1474,12 @@ PHP_FUNCTION(mysql_drop_db)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (mysql_drop_db(mysql->conn, db)==0) {
|
||||
if (mysql_drop_db(mysql->conn, db) == 0) {
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
@ -1542,7 +1570,8 @@ static void php_mysql_do_query_general(php_mysql_conn *mysql, char *query, int q
|
||||
}
|
||||
}
|
||||
MySG(result_allocated)++;
|
||||
ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
|
||||
ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
|
||||
|
||||
if (use_store == MYSQL_USE_RESULT) {
|
||||
mysql->active_result_res = Z_RES_P(return_value);
|
||||
Z_ADDREF_P(return_value);
|
||||
@ -1568,7 +1597,9 @@ static void php_mysql_do_query(INTERNAL_FUNCTION_PARAMETERS, int use_store)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
php_mysql_do_query_general(mysql, query, query_len, NULL, use_store, return_value);
|
||||
@ -1609,7 +1640,9 @@ PHP_FUNCTION(mysql_db_query)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
php_error_docref(NULL, E_DEPRECATED, "This function is deprecated; use mysql_query() instead");
|
||||
@ -1635,7 +1668,9 @@ PHP_FUNCTION(mysql_list_dbs)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
php_error_docref(NULL, E_DEPRECATED, "This function is deprecated; use mysql_query() with SHOW DATABASES instead");
|
||||
@ -1648,7 +1683,7 @@ PHP_FUNCTION(mysql_list_dbs)
|
||||
}
|
||||
|
||||
MySG(result_allocated)++;
|
||||
ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
|
||||
ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1671,7 +1706,9 @@ PHP_FUNCTION(mysql_list_tables)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!php_mysql_select_db(mysql, db)) {
|
||||
@ -1685,7 +1722,7 @@ PHP_FUNCTION(mysql_list_tables)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
MySG(result_allocated)++;
|
||||
ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
|
||||
ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1708,7 +1745,9 @@ PHP_FUNCTION(mysql_list_fields)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!php_mysql_select_db(mysql, db)) {
|
||||
@ -1722,7 +1761,7 @@ PHP_FUNCTION(mysql_list_fields)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
MySG(result_allocated)++;
|
||||
ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
|
||||
ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1743,7 +1782,9 @@ PHP_FUNCTION(mysql_list_processes)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PHPMY_UNBUFFERED_QUERY_CHECK();
|
||||
@ -1755,7 +1796,7 @@ PHP_FUNCTION(mysql_list_processes)
|
||||
}
|
||||
|
||||
MySG(result_allocated)++;
|
||||
ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
|
||||
ZVAL_RES(return_value, zend_register_resource(mysql_result, le_result));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1780,7 +1821,9 @@ PHP_FUNCTION(mysql_error)
|
||||
}
|
||||
mysql = (php_mysql_conn*)MySG(default_link)->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_STRING((char *)mysql_error(mysql->conn));
|
||||
@ -1809,7 +1852,9 @@ PHP_FUNCTION(mysql_errno)
|
||||
}
|
||||
mysql = (php_mysql_conn*)MySG(default_link)->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_LONG(mysql_errno(mysql->conn));
|
||||
@ -1833,7 +1878,9 @@ PHP_FUNCTION(mysql_affected_rows)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* conversion from int64 to long happing here */
|
||||
@ -1884,7 +1931,9 @@ PHP_FUNCTION(mysql_real_escape_string)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* assume worst case situation, which is 2x of the original string.
|
||||
@ -1914,7 +1963,9 @@ PHP_FUNCTION(mysql_insert_id)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* conversion from int64 to long happing here */
|
||||
@ -1944,7 +1995,9 @@ Q: String or long first?
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
|
||||
if ((mysql_result = (MYSQL_RES*)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (row < 0 || row >= (int)mysql_num_rows(mysql_result)) {
|
||||
php_error_docref(NULL, E_WARNING, "Unable to jump to row %pd on MySQL result index %d", row, Z_RES_P(result)->handle);
|
||||
@ -2029,7 +2082,9 @@ PHP_FUNCTION(mysql_num_rows)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
|
||||
if ((mysql_result = (MYSQL_RES*)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* conversion from int64 to long happing here */
|
||||
RETURN_LONG((zend_long) mysql_num_rows(mysql_result));
|
||||
@ -2047,7 +2102,9 @@ PHP_FUNCTION(mysql_num_fields)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
|
||||
if ((mysql_result = (MYSQL_RES*)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(mysql_num_fields(mysql_result));
|
||||
}
|
||||
@ -2116,7 +2173,9 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_
|
||||
result_type = MYSQL_BOTH;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, res, -1, "MySQL result", le_result);
|
||||
if ((mysql_result = (MYSQL_RES*)zend_fetch_resource_ex(res, "MySQL result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
#ifndef MYSQL_USE_MYSQLND
|
||||
if ((mysql_row = mysql_fetch_row(mysql_result)) == NULL ||
|
||||
@ -2274,7 +2333,9 @@ PHP_FUNCTION(mysql_data_seek)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
|
||||
if ((mysql_result = zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (offset < 0 || offset >= (int)mysql_num_rows(mysql_result)) {
|
||||
php_error_docref(NULL, E_WARNING, "Offset %pd is invalid for MySQL result index %d (or the query data is unbuffered)", offset, Z_RES_P(result)->handle);
|
||||
@ -2299,7 +2360,9 @@ PHP_FUNCTION(mysql_fetch_lengths)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
|
||||
if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((lengths=mysql_fetch_lengths(mysql_result))==NULL) {
|
||||
RETURN_FALSE;
|
||||
@ -2402,7 +2465,9 @@ PHP_FUNCTION(mysql_fetch_field)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
|
||||
if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ZEND_NUM_ARGS() > 1) {
|
||||
if (field<0 || field >= (int)mysql_num_fields(mysql_result)) {
|
||||
@ -2447,7 +2512,10 @@ PHP_FUNCTION(mysql_field_seek)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &result, &offset) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
|
||||
|
||||
if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (offset < 0 || offset >= (int)mysql_num_fields(mysql_result)) {
|
||||
php_error_docref(NULL, E_WARNING, "Field %pd is invalid for MySQL result index %d", offset, Z_RES_P(result)->handle);
|
||||
@ -2479,7 +2547,9 @@ static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
|
||||
if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (field < 0 || field >= (int)mysql_num_fields(mysql_result)) {
|
||||
php_error_docref(NULL, E_WARNING, "Field %pd is invalid for MySQL result index %d", field, Z_RES_P(result)->handle);
|
||||
@ -2636,7 +2706,9 @@ PHP_FUNCTION(mysql_free_result)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
|
||||
if ((mysql_result = (MYSQL_RES *)zend_fetch_resource(Z_RES_P(result), "MySQL result", le_result)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zend_list_close(Z_RES_P(result));
|
||||
RETURN_TRUE;
|
||||
@ -2659,7 +2731,9 @@ PHP_FUNCTION(mysql_ping)
|
||||
CHECK_LINK(res);
|
||||
mysql = (php_mysql_conn*)res->ptr;
|
||||
} else {
|
||||
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, -1, "MySQL-Link", le_link, le_plink);
|
||||
if (!(mysql = (php_mysql_conn *)zend_fetch_resource2(Z_RES_P(mysql_link), "MySQL-Link", le_link, le_plink))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PHPMY_UNBUFFERED_QUERY_CHECK();
|
||||
|
@ -357,24 +357,32 @@ typedef struct {
|
||||
|
||||
#define PHP_OCI_REGISTER_RESOURCE(resource, le_resource) \
|
||||
do { \
|
||||
resource->id = ZEND_REGISTER_RESOURCE(NULL, resource, le_resource); \
|
||||
resource->id = zend_register_resource(resource, le_resource); \
|
||||
} while (0)
|
||||
|
||||
#define PHP_OCI_ZVAL_TO_CONNECTION(zval, connection) \
|
||||
ZEND_FETCH_RESOURCE2(connection, php_oci_connection *, zval, -1, "oci8 connection", le_connection, le_pconnection)
|
||||
if ((connection = (php_oci_connection *)zend_fetch_resource2(Z_RES_P(zval), "oci8 connection", le_connection, le_pconnection)) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
#define PHP_OCI_ZVAL_TO_STATEMENT(zval, statement) \
|
||||
ZEND_FETCH_RESOURCE(statement, php_oci_statement *, zval, -1, "oci8 statement", le_statement)
|
||||
if ((statement = (php_oci_statement *)zend_fetch_resource(Z_RES_P(zval), "oci8 statement", le_statement)) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
#define PHP_OCI_ZVAL_TO_DESCRIPTOR(zval, descriptor) \
|
||||
ZEND_FETCH_RESOURCE(descriptor, php_oci_descriptor *, zval, -1, "oci8 descriptor", le_descriptor)
|
||||
if ((descriptor = (php_oci_descriptor *)zend_fetch_resource(Z_RES_P(zval), "oci8 descriptor", le_descriptor)) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
#define PHP_OCI_ZVAL_TO_COLLECTION(zval, collection) \
|
||||
ZEND_FETCH_RESOURCE(collection, php_oci_collection *, zval, -1, "oci8 collection", le_collection)
|
||||
if ((collection = (php_oci_collection *)zend_fetch_resource(Z_RES_P(zval), "oci8 collection", le_collection)) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
#define PHP_OCI_FETCH_RESOURCE_EX(zval, var, type, name, resource_type) \
|
||||
do { \
|
||||
var = (type) zend_fetch_resource(zval, -1, name, NULL, 1, resource_type); \
|
||||
var = (type) zend_fetch_resource(Z_RES_P(zval), name, resource_type); \
|
||||
if (!var) { \
|
||||
return 1; \
|
||||
} \
|
||||
|
@ -1351,9 +1351,8 @@ static X509 * php_openssl_x509_from_zval(zval * val, int makeresource, zend_reso
|
||||
if (Z_TYPE_P(val) == IS_RESOURCE) {
|
||||
/* is it an x509 resource ? */
|
||||
void * what;
|
||||
int type;
|
||||
|
||||
what = zend_fetch_resource(val, -1, "OpenSSL X.509", &type, 1, le_x509);
|
||||
what = zend_fetch_resource_ex(val, "OpenSSL X.509", le_x509);
|
||||
if (!what) {
|
||||
return NULL;
|
||||
}
|
||||
@ -1362,12 +1361,7 @@ static X509 * php_openssl_x509_from_zval(zval * val, int makeresource, zend_reso
|
||||
*resourceval = Z_RES_P(val);
|
||||
Z_ADDREF_P(val);
|
||||
}
|
||||
if (type == le_x509) {
|
||||
return (X509*)what;
|
||||
}
|
||||
/* other types could be used here - eg: file pointers and read in the data from them */
|
||||
|
||||
return NULL;
|
||||
return (X509*)what;
|
||||
}
|
||||
|
||||
if (!(Z_TYPE_P(val) == IS_STRING || Z_TYPE_P(val) == IS_OBJECT)) {
|
||||
@ -1407,7 +1401,7 @@ static X509 * php_openssl_x509_from_zval(zval * val, int makeresource, zend_reso
|
||||
}
|
||||
|
||||
if (cert && makeresource && resourceval) {
|
||||
*resourceval = zend_register_resource(NULL, cert, le_x509);
|
||||
*resourceval = zend_register_resource(cert, le_x509);
|
||||
}
|
||||
return cert;
|
||||
}
|
||||
@ -2289,7 +2283,9 @@ PHP_FUNCTION(openssl_x509_free)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &x509) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(cert, X509 *, x509, -1, "OpenSSL X.509", le_x509);
|
||||
if ((cert = (X509 *)zend_fetch_resource(Z_RES_P(x509), "OpenSSL X.509", le_x509)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_list_close(Z_RES_P(x509));
|
||||
}
|
||||
/* }}} */
|
||||
@ -2766,9 +2762,8 @@ static X509_REQ * php_openssl_csr_from_zval(zval * val, int makeresource, zend_r
|
||||
}
|
||||
if (Z_TYPE_P(val) == IS_RESOURCE) {
|
||||
void * what;
|
||||
int type;
|
||||
|
||||
what = zend_fetch_resource(val, -1, "OpenSSL X.509 CSR", &type, 1, le_csr);
|
||||
what = zend_fetch_resource_ex(val, "OpenSSL X.509 CSR", le_csr);
|
||||
if (what) {
|
||||
if (resourceval) {
|
||||
*resourceval = Z_RES_P(val);
|
||||
@ -2997,7 +2992,7 @@ PHP_FUNCTION(openssl_csr_sign)
|
||||
}
|
||||
|
||||
/* Succeeded; lets return the cert */
|
||||
zend_register_resource(return_value, new_cert, le_x509);
|
||||
ZVAL_RES(return_value, zend_register_resource(new_cert, le_x509));
|
||||
new_cert = NULL;
|
||||
|
||||
cleanup:
|
||||
@ -3074,7 +3069,7 @@ PHP_FUNCTION(openssl_csr_new)
|
||||
RETVAL_TRUE;
|
||||
|
||||
if (X509_REQ_sign(csr, req.priv_key, req.digest)) {
|
||||
zend_register_resource(return_value, csr, le_csr);
|
||||
ZVAL_RES(return_value, zend_register_resource(csr, le_csr));
|
||||
csr = NULL;
|
||||
} else {
|
||||
php_error_docref(NULL, E_WARNING, "Error signing request");
|
||||
@ -3083,7 +3078,7 @@ PHP_FUNCTION(openssl_csr_new)
|
||||
if (we_made_the_key) {
|
||||
/* and a resource for the private key */
|
||||
zval_dtor(out_pkey);
|
||||
zend_register_resource(out_pkey, req.priv_key, le_key);
|
||||
ZVAL_RES(out_pkey, zend_register_resource(req.priv_key, le_key));
|
||||
req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */
|
||||
} else if (key_resource != NULL) {
|
||||
req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */
|
||||
@ -3156,8 +3151,7 @@ PHP_FUNCTION(openssl_csr_get_public_key)
|
||||
}
|
||||
|
||||
tpubkey=X509_REQ_get_pubkey(csr);
|
||||
zend_register_resource(return_value, tpubkey, le_key);
|
||||
return;
|
||||
RETURN_RES(zend_register_resource(tpubkey, le_key));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -3225,9 +3219,8 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval * val, int public_key, char * p
|
||||
|
||||
if (Z_TYPE_P(val) == IS_RESOURCE) {
|
||||
void * what;
|
||||
int type;
|
||||
|
||||
what = zend_fetch_resource(val, -1, "OpenSSL X.509/key", &type, 2, le_x509, le_key);
|
||||
what = zend_fetch_resource2_ex(val, "OpenSSL X.509/key", le_x509, le_key);
|
||||
if (!what) {
|
||||
TMP_CLEAN;
|
||||
}
|
||||
@ -3235,11 +3228,11 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval * val, int public_key, char * p
|
||||
*resourceval = Z_RES_P(val);
|
||||
Z_ADDREF_P(val);
|
||||
}
|
||||
if (type == le_x509) {
|
||||
if (Z_RES_P(val)->type == le_x509) {
|
||||
/* extract key from cert, depending on public_key param */
|
||||
cert = (X509*)what;
|
||||
free_cert = 0;
|
||||
} else if (type == le_key) {
|
||||
} else if (Z_RES_P(val)->type == le_key) {
|
||||
int is_priv;
|
||||
|
||||
is_priv = php_openssl_is_private_key((EVP_PKEY*)what);
|
||||
@ -3326,7 +3319,7 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval * val, int public_key, char * p
|
||||
X509_free(cert);
|
||||
}
|
||||
if (key && makeresource && resourceval) {
|
||||
*resourceval = ZEND_REGISTER_RESOURCE(NULL, key, le_key);
|
||||
*resourceval = zend_register_resource(key, le_key);
|
||||
}
|
||||
if (Z_TYPE(tmp) == IS_STRING) {
|
||||
zval_dtor(&tmp);
|
||||
@ -3519,8 +3512,7 @@ PHP_FUNCTION(openssl_pkey_new)
|
||||
OPENSSL_PKEY_SET_BN(Z_ARRVAL_P(data), rsa, iqmp);
|
||||
if (rsa->n && rsa->d) {
|
||||
if (EVP_PKEY_assign_RSA(pkey, rsa)) {
|
||||
zend_register_resource(return_value, pkey, le_key);
|
||||
return;
|
||||
RETURN_RES(zend_register_resource(pkey, le_key));
|
||||
}
|
||||
}
|
||||
RSA_free(rsa);
|
||||
@ -3544,8 +3536,7 @@ PHP_FUNCTION(openssl_pkey_new)
|
||||
DSA_generate_key(dsa);
|
||||
}
|
||||
if (EVP_PKEY_assign_DSA(pkey, dsa)) {
|
||||
zend_register_resource(return_value, pkey, le_key);
|
||||
return;
|
||||
RETURN_RES(zend_register_resource(pkey, le_key));
|
||||
}
|
||||
}
|
||||
DSA_free(dsa);
|
||||
@ -3586,7 +3577,7 @@ PHP_FUNCTION(openssl_pkey_new)
|
||||
{
|
||||
if (php_openssl_generate_private_key(&req)) {
|
||||
/* pass back a key resource */
|
||||
zend_register_resource(return_value, req.priv_key, le_key);
|
||||
RETVAL_RES(zend_register_resource(req.priv_key, le_key));
|
||||
/* make sure the cleanup code doesn't zap it! */
|
||||
req.priv_key = NULL;
|
||||
}
|
||||
@ -3775,7 +3766,9 @@ PHP_FUNCTION(openssl_pkey_free)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &key) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(pkey, EVP_PKEY *, key, -1, "OpenSSL key", le_key);
|
||||
if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), "OpenSSL key", le_key)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_list_close(Z_RES_P(key));
|
||||
}
|
||||
/* }}} */
|
||||
@ -3818,8 +3811,7 @@ PHP_FUNCTION(openssl_pkey_get_details)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &key) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(pkey, EVP_PKEY *, key, -1, "OpenSSL key", le_key);
|
||||
if (!pkey) {
|
||||
if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), "OpenSSL key", le_key)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
out = BIO_new(BIO_s_mem());
|
||||
@ -5350,8 +5342,10 @@ PHP_FUNCTION(openssl_dh_compute_key)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sr", &pub_str, &pub_len, &key) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(pkey, EVP_PKEY *, key, -1, "OpenSSL key", le_key);
|
||||
if (!pkey || EVP_PKEY_type(pkey->type) != EVP_PKEY_DH || !pkey->pkey.dh) {
|
||||
if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), "OpenSSL key", le_key)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DH || !pkey->pkey.dh) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1563,7 +1563,7 @@ static int capture_peer_certs(php_stream *stream, php_openssl_netstream_data_t *
|
||||
"ssl", "capture_peer_cert")) &&
|
||||
zend_is_true(val)
|
||||
) {
|
||||
zend_register_resource(&zcert, peer_cert, php_openssl_get_x509_list_id());
|
||||
ZVAL_RES(&zcert, zend_register_resource(peer_cert, php_openssl_get_x509_list_id()));
|
||||
php_stream_context_set_option(PHP_STREAM_CONTEXT(stream), "ssl", "peer_certificate", &zcert);
|
||||
cert_captured = 1;
|
||||
}
|
||||
@ -1583,7 +1583,7 @@ static int capture_peer_certs(php_stream *stream, php_openssl_netstream_data_t *
|
||||
|
||||
for (i = 0; i < sk_X509_num(chain); i++) {
|
||||
X509 *mycert = X509_dup(sk_X509_value(chain, i));
|
||||
zend_register_resource(&zcert, mycert, php_openssl_get_x509_list_id());
|
||||
ZVAL_RES(&zcert, zend_register_resource(mycert, php_openssl_get_x509_list_id()));
|
||||
add_next_index_zval(&arr, &zcert);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -215,8 +215,7 @@ PHP_FUNCTION(shmop_open)
|
||||
|
||||
shmop->size = shm.shm_segsz;
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, shmop, shm_type);
|
||||
RETURN_LONG(Z_RES_HANDLE_P(return_value));
|
||||
RETURN_RES(zend_register_resource(shmop, shm_type));
|
||||
err:
|
||||
efree(shmop);
|
||||
RETURN_FALSE;
|
||||
@ -227,17 +226,20 @@ err:
|
||||
reads from a shm segment */
|
||||
PHP_FUNCTION(shmop_read)
|
||||
{
|
||||
zend_long shmid, start, count;
|
||||
zval *shmid;
|
||||
zend_long start, count;
|
||||
struct php_shmop *shmop;
|
||||
char *startaddr;
|
||||
int bytes;
|
||||
zend_string *return_string;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &shmid, &start, &count) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rll", &shmid, &start, &count) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(shmop, struct php_shmop *, NULL, shmid, "shmop", shm_type);
|
||||
if ((shmop = (struct php_shmop *)zend_fetch_resource(Z_RES_P(shmid), "shmop", shm_type)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (start < 0 || start > shmop->size) {
|
||||
php_error_docref(NULL, E_WARNING, "start is out of range");
|
||||
@ -262,17 +264,19 @@ PHP_FUNCTION(shmop_read)
|
||||
closes a shared memory segment */
|
||||
PHP_FUNCTION(shmop_close)
|
||||
{
|
||||
zend_long shmid;
|
||||
zval *res;
|
||||
zval *shmid;
|
||||
struct php_shmop *shmop;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &shmid) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &shmid) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
res = zend_hash_index_find(&EG(regular_list), shmid);
|
||||
if (res) {
|
||||
zend_list_close(Z_RES_P(res));
|
||||
|
||||
if ((shmop = (struct php_shmop *)zend_fetch_resource(Z_RES_P(shmid), "shmop", shm_type)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zend_list_close(Z_RES_P(shmid));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -280,14 +284,16 @@ PHP_FUNCTION(shmop_close)
|
||||
returns the shm size */
|
||||
PHP_FUNCTION(shmop_size)
|
||||
{
|
||||
zend_long shmid;
|
||||
zval *shmid;
|
||||
struct php_shmop *shmop;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &shmid) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &shmid) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(shmop, struct php_shmop *, NULL, shmid, "shmop", shm_type);
|
||||
if ((shmop = (struct php_shmop *)zend_fetch_resource(Z_RES_P(shmid), "shmop", shm_type)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(shmop->size);
|
||||
}
|
||||
@ -299,14 +305,17 @@ PHP_FUNCTION(shmop_write)
|
||||
{
|
||||
struct php_shmop *shmop;
|
||||
int writesize;
|
||||
zend_long shmid, offset;
|
||||
zend_long offset;
|
||||
zend_string *data;
|
||||
zval *shmid;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lSl", &shmid, &data, &offset) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rSl", &shmid, &data, &offset) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(shmop, struct php_shmop *, NULL, shmid, "shmop", shm_type);
|
||||
if ((shmop = (struct php_shmop *)zend_fetch_resource(Z_RES_P(shmid), "shmop", shm_type)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((shmop->shmatflg & SHM_RDONLY) == SHM_RDONLY) {
|
||||
php_error_docref(NULL, E_WARNING, "trying to write to a read only segment");
|
||||
@ -329,14 +338,16 @@ PHP_FUNCTION(shmop_write)
|
||||
mark segment for deletion */
|
||||
PHP_FUNCTION(shmop_delete)
|
||||
{
|
||||
zend_long shmid;
|
||||
zval *shmid;
|
||||
struct php_shmop *shmop;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &shmid) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &shmid) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(shmop, struct php_shmop *, NULL, shmid, "shmop", shm_type);
|
||||
if ((shmop = (struct php_shmop *)zend_fetch_resource(Z_RES_P(shmid), "shmop", shm_type)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (shmctl(shmop->shmid, IPC_RMID, NULL)) {
|
||||
php_error_docref(NULL, E_WARNING, "can't mark segment for deletion (are you the owner?)");
|
||||
|
@ -471,7 +471,7 @@ try_again:
|
||||
if (stream != NULL) {
|
||||
php_url *orig;
|
||||
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "httpurl", sizeof("httpurl")-1)) != NULL &&
|
||||
(orig = (php_url *) zend_fetch_resource(tmp, -1, "httpurl", NULL, 1, le_url)) != NULL &&
|
||||
(orig = (php_url *) zend_fetch_resource_ex(tmp, "httpurl", le_url)) != NULL &&
|
||||
((use_proxy && !use_ssl) ||
|
||||
(((use_ssl && orig->scheme != NULL && strcmp(orig->scheme, "https") == 0) ||
|
||||
(!use_ssl && orig->scheme == NULL) ||
|
||||
@ -517,7 +517,7 @@ try_again:
|
||||
|
||||
if (stream) {
|
||||
zval *cookies, *login, *password;
|
||||
zend_resource *ret = zend_register_resource(NULL, phpurl, le_url);
|
||||
zend_resource *ret = zend_register_resource(phpurl, le_url);
|
||||
|
||||
add_property_resource(this_ptr, "httpurl", ret);
|
||||
/*zend_list_addref(ret);*/
|
||||
|
@ -139,16 +139,16 @@ static void soap_error_handler(int error_num, const char *error_filename, const
|
||||
}
|
||||
|
||||
#define FIND_SDL_PROPERTY(ss,tmp) (tmp = zend_hash_str_find(Z_OBJPROP_P(ss), "sdl", sizeof("sdl")-1))
|
||||
#define FETCH_SDL_RES(ss,tmp) ss = (sdlPtr) zend_fetch_resource(tmp, -1, "sdl", NULL, 1, le_sdl)
|
||||
#define FETCH_SDL_RES(ss,tmp) ss = (sdlPtr) zend_fetch_resource_ex(tmp, "sdl", le_sdl)
|
||||
|
||||
#define FIND_TYPEMAP_PROPERTY(ss,tmp) (tmp = zend_hash_str_find(Z_OBJPROP_P(ss), "typemap", sizeof("typemap")-1))
|
||||
#define FETCH_TYPEMAP_RES(ss,tmp) ss = (HashTable*) zend_fetch_resource(tmp, -1, "typemap", NULL, 1, le_typemap)
|
||||
#define FETCH_TYPEMAP_RES(ss,tmp) ss = (HashTable*) zend_fetch_resource_ex(tmp, "typemap", le_typemap)
|
||||
|
||||
#define FETCH_THIS_SERVICE(ss) \
|
||||
{ \
|
||||
zval *tmp; \
|
||||
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(getThis()),"service", sizeof("service")-1)) != NULL) { \
|
||||
ss = (soapServicePtr)zend_fetch_resource(tmp, -1, "service", NULL, 1, le_service); \
|
||||
ss = (soapServicePtr)zend_fetch_resource_ex(tmp, "service", le_service); \
|
||||
} else { \
|
||||
php_error_docref(NULL, E_WARNING, "Can not fetch service object"); \
|
||||
SOAP_SERVER_END_CODE(); \
|
||||
@ -1245,7 +1245,7 @@ PHP_METHOD(SoapServer, SoapServer)
|
||||
service->typemap = soap_create_typemap(service->sdl, typemap_ht);
|
||||
}
|
||||
|
||||
res = zend_register_resource(NULL, service, le_service);
|
||||
res = zend_register_resource(service, le_service);
|
||||
add_property_resource(getThis(), "service", res);
|
||||
|
||||
SOAP_SERVER_END_CODE();
|
||||
@ -2252,7 +2252,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
|
||||
if (Z_OBJ(SOAP_GLOBAL(error_object)) &&
|
||||
instanceof_function(Z_OBJCE(SOAP_GLOBAL(error_object)), soap_server_class_entry) &&
|
||||
(tmp = zend_hash_str_find(Z_OBJPROP(SOAP_GLOBAL(error_object)), "service", sizeof("service")-1)) != NULL &&
|
||||
(service = (soapServicePtr)zend_fetch_resource(tmp, -1, "service", NULL, 1, le_service)) &&
|
||||
(service = (soapServicePtr)zend_fetch_resource_ex(tmp, "service", le_service)) &&
|
||||
!service->send_errors) {
|
||||
strcpy(buffer, "Internal Error");
|
||||
} else {
|
||||
@ -2547,7 +2547,7 @@ PHP_METHOD(SoapClient, SoapClient)
|
||||
SOAP_GLOBAL(soap_version) = soap_version;
|
||||
|
||||
sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl), cache_wsdl);
|
||||
res = zend_register_resource(NULL, sdl, le_sdl);
|
||||
res = zend_register_resource(sdl, le_sdl);
|
||||
|
||||
add_property_resource(this_ptr, "sdl", res);
|
||||
|
||||
@ -2559,7 +2559,7 @@ PHP_METHOD(SoapClient, SoapClient)
|
||||
if (typemap) {
|
||||
zend_resource *res;
|
||||
|
||||
res = zend_register_resource(NULL, typemap, le_typemap);
|
||||
res = zend_register_resource(typemap, le_typemap);
|
||||
add_property_resource(this_ptr, "typemap", res);
|
||||
}
|
||||
}
|
||||
|
@ -1351,15 +1351,13 @@ static void from_zval_write_fd_array_aux(zval *elem, unsigned i, void **args, se
|
||||
php_stream *stream;
|
||||
php_socket *sock;
|
||||
|
||||
ZEND_FETCH_RESOURCE_NO_RETURN(sock, php_socket *, elem, -1,
|
||||
NULL, php_sockets_le_socket());
|
||||
sock = (php_socket *)zend_fetch_resource_ex(elem, NULL, php_sockets_le_socket());
|
||||
if (sock) {
|
||||
iarr[i] = sock->bsd_socket;
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE2_NO_RETURN(stream, php_stream *, elem, -1,
|
||||
NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
stream = (php_stream *)zend_fetch_resource2_ex(elem, NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
if (stream == NULL) {
|
||||
do_from_zval_err(ctx, "resource is not a stream or a socket");
|
||||
return;
|
||||
@ -1423,7 +1421,7 @@ void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx)
|
||||
}
|
||||
if (S_ISSOCK(statbuf.st_mode)) {
|
||||
php_socket *sock = socket_import_file_descriptor(fd);
|
||||
zend_register_resource(&elem, sock, php_sockets_le_socket());
|
||||
ZVAL_RES(&elem, zend_register_resource(sock, php_sockets_le_socket()));
|
||||
} else {
|
||||
php_stream *stream = php_stream_fopen_from_fd(fd, "rw", NULL);
|
||||
php_stream_to_zval(stream, &elem);
|
||||
|
@ -181,8 +181,10 @@ PHP_FUNCTION(socket_sendmsg)
|
||||
|
||||
LONG_CHECK_VALID_INT(flags);
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, zsocket, -1,
|
||||
php_sockets_le_socket_name, php_sockets_le_socket());
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(zsocket),
|
||||
php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
msghdr = from_zval_run_conversions(zmsg, php_sock, from_zval_write_msghdr_send,
|
||||
sizeof(*msghdr), "msghdr", &allocations, &err);
|
||||
@ -224,8 +226,10 @@ PHP_FUNCTION(socket_recvmsg)
|
||||
|
||||
LONG_CHECK_VALID_INT(flags);
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, zsocket, -1,
|
||||
php_sockets_le_socket_name, php_sockets_le_socket());
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(zsocket),
|
||||
php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
msghdr = from_zval_run_conversions(zmsg, php_sock, from_zval_write_msghdr_recv,
|
||||
sizeof(*msghdr), "msghdr", &allocations, &err);
|
||||
|
@ -781,7 +781,7 @@ static int php_sock_array_to_fd_set(zval *sock_array, fd_set *fds, PHP_SOCKET *m
|
||||
if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
|
||||
|
||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(sock_array), element) {
|
||||
php_sock = (php_socket*) zend_fetch_resource(element, -1, le_socket_name, NULL, 1, le_socket);
|
||||
php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
|
||||
if (!php_sock) continue; /* If element is not a resource, skip it */
|
||||
|
||||
PHP_SAFE_FD_SET(php_sock->bsd_socket, fds);
|
||||
@ -809,7 +809,7 @@ static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds) /* {{{ */
|
||||
|
||||
array_init(&new_hash);
|
||||
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(sock_array), num_key, key, element) {
|
||||
php_sock = (php_socket*) zend_fetch_resource(element, -1, le_socket_name, NULL, 1, le_socket);
|
||||
php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
|
||||
if (!php_sock) continue; /* If element is not a resource, skip it */
|
||||
|
||||
if (PHP_SAFE_FD_ISSET(php_sock->bsd_socket, fds)) {
|
||||
@ -927,7 +927,7 @@ PHP_FUNCTION(socket_create_listen)
|
||||
php_sock->error = 0;
|
||||
php_sock->blocking = 1;
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, php_sock, le_socket);
|
||||
RETURN_RES(zend_register_resource(php_sock, le_socket));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -944,13 +944,15 @@ PHP_FUNCTION(socket_accept)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!php_accept_connect(php_sock, &new_sock, (struct sockaddr*)&sa, &php_sa_len)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, new_sock, le_socket);
|
||||
RETURN_RES(zend_register_resource(new_sock, le_socket));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -965,13 +967,14 @@ PHP_FUNCTION(socket_set_nonblock)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!Z_ISUNDEF(php_sock->zstream)) {
|
||||
php_stream *stream;
|
||||
/* omit notice if resource doesn't exist anymore */
|
||||
stream = zend_fetch_resource(&php_sock->zstream, -1,
|
||||
NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
|
||||
stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
if (stream != NULL) {
|
||||
if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, 0,
|
||||
NULL) != -1) {
|
||||
@ -1002,15 +1005,16 @@ PHP_FUNCTION(socket_set_block)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* if socket was created from a stream, give the stream a chance to take
|
||||
* care of the operation itself, thereby allowing it to update its internal
|
||||
* state */
|
||||
if (!Z_ISUNDEF(php_sock->zstream)) {
|
||||
php_stream *stream;
|
||||
stream = zend_fetch_resource(&php_sock->zstream, -1,
|
||||
NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
|
||||
stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
if (stream != NULL) {
|
||||
if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, 1,
|
||||
NULL) != -1) {
|
||||
@ -1042,7 +1046,9 @@ PHP_FUNCTION(socket_listen)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (listen(php_sock->bsd_socket, backlog) != 0) {
|
||||
PHP_SOCKET_ERROR(php_sock, "unable to listen on socket", errno);
|
||||
@ -1063,7 +1069,10 @@ PHP_FUNCTION(socket_close)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!Z_ISUNDEF(php_sock->zstream)) {
|
||||
php_stream *stream = NULL;
|
||||
php_stream_from_zval_no_verify(stream, &php_sock->zstream);
|
||||
@ -1093,7 +1102,9 @@ PHP_FUNCTION(socket_write)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ZEND_NUM_ARGS() < 3) {
|
||||
length = str_len;
|
||||
@ -1135,7 +1146,9 @@ PHP_FUNCTION(socket_read)
|
||||
|
||||
tmpbuf = zend_string_alloc(length, 0);
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (type == PHP_NORMAL_READ) {
|
||||
retval = php_read(php_sock, tmpbuf->val, length, 0);
|
||||
@ -1193,7 +1206,9 @@ PHP_FUNCTION(socket_getsockname)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
sa = (struct sockaddr *) &sa_storage;
|
||||
|
||||
@ -1274,7 +1289,9 @@ PHP_FUNCTION(socket_getpeername)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
sa = (struct sockaddr *) &sa_storage;
|
||||
|
||||
@ -1371,7 +1388,7 @@ PHP_FUNCTION(socket_create)
|
||||
php_sock->error = 0;
|
||||
php_sock->blocking = 1;
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, php_sock, le_socket);
|
||||
RETURN_RES(zend_register_resource(php_sock, le_socket));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1391,7 +1408,9 @@ PHP_FUNCTION(socket_connect)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch(php_sock->type) {
|
||||
#if HAVE_IPV6
|
||||
@ -1495,7 +1514,9 @@ PHP_FUNCTION(socket_bind)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch(php_sock->type) {
|
||||
case AF_UNIX:
|
||||
@ -1575,7 +1596,9 @@ PHP_FUNCTION(socket_recv)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, php_sock_res, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(php_sock_res), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* overflow check */
|
||||
if ((len + 1) < 2) {
|
||||
@ -1621,7 +1644,9 @@ PHP_FUNCTION(socket_send)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
retval = send(php_sock->bsd_socket, buf, (buf_len < len ? buf_len : len), flags);
|
||||
|
||||
@ -1656,7 +1681,9 @@ PHP_FUNCTION(socket_recvfrom)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* overflow check */
|
||||
if ((arg3 + 2) < 3) {
|
||||
@ -1779,7 +1806,9 @@ PHP_FUNCTION(socket_sendto)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch (php_sock->type) {
|
||||
case AF_UNIX:
|
||||
@ -1855,7 +1884,9 @@ PHP_FUNCTION(socket_get_option)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (level == IPPROTO_IP) {
|
||||
switch (optname) {
|
||||
@ -1968,7 +1999,9 @@ PHP_FUNCTION(socket_set_option)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
set_errno(0);
|
||||
|
||||
@ -2138,8 +2171,8 @@ PHP_FUNCTION(socket_create_pair)
|
||||
php_sock[0]->blocking = 1;
|
||||
php_sock[1]->blocking = 1;
|
||||
|
||||
ZEND_REGISTER_RESOURCE(&retval[0], php_sock[0], le_socket);
|
||||
ZEND_REGISTER_RESOURCE(&retval[1], php_sock[1], le_socket);
|
||||
ZVAL_RES(&retval[0], zend_register_resource(php_sock[0], le_socket));
|
||||
ZVAL_RES(&retval[1], zend_register_resource(php_sock[1], le_socket));
|
||||
|
||||
add_index_zval(fds_array_zval, 0, &retval[0]);
|
||||
add_index_zval(fds_array_zval, 1, &retval[1]);
|
||||
@ -2162,7 +2195,9 @@ PHP_FUNCTION(socket_shutdown)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket*, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (shutdown(php_sock->bsd_socket, how_shutdown) != 0) {
|
||||
PHP_SOCKET_ERROR(php_sock, "unable to shutdown socket", errno);
|
||||
@ -2186,7 +2221,9 @@ PHP_FUNCTION(socket_last_error)
|
||||
}
|
||||
|
||||
if (arg1) {
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket*, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
RETVAL_LONG(php_sock->error);
|
||||
} else {
|
||||
RETVAL_LONG(SOCKETS_G(last_error));
|
||||
@ -2206,7 +2243,9 @@ PHP_FUNCTION(socket_clear_error)
|
||||
}
|
||||
|
||||
if (arg1) {
|
||||
ZEND_FETCH_RESOURCE(php_sock, php_socket*, arg1, -1, le_socket_name, le_socket);
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
php_sock->error = 0;
|
||||
} else {
|
||||
SOCKETS_G(last_error) = 0;
|
||||
@ -2306,7 +2345,7 @@ PHP_FUNCTION(socket_import_stream)
|
||||
php_stream_set_option(stream, PHP_STREAM_OPTION_READ_BUFFER,
|
||||
PHP_STREAM_BUFFER_NONE, NULL);
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, retsock, le_socket);
|
||||
RETURN_RES(zend_register_resource(retsock, le_socket));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -85,14 +85,19 @@ static zend_class_entry *dir_class_entry_ptr;
|
||||
php_error_docref(NULL, E_WARNING, "Unable to find my handle property"); \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
ZEND_FETCH_RESOURCE(dirp, php_stream *, tmp, -1, "Directory", php_file_le_stream()); \
|
||||
if ((dirp = (php_stream *)zend_fetch_resource_ex(tmp, "Directory", php_file_le_stream())) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
} else { \
|
||||
ZEND_FETCH_RESOURCE(dirp, php_stream *, 0, (int)DIRG(default_dir)->handle, "Directory", php_file_le_stream()); \
|
||||
if (!DIRG(default_dir) || \
|
||||
(dirp = (php_stream *)zend_fetch_resource(DIRG(default_dir), "Directory", php_file_le_stream())) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
dirp = (php_stream *) zend_fetch_resource(id, -1, "Directory", NULL, 1, php_file_le_stream()); \
|
||||
if (!dirp) \
|
||||
if ((dirp = (php_stream *)zend_fetch_resource(Z_RES_P(id), "Directory", php_file_le_stream())) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* {{{ arginfo */
|
||||
|
@ -128,10 +128,8 @@ php_file_globals file_globals;
|
||||
/* }}} */
|
||||
|
||||
#define PHP_STREAM_TO_ZVAL(stream, arg) \
|
||||
php_stream_from_zval_no_verify(stream, arg); \
|
||||
if (stream == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
ZEND_ASSERT(Z_TYPE_P(arg) == IS_RESOURCE); \
|
||||
php_stream_from_res(stream, Z_RES_P(arg));
|
||||
|
||||
/* {{{ ZTS-stuff / Globals / Prototypes */
|
||||
|
||||
@ -1157,7 +1155,7 @@ PHPAPI PHP_FUNCTION(fgetss)
|
||||
Implements a mostly ANSI compatible fscanf() */
|
||||
PHP_FUNCTION(fscanf)
|
||||
{
|
||||
int result, type, argc = 0;
|
||||
int result, argc = 0;
|
||||
size_t format_len;
|
||||
zval *args = NULL;
|
||||
zval *file_handle;
|
||||
@ -1169,7 +1167,7 @@ PHP_FUNCTION(fscanf)
|
||||
return;
|
||||
}
|
||||
|
||||
what = zend_fetch_resource(file_handle, -1, "File-Handle", &type, 2, php_file_le_stream(), php_file_le_pstream());
|
||||
what = zend_fetch_resource2(Z_RES_P(file_handle), "File-Handle", php_file_le_stream(), php_file_le_pstream());
|
||||
|
||||
/* we can't do a ZEND_VERIFY_RESOURCE(what), otherwise we end up
|
||||
* with a leak if we have an invalid filehandle. This needs changing
|
||||
|
@ -266,7 +266,9 @@ PHP_FUNCTION(proc_terminate)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, "process", le_proc_open);
|
||||
if ((proc = (struct php_process_handle *)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
if (TerminateProcess(proc->childHandle, 255)) {
|
||||
@ -295,7 +297,9 @@ PHP_FUNCTION(proc_close)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, "process", le_proc_open);
|
||||
if ((proc = (struct php_process_handle *)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
FG(pclose_wait) = 1;
|
||||
zend_list_close(Z_RES_P(zproc));
|
||||
@ -323,7 +327,9 @@ PHP_FUNCTION(proc_get_status)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, "process", le_proc_open);
|
||||
if ((proc = (struct php_process_handle *)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
@ -946,7 +952,7 @@ PHP_FUNCTION(proc_open)
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, proc, le_proc_open);
|
||||
ZVAL_RES(return_value, zend_register_resource(proc, le_proc_open));
|
||||
return;
|
||||
|
||||
exit_fail:
|
||||
|
@ -916,11 +916,11 @@ static php_stream_context *decode_context_param(zval *contextresource)
|
||||
{
|
||||
php_stream_context *context = NULL;
|
||||
|
||||
context = zend_fetch_resource(contextresource, -1, NULL, NULL, 1, php_le_stream_context());
|
||||
context = zend_fetch_resource_ex(contextresource, NULL, php_le_stream_context());
|
||||
if (context == NULL) {
|
||||
php_stream *stream;
|
||||
|
||||
stream = zend_fetch_resource(contextresource, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream);
|
||||
stream = zend_fetch_resource2_ex(contextresource, NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
|
||||
if (stream) {
|
||||
context = PHP_STREAM_CONTEXT(stream);
|
||||
@ -1182,7 +1182,7 @@ static void apply_filter_to_stream(int append, INTERNAL_FUNCTION_PARAMETERS)
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
filter->res = ZEND_REGISTER_RESOURCE(NULL, filter, php_file_le_stream_filter());
|
||||
filter->res = zend_register_resource(filter, php_file_le_stream_filter());
|
||||
GC_REFCOUNT(filter->res)++;
|
||||
RETURN_RES(filter->res);
|
||||
} else {
|
||||
@ -1218,7 +1218,7 @@ PHP_FUNCTION(stream_filter_remove)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
filter = zend_fetch_resource(zfilter, -1, NULL, NULL, 1, php_file_le_stream_filter());
|
||||
filter = zend_fetch_resource(Z_RES_P(zfilter), NULL, php_file_le_stream_filter());
|
||||
if (!filter) {
|
||||
php_error_docref(NULL, E_WARNING, "Invalid resource given, not a stream filter");
|
||||
RETURN_FALSE;
|
||||
|
@ -40,15 +40,6 @@ static int le_userfilters;
|
||||
static int le_bucket_brigade;
|
||||
static int le_bucket;
|
||||
|
||||
#define GET_FILTER_FROM_OBJ() { \
|
||||
zval **tmp; \
|
||||
if (FAILURE == zend_hash_index_find(Z_OBJPROP_P(this_ptr), 0, (void**)&tmp)) { \
|
||||
php_error_docref(NULL, E_WARNING, "filter property vanished"); \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
ZEND_FETCH_RESOURCE(filter, php_stream_filter*, tmp, -1, "filter", le_userfilters); \
|
||||
}
|
||||
|
||||
/* define the base filter class */
|
||||
|
||||
PHP_FUNCTION(user_filter_nop)
|
||||
@ -198,9 +189,8 @@ php_stream_filter_status_t userfilter_filter(
|
||||
ZVAL_STRINGL(&func_name, "filter", sizeof("filter")-1);
|
||||
|
||||
/* Setup calling arguments */
|
||||
ZEND_REGISTER_RESOURCE(&args[0], buckets_in, le_bucket_brigade);
|
||||
|
||||
ZEND_REGISTER_RESOURCE(&args[1], buckets_out, le_bucket_brigade);
|
||||
ZVAL_RES(&args[0], zend_register_resource(buckets_in, le_bucket_brigade));
|
||||
ZVAL_RES(&args[1], zend_register_resource(buckets_out, le_bucket_brigade));
|
||||
|
||||
if (bytes_consumed) {
|
||||
ZVAL_LONG(&args[2], *bytes_consumed);
|
||||
@ -381,7 +371,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
|
||||
zval_ptr_dtor(&func_name);
|
||||
|
||||
/* set the filter property, this will be used during cleanup */
|
||||
ZEND_REGISTER_RESOURCE(&zfilter, filter, le_userfilters);
|
||||
ZVAL_RES(&zfilter, zend_register_resource(filter, le_userfilters));
|
||||
ZVAL_COPY_VALUE(&filter->abstract, &obj);
|
||||
add_property_zval(&obj, "filter", &zfilter);
|
||||
/* add_property_zval increments the refcount which is unwanted here */
|
||||
@ -409,16 +399,19 @@ PHP_FUNCTION(stream_bucket_make_writeable)
|
||||
php_stream_bucket_brigade *brigade;
|
||||
php_stream_bucket *bucket;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zbrigade) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zbrigade) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(brigade, php_stream_bucket_brigade *, zbrigade, -1, PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade);
|
||||
if ((brigade = (php_stream_bucket_brigade*)zend_fetch_resource(
|
||||
Z_RES_P(zbrigade), PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZVAL_NULL(return_value);
|
||||
|
||||
if (brigade->head && (bucket = php_stream_bucket_make_writeable(brigade->head))) {
|
||||
ZEND_REGISTER_RESOURCE(&zbucket, bucket, le_bucket);
|
||||
ZVAL_RES(&zbucket, zend_register_resource(bucket, le_bucket));
|
||||
object_init(return_value);
|
||||
add_property_zval(return_value, "bucket", &zbucket);
|
||||
/* add_property_zval increments the refcount which is unwanted here */
|
||||
@ -437,7 +430,7 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
|
||||
php_stream_bucket_brigade *brigade;
|
||||
php_stream_bucket *bucket;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zo", &zbrigade, &zobject) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ro", &zbrigade, &zobject) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@ -446,8 +439,14 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(brigade, php_stream_bucket_brigade *, zbrigade, -1, PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade);
|
||||
ZEND_FETCH_RESOURCE(bucket, php_stream_bucket *, pzbucket, -1, PHP_STREAM_BUCKET_RES_NAME, le_bucket);
|
||||
if ((brigade = (php_stream_bucket_brigade*)zend_fetch_resource(
|
||||
Z_RES_P(zbrigade), PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((bucket = (php_stream_bucket *)zend_fetch_resource_ex(pzbucket, PHP_STREAM_BUCKET_RES_NAME, le_bucket)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (NULL != (pzdata = zend_hash_str_find(Z_OBJPROP_P(zobject), "data", sizeof("data")-1)) && Z_TYPE_P(pzdata) == IS_STRING) {
|
||||
if (!bucket->own_buf) {
|
||||
@ -519,7 +518,7 @@ PHP_FUNCTION(stream_bucket_new)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(&zbucket, bucket, le_bucket);
|
||||
ZVAL_RES(&zbucket, zend_register_resource(bucket, le_bucket));
|
||||
object_init(return_value);
|
||||
add_property_zval(return_value, "bucket", &zbucket);
|
||||
/* add_property_zval increments the refcount which is unwanted here */
|
||||
|
@ -164,7 +164,9 @@ PHP_FUNCTION(msg_set_queue)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, queue, -1, "sysvmsg queue", le_sysvmsg);
|
||||
if ((mq = (sysvmsg_queue_t *)zend_fetch_resource(Z_RES_P(queue), "sysvmsg queue", le_sysvmsg)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (msgctl(mq->id, IPC_STAT, &stat) == 0) {
|
||||
zval *item;
|
||||
@ -207,7 +209,9 @@ PHP_FUNCTION(msg_stat_queue)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, queue, -1, "sysvmsg queue", le_sysvmsg);
|
||||
if ((mq = (sysvmsg_queue_t *)zend_fetch_resource(Z_RES_P(queue), "sysvmsg queue", le_sysvmsg)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (msgctl(mq->id, IPC_STAT, &stat) == 0) {
|
||||
array_init(return_value);
|
||||
@ -284,7 +288,9 @@ PHP_FUNCTION(msg_remove_queue)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, queue, -1, "sysvmsg queue", le_sysvmsg);
|
||||
if ((mq = (sysvmsg_queue_t *)zend_fetch_resource(Z_RES_P(queue), "sysvmsg queue", le_sysvmsg)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (msgctl(mq->id, IPC_RMID, NULL) == 0) {
|
||||
RETVAL_TRUE;
|
||||
@ -336,7 +342,9 @@ PHP_FUNCTION(msg_receive)
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, queue, -1, "sysvmsg queue", le_sysvmsg);
|
||||
if ((mq = (sysvmsg_queue_t *)zend_fetch_resource(Z_RES_P(queue), "sysvmsg queue", le_sysvmsg)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
messagebuffer = (struct php_msgbuf *) safe_emalloc(maxsize, 1, sizeof(struct php_msgbuf));
|
||||
|
||||
@ -400,7 +408,9 @@ PHP_FUNCTION(msg_send)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t*, queue, -1, "sysvmsg queue", le_sysvmsg);
|
||||
if ((mq = (sysvmsg_queue_t *)zend_fetch_resource(Z_RES_P(queue), "sysvmsg queue", le_sysvmsg)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (do_serialize) {
|
||||
smart_str msg_var = {0};
|
||||
|
@ -290,7 +290,7 @@ PHP_FUNCTION(sem_get)
|
||||
sem_ptr->count = 0;
|
||||
sem_ptr->auto_release = auto_release;
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, sem_ptr, php_sysvsem_module.le_sem);
|
||||
RETVAL_RES(zend_register_resource(sem_ptr, php_sysvsem_module.le_sem));
|
||||
sem_ptr->id = Z_RES_HANDLE_P(return_value);
|
||||
}
|
||||
/* }}} */
|
||||
@ -314,7 +314,9 @@ static void php_sysvsem_semop(INTERNAL_FUNCTION_PARAMETERS, int acquire)
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(sem_ptr, sysvsem_sem *, arg_id, -1, "SysV semaphore", php_sysvsem_module.le_sem);
|
||||
if ((sem_ptr = (sysvsem_sem *)zend_fetch_resource(Z_RES_P(arg_id), "SysV semaphore", php_sysvsem_module.le_sem)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!acquire && sem_ptr->count == 0) {
|
||||
php_error_docref(NULL, E_WARNING, "SysV semaphore %ld (key 0x%x) is not currently acquired", Z_LVAL_P(arg_id), sem_ptr->key);
|
||||
@ -376,7 +378,9 @@ PHP_FUNCTION(sem_remove)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(sem_ptr, sysvsem_sem *, arg_id, -1, "SysV semaphore", php_sysvsem_module.le_sem);
|
||||
if ((sem_ptr = (sysvsem_sem *)zend_fetch_resource(Z_RES_P(arg_id), "SysV semaphore", php_sysvsem_module.le_sem)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
#if HAVE_SEMUN
|
||||
un.buf = &buf;
|
||||
|
@ -112,7 +112,11 @@ ZEND_GET_MODULE(sysvshm)
|
||||
|
||||
#undef shm_ptr /* undefine AIX-specific macro */
|
||||
|
||||
#define SHM_FETCH_RESOURCE(shm_ptr, z_ptr) ZEND_FETCH_RESOURCE(shm_ptr, sysvshm_shm *, z_ptr, -1, PHP_SHM_RSRC_NAME, php_sysvshm.le_shm)
|
||||
#define SHM_FETCH_RESOURCE(shm_ptr, z_ptr) do { \
|
||||
if ((shm_ptr = (sysvshm_shm *)zend_fetch_resource(Z_RES_P(z_ptr), PHP_SHM_RSRC_NAME, php_sysvshm.le_shm)) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
THREAD_LS sysvshm_module php_sysvshm;
|
||||
|
||||
@ -197,7 +201,7 @@ PHP_FUNCTION(shm_attach)
|
||||
shm_list_ptr->id = shm_id;
|
||||
shm_list_ptr->ptr = chunk_ptr;
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, shm_list_ptr, php_sysvshm.le_shm);
|
||||
RETURN_RES(zend_register_resource(shm_list_ptr, php_sysvshm.le_shm));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -257,7 +261,7 @@ PHP_FUNCTION(shm_put_var)
|
||||
php_var_serialize(&shm_var, arg_var, &var_hash);
|
||||
PHP_VAR_SERIALIZE_DESTROY(var_hash);
|
||||
|
||||
shm_list_ptr = zend_fetch_resource(shm_id, -1, PHP_SHM_RSRC_NAME, NULL, 1, php_sysvshm.le_shm);
|
||||
shm_list_ptr = zend_fetch_resource(Z_RES_P(shm_id), PHP_SHM_RSRC_NAME, php_sysvshm.le_shm);
|
||||
if (!shm_list_ptr) {
|
||||
smart_str_free(&shm_var);
|
||||
RETURN_FALSE;
|
||||
|
@ -1177,7 +1177,7 @@ PHP_FUNCTION(wddx_packet_start)
|
||||
php_wddx_packet_start(packet, comment, comment_len);
|
||||
php_wddx_add_chunk_static(packet, WDDX_STRUCT_S);
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, packet, le_wddx);
|
||||
RETURN_RES(zend_register_resource(packet, le_wddx));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1192,7 +1192,9 @@ PHP_FUNCTION(wddx_packet_end)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(packet, wddx_packet *, packet_id, -1, "WDDX packet ID", le_wddx);
|
||||
if ((packet = (wddx_packet *)zend_fetch_resource(Z_RES_P(packet_id), "WDDX packet ID", le_wddx)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
php_wddx_add_chunk_static(packet, WDDX_STRUCT_E);
|
||||
|
||||
@ -1218,11 +1220,7 @@ PHP_FUNCTION(wddx_add_vars)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ZEND_FETCH_RESOURCE_NO_RETURN(packet, wddx_packet *, packet_id, -1, "WDDX packet ID", le_wddx)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!packet) {
|
||||
if ((packet = (wddx_packet *)zend_fetch_resource(Z_RES_P(packet_id), "WDDX packet ID", le_wddx)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_supp
|
||||
|
||||
XML_SetUserData(parser->parser, parser);
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, parser, le_xml_parser);
|
||||
RETVAL_RES(zend_register_resource(parser, le_xml_parser));
|
||||
ZVAL_COPY(&parser->index, return_value);
|
||||
}
|
||||
/* }}} */
|
||||
@ -1173,7 +1173,9 @@ PHP_FUNCTION(xml_set_object)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* please leave this commented - or ask thies@thieso.net before doing it (again) */
|
||||
if (!Z_ISUNDEF(parser->object)) {
|
||||
@ -1202,7 +1204,9 @@ PHP_FUNCTION(xml_set_element_handler)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xml_set_handler(&parser->startElementHandler, shdl);
|
||||
xml_set_handler(&parser->endElementHandler, ehdl);
|
||||
@ -1222,7 +1226,9 @@ PHP_FUNCTION(xml_set_character_data_handler)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xml_set_handler(&parser->characterDataHandler, hdl);
|
||||
XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler);
|
||||
@ -1241,7 +1247,9 @@ PHP_FUNCTION(xml_set_processing_instruction_handler)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xml_set_handler(&parser->processingInstructionHandler, hdl);
|
||||
XML_SetProcessingInstructionHandler(parser->parser, _xml_processingInstructionHandler);
|
||||
@ -1260,7 +1268,9 @@ PHP_FUNCTION(xml_set_default_handler)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xml_set_handler(&parser->defaultHandler, hdl);
|
||||
XML_SetDefaultHandler(parser->parser, _xml_defaultHandler);
|
||||
@ -1279,7 +1289,9 @@ PHP_FUNCTION(xml_set_unparsed_entity_decl_handler)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xml_set_handler(&parser->unparsedEntityDeclHandler, hdl);
|
||||
XML_SetUnparsedEntityDeclHandler(parser->parser, _xml_unparsedEntityDeclHandler);
|
||||
@ -1297,7 +1309,10 @@ PHP_FUNCTION(xml_set_notation_decl_handler)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz", &pind, &hdl) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xml_set_handler(&parser->notationDeclHandler, hdl);
|
||||
XML_SetNotationDeclHandler(parser->parser, _xml_notationDeclHandler);
|
||||
@ -1315,7 +1330,10 @@ PHP_FUNCTION(xml_set_external_entity_ref_handler)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz", &pind, &hdl) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xml_set_handler(&parser->externalEntityRefHandler, hdl);
|
||||
XML_SetExternalEntityRefHandler(parser->parser, (void *) _xml_externalEntityRefHandler);
|
||||
@ -1334,7 +1352,9 @@ PHP_FUNCTION(xml_set_start_namespace_decl_handler)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xml_set_handler(&parser->startNamespaceDeclHandler, hdl);
|
||||
XML_SetStartNamespaceDeclHandler(parser->parser, _xml_startNamespaceDeclHandler);
|
||||
@ -1353,7 +1373,9 @@ PHP_FUNCTION(xml_set_end_namespace_decl_handler)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xml_set_handler(&parser->endNamespaceDeclHandler, hdl);
|
||||
XML_SetEndNamespaceDeclHandler(parser->parser, _xml_endNamespaceDeclHandler);
|
||||
@ -1375,7 +1397,10 @@ PHP_FUNCTION(xml_parse)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|l", &pind, &data, &data_len, &isFinal) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
parser->isparsing = 1;
|
||||
ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, isFinal);
|
||||
@ -1405,7 +1430,9 @@ PHP_FUNCTION(xml_parse_into_struct)
|
||||
array_init(info);
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zval_ptr_dtor(xdata);
|
||||
array_init(xdata);
|
||||
@ -1442,7 +1469,9 @@ PHP_FUNCTION(xml_get_error_code)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG((zend_long)XML_GetErrorCode(parser->parser));
|
||||
}
|
||||
@ -1477,7 +1506,9 @@ PHP_FUNCTION(xml_get_current_line_number)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETVAL_LONG(XML_GetCurrentLineNumber(parser->parser));
|
||||
}
|
||||
@ -1494,7 +1525,9 @@ PHP_FUNCTION(xml_get_current_column_number)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETVAL_LONG(XML_GetCurrentColumnNumber(parser->parser));
|
||||
}
|
||||
@ -1511,7 +1544,9 @@ PHP_FUNCTION(xml_get_current_byte_index)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETVAL_LONG(XML_GetCurrentByteIndex(parser->parser));
|
||||
}
|
||||
@ -1529,7 +1564,9 @@ PHP_FUNCTION(xml_parser_free)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (parser->isparsing == 1) {
|
||||
php_error_docref(NULL, E_WARNING, "Parser cannot be freed while it is parsing.");
|
||||
@ -1555,7 +1592,9 @@ PHP_FUNCTION(xml_parser_set_option)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch (opt) {
|
||||
case PHP_XML_OPTION_CASE_FOLDING:
|
||||
@ -1601,7 +1640,10 @@ PHP_FUNCTION(xml_parser_get_option)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pind, &opt) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
|
||||
|
||||
if ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), "XML Parser", le_xml_parser)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch (opt) {
|
||||
case PHP_XML_OPTION_CASE_FOLDING:
|
||||
|
@ -827,7 +827,7 @@ PHP_FUNCTION(xmlrpc_server_create)
|
||||
XMLRPC_ServerRegisterIntrospectionCallback(server->server_ptr, php_xmlrpc_introspection_callback);
|
||||
|
||||
/* store for later use */
|
||||
ZEND_REGISTER_RESOURCE(return_value, server, le_xmlrpc_server);
|
||||
RETURN_RES(zend_register_resource(server, le_xmlrpc_server));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -844,14 +844,14 @@ PHP_FUNCTION(xmlrpc_server_destroy)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, arg1, -1, "xmlrpc server", le_xmlrpc_server);
|
||||
|
||||
if (server) {
|
||||
bSuccess = zend_list_close(Z_RES_P(arg1));
|
||||
/* called by hashtable destructor
|
||||
* destroy_server_data(server);
|
||||
*/
|
||||
if ((server = (xmlrpc_server_data *)zend_fetch_resource(Z_RES_P(arg1), "xmlrpc server", le_xmlrpc_server)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
bSuccess = zend_list_close(Z_RES_P(arg1));
|
||||
/* called by hashtable destructor
|
||||
* destroy_server_data(server);
|
||||
*/
|
||||
RETURN_BOOL(bSuccess == SUCCESS);
|
||||
}
|
||||
/* }}} */
|
||||
@ -964,7 +964,9 @@ PHP_FUNCTION(xmlrpc_server_register_method)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, handle, -1, "xmlrpc server", le_xmlrpc_server);
|
||||
if ((server = (xmlrpc_server_data *)zend_fetch_resource(Z_RES_P(handle), "xmlrpc server", le_xmlrpc_server)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* register with C engine. every method just calls our standard callback,
|
||||
* and it then dispatches to php as necessary
|
||||
@ -994,7 +996,9 @@ PHP_FUNCTION(xmlrpc_server_register_introspection_callback)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, handle, -1, "xmlrpc server", le_xmlrpc_server);
|
||||
if ((server = (xmlrpc_server_data *)zend_fetch_resource(Z_RES_P(handle), "xmlrpc server", le_xmlrpc_server)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (Z_REFCOUNTED_P(method_name)) {
|
||||
Z_ADDREF_P(method_name);
|
||||
@ -1032,7 +1036,9 @@ PHP_FUNCTION(xmlrpc_server_call_method)
|
||||
set_output_options(&out, output_opts);
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, handle, -1, "xmlrpc server", le_xmlrpc_server);
|
||||
if ((server = (xmlrpc_server_data *)zend_fetch_resource(Z_RES_P(handle), "xmlrpc server", le_xmlrpc_server)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* HACK: use output encoding for now */
|
||||
input_opts.xml_elem_opts.encoding = utf8_get_encoding_id_from_string(out.xmlrpc_out.xml_elem_opts.encoding);
|
||||
@ -1122,7 +1128,9 @@ PHP_FUNCTION(xmlrpc_server_add_introspection_data)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, handle, -1, "xmlrpc server", le_xmlrpc_server);
|
||||
if ((server = (xmlrpc_server_data *)zend_fetch_resource(Z_RES_P(handle), "xmlrpc server", le_xmlrpc_server)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xDesc = PHP_to_XMLRPC(desc);
|
||||
if (xDesc) {
|
||||
|
@ -709,7 +709,9 @@ static void php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_rea
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (err_string != NULL) {
|
||||
@ -745,7 +747,9 @@ static void php_xmlwriter_end(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_read_int_t
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ptr = intern->ptr;
|
||||
@ -782,7 +786,9 @@ static PHP_FUNCTION(xmlwriter_set_indent)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rb", &pind, &indent) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -848,7 +854,9 @@ static PHP_FUNCTION(xmlwriter_start_attribute_ns)
|
||||
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid Attribute Name");
|
||||
@ -890,7 +898,9 @@ static PHP_FUNCTION(xmlwriter_write_attribute)
|
||||
&name, &name_len, &content, &content_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid Attribute Name");
|
||||
@ -933,7 +943,9 @@ static PHP_FUNCTION(xmlwriter_write_attribute_ns)
|
||||
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid Attribute Name");
|
||||
@ -983,7 +995,9 @@ static PHP_FUNCTION(xmlwriter_start_element_ns)
|
||||
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid Element Name");
|
||||
@ -1041,7 +1055,9 @@ static PHP_FUNCTION(xmlwriter_write_element)
|
||||
&name, &name_len, &content, &content_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid Element Name");
|
||||
@ -1093,7 +1109,9 @@ static PHP_FUNCTION(xmlwriter_write_element_ns)
|
||||
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid Element Name");
|
||||
@ -1162,7 +1180,9 @@ static PHP_FUNCTION(xmlwriter_write_pi)
|
||||
&name, &name_len, &content, &content_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid PI Target");
|
||||
@ -1196,7 +1216,9 @@ static PHP_FUNCTION(xmlwriter_start_cdata)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ptr = intern->ptr;
|
||||
@ -1261,7 +1283,9 @@ static PHP_FUNCTION(xmlwriter_start_comment)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ptr = intern->ptr;
|
||||
@ -1317,7 +1341,9 @@ static PHP_FUNCTION(xmlwriter_start_document)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!", &pind, &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ptr = intern->ptr;
|
||||
@ -1363,8 +1389,9 @@ static PHP_FUNCTION(xmlwriter_start_dtd)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
ptr = intern->ptr;
|
||||
|
||||
@ -1410,7 +1437,9 @@ static PHP_FUNCTION(xmlwriter_write_dtd)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ptr = intern->ptr;
|
||||
@ -1464,7 +1493,9 @@ static PHP_FUNCTION(xmlwriter_write_dtd_element)
|
||||
&name, &name_len, &content, &content_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid Element Name");
|
||||
@ -1522,7 +1553,9 @@ static PHP_FUNCTION(xmlwriter_write_dtd_attlist)
|
||||
&name, &name_len, &content, &content_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid Element Name");
|
||||
@ -1561,7 +1594,9 @@ static PHP_FUNCTION(xmlwriter_start_dtd_entity)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsb", &pind, &name, &name_len, &isparm) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid Attribute Name");
|
||||
@ -1616,7 +1651,9 @@ static PHP_FUNCTION(xmlwriter_write_dtd_entity)
|
||||
&sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
XMLW_NAME_CHK("Invalid Element Name");
|
||||
@ -1684,7 +1721,7 @@ static PHP_FUNCTION(xmlwriter_open_uri)
|
||||
ze_obj->xmlwriter_ptr = intern;
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
|
||||
RETURN_RES(zend_register_resource(intern, le_xmlwriter));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -1727,7 +1764,7 @@ static PHP_FUNCTION(xmlwriter_open_memory)
|
||||
ze_obj->xmlwriter_ptr = intern;
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
|
||||
RETURN_RES(zend_register_resource(intern, le_xmlwriter));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1753,7 +1790,9 @@ static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(intern, xmlwriter_object *, pind, -1, "XMLWriter", le_xmlwriter);
|
||||
if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
ptr = intern->ptr;
|
||||
|
||||
|
@ -1130,7 +1130,7 @@ static PHP_NAMED_FUNCTION(zif_zip_open)
|
||||
rsrc_int->index_current = 0;
|
||||
rsrc_int->num_files = zip_get_num_files(rsrc_int->za);
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, rsrc_int, le_zip_dir);
|
||||
RETURN_RES(zend_register_resource(rsrc_int, le_zip_dir));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -1144,7 +1144,10 @@ static PHP_NAMED_FUNCTION(zif_zip_close)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zip) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_FETCH_RESOURCE(z_rsrc, zip_rsrc *, zip, -1, le_zip_dir_name, le_zip_dir);
|
||||
|
||||
if ((z_rsrc = (zip_rsrc *)zend_fetch_resource(Z_RES_P(zip), le_zip_dir_name, le_zip_dir)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* really close the zip will break BC :-D */
|
||||
zend_list_close(Z_RES_P(zip));
|
||||
@ -1164,7 +1167,9 @@ static PHP_NAMED_FUNCTION(zif_zip_read)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(rsrc_int, zip_rsrc *, zip_dp, -1, le_zip_dir_name, le_zip_dir);
|
||||
if ((rsrc_int = (zip_rsrc *)zend_fetch_resource(Z_RES_P(zip_dp), le_zip_dir_name, le_zip_dir)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (rsrc_int && rsrc_int->za) {
|
||||
if (rsrc_int->index_current >= rsrc_int->num_files) {
|
||||
@ -1183,7 +1188,7 @@ static PHP_NAMED_FUNCTION(zif_zip_read)
|
||||
zr_rsrc->zf = zip_fopen_index(rsrc_int->za, rsrc_int->index_current, 0);
|
||||
if (zr_rsrc->zf) {
|
||||
rsrc_int->index_current++;
|
||||
ZEND_REGISTER_RESOURCE(return_value, zr_rsrc, le_zip_entry);
|
||||
RETURN_RES(zend_register_resource(zr_rsrc, le_zip_entry));
|
||||
} else {
|
||||
efree(zr_rsrc);
|
||||
RETURN_FALSE;
|
||||
@ -1211,8 +1216,13 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_open)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(zr_rsrc, zip_read_rsrc *, zip_entry, -1, le_zip_entry_name, le_zip_entry);
|
||||
ZEND_FETCH_RESOURCE(z_rsrc, zip_rsrc *, zip, -1, le_zip_dir_name, le_zip_dir);
|
||||
if ((zr_rsrc = (zip_read_rsrc *)zend_fetch_resource(Z_RES_P(zip_entry), le_zip_entry_name, le_zip_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((z_rsrc = (zip_rsrc *)zend_fetch_resource(Z_RES_P(zip), le_zip_dir_name, le_zip_dir)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (zr_rsrc->zf != NULL) {
|
||||
RETURN_TRUE;
|
||||
@ -1233,7 +1243,9 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_close)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(zr_rsrc, zip_read_rsrc *, zip_entry, -1, le_zip_entry_name, le_zip_entry);
|
||||
if ((zr_rsrc = (zip_read_rsrc *)zend_fetch_resource(Z_RES_P(zip_entry), le_zip_entry_name, le_zip_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_BOOL(SUCCESS == zend_list_close(Z_RES_P(zip_entry)));
|
||||
}
|
||||
@ -1253,7 +1265,9 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_read)
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(zr_rsrc, zip_read_rsrc *, zip_entry, -1, le_zip_entry_name, le_zip_entry);
|
||||
if ((zr_rsrc = (zip_read_rsrc *)zend_fetch_resource(Z_RES_P(zip_entry), le_zip_entry_name, le_zip_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (len <= 0) {
|
||||
len = 1024;
|
||||
@ -1285,7 +1299,9 @@ static void php_zip_entry_get_info(INTERNAL_FUNCTION_PARAMETERS, int opt) /* {{{
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(zr_rsrc, zip_read_rsrc *, zip_entry, -1, le_zip_entry_name, le_zip_entry);
|
||||
if ((zr_rsrc = (zip_read_rsrc *)zend_fetch_resource(Z_RES_P(zip_entry), le_zip_entry_name, le_zip_entry)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!zr_rsrc->zf) {
|
||||
RETURN_FALSE;
|
||||
|
@ -253,8 +253,20 @@ END_EXTERN_C()
|
||||
* when the resources are auto-destructed */
|
||||
#define php_stream_to_zval(stream, zval) { ZVAL_RES(zval, (stream)->res); (stream)->__exposed++; }
|
||||
|
||||
#define php_stream_from_zval(xstr, pzval) ZEND_FETCH_RESOURCE2((xstr), php_stream *, (pzval), -1, "stream", php_file_le_stream(), php_file_le_pstream())
|
||||
#define php_stream_from_zval_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource((pzval), -1, "stream", NULL, 2, php_file_le_stream(), php_file_le_pstream())
|
||||
#define php_stream_from_zval(xstr, pzval) do { \
|
||||
if (((xstr) = (php_stream*)zend_fetch_resource2_ex((pzval), \
|
||||
"stream", php_file_le_stream(), php_file_le_pstream())) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
} while (0)
|
||||
#define php_stream_from_res(xstr, res) do { \
|
||||
if (((xstr) = (php_stream*)zend_fetch_resource2((res), \
|
||||
"stream", php_file_le_stream(), php_file_le_pstream())) == NULL) { \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
} while (0)
|
||||
#define php_stream_from_res_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource((res), "stream", php_file_le_stream(), php_file_le_pstream())
|
||||
#define php_stream_from_zval_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource2_ex((pzval), "stream", php_file_le_stream(), php_file_le_pstream())
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
PHPAPI php_stream *php_stream_encloses(php_stream *enclosing, php_stream *enclosed);
|
||||
|
@ -33,7 +33,7 @@ typedef void (*php_stream_notification_func)(php_stream_context *context,
|
||||
If no context was passed, use the default context
|
||||
The default context has not yet been created, do it now. */
|
||||
#define php_stream_context_from_zval(zcontext, nocontext) ( \
|
||||
(zcontext) ? zend_fetch_resource(zcontext, -1, "Stream-Context", NULL, 1, php_le_stream_context()) : \
|
||||
(zcontext) ? zend_fetch_resource_ex(zcontext, "Stream-Context", php_le_stream_context()) : \
|
||||
(nocontext) ? NULL : \
|
||||
FG(default_context) ? FG(default_context) : \
|
||||
(FG(default_context) = php_stream_context_alloc()) )
|
||||
|
@ -140,7 +140,7 @@ PHPAPI int php_stream_from_persistent_id(const char *persistent_id, php_stream *
|
||||
*stream = (php_stream*)le->ptr;
|
||||
if (!regentry) { /* not found in regular list */
|
||||
GC_REFCOUNT(le)++;
|
||||
(*stream)->res = ZEND_REGISTER_RESOURCE(NULL, *stream, le_pstream);
|
||||
(*stream)->res = zend_register_resource(*stream, le_pstream);
|
||||
} else {
|
||||
GC_REFCOUNT(regentry)++;
|
||||
(*stream)->res = regentry;
|
||||
@ -325,7 +325,7 @@ fprintf(stderr, "stream_alloc: %s:%p persistent=%s\n", ops->label, ret, persiste
|
||||
}
|
||||
}
|
||||
|
||||
ret->res = ZEND_REGISTER_RESOURCE(NULL, ret, persistent_id ? le_pstream : le_stream);
|
||||
ret->res = zend_register_resource(ret, persistent_id ? le_pstream : le_stream);
|
||||
strlcpy(ret->mode, mode, sizeof(ret->mode));
|
||||
|
||||
ret->wrapper = NULL;
|
||||
@ -2211,7 +2211,7 @@ PHPAPI php_stream_context *php_stream_context_alloc(void)
|
||||
context->notifier = NULL;
|
||||
array_init(&context->options);
|
||||
|
||||
context->res = ZEND_REGISTER_RESOURCE(NULL, context, php_le_stream_context());
|
||||
context->res = zend_register_resource(context, php_le_stream_context());
|
||||
return context;
|
||||
}
|
||||
|
||||
|
@ -503,7 +503,7 @@ PHP_FUNCTION(stream_wrapper_register)
|
||||
uwrap->wrapper.abstract = uwrap;
|
||||
uwrap->wrapper.is_url = ((flags & PHP_STREAM_IS_URL) != 0);
|
||||
|
||||
rsrc = ZEND_REGISTER_RESOURCE(NULL, uwrap, le_protocols);
|
||||
rsrc = zend_register_resource(uwrap, le_protocols);
|
||||
|
||||
if ((uwrap->ce = zend_lookup_class(classname)) != NULL) {
|
||||
if (php_register_url_stream_wrapper_volatile(protocol->val, &uwrap->wrapper) == SUCCESS) {
|
||||
|
Loading…
Reference in New Issue
Block a user