summaryrefslogtreecommitdiff
path: root/ext/mysqli/mysqli_embedded.c
diff options
context:
space:
mode:
authorGeorg Richter <georg@php.net>2005-01-08 15:11:37 +0000
committerGeorg Richter <georg@php.net>2005-01-08 15:11:37 +0000
commit6b49e2d9e733c81b1c002c852688ed1a20fef042 (patch)
tree9e91d772465baa73c3a343880188830ee1be04c9 /ext/mysqli/mysqli_embedded.c
parent0854cad7a2ebd32666c08ca7da5a025afa3841f0 (diff)
downloadphp-git-6b49e2d9e733c81b1c002c852688ed1a20fef042.tar.gz
fixed compile bug under Windows (libmysql.def currently doesn't export mysql_server_init/end).
Thanks to Sebastian Bergmann for reporting
Diffstat (limited to 'ext/mysqli/mysqli_embedded.c')
-rw-r--r--ext/mysqli/mysqli_embedded.c90
1 files changed, 44 insertions, 46 deletions
diff --git a/ext/mysqli/mysqli_embedded.c b/ext/mysqli/mysqli_embedded.c
index 9990bd9b5f..dd51349714 100644
--- a/ext/mysqli/mysqli_embedded.c
+++ b/ext/mysqli/mysqli_embedded.c
@@ -31,6 +31,7 @@
initialize and start embedded server */
PHP_FUNCTION(mysqli_embedded_server_start)
{
+#ifdef HAVE_EMBEDDED_MYSQLI
int argc = 0;
char **arguments;
char **groups;
@@ -50,68 +51,63 @@ PHP_FUNCTION(mysqli_embedded_server_start)
mysql_server_init(-1,NULL, NULL);
RETURN_TRUE;
}
+ /* get arguments */
+ if ((argc = zend_hash_num_elements(HASH_OF(*args)))) {
+ arguments = safe_emalloc(sizeof(char *), argc + 1, 0);
+ arguments[0] = NULL;
- if (MyG(embedded)) {
- /* get arguments */
- if ((argc = zend_hash_num_elements(HASH_OF(*args)))) {
- arguments = safe_emalloc(sizeof(char *), argc + 1, 0);
- arguments[0] = NULL;
-
- zend_hash_internal_pointer_reset_ex(HASH_OF(*args), &pos);
+ zend_hash_internal_pointer_reset_ex(HASH_OF(*args), &pos);
- for (index = 0;; zend_hash_move_forward_ex(HASH_OF(*args), &pos)) {
- zval **item;
+ for (index = 0;; zend_hash_move_forward_ex(HASH_OF(*args), &pos)) {
+ zval **item;
- if (zend_hash_get_current_data_ex(HASH_OF(*args), (void **) &item, &pos) == FAILURE) {
- break;
- }
-
- convert_to_string_ex(item);
-
- arguments[++index] = Z_STRVAL_PP(item);
+ if (zend_hash_get_current_data_ex(HASH_OF(*args), (void **) &item, &pos) == FAILURE) {
+ break;
}
- argc++;
- }
- /* get groups */
- if ((zend_hash_num_elements(HASH_OF(*grps)))) {
- groups = safe_emalloc(sizeof(char *), zend_hash_num_elements(HASH_OF(*grps)) + 1, 0);
- arguments[0] = NULL;
+ convert_to_string_ex(item);
- zend_hash_internal_pointer_reset_ex(HASH_OF(*args), &pos);
+ arguments[++index] = Z_STRVAL_PP(item);
+ }
+ argc++;
+ }
- for (index = 0;; zend_hash_move_forward_ex(HASH_OF(*args), &pos)) {
- zval ** item;
-
- if (zend_hash_get_current_data_ex(HASH_OF(*args), (void **) &item, &pos) == FAILURE) {
- break;
- }
+ /* get groups */
+ if ((zend_hash_num_elements(HASH_OF(*grps)))) {
+ groups = safe_emalloc(sizeof(char *), zend_hash_num_elements(HASH_OF(*grps)) + 1, 0);
+ arguments[0] = NULL;
- convert_to_string_ex(item);
+ zend_hash_internal_pointer_reset_ex(HASH_OF(*args), &pos);
- groups[++index] = Z_STRVAL_PP(item);
+ for (index = 0;; zend_hash_move_forward_ex(HASH_OF(*args), &pos)) {
+ zval ** item;
+
+ if (zend_hash_get_current_data_ex(HASH_OF(*args), (void **) &item, &pos) == FAILURE) {
+ break;
}
- groups[index] = NULL;
- } else {
- groups = safe_emalloc(sizeof(char *), 1, 0);
- groups[0] = NULL;
- }
- rc = mysql_server_init(argc, arguments, NULL);
+ convert_to_string_ex(item);
- if (argc) {
- efree(arguments);
+ groups[++index] = Z_STRVAL_PP(item);
}
- efree(groups);
+ groups[index] = NULL;
+ } else {
+ groups = safe_emalloc(sizeof(char *), 1, 0);
+ groups[0] = NULL;
+ }
- if (rc) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
+ rc = mysql_server_init(argc, arguments, NULL);
+
+ if (argc) {
+ efree(arguments);
}
+ efree(groups);
- php_error_docref(NULL TSRMLS_CC, E_ERROR,
- "Can't start embedded server. PHP wasn't configured with mysql embedded server support");
+ if (rc) {
+ RETURN_FALSE;
+ }
+ RETURN_TRUE;
+#endif
}
/* }}} */
@@ -119,6 +115,8 @@ PHP_FUNCTION(mysqli_embedded_server_start)
*/
PHP_FUNCTION(mysqli_embedded_server_end)
{
+#ifdef HAVE_MYSQLI_EMBEDDED
mysql_server_end();
+#endif
}
/* }}} */