⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ifx.ec

📁 php-4.4.7学习linux时下载的源代码
💻 EC
📖 第 1 页 / 共 5 页
字号:
/*   +----------------------------------------------------------------------+   | PHP Version 4                                                        |   +----------------------------------------------------------------------+   | Copyright (c) 1997-2006 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.               |   +----------------------------------------------------------------------+   | Authors: Danny Heijl  <Danny.Heijl@cevi.be> : initial cut (ODS 7.2x) |   |                                               PHP4 port              |   |          Christian Cartus <chc@idgruppe.de> : blobs, and IUS 9       |   |          Jouni Ahto <jouni.ahto@exdec.fi>   : configuration stuff    |   |          Corne' Cornelius <cornec@reach.co.za> : input descriptors   |   | Based on the MySQL code by:  Zeev Suraski <zeev@php.net>             |   +----------------------------------------------------------------------+*//* $Id: ifx.ec,v 1.69.2.28.2.3 2006/01/13 14:31:19 sas Exp $ *//* ------------------------------------------------------------------- * if you want a function reference : "grep '^\*\*' ifx.ec" will give * you a very short one * -------------------------------------------------------------------*//* TODO: * * ? Safe mode implementation *//* prevent mod_ssl.h's header file from being included. */#define AP_HOOK_H#ifdef HAVE_CONFIG_H#include "config.h"#endif#include "php.h"#include "php_globals.h"#include "ext/standard/php_standard.h"#include "php_open_temporary_file.h"#include "php_informix.h"#include "php_informix_includes.h"#include "php_globals.h"#include "php_ini.h"#ifdef PHP_WIN32#include <winsock.h>#endif#ifdef ZTS#define IFX_THRD_ID tsrm_thread_id()#else#define IFX_THRD_ID 0#endif#if HAVE_SYS_TYPES_H#include <sys/types.h>#endif#if HAVE_NETDB_H#include <netdb.h>#endif#if HAVE_NETINET_IN_H#include <netinet/in.h>#endif#if HAVE_IFX/* local function prototypes */static void php_ifx_set_default_link(int id TSRMLS_DC);static long php_intifx_getType(long id, HashTable *list TSRMLS_DC);static long php_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list TSRMLS_DC);static long php_intifx_init_blob(loc_t *blob, long mode, long new TSRMLS_DC);static long php_intifx_init_blob_inmem(loc_t *blob, long new TSRMLS_DC);static long php_intifx_init_blob_infile(loc_t *blob, long new TSRMLS_DC);static void php_intifx_release_blob(loc_t *blob TSRMLS_DC);static long php_intifx_free_blob(long id, HashTable *list TSRMLS_DC);static long php_intifx_get_blob(long bid, HashTable *list, char** content TSRMLS_DC);static long php_intifx_update_blob(long bid, char* param, long len, HashTable *list TSRMLS_DC);static loc_t *php_intifx_get_blobloc(long bid, HashTable *list TSRMLS_DC);static char* php_intifx_create_tmpfile(TSRMLS_D);static long php_intifx_copy_blob(long bid, HashTable *list TSRMLS_DC);static long php_intifx_alloc_ibind(IFX_RES *Ifx_Result, int items TSRMLS_DC);static long php_intifx_preparse(char *statement TSRMLS_DC);static long php_intifx_count_descriptors(char *p_statemid TSRMLS_DC);static char* php_intifx_null(TSRMLS_D);static long php_intifx_create_char(char* param, long len, HashTable *list TSRMLS_DC);static long php_intifx_free_char(long id, HashTable *list TSRMLS_DC);static long php_intifx_update_char(long bid, char* param, long len, HashTable *list TSRMLS_DC);static long php_intifx_get_char(long bid, HashTable *list, char** content TSRMLS_DC);#if HAVE_IFX_IUSstatic long php_intifxus_create_slob(long create_mode, HashTable *list TSRMLS_DC);static long php_intifxus_free_slob(long bid, HashTable *list TSRMLS_DC);static long php_intifxus_close_slob(long bid, HashTable *list TSRMLS_DC);static long php_intifxus_open_slob(long bid, long create_mode, HashTable *list TSRMLS_DC);static long php_intifxus_new_slob(HashTable *list TSRMLS_DC);static ifx_lo_t *php_intifxus_get_slobloc(long bid, HashTable *list TSRMLS_DC);#endif/* 7.10 on (at least) AIX is missing this */#ifndef CLIENT_SQLI_VER#define CLIENT_SQLI_VER IFX_VERSION#endif#define TYPE_BLBYTE   0#define TYPE_BLTEXT   1#define TYPE_SLOB     2#define TYPE_CHAR     3#define BLMODE_INMEM  0#define BLMODE_INFILE 1#define IFX_SCROLL    1#define IFX_HOLD      2EXEC SQL include locator;EXEC SQL include sqltypes;EXEC SQL include sqlstype;#include <errno.h>typedef char IFX[128];#define SAFE_STRING(s) ((s) ? (s) : "")#define PHP_IFX_CHECK_CONNECTION(ifx)       \        {                                   \            if (ifx_check() < 0) {          \                char *ifx_err = ifx_error(ifx); \                IFXG(sv_sqlcode) = SQLCODE; \                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Set connection %s fails (%s)", ifx, ifx_err); \                efree(ifx_err);		    \                RETURN_FALSE;               \            }                               \        }    function_entry ifx_functions[] = {	PHP_FE(ifx_connect,            NULL)	PHP_FE(ifx_pconnect,           NULL)	PHP_FE(ifx_close,              NULL)	PHP_FE(ifx_query,              NULL)	PHP_FE(ifx_prepare,            NULL)	PHP_FE(ifx_do,                 NULL)	PHP_FE(ifx_error,              NULL)	PHP_FE(ifx_errormsg,           NULL)	PHP_FE(ifx_affected_rows,      NULL)	PHP_FE(ifx_num_rows,           NULL)	PHP_FE(ifx_num_fields,         NULL)	PHP_FE(ifx_fetch_row,          NULL)	PHP_FE(ifx_free_result,        NULL)	PHP_FE(ifx_htmltbl_result,     NULL)	PHP_FE(ifx_fieldtypes,         NULL)	PHP_FE(ifx_fieldproperties,    NULL)	PHP_FE(ifx_getsqlca,           NULL)	PHP_FE(ifx_create_blob,        NULL)	PHP_FE(ifx_free_blob,          NULL)	PHP_FE(ifx_get_blob,           NULL)	PHP_FE(ifx_update_blob,        NULL)	PHP_FE(ifx_copy_blob,          NULL)	PHP_FE(ifx_textasvarchar,      NULL)	PHP_FE(ifx_byteasvarchar,      NULL)	PHP_FE(ifx_nullformat,         NULL)	PHP_FE(ifx_blobinfile_mode,    NULL)	PHP_FE(ifx_create_char,        NULL)	PHP_FE(ifx_free_char,          NULL)	PHP_FE(ifx_get_char,           NULL)	PHP_FE(ifx_update_char,        NULL)$ifdef HAVE_IFX_IUS;	PHP_FE(ifxus_create_slob,      NULL)	PHP_FE(ifxus_close_slob,       NULL)	PHP_FE(ifxus_open_slob,        NULL)	PHP_FE(ifxus_free_slob,        NULL)	PHP_FE(ifxus_read_slob,        NULL)	PHP_FE(ifxus_write_slob,       NULL)	PHP_FE(ifxus_seek_slob,        NULL)	PHP_FE(ifxus_tell_slob,        NULL)$endif;	{NULL,NULL,NULL}};zend_module_entry ifx_module_entry = {	STANDARD_MODULE_HEADER,	"informix", 	ifx_functions, 	PHP_MINIT(ifx), 	PHP_MSHUTDOWN(ifx), 	PHP_RINIT(ifx), 	NULL, 	PHP_MINFO(ifx),	NO_VERSION_YET,	STANDARD_MODULE_PROPERTIES};ZEND_DECLARE_MODULE_GLOBALS(ifx)#ifdef COMPILE_DL_INFORMIXZEND_GET_MODULE(ifx)#endif/* True globals, no need for thread safety */static int le_link, le_plink, le_result, le_idresult;#define DUP    1EXEC SQL DEFINE IFX_SUCCESS 0;EXEC SQL DEFINE IFX_WARNING 1;EXEC SQL DEFINE IFX_ERROR  -1;EXEC SQL DEFINE IFX_NODATA 100;static int ifx_check(){	int _ifx_check;	_ifx_check = IFX_ERROR;	if (SQLSTATE[0] == '0') {		switch (SQLSTATE[1]) {			case '0':				_ifx_check = IFX_SUCCESS;				break;			case '1':				_ifx_check = IFX_WARNING;				break;			case '2':				_ifx_check = IFX_NODATA;				break;			default :				_ifx_check = IFX_ERROR;			break;		}  	}	return _ifx_check;}static char *ifx_error(ifx)EXEC SQL BEGIN DECLARE SECTION;	PARAMETER char *ifx;EXEC SQL END DECLARE SECTION;{	char *ifx_err_msg;	char c;	int errorcode;	TSRMLS_FETCH();	if (IFXG(sv_sqlcode) == 0) {		errorcode = SQLCODE;	} else {		errorcode = IFXG(sv_sqlcode);	}		switch (ifx_check()) {		case IFX_SUCCESS:			c = ' ';			break;		case IFX_WARNING:			c = 'W';			break;		case IFX_ERROR:			c = 'E';			break;		case IFX_NODATA:			c = 'N';			break;		default:			c = '?';			break;	}	ifx_err_msg = emalloc(64);	sprintf(ifx_err_msg, "%c [SQLSTATE=%c%c %c%c%c  SQLCODE=%d]",		c,		SQLSTATE[0],		SQLSTATE[1],		SQLSTATE[2],		SQLSTATE[3],		SQLSTATE[4],		errorcode	);	return(ifx_err_msg);}static void ifx_do_close(link)EXEC SQL BEGIN DECLARE SECTION;	PARAMETER char *link;EXEC SQL END DECLARE SECTION;{	char *ifx_err = NULL;	TSRMLS_FETCH();	EXEC SQL SET CONNECTION :link;                	if (ifx_check() >= 0) {		EXEC SQL DISCONNECT :link;		/* check if were in a transaction */		if (SQLCODE == -1800)   {			EXEC SQL SET CONNECTION :link;			EXEC SQL ROLLBACK WORK;			if (ifx_check() == 0)   {				/* DISCONNECT again, after rollback */				EXEC SQL DISCONNECT :link;				if (ifx_check() < 0)   {					IFXG(sv_sqlcode) = SQLCODE;					php_error_docref(NULL TSRMLS_CC, E_WARNING, "Disconnect link %s after Automatic Rollback fails (%s)", link, (ifx_err = ifx_error(link)));				}			}			if (ifx_check() < 0)   {				/* CLOSE database if rollback or disconnect fails */				EXEC SQL CLOSE DATABASE;				if (ifx_check() < 0)   {					IFXG(sv_sqlcode) = SQLCODE;					php_error_docref(NULL TSRMLS_CC, E_WARNING, "Close database fails %s (%s)", link, (ifx_err = ifx_error(link)));				}			}		}		else if (SQLCODE < 0)   {			IFXG(sv_sqlcode) = SQLCODE;			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Disconnect link %s fails (%s)", link, (ifx_err = ifx_error(link)));		}	}       	else   {		IFXG(sv_sqlcode) = SQLCODE;		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Set connection %s fails (%s)", link, (ifx_err = ifx_error(link)));	}	if (ifx_err) {		efree(ifx_err);	}}static void _close_ifx_link(zend_rsrc_list_entry *rsrc TSRMLS_DC){	char *link;	link=(char *)rsrc->ptr;	ifx_do_close(link);	efree(link);	IFXG(num_links)--;}static void _close_ifx_plink(zend_rsrc_list_entry *rsrc TSRMLS_DC){	char *link;	link = (char *)rsrc->ptr;	ifx_do_close(link);	free(link);	IFXG(num_persistent)--;	IFXG(num_links)--;}static void ifx_free_result(zend_rsrc_list_entry *rsrc TSRMLS_DC){	IFX_RES *Ifx_Result = (IFX_RES *)rsrc->ptr;	efree(Ifx_Result);}static void ifx_free_blob(zend_rsrc_list_entry *rsrc TSRMLS_DC){	IFX_IDRES *Ifx_blob = (IFX_IDRES *)rsrc->ptr;	php_intifx_release_blob(&Ifx_blob->BLOB.blob_data TSRMLS_CC);	efree(Ifx_blob); }PHP_INI_BEGIN()	STD_PHP_INI_BOOLEAN("ifx.allow_persistent", "1",  PHP_INI_SYSTEM, OnUpdateInt,    allow_persistent, zend_ifx_globals, ifx_globals)	STD_PHP_INI_ENTRY_EX("ifx.max_persistent",  "-1", PHP_INI_SYSTEM, OnUpdateInt,    max_persistent,   zend_ifx_globals, ifx_globals, display_link_numbers)	STD_PHP_INI_ENTRY_EX("ifx.max_links",       "-1", PHP_INI_SYSTEM, OnUpdateInt,    max_links,        zend_ifx_globals, ifx_globals, display_link_numbers)	STD_PHP_INI_ENTRY("ifx.default_host",       NULL, PHP_INI_SYSTEM, OnUpdateString, default_host,     zend_ifx_globals, ifx_globals)	STD_PHP_INI_ENTRY("ifx.default_user",       NULL, PHP_INI_SYSTEM, OnUpdateString, default_user,     zend_ifx_globals, ifx_globals)	STD_PHP_INI_ENTRY("ifx.default_password",   NULL, PHP_INI_SYSTEM, OnUpdateString, default_password, zend_ifx_globals, ifx_globals)	STD_PHP_INI_ENTRY("ifx.blobinfile",         "1",  PHP_INI_ALL,    OnUpdateInt,    blobinfile,       zend_ifx_globals, ifx_globals)	STD_PHP_INI_ENTRY("ifx.textasvarchar",      "0",  PHP_INI_ALL,    OnUpdateInt,    textasvarchar,    zend_ifx_globals, ifx_globals)	STD_PHP_INI_ENTRY("ifx.byteasvarchar",      "0",  PHP_INI_ALL,    OnUpdateInt,    byteasvarchar,    zend_ifx_globals, ifx_globals)	STD_PHP_INI_ENTRY("ifx.charasvarchar",      "0",  PHP_INI_ALL,    OnUpdateInt,    charasvarchar,    zend_ifx_globals, ifx_globals)	STD_PHP_INI_ENTRY("ifx.nullformat",         "0",  PHP_INI_ALL,    OnUpdateInt,    nullformat,       zend_ifx_globals, ifx_globals)PHP_INI_END()static void php_ifx_init_globals(zend_ifx_globals *ifx_globals){	ifx_globals->num_persistent = 0;	ifx_globals->nullvalue[0]   = 0;	strcpy(ifx_globals->nullstring, "NULL");	ifx_globals->num_persistent = 0;	ifx_globals->sv_sqlcode     = 0;}PHP_MINIT_FUNCTION(ifx){	ZEND_INIT_MODULE_GLOBALS(ifx, php_ifx_init_globals, NULL);	REGISTER_INI_ENTRIES();	le_result   = zend_register_list_destructors_ex(ifx_free_result, NULL,  "informix result",          module_number);	le_idresult = zend_register_list_destructors_ex(ifx_free_blob,   NULL,  "informix id result",       module_number);	le_link     = zend_register_list_destructors_ex(_close_ifx_link, NULL,  "informix link",            module_number);	le_plink    = zend_register_list_destructors_ex(NULL, _close_ifx_plink, "informix persistent link", module_number);	ifx_module_entry.type = type;	REGISTER_LONG_CONSTANT("IFX_SCROLL",      IFX_SCROLL,  CONST_CS | CONST_PERSISTENT);	REGISTER_LONG_CONSTANT("IFX_HOLD",        IFX_HOLD,    CONST_CS | CONST_PERSISTENT);$ifdef HAVE_IFX_IUS;	REGISTER_LONG_CONSTANT("IFX_LO_RDONLY",   LO_RDONLY,   CONST_CS | CONST_PERSISTENT);	REGISTER_LONG_CONSTANT("IFX_LO_WRONLY",   LO_WRONLY,   CONST_CS | CONST_PERSISTENT);	REGISTER_LONG_CONSTANT("IFX_LO_APPEND",   LO_APPEND,   CONST_CS | CONST_PERSISTENT);	REGISTER_LONG_CONSTANT("IFX_LO_RDWR",     LO_RDWR,     CONST_CS | CONST_PERSISTENT);	REGISTER_LONG_CONSTANT("IFX_LO_BUFFER",   LO_BUFFER,   CONST_CS | CONST_PERSISTENT);	REGISTER_LONG_CONSTANT("IFX_LO_NOBUFFER", LO_NOBUFFER, CONST_CS | CONST_PERSISTENT);$endif;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -