1 : /*
2 : +----------------------------------------------------------------------+
3 : | PHP Version 5 |
4 : +----------------------------------------------------------------------+
5 : | Copyright (c) 1997-2009 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 : | Author: Georg Richter <georg@php.net> |
16 : +----------------------------------------------------------------------+
17 :
18 : */
19 : #ifdef HAVE_CONFIG_H
20 : #include "config.h"
21 : #endif
22 :
23 : #include <signal.h>
24 :
25 : #include "php.h"
26 : #include "php_ini.h"
27 : #include "ext/standard/info.h"
28 : #include "php_mysqli.h"
29 :
30 : /* {{{ proto bool mysqli_embedded_server_start(bool start, array arguments, array groups)
31 : initialize and start embedded server */
32 : PHP_FUNCTION(mysqli_embedded_server_start)
33 0 : {
34 : #ifdef HAVE_EMBEDDED_MYSQLI
35 : int argc = 0;
36 : char **arguments;
37 : char **groups;
38 : zval **args, **grps, **start;
39 : HashPosition pos;
40 : int index, rc;
41 :
42 : if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &start, &args, &grps) == FAILURE) {
43 : ZEND_WRONG_PARAM_COUNT();
44 : }
45 :
46 : convert_to_long_ex(start);
47 : convert_to_array_ex(args);
48 : convert_to_array_ex(grps);
49 :
50 : if (!Z_LVAL_PP(start)) {
51 : mysql_server_init(-1,NULL, NULL);
52 : RETURN_TRUE;
53 : }
54 : /* get arguments */
55 : if ((argc = zend_hash_num_elements(HASH_OF(*args)))) {
56 : arguments = safe_emalloc(sizeof(char *), argc + 1, 0);
57 : arguments[0] = NULL;
58 :
59 : zend_hash_internal_pointer_reset_ex(HASH_OF(*args), &pos);
60 :
61 : for (index = 0;; zend_hash_move_forward_ex(HASH_OF(*args), &pos)) {
62 : zval **item;
63 :
64 : if (zend_hash_get_current_data_ex(HASH_OF(*args), (void **) &item, &pos) == FAILURE) {
65 : break;
66 : }
67 :
68 : convert_to_string_ex(item);
69 :
70 : arguments[++index] = Z_STRVAL_PP(item);
71 : }
72 : argc++;
73 : }
74 :
75 : /* get groups */
76 : if ((zend_hash_num_elements(HASH_OF(*grps)))) {
77 : groups = safe_emalloc(sizeof(char *), zend_hash_num_elements(HASH_OF(*grps)) + 1, 0);
78 : groups[0] = NULL;
79 :
80 : zend_hash_internal_pointer_reset_ex(HASH_OF(*grps), &pos);
81 :
82 : for (index = 0;; zend_hash_move_forward_ex(HASH_OF(*grps), &pos)) {
83 : zval ** item;
84 :
85 : if (zend_hash_get_current_data_ex(HASH_OF(*grps), (void **) &item, &pos) == FAILURE) {
86 : break;
87 : }
88 :
89 : convert_to_string_ex(item);
90 :
91 : groups[++index] = Z_STRVAL_PP(item);
92 : }
93 : groups[index] = NULL;
94 : } else {
95 : groups = safe_emalloc(sizeof(char *), 1, 0);
96 : groups[0] = NULL;
97 : }
98 :
99 : rc = mysql_server_init(argc, arguments, groups);
100 :
101 : if (argc) {
102 : efree(arguments);
103 : }
104 : efree(groups);
105 :
106 : if (rc) {
107 : RETURN_FALSE;
108 : }
109 : RETURN_TRUE;
110 : #endif
111 0 : }
112 : /* }}} */
113 :
114 : /* {{{ proto void mysqli_embedded_server_end(void)
115 : */
116 : PHP_FUNCTION(mysqli_embedded_server_end)
117 0 : {
118 : #ifdef HAVE_MYSQLI_EMBEDDED
119 : mysql_server_end();
120 : #endif
121 0 : }
122 : /* }}} */
123 :
124 : /*
125 : * Local variables:
126 : * tab-width: 4
127 : * c-basic-offset: 4
128 : * indent-tabs-mode: t
129 : * End:
130 : * vim600: noet sw=4 ts=4 fdm=marker
131 : * vim<600: noet sw=4 ts=4
132 : */
|