2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1997-2013 The PHP Group |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Jani Lehtimäki <jkl@njet.net> |
16 | Thies C. Arntzen <thies@thieso.net> |
17 | Sascha Schumann <sascha@schumann.cx> |
18 +----------------------------------------------------------------------+
29 #include "php_string.h"
31 #include "php_smart_str.h"
32 #include "basic_functions.h"
34 #include "hphp/runtime/base/complex-types.h"
35 #include "ext/standard/php_smart_str.h"
36 #include "hphp/runtime/ext/ext_variable.h"
38 #define COMMON (Z_ISREF_PP(struc) ? "&" : "")
41 PHPAPI
void php_var_serialize(smart_str
*buf
, zval
**struc
, php_serialize_data_t
*var_hash TSRMLS_DC
) {
42 HPHP::String s
= HPHP::f_serialize(HPHP::tvAsVariant((*struc
)->tv()));
43 smart_str_appendl(buf
, s
.data(), s
.size());
45 PHPAPI
int php_var_unserialize(zval
**rval
, const unsigned char **p
, const unsigned char *max
, php_unserialize_data_t
*var_hash TSRMLS_DC
) {
46 HPHP::Variant ret
= HPHP::f_unserialize(HPHP::String((const char*) *p
, max
- *p
, HPHP::CopyString
));
48 HPHP::cellDup(*ret
.asCell(), *(*rval
)->tv());
49 return !ret
.isBoolean() || ret
.toBoolean();
51 PHPAPI
void var_destroy(php_unserialize_data_t
*var_hash
) {