disabled
  B   lY>eJ}@?q1h?_I|+a=J*e8n2ژo (5    /*
  +----------------------------------------------------------------------+
  | PHP Version 5                                                        |
  +----------------------------------------------------------------------+
  | Copyright (c) 1997-2016 The PHP Group                                |
  +----------------------------------------------------------------------+
  | This source file is subject to version 3.01 of the PHP license,      |
  | that is bundled with this package in the file LICENSE, and is        |
  | available through the world-wide-web at the following url:           |
  | http://www.php.net/license/3_01.txt                                  |
  | If you did not receive a copy of the PHP license and are unable to   |
  | obtain it through the world-wide-web, please send a note to          |
  | license@php.net so we can mail you a copy immediately.               |
  +----------------------------------------------------------------------+
  | Author: Wez Furlong <wez@php.net>                                    |
  |         Marcus Boerger <helly@php.net>                               |
  |         Sterling Hughes <sterling@php.net>                           |
  +----------------------------------------------------------------------+
*/

/* $Id$ */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <ctype.h>
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_pdo.h"
#include "php_pdo_driver.h"
#include "php_pdo_int.h"
#include "zend_exceptions.h"

static zend_class_entry *spl_ce_RuntimeException;

ZEND_DECLARE_MODULE_GLOBALS(pdo)
static PHP_GINIT_FUNCTION(pdo);

/* True global resources - no need for thread safety here */

/* the registry of PDO drivers */
HashTable pdo_driver_hash;

/* we use persistent resources for the driver connection stuff */
static int le_ppdo;

int php_pdo_list_entry(void)
{
	return le_ppdo;
}

/* for exceptional circumstances */
zend_class_entry *pdo_exception_ce;

PDO_API zend_class_entry *php_pdo_get_dbh_ce(void)
{
	return pdo_dbh_ce;
}

PDO_API zend_class_entry *php_pdo_get_exception(void)
{
	return pdo_exception_ce;
}

PDO_API char *php_pdo_str_tolower_dup(const char *src, int len)
{
	char *dest = emalloc(len + 1);
	zend_str_tolower_copy(dest, src, len);
	return dest;
}

PDO_API zend_class_entry *php_pdo_get_exception_base(int root TSRMLS_DC)
{
#if can_handle_soft_dependency_on_SPL && defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
	if (!root) {
		if (!spl_ce_RuntimeException) {
			zend_class_entry **pce;

			if (zend_hash_find(CG(class_table), "runtimeexception", sizeof("RuntimeException"), (void **) &pce) == SUCCESS) {
				spl_ce_RuntimeException = *pce;
				return *pce;
			}
		} else {
			return spl_ce_RuntimeException;
		}
	}
#endif
#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 2)
	return zend_exception_get_default();
#else
	return zend_exception_get_default(TSRMLS_C);
#endif
}

zend_class_entry *pdo_dbh_ce, *pdo_dbstmt_ce, *pdo_row_ce;

/* {{{ proto array pdo_drivers()
 Return array of available PDO drivers */
PHP_FUNCTION(pdo_drivers)
{
	HashPosition pos;
	pdo_driver_t **pdriver;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}
	
	array_init(return_value);

	zend_hash_internal_pointer_reset_ex(&pdo_driver_hash, &pos);
	while (SUCCESS == zend_hash_get_current_data_ex(&pdo_driver_hash, (void**)&pdriver, &pos)) {
		add_next_index_stringl(return_value, (char*)(*pdriver)->driver_name, (*pdriver)->driver_name_len, 1);
		zend_hash_move_forward_ex(&pdo_driver_hash, &pos);
	}
}
/* }}} */

/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO(arginfo_pdo_drivers, 0)
ZEND_END_ARG_INFO()
/* }}} */

/* {{{ pdo_functions[] */
const zend_function_entry pdo_functions[] = {
	PHP_FE(pdo_drivers,             arginfo_pdo_drivers)
	PHP_FE_END
};
/* }}} */

/* {{{ pdo_functions[] */
#if ZEND_MODULE_API_NO >= 20050922
static const zend_module_dep pdo_deps[] = {
#ifdef HAVE_SPL
	ZEND_MOD_REQUIRED("sp