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

📄 hwapi.cpp

📁 php-4.4.7学习linux时下载的源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/*   +----------------------------------------------------------------------+   | PHP version 4.0                                                      |   +----------------------------------------------------------------------+   | Copyright (c) 1997, 1998, 1999, 2000 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: Uwe Steinmann                                               |   +----------------------------------------------------------------------+ *//* $Id: hwapi.cpp,v 1.2.2.1.8.1 2006/01/01 13:46:53 sniper Exp $ */#include <stdlib.h>#include <errno.h>extern "C"{#include "php.h"#include "php_globals.h"#include "ext/standard/head.h"#include "ext/standard/info.h"#if 0#include "ext/standard/php_standard.h"#include "fopen-wrappers.h"#endif#include "SAPI.h"}#ifdef PHP_WIN32#include <winsock.h>#endif#ifdef HAVE_MMAP #include <sys/mman.h>#endif#if HAVE_HWAPIstatic int le_hwapip;static int le_hwapi_objectp;static int le_hwapi_attributep;static int le_hwapi_errorp;static int le_hwapi_contentp;static int le_hwapi_reasonp;static zend_class_entry *hw_api_class_entry_ptr;static zend_class_entry *hw_api_object_class_entry_ptr;static zend_class_entry *hw_api_attribute_class_entry_ptr;static zend_class_entry *hw_api_error_class_entry_ptr;static zend_class_entry *hw_api_content_class_entry_ptr;static zend_class_entry *hw_api_reason_class_entry_ptr;#include "php_ini.h"#include "php_hwapi.h"//#ifdef __cplusplus//extern "C" {#include <sdk/api/api.h>#include <sdk/hgcsp/apihgcsp.h>//}//#endiffunction_entry hwapi_functions[] = {	PHP_FE(hwapi_dummy,								NULL)	PHP_FE(hwapi_init,								NULL)	PHP_FE(hwapi_hgcsp,								NULL)	PHP_FE(hwapi_object,								NULL)	PHP_FE(hwapi_children,								NULL)	PHP_FE(hwapi_parents,								NULL)	PHP_FE(hwapi_find,								NULL)	PHP_FE(hwapi_identify,								NULL)	PHP_FE(hwapi_remove,								NULL)	PHP_FE(hwapi_content,								NULL)	PHP_FE(hwapi_copy,								NULL)	PHP_FE(hwapi_link,								NULL)	PHP_FE(hwapi_move,								NULL)	PHP_FE(hwapi_lock,								NULL)	PHP_FE(hwapi_unlock,								NULL)	PHP_FE(hwapi_replace,								NULL)	PHP_FE(hwapi_object_new,								NULL)	PHP_FE(hwapi_object_count,								NULL)	PHP_FE(hwapi_object_title,								NULL)	PHP_FE(hwapi_object_attreditable,								NULL)	PHP_FE(hwapi_object_assign,								NULL)	PHP_FE(hwapi_object_attribute,								NULL)	PHP_FE(hwapi_object_insert,								NULL)	PHP_FE(hwapi_object_remove,								NULL)	PHP_FE(hwapi_object_value,								NULL)	PHP_FE(hwapi_attribute_new,								NULL)	PHP_FE(hwapi_attribute_key,								NULL)	PHP_FE(hwapi_attribute_value,								NULL)	PHP_FE(hwapi_attribute_values,								NULL)	PHP_FE(hwapi_attribute_langdepvalue,								NULL)	PHP_FE(hwapi_content_new,								NULL)	{NULL, NULL, NULL}};static function_entry php_hw_api_functions[] = {	{"hgcsp", PHP_FN(hwapi_hgcsp), NULL},	{"object", PHP_FN(hwapi_object), NULL},	{"children", PHP_FN(hwapi_children), NULL},	{"mychildren", PHP_FN(hwapi_mychildren), NULL},	{"parents", PHP_FN(hwapi_parents), NULL},	{"find", PHP_FN(hwapi_find), NULL},	{"identify", PHP_FN(hwapi_identify), NULL},	{"remove", PHP_FN(hwapi_remove), NULL},	{"content", PHP_FN(hwapi_content), NULL},	{"copy", PHP_FN(hwapi_copy), NULL},	{"link", PHP_FN(hwapi_link), NULL},	{"move", PHP_FN(hwapi_move), NULL},	{"lock", PHP_FN(hwapi_lock),	NULL},	{"unlock", PHP_FN(hwapi_unlock), NULL},	{"replace", PHP_FN(hwapi_replace), NULL},	{"insert", PHP_FN(hwapi_insert), NULL},	{"insertdocument", PHP_FN(hwapi_insertdocument), NULL},	{"insertcollection", PHP_FN(hwapi_insertcollection), NULL},	{"srcanchors", PHP_FN(hwapi_srcanchors), NULL},	{"dstanchors", PHP_FN(hwapi_dstanchors), NULL},	{"objectbyanchor", PHP_FN(hwapi_objectbyanchor), NULL},	{"dstofsrcanchor", PHP_FN(hwapi_dstofsrcanchor), NULL},	{"srcsofdst", PHP_FN(hwapi_srcsofdst), NULL},	{"checkin", PHP_FN(hwapi_checkin), NULL},	{"checkout", PHP_FN(hwapi_checkout), NULL},	{"setcommittedversion", PHP_FN(hwapi_setcommittedversion), NULL},	{"revert", PHP_FN(hwapi_revert), NULL},	{"history", PHP_FN(hwapi_history), NULL},	{"removeversion", PHP_FN(hwapi_removeversion), NULL},	{"freeversion", PHP_FN(hwapi_freeversion), NULL},	{"configurationhistory", PHP_FN(hwapi_configurationhistory), NULL},	{"saveconfiguration", PHP_FN(hwapi_saveconfiguration), NULL},	{"restoreconfiguration", PHP_FN(hwapi_restoreconfiguration), NULL},	{"removeconfiguration", PHP_FN(hwapi_removeconfiguration), NULL},	{"mergeconfiguration", PHP_FN(hwapi_mergeconfiguration), NULL},	{"user", PHP_FN(hwapi_user), NULL},	{"userlist", PHP_FN(hwapi_userlist), NULL},	{"hwstat", PHP_FN(hwapi_hwstat), NULL},	{"dcstat", PHP_FN(hwapi_dcstat), NULL},	{"dbstat", PHP_FN(hwapi_dbstat), NULL},	{"ftstat", PHP_FN(hwapi_ftstat), NULL},	{"info", PHP_FN(hwapi_info), NULL},	{NULL, NULL, NULL}};static function_entry php_hw_api_object_functions[] = {	{"hw_api_object", PHP_FN(hwapi_object_new), NULL},	{"count", PHP_FN(hwapi_object_count), NULL},	{"title", PHP_FN(hwapi_object_title), NULL},	{"attributeeditable", PHP_FN(hwapi_object_attreditable), NULL},	{"assign", PHP_FN(hwapi_object_assign), NULL},	{"attribute", PHP_FN(hwapi_object_attribute), NULL},	{"insert", PHP_FN(hwapi_object_insert), NULL},	{"remove", PHP_FN(hwapi_object_remove), NULL},	{"value", PHP_FN(hwapi_object_value), NULL},	{NULL, NULL, NULL}};static function_entry php_hw_api_attribute_functions[] = {	{"hw_api_attribute", PHP_FN(hwapi_attribute_new), NULL},	{"key", PHP_FN(hwapi_attribute_key), NULL},	{"value", PHP_FN(hwapi_attribute_value), NULL},	{"values", PHP_FN(hwapi_attribute_values), NULL},	{"langdepvalue", PHP_FN(hwapi_attribute_langdepvalue), NULL},	{NULL, NULL, NULL}};static function_entry php_hw_api_error_functions[] = {	{"count", PHP_FN(hwapi_error_count), NULL},	{"reason", PHP_FN(hwapi_error_reason), NULL},	{NULL, NULL, NULL}};static function_entry php_hw_api_content_functions[] = {	{"hw_api_content", PHP_FN(hwapi_content_new), NULL},	{"read", PHP_FN(hwapi_content_read), NULL},	{"mimetype", PHP_FN(hwapi_content_mimetype), NULL},	{NULL, NULL, NULL}};static function_entry php_hw_api_reason_functions[] = {	{"type", PHP_FN(hwapi_reason_type), NULL},	{"description", PHP_FN(hwapi_reason_description), NULL},	{NULL, NULL, NULL}};void hw_api_class_startup();void hw_api_object_class_startup();void hw_api_attribute_class_startup();void hw_api_error_class_startup();void hw_api_content_class_startup();void hw_api_reason_class_startup();static zval *php_hwapi_object_new(void *obj, int rsrc_type);zend_module_entry hwapi_module_entry = {	STANDARD_MODULE_HEADER,	"hwapi",	hwapi_functions,	PHP_MINIT(hwapi),	PHP_MSHUTDOWN(hwapi),	PHP_RINIT(hwapi),	NULL,	PHP_MINFO(hwapi),	NO_VERSION_YET,	STANDARD_MODULE_PROPERTIES};#ifdef ZTSint hwapi_globals_id;#elsePHP_HWAPI_API zend_hwapi_globals hwapi_globals;#endif#ifdef COMPILE_DL_HWAPIZEND_GET_MODULE(hwapi)#endifstatic void print_reason(const HW_API_Reason& reason) {	HW_API_String str_type;	switch(reason.type()) {		case HW_API_Reason::HW_API_ERROR:			str_type = "Error";			break;		case HW_API_Reason::HW_API_WARNING:			str_type = "Warning";			break;		case HW_API_Reason::HW_API_MESSAGE:			str_type = "Message";			break;	}	fprintf(stderr, "%s: %s\n", str_type.string(), reason.description("en").string());}static void print_error(const HW_API_Error& error) {	for (int i=0; i < error.count(); i++) {		HW_API_Reason reason;		error.reason(i, reason);		print_reason(reason);	}}static void print_object(const HW_API_Object& object) {	fprintf(stderr, "%s\n", object.title("en").string());	for (int i=0; i < object.count(); i++) {		HW_API_Attribute attrib;		object.attribute(i, attrib);		fprintf(stderr, "%s=%s\n", attrib.key().string(), attrib.value().string());	}}static void php_hwapi_init_globals(zend_hwapi_globals *hwapi_globals) {}static void php_free_hwapi(zend_rsrc_list_entry *rsrc) {	HW_API *obj;	obj = (HW_API *) (rsrc->ptr);	delete obj;}static void php_free_hwapi_object(zend_rsrc_list_entry *rsrc) {	HW_API_Object *obj;	obj = (HW_API_Object *) (rsrc->ptr);	delete obj;}static void php_free_hwapi_attribute(zend_rsrc_list_entry *rsrc) {	HW_API_Attribute *obj;	obj = (HW_API_Attribute *) (rsrc->ptr);	if(obj)		delete obj;}static void php_free_hwapi_error(zend_rsrc_list_entry *rsrc) {	HW_API_Error *obj;	obj = (HW_API_Error *) (rsrc->ptr);	if(obj)		delete obj;}static void php_free_hwapi_content(zend_rsrc_list_entry *rsrc) {	HW_API_Content *obj;	obj = (HW_API_Content *) (rsrc->ptr);	if(obj)		delete obj;}static void php_free_hwapi_reason(zend_rsrc_list_entry *rsrc) {	HW_API_Reason *obj;	obj = (HW_API_Reason *) (rsrc->ptr);	if(obj)		delete obj;}static void print_hwapi_stringarray(const HW_API_StringArray& strings) {	for(int i=0; i<strings.count(); i++) {		HW_API_String str;		strings.string(i, str);		fprintf(stderr, "%s\n", str.string());	}}static int stringArray2indexArray(pval **return_value, HW_API_StringArray *values) {	if (array_init(*return_value) == FAILURE) {		return 0;	}	for (int i=0; i<values->count(); i++) {		HW_API_String str;		values->string(i, str);		str.string();		add_next_index_string(*return_value, (char *) str.string(), 1);	}	return 1;}static int objectArray2indexArray(pval **return_value, HW_API_ObjectArray *objarr) {	if (array_init(*return_value) == FAILURE) {		return 0;	}	for(int i=0; i<objarr->count(); i++) {		zval *child;		HW_API_Object obj, *objp;		objarr->object(i, obj);		objp = new HW_API_Object(obj);		child = php_hwapi_object_new(objp, le_hwapi_objectp);		add_next_index_zval(*return_value, child);	}	return 1;}static void *php_hwapi_get_object(zval *wrapper, int rsrc_type1) {	void *obj;	zval **handle;	int type;	if (Z_TYPE_P(wrapper) != IS_OBJECT) {		php_error(E_ERROR, "Wrapper is not an object");	}	if (zend_hash_find(Z_OBJPROP_P(wrapper), "this", sizeof("this"), (void **)&handle) == FAILURE) {		php_error(E_ERROR, "Underlying object missing");	}	obj = zend_list_find(Z_LVAL_PP(handle), &type);	if (!obj || (type != rsrc_type1)) {		php_error(E_ERROR, "Underlying object missing or of invalid type");	}	return obj;}static zval *php_hwapi_object_new(void *obj, int rsrc_type) {	zval *wrapper, *handle;	int ret;	MAKE_STD_ZVAL(wrapper);	if (!obj) {		ZVAL_NULL(wrapper);		return wrapper;	}	/* construct an object with some methods */	if(rsrc_type == le_hwapi_attributep)		object_init_ex(wrapper, hw_api_attribute_class_entry_ptr);	else if(rsrc_type == le_hwapi_objectp)		object_init_ex(wrapper, hw_api_object_class_entry_ptr);	else if(rsrc_type == le_hwapip)		object_init_ex(wrapper, hw_api_class_entry_ptr);	else if(rsrc_type == le_hwapi_errorp)		object_init_ex(wrapper, hw_api_error_class_entry_ptr);	else if(rsrc_type == le_hwapi_contentp)		object_init_ex(wrapper, hw_api_content_class_entry_ptr);	else if(rsrc_type == le_hwapi_reasonp)		object_init_ex(wrapper, hw_api_reason_class_entry_ptr);	MAKE_STD_ZVAL(handle);	ZEND_REGISTER_RESOURCE(handle, obj, rsrc_type);	zend_hash_update(Z_OBJPROP_P(wrapper), "this", sizeof("this"), &handle, sizeof(zval *), NULL);	return(wrapper);}static HW_API_StringArray *make_HW_API_StringArray(HashTable *lht) {	int count, j;	HW_API_StringArray *sarr;	sarr = new HW_API_StringArray();	count = zend_hash_num_elements(lht);	zend_hash_internal_pointer_reset(lht);	for(j=0; j<count; j++) {		zval **keydata;		zend_hash_get_current_data(lht, (void **) &keydata);		switch((*keydata)->type) {			case IS_STRING:				sarr->insert((HW_API_String) (*keydata)->value.str.val);				break;		}		zend_hash_move_forward(lht);	}	return sarr;}static HW_API_object_In *make_HW_API_object_In(zval *arg1) {	int count, i;	HashTable *lht;	HW_API_object_In *in;	lht = arg1->value.ht;	if(0 == (count = zend_hash_num_elements(lht))) {		return NULL;	}	in = new HW_API_object_In();	zend_hash_internal_pointer_reset(lht);	for(i=0; i<count; i++) {		ulong ind;		char *key;		zval **keydata;		zend_hash_get_current_data(lht, (void **) &keydata);		zend_hash_get_current_key(lht, &key, &ind, 0);		switch((*keydata)->type) {			case IS_STRING:				if(!strcmp(key, "objectIdentifier"))					in->setObjectIdentifier((*keydata)->value.str.val);				else if(!strcmp(key, "version"))					in->setVersion((*keydata)->value.str.val);				break;			case IS_ARRAY: {				HW_API_StringArray *sarr;				if(!strcmp(key, "attributeSelector")) {					sarr = make_HW_API_StringArray((*keydata)->value.ht);					in->setAttributeSelector(*sarr);					/* FIXME: sarr can be propperly by freed now */				}				break;				}		}		zend_hash_move_forward(lht);	}	return(in);}static HW_API_children_In *make_HW_API_children_In(zval *arg1) {	int count, i;	HashTable *lht;	HW_API_children_In *in;	lht = arg1->value.ht;	if(0 == (count = zend_hash_num_elements(lht))) {		return NULL;	}	in = new HW_API_children_In();	zend_hash_internal_pointer_reset(lht);	for(i=0; i<count; i++) {		ulong ind;		char *key;		zval **keydata;		zend_hash_get_current_data(lht, (void **) &keydata);		zend_hash_get_current_key(lht, &key, &ind, 0);		switch((*keydata)->type) {			case IS_STRING:				if(!strcmp(key, "objectIdentifier"))					in->setObjectIdentifier((*keydata)->value.str.val);				else if(!strcmp(key, "objectQuery"))					in->setObjectQuery((*keydata)->value.str.val);				break;			case IS_ARRAY: {				HW_API_StringArray *sarr;				if(!strcmp(key, "attributeSelector")) {					sarr = make_HW_API_StringArray((*keydata)->value.ht);					in->setAttributeSelector(*sarr);					/* FIXME: sarr can be propperly by freed now */				}				break;				}		}		zend_hash_move_forward(lht);

⌨️ 快捷键说明

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