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

📄 tcl_internal.c

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 C
📖 第 1 页 / 共 2 页
字号:
/*- * See the file LICENSE for redistribution information. * * Copyright (c) 1999-2001 *	Sleepycat Software.  All rights reserved. */#include "db_config.h"#ifndef lintstatic const char revid[] = "$Id: tcl_internal.c,v 11.54 2002/08/15 02:47:46 bostic Exp $";#endif /* not lint */#ifndef NO_SYSTEM_INCLUDES#include <sys/types.h>#include <stdlib.h>#include <string.h>#include <tcl.h>#endif#include "db_int.h"#include "dbinc/tcl_db.h"#include "dbinc/db_page.h"#include "dbinc/db_am.h"#include "dbinc_auto/db_ext.h"/* * * internal.c -- * *	This file contains internal functions we need to maintain *	state for our Tcl interface. * *	NOTE: This all uses a linear linked list.  If we end up with *	too many info structs such that this is a performance hit, it *	should be redone using hashes or a list per type.  The assumption *	is that the user won't have more than a few dozen info structs *	in operation at any given point in time.  Even a complicated *	application with a few environments, nested transactions, locking, *	and several databases open, using cursors should not have a *	negative performance impact, in terms of searching the list to *	get/manipulate the info structure. *//* * Prototypes for procedures defined later in this file: */static void tcl_flag_callback __P((u_int32_t, const FN *, void *));/* * Private structure type used to pass both an interp and an object into * a callback's single void *. */struct __tcl_callback_bundle {	Tcl_Interp *interp;	Tcl_Obj *obj;};#define	GLOB_CHAR(c)	((c) == '*' || (c) == '?')/* * PUBLIC: DBTCL_INFO *_NewInfo __P((Tcl_Interp *, * PUBLIC:    void *, char *, enum INFOTYPE)); * * _NewInfo -- * * This function will create a new info structure and fill it in * with the name and pointer, id and type. */DBTCL_INFO *_NewInfo(interp, anyp, name, type)	Tcl_Interp *interp;	void *anyp;	char *name;	enum INFOTYPE type;{	DBTCL_INFO *p;	int i, ret;	if ((ret = __os_malloc(NULL, sizeof(DBTCL_INFO), &p)) != 0) {		Tcl_SetResult(interp, db_strerror(ret), TCL_STATIC);		return (NULL);	}	if ((ret = __os_strdup(NULL, name, &p->i_name)) != 0) {		Tcl_SetResult(interp, db_strerror(ret), TCL_STATIC);		__os_free(NULL, p);		return (NULL);	}	p->i_interp = interp;	p->i_anyp = anyp;	p->i_data = 0;	p->i_data2 = 0;	p->i_type = type;	p->i_parent = NULL;	p->i_err = NULL;	p->i_errpfx = NULL;	p->i_lockobj.data = NULL;	p->i_btcompare = NULL;	p->i_dupcompare = NULL;	p->i_hashproc = NULL;	p->i_second_call = NULL;	p->i_rep_eid = NULL;	p->i_rep_send = NULL;	for (i = 0; i < MAX_ID; i++)		p->i_otherid[i] = 0;	LIST_INSERT_HEAD(&__db_infohead, p, entries);	return (p);}/* * PUBLIC: void *_NameToPtr __P((CONST char *)); */void	*_NameToPtr(name)	CONST char *name;{	DBTCL_INFO *p;	for (p = LIST_FIRST(&__db_infohead); p != NULL;	    p = LIST_NEXT(p, entries))		if (strcmp(name, p->i_name) == 0)			return (p->i_anyp);	return (NULL);}/* * PUBLIC: DBTCL_INFO *_PtrToInfo __P((CONST void *)); */DBTCL_INFO *_PtrToInfo(ptr)	CONST void *ptr;{	DBTCL_INFO *p;	for (p = LIST_FIRST(&__db_infohead); p != NULL;	    p = LIST_NEXT(p, entries))		if (p->i_anyp == ptr)			return (p);	return (NULL);}/* * PUBLIC: DBTCL_INFO *_NameToInfo __P((CONST char *)); */DBTCL_INFO *_NameToInfo(name)	CONST char *name;{	DBTCL_INFO *p;	for (p = LIST_FIRST(&__db_infohead); p != NULL;	    p = LIST_NEXT(p, entries))		if (strcmp(name, p->i_name) == 0)			return (p);	return (NULL);}/* * PUBLIC: void  _SetInfoData __P((DBTCL_INFO *, void *)); */void_SetInfoData(p, data)	DBTCL_INFO *p;	void *data;{	if (p == NULL)		return;	p->i_anyp = data;	return;}/* * PUBLIC: void  _DeleteInfo __P((DBTCL_INFO *)); */void_DeleteInfo(p)	DBTCL_INFO *p;{	if (p == NULL)		return;	LIST_REMOVE(p, entries);	if (p->i_lockobj.data != NULL)		__os_free(NULL, p->i_lockobj.data);	if (p->i_err != NULL) {		fclose(p->i_err);		p->i_err = NULL;	}	if (p->i_errpfx != NULL)		__os_free(NULL, p->i_errpfx);	if (p->i_btcompare != NULL)		Tcl_DecrRefCount(p->i_btcompare);	if (p->i_dupcompare != NULL)		Tcl_DecrRefCount(p->i_dupcompare);	if (p->i_hashproc != NULL)		Tcl_DecrRefCount(p->i_hashproc);	if (p->i_second_call != NULL)		Tcl_DecrRefCount(p->i_second_call);	if (p->i_rep_eid != NULL)		Tcl_DecrRefCount(p->i_rep_eid);	if (p->i_rep_send != NULL)		Tcl_DecrRefCount(p->i_rep_send);	__os_free(NULL, p->i_name);	__os_free(NULL, p);	return;}/* * PUBLIC: int _SetListElem __P((Tcl_Interp *, * PUBLIC:    Tcl_Obj *, void *, int, void *, int)); */int_SetListElem(interp, list, elem1, e1cnt, elem2, e2cnt)	Tcl_Interp *interp;	Tcl_Obj *list;	void *elem1, *elem2;	int e1cnt, e2cnt;{	Tcl_Obj *myobjv[2], *thislist;	int myobjc;	myobjc = 2;	myobjv[0] = Tcl_NewByteArrayObj((u_char *)elem1, e1cnt);	myobjv[1] = Tcl_NewByteArrayObj((u_char *)elem2, e2cnt);	thislist = Tcl_NewListObj(myobjc, myobjv);	if (thislist == NULL)		return (TCL_ERROR);	return (Tcl_ListObjAppendElement(interp, list, thislist));}/* * PUBLIC: int _SetListElemInt __P((Tcl_Interp *, Tcl_Obj *, void *, int)); */int_SetListElemInt(interp, list, elem1, elem2)	Tcl_Interp *interp;	Tcl_Obj *list;	void *elem1;	int elem2;{	Tcl_Obj *myobjv[2], *thislist;	int myobjc;	myobjc = 2;	myobjv[0] = Tcl_NewByteArrayObj((u_char *)elem1, strlen((char *)elem1));	myobjv[1] = Tcl_NewIntObj(elem2);	thislist = Tcl_NewListObj(myobjc, myobjv);	if (thislist == NULL)		return (TCL_ERROR);	return (Tcl_ListObjAppendElement(interp, list, thislist));}/* * PUBLIC: int _SetListRecnoElem __P((Tcl_Interp *, Tcl_Obj *, * PUBLIC:     db_recno_t, u_char *, int)); */int_SetListRecnoElem(interp, list, elem1, elem2, e2size)	Tcl_Interp *interp;	Tcl_Obj *list;	db_recno_t elem1;	u_char *elem2;	int e2size;{	Tcl_Obj *myobjv[2], *thislist;	int myobjc;	myobjc = 2;	myobjv[0] = Tcl_NewLongObj((long)elem1);	myobjv[1] = Tcl_NewByteArrayObj(elem2, e2size);	thislist = Tcl_NewListObj(myobjc, myobjv);	if (thislist == NULL)		return (TCL_ERROR);	return (Tcl_ListObjAppendElement(interp, list, thislist));}/* * _Set3DBTList -- *	This is really analogous to both _SetListElem and *	_SetListRecnoElem--it's used for three-DBT lists returned by *	DB->pget and DBC->pget().  We'd need a family of four functions *	to handle all the recno/non-recno cases, however, so we make *	this a little more aware of the internals and do the logic inside. * *	XXX *	One of these days all these functions should probably be cleaned up *	to eliminate redundancy and bring them into the standard DB *	function namespace. * * PUBLIC: int _Set3DBTList __P((Tcl_Interp *, Tcl_Obj *, DBT *, int, * PUBLIC:     DBT *, int, DBT *)); */int_Set3DBTList(interp, list, elem1, is1recno, elem2, is2recno, elem3)	Tcl_Interp *interp;	Tcl_Obj *list;	DBT *elem1, *elem2, *elem3;	int is1recno, is2recno;{	Tcl_Obj *myobjv[3], *thislist;	if (is1recno)		myobjv[0] = Tcl_NewLongObj((long)*(db_recno_t *)elem1->data);	else		myobjv[0] =		    Tcl_NewByteArrayObj((u_char *)elem1->data, elem1->size);	if (is2recno)		myobjv[1] = Tcl_NewLongObj((long)*(db_recno_t *)elem2->data);	else		myobjv[1] =		    Tcl_NewByteArrayObj((u_char *)elem2->data, elem2->size);	myobjv[2] = Tcl_NewByteArrayObj((u_char *)elem3->data, elem3->size);	thislist = Tcl_NewListObj(3, myobjv);	if (thislist == NULL)		return (TCL_ERROR);	return (Tcl_ListObjAppendElement(interp, list, thislist));}/* * _SetMultiList -- build a list for return from multiple get. * * PUBLIC: int _SetMultiList __P((Tcl_Interp *, * PUBLIC:	    Tcl_Obj *, DBT *, DBT*, int, int)); */int_SetMultiList(interp, list, key, data, type, flag)	Tcl_Interp *interp;	Tcl_Obj *list;	DBT *key, *data;	int type, flag;{	db_recno_t recno;	u_int32_t dlen, klen;	int result;	void *pointer, *dp, *kp;	recno = 0;	dlen = 0;	kp = NULL;	DB_MULTIPLE_INIT(pointer, data);	result = TCL_OK;	if (type == DB_RECNO || type == DB_QUEUE)		recno = *(db_recno_t *) key->data;	else		kp = key->data;	klen = key->size;	do {

⌨️ 快捷键说明

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