version 1.1.1.1, 2012/02/21 23:48:02
|
version 1.1.1.2, 2012/05/29 12:34:43
|
Line 12
|
Line 12
|
| obtain it through the world-wide-web, please send a note to | |
| obtain it through the world-wide-web, please send a note to | |
| license@php.net so we can mail you a copy immediately. | |
| license@php.net so we can mail you a copy immediately. | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Authors: Jani Lehtimäki <jkl@njet.net> | | | Authors: Jani Lehtimäki <jkl@njet.net> | |
| Thies C. Arntzen <thies@thieso.net> | |
| Thies C. Arntzen <thies@thieso.net> | |
| Sascha Schumann <sascha@schumann.cx> | |
| Sascha Schumann <sascha@schumann.cx> | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
Line 56 static int php_array_element_dump(zval **zv TSRMLS_DC,
|
Line 56 static int php_array_element_dump(zval **zv TSRMLS_DC,
|
static int php_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ |
static int php_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ |
{ |
{ |
int level; |
int level; |
char *prop_name, *class_name; | const char *prop_name, *class_name; |
|
|
level = va_arg(args, int); |
level = va_arg(args, int); |
|
|
Line 87 static int php_object_property_dump(zval **zv TSRMLS_D
|
Line 87 static int php_object_property_dump(zval **zv TSRMLS_D
|
PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ |
PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ |
{ |
{ |
HashTable *myht; |
HashTable *myht; |
char *class_name; | const char *class_name; |
zend_uint class_name_len; |
zend_uint class_name_len; |
int (*php_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*); |
int (*php_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*); |
int is_temp; |
int is_temp; |
Line 133 PHPAPI void php_var_dump(zval **struc, int level TSRML
|
Line 133 PHPAPI void php_var_dump(zval **struc, int level TSRML
|
return; |
return; |
} |
} |
|
|
Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC); | if (Z_OBJ_HANDLER(**struc, get_class_name)) { |
php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0); | Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC); |
efree(class_name); | php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0); |
| efree((char*)class_name); |
| } else { |
| php_printf("%sobject(unknown class)#%d (%d) {\n", COMMON, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0); |
| } |
php_element_dump_func = php_object_property_dump; |
php_element_dump_func = php_object_property_dump; |
head_done: |
head_done: |
if (myht) { |
if (myht) { |
Line 152 head_done:
|
Line 156 head_done:
|
PUTS("}\n"); |
PUTS("}\n"); |
break; |
break; |
case IS_RESOURCE: { |
case IS_RESOURCE: { |
char *type_name; | const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC); |
| |
type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC); | |
php_printf("%sresource(%ld) of type (%s)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown"); |
php_printf("%sresource(%ld) of type (%s)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown"); |
break; |
break; |
} |
} |
Line 211 static int zval_array_element_dump(zval **zv TSRMLS_DC
|
Line 213 static int zval_array_element_dump(zval **zv TSRMLS_DC
|
static int zval_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ |
static int zval_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ |
{ |
{ |
int level; |
int level; |
char *prop_name, *class_name; | const char *prop_name, *class_name; |
|
|
level = va_arg(args, int); |
level = va_arg(args, int); |
|
|
Line 240 static int zval_object_property_dump(zval **zv TSRMLS_
|
Line 242 static int zval_object_property_dump(zval **zv TSRMLS_
|
PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ |
PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ |
{ |
{ |
HashTable *myht = NULL; |
HashTable *myht = NULL; |
char *class_name; | const char *class_name; |
zend_uint class_name_len; |
zend_uint class_name_len; |
int (*zval_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*); |
int (*zval_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*); |
int is_temp = 0; |
int is_temp = 0; |
Line 282 PHPAPI void php_debug_zval_dump(zval **struc, int leve
|
Line 284 PHPAPI void php_debug_zval_dump(zval **struc, int leve
|
PUTS("*RECURSION*\n"); |
PUTS("*RECURSION*\n"); |
return; |
return; |
} |
} |
if (Z_OBJ_HANDLER_PP(struc, get_class_name)) { | Z_OBJ_HANDLER_PP(struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC); |
Z_OBJ_HANDLER_PP(struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC); | php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc)); |
php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc)); | efree((char*)class_name); |
efree(class_name); | |
} else { | |
php_printf("%sobject(unknown class)#%d (%d) refcount(%u){\n", COMMON, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc)); | |
} | |
zval_element_dump_func = zval_object_property_dump; |
zval_element_dump_func = zval_object_property_dump; |
head_done: |
head_done: |
if (myht) { |
if (myht) { |
Line 304 head_done:
|
Line 302 head_done:
|
PUTS("}\n"); |
PUTS("}\n"); |
break; |
break; |
case IS_RESOURCE: { |
case IS_RESOURCE: { |
char *type_name; | const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC); |
| |
type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC); | |
php_printf("%sresource(%ld) of type (%s) refcount(%u)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown", Z_REFCOUNT_PP(struc)); |
php_printf("%sresource(%ld) of type (%s) refcount(%u)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown", Z_REFCOUNT_PP(struc)); |
break; |
break; |
} |
} |
Line 357 static int php_array_element_export(zval **zv TSRMLS_D
|
Line 353 static int php_array_element_export(zval **zv TSRMLS_D
|
buffer_append_spaces(buf, level+1); |
buffer_append_spaces(buf, level+1); |
smart_str_append_long(buf, (long) hash_key->h); |
smart_str_append_long(buf, (long) hash_key->h); |
smart_str_appendl(buf, " => ", 4); |
smart_str_appendl(buf, " => ", 4); |
|
|
} else { /* string key */ |
} else { /* string key */ |
char *key, *tmp_str; |
char *key, *tmp_str; |
int key_len, tmp_len; |
int key_len, tmp_len; |
Line 376 static int php_array_element_export(zval **zv TSRMLS_D
|
Line 373 static int php_array_element_export(zval **zv TSRMLS_D
|
|
|
smart_str_appendc(buf, ','); |
smart_str_appendc(buf, ','); |
smart_str_appendc(buf, '\n'); |
smart_str_appendc(buf, '\n'); |
| |
return 0; |
return 0; |
} |
} |
/* }}} */ |
/* }}} */ |
Line 391 static int php_object_element_export(zval **zv TSRMLS_
|
Line 388 static int php_object_element_export(zval **zv TSRMLS_
|
|
|
buffer_append_spaces(buf, level + 2); |
buffer_append_spaces(buf, level + 2); |
if (hash_key->nKeyLength != 0) { |
if (hash_key->nKeyLength != 0) { |
char *class_name, /* ignored, but must be passed to unmangle */ | const char *class_name; /* ignored, but must be passed to unmangle */ |
*pname, | const char *pname; |
*pname_esc; | char *pname_esc; |
int pname_esc_len; |
int pname_esc_len; |
|
|
zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, |
zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, |
Line 406 static int php_object_element_export(zval **zv TSRMLS_
|
Line 403 static int php_object_element_export(zval **zv TSRMLS_
|
smart_str_appendc(buf, '\''); |
smart_str_appendc(buf, '\''); |
efree(pname_esc); |
efree(pname_esc); |
} else { |
} else { |
smart_str_append_long(buf, hash_key->h); | smart_str_append_long(buf, (long) hash_key->h); |
} |
} |
|
|
smart_str_appendl(buf, " => ", 4); |
smart_str_appendl(buf, " => ", 4); |
php_var_export_ex(zv, level + 2, buf TSRMLS_CC); |
php_var_export_ex(zv, level + 2, buf TSRMLS_CC); |
smart_str_appendc(buf, ','); |
smart_str_appendc(buf, ','); |
smart_str_appendc(buf, '\n'); |
smart_str_appendc(buf, '\n'); |
|
|
return 0; |
return 0; |
} |
} |
/* }}} */ |
/* }}} */ |
Line 423 PHPAPI void php_var_export_ex(zval **struc, int level,
|
Line 418 PHPAPI void php_var_export_ex(zval **struc, int level,
|
HashTable *myht; |
HashTable *myht; |
char *tmp_str, *tmp_str2; |
char *tmp_str, *tmp_str2; |
int tmp_len, tmp_len2; |
int tmp_len, tmp_len2; |
char *class_name; | const char *class_name; |
zend_uint class_name_len; |
zend_uint class_name_len; |
|
|
switch (Z_TYPE_PP(struc)) { |
switch (Z_TYPE_PP(struc)) { |
case IS_BOOL: |
case IS_BOOL: |
if (Z_LVAL_PP(struc)) { | if (Z_LVAL_PP(struc)) { |
smart_str_appendl(buf, "true", 4); | smart_str_appendl(buf, "true", 4); |
} else { | } else { |
smart_str_appendl(buf, "false", 5); | smart_str_appendl(buf, "false", 5); |
} | } |
break; |
break; |
case IS_NULL: |
case IS_NULL: |
smart_str_appendl(buf, "NULL", 4); |
smart_str_appendl(buf, "NULL", 4); |
Line 469 PHPAPI void php_var_export_ex(zval **struc, int level,
|
Line 464 PHPAPI void php_var_export_ex(zval **struc, int level,
|
buffer_append_spaces(buf, level - 1); |
buffer_append_spaces(buf, level - 1); |
} |
} |
smart_str_appendc(buf, ')'); |
smart_str_appendc(buf, ')'); |
| |
break; |
break; |
|
|
case IS_OBJECT: |
case IS_OBJECT: |
myht = Z_OBJPROP_PP(struc); |
myht = Z_OBJPROP_PP(struc); |
if (level > 1) { |
if (level > 1) { |
Line 482 PHPAPI void php_var_export_ex(zval **struc, int level,
|
Line 478 PHPAPI void php_var_export_ex(zval **struc, int level,
|
smart_str_appendl(buf, class_name, class_name_len); |
smart_str_appendl(buf, class_name, class_name_len); |
smart_str_appendl(buf, "::__set_state(array(\n", 21); |
smart_str_appendl(buf, "::__set_state(array(\n", 21); |
|
|
efree(class_name); | efree((char*)class_name); |
if (myht) { |
if (myht) { |
zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_object_element_export, 2, level, buf); | zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_object_element_export, 1, level, buf); |
} |
} |
if (level > 1) { |
if (level > 1) { |
buffer_append_spaces(buf, level - 1); |
buffer_append_spaces(buf, level - 1); |
Line 510 PHPAPI void php_var_export(zval **struc, int level TSR
|
Line 506 PHPAPI void php_var_export(zval **struc, int level TSR
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
|
|
/* {{{ proto mixed var_export(mixed var [, bool return]) |
/* {{{ proto mixed var_export(mixed var [, bool return]) |
Outputs or returns a string representation of a variable */ |
Outputs or returns a string representation of a variable */ |
PHP_FUNCTION(var_export) |
PHP_FUNCTION(var_export) |
Line 564 static inline int php_add_var_hash(HashTable *var_hash
|
Line 561 static inline int php_add_var_hash(HashTable *var_hash
|
var_no = -1; |
var_no = -1; |
zend_hash_next_index_insert(var_hash, &var_no, sizeof(var_no), NULL); |
zend_hash_next_index_insert(var_hash, &var_no, sizeof(var_no), NULL); |
} |
} |
|
#if 0 |
|
fprintf(stderr, "- had var (%d): %lu\n", Z_TYPE_P(var), **(ulong**)var_old); |
|
#endif |
return FAILURE; |
return FAILURE; |
} |
} |
|
|
/* +1 because otherwise hash will think we are trying to store NULL pointer */ |
/* +1 because otherwise hash will think we are trying to store NULL pointer */ |
var_no = zend_hash_num_elements(var_hash) + 1; |
var_no = zend_hash_num_elements(var_hash) + 1; |
zend_hash_add(var_hash, p, len, &var_no, sizeof(var_no), NULL); |
zend_hash_add(var_hash, p, len, &var_no, sizeof(var_no), NULL); |
|
#if 0 |
|
fprintf(stderr, "+ add var (%d): %lu\n", Z_TYPE_P(var), var_no); |
|
#endif |
return SUCCESS; |
return SUCCESS; |
} |
} |
/* }}} */ |
/* }}} */ |
Line 785 static void php_var_serialize_intern(smart_str *buf, z
|
Line 788 static void php_var_serialize_intern(smart_str *buf, z
|
if (ce && ce != PHP_IC_ENTRY && zend_hash_exists(&ce->function_table, "__sleep", sizeof("__sleep"))) { |
if (ce && ce != PHP_IC_ENTRY && zend_hash_exists(&ce->function_table, "__sleep", sizeof("__sleep"))) { |
INIT_PZVAL(&fname); |
INIT_PZVAL(&fname); |
ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1, 0); |
ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1, 0); |
|
BG(serialize_lock)++; |
res = call_user_function_ex(CG(function_table), &struc, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC); |
res = call_user_function_ex(CG(function_table), &struc, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC); |
|
BG(serialize_lock)--; |
|
|
if (res == SUCCESS && !EG(exception)) { |
if (res == SUCCESS && !EG(exception)) { |
if (retval_ptr) { |
if (retval_ptr) { |
Line 880 static void php_var_serialize_intern(smart_str *buf, z
|
Line 885 static void php_var_serialize_intern(smart_str *buf, z
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
PHPAPI void php_var_serialize(smart_str *buf, zval **struc, HashTable *var_hash TSRMLS_DC) /* {{{ */ | PHPAPI void php_var_serialize(smart_str *buf, zval **struc, php_serialize_data_t *var_hash TSRMLS_DC) /* {{{ */ |
{ |
{ |
php_var_serialize_intern(buf, *struc, var_hash TSRMLS_CC); | php_var_serialize_intern(buf, *struc, *var_hash TSRMLS_CC); |
smart_str_0(buf); |
smart_str_0(buf); |
} |
} |
/* }}} */ |
/* }}} */ |