1 /*
2   +----------------------------------------------------------------------+
3   | Copyright (c) 2010 The PHP Group                                     |
4   +----------------------------------------------------------------------+
5   | This source file is subject to version 3.01 of the PHP license,      |
6   | that is bundled with this package in the file LICENSE, and is        |
7   | available through the world-wide-web at the following url:           |
8   | http://www.php.net/license/3_01.txt.                                 |
9   | If you did not receive a copy of the PHP license and are unable to   |
10   | obtain it through the world-wide-web, please send a note to          |
11   | license@php.net so we can mail you a copy immediately.               |
12   +----------------------------------------------------------------------+
13   | Authors: Timandes White <timands@gmail.com>                          |
14   +----------------------------------------------------------------------+
15 */
16 #include <php.h>
17 
18 #include "php_zookeeper_stat.h"
19 
20 void php_stat_to_array(const struct Stat *stat, zval *array)
21 {
22     if( !array ) {
23         return;
24     }
25     if( Z_TYPE_P(array) != IS_ARRAY ) {
26         zval_ptr_dtor(array);
27         array_init(array);
28     } else {
29 		SEPARATE_ARRAY(array);
30 	}
31 
32     add_assoc_double_ex(array, ZEND_STRL("czxid"), stat->czxid);
33     add_assoc_double_ex(array, ZEND_STRL("mzxid"), stat->mzxid);
34     add_assoc_double_ex(array, ZEND_STRL("ctime"), stat->ctime);
35     add_assoc_double_ex(array, ZEND_STRL("mtime"), stat->mtime);
36     add_assoc_long_ex(array, ZEND_STRL("version"), stat->version);
37     add_assoc_long_ex(array, ZEND_STRL("cversion"), stat->cversion);
38     add_assoc_long_ex(array, ZEND_STRL("aversion"), stat->aversion);
39     add_assoc_double_ex(array, ZEND_STRL("ephemeralOwner"), stat->ephemeralOwner);
40     add_assoc_long_ex(array, ZEND_STRL("dataLength"), stat->dataLength);
41     add_assoc_long_ex(array, ZEND_STRL("numChildren"), stat->numChildren);
42     add_assoc_double_ex(array, ZEND_STRL("pzxid"), stat->pzxid);
43 }
44