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

📄 hw.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* }}} *//* {{{ proto void hw_close(int link)   Close connection to Hyperwave server */PHP_FUNCTION(hw_close){	pval **arg1;	int id, type;	hw_connection *ptr;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long_ex(arg1);	id=Z_LVAL_PP(arg1);	ptr = zend_list_find(id, &type);	if(!ptr || (type!=le_socketp && type!=le_psocketp)) {		php_error(E_WARNING, "%s(): Unable to find file identifier %d", get_active_function_name(TSRMLS_C), id);		RETURN_FALSE;	}	zend_list_delete(id);	RETURN_TRUE;}/* }}} *//* {{{ proto void hw_info(int link)   Outputs info string */PHP_FUNCTION(hw_info){	pval **arg1;	int id, type;	hw_connection *ptr;	char *str;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long_ex(arg1);	id=Z_LVAL_PP(arg1);	ptr = zend_list_find(id, &type);	if(!ptr || (type!=le_socketp && type!=le_psocketp)) {		php_error(E_WARNING, "%s(): Unable to find file identifier %d", get_active_function_name(TSRMLS_C), id);		RETURN_FALSE;	}	if(NULL != (str = get_hw_info(ptr))) {		/*		php_printf("%s\n", str);		efree(str);		*/		Z_STRLEN_P(return_value) = strlen(str);		Z_STRVAL_P(return_value) = str;		Z_TYPE_P(return_value) = IS_STRING;		return;		}	RETURN_FALSE;}/* }}} *//* {{{ proto int hw_error(int link)   Returns last error number */PHP_FUNCTION(hw_error){	pval **arg1;	int id, type;	hw_connection *ptr;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long_ex(arg1);	id=Z_LVAL_PP(arg1);	ptr = zend_list_find(id, &type);	if(!ptr || (type!=le_socketp && type!=le_psocketp)) {		php_error(E_WARNING, "%s(): Unable to find file identifier %d", get_active_function_name(TSRMLS_C), id);		RETURN_FALSE;	}	RETURN_LONG(ptr->lasterror);}/* }}} *//* {{{ proto string hw_errormsg(int link)   Returns last error message */PHP_FUNCTION(hw_errormsg){	pval **arg1;	int id, type;	hw_connection *ptr;	char errstr[100];	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long_ex(arg1);	id=Z_LVAL_PP(arg1);	ptr = zend_list_find(id, &type);	if(!ptr || (type!=le_socketp && type!=le_psocketp)) {		php_error(E_WARNING, "%s(): Unable to find file identifier %d", get_active_function_name(TSRMLS_C), id);		RETURN_FALSE;	}	switch (ptr->lasterror) {		case 0:			sprintf(errstr, "No error");			break;		case NOACCESS:			sprintf(errstr, "Access denied");			break;		case NODOCS:			sprintf(errstr, "No documents");			break;		case NONAME:			sprintf(errstr, "No collection name");			break;		case NODOC:			sprintf(errstr, "Object is not a document");			break;		case NOOBJ:			sprintf(errstr, "No object received");			break;		case NOCOLLS:			sprintf(errstr, "No collections received");			break;		case DBSTUBNG:			sprintf(errstr, "Connection to low-level database failed");			break;		case NOTFOUND:			sprintf(errstr, "Object not found");			break;		case EXIST:			sprintf(errstr, "Collection already exists");			break;		case FATHERDEL:			sprintf(errstr, "parent collection disappeared");			break;		case FATHNOCOLL:			sprintf(errstr, "parent collection not a collection");			break;		case NOTEMPTY:			sprintf(errstr, "Collection not empty");			break;		case DESTNOCOLL:			sprintf(errstr, "Destination not a collection");			break;		case SRCEQDEST:			sprintf(errstr, "Source equals destination");			break;		case REQPEND:			sprintf(errstr, "Request pending");			break;		case TIMEOUT:			sprintf(errstr, "Timeout");			break;		case NAMENOTUNIQUE:			sprintf(errstr, "Name not unique");			break;		case WRITESTOPPED:			sprintf(errstr, "Database now read-only; try again later");			break;		case LOCKED:			sprintf(errstr, "Object locked; try again later");			break;		case CHANGEBASEFLD:			sprintf(errstr, "Change of base-attribute");			break;		case NOTREMOVED:			sprintf(errstr, "Attribute not removed");			break;		case FLDEXISTS:			sprintf(errstr, "Attribute exists");			break;		case CMDSYNTAX:			sprintf(errstr, "Syntax error in command");			break;		case NOLANGUAGE:			sprintf(errstr, "No or unknown language specified");			break;		case WRGTYPE:			sprintf(errstr, "Wrong type in object");			break;		case WRGVERSION:			sprintf(errstr, "Client version too old");			break;		case CONNECTION:			sprintf(errstr, "No connection to other server");			break;		case SYNC:			sprintf(errstr, "Synchronization error");			break;		case NOPATH:			sprintf(errstr, "No path entry");			break;		case WRGPATH:			sprintf(errstr, "Wrong path entry");			break;		case PASSWD:			sprintf(errstr, "Wrong password (server-to-server server authentication)");			break;		case LC_NO_MORE_USERS:			sprintf(errstr, "No more users for license");			break;		case LC_NO_MORE_DOCS:			sprintf(errstr, "No more documents for this session and license");			break;		case RSERV_NRESP:			sprintf(errstr, "Remote server not responding");			break;		case Q_OVERFLOW:			sprintf(errstr, "Query overflow");			break;		case USR_BREAK:			sprintf(errstr, "Break by user");			break;		case N_IMPL:			sprintf(errstr, "Not implemented");			break;		case WRG_VALUE:			sprintf(errstr, "Wrong value");			break;		case INSUFF_FUNDS:			sprintf(errstr, "Insufficient funds");			break;		case REORG:			sprintf(errstr, "Reorganization in progress");			break;		case USER_LIMIT:			sprintf(errstr, "Limit of simultaneous users reached");			break;		case FTCONNECT:			sprintf(errstr, "No connection to fulltext server");			break;		case FTTIMEOUT:			sprintf(errstr, "Connection timed out");			break;		case FTINDEX:			sprintf(errstr, "Something wrong with fulltext index");			break;		case FTSYNTAX:			sprintf(errstr, "Query syntax error");			break;		case REQUESTPENDING:			sprintf(errstr, "Request pending");			break;		case NOCONNECTION:			sprintf(errstr, "No connection to document server");			break;		case WRONGVERSION:			sprintf(errstr, "Wrong protocol version");			break;		case NOTINITIALIZED:			sprintf(errstr, "Not initialized");			break;		case BADREQUEST:			sprintf(errstr, "Bad request");			break;		case BADLRN:			sprintf(errstr, "Bad document number");			break;		case OPENSTORE_WRITE:			sprintf(errstr, "Cannot write to local store");			break;		case OPENSTORE_READ:			sprintf(errstr, "Cannot read from local store");			break;		case READSTORE:			sprintf(errstr, "Store read error");			break;		case WRITESTORE:			sprintf(errstr, "Write error");			break;		case CLOSESTORE:			sprintf(errstr, "Close error");			break;		case BADPATH:			sprintf(errstr, "Bad path");			break;		case NOPATHDC:			sprintf(errstr, "No path");			break;		case OPENFILE:			sprintf(errstr, "Cannot open file");			break;		case READFILE:			sprintf(errstr, "Cannot read from file // same");			break;		case WRITEFILE:			sprintf(errstr, "Cannot write to file");			break;		case CONNECTCLIENT:			sprintf(errstr, "Could not connect to client");			break;		case ACCEPT:			sprintf(errstr, "Could not accept connection");			break;		case READSOCKET:			sprintf(errstr, "Could not read from socket");			break;		case WRITESOCKET:			sprintf(errstr, "Could not write to socket");			break;		case TOOMUCHDATA:			sprintf(errstr, "Received too much data");			break;		case TOOFEWDATA:			sprintf(errstr, "Received too few data // ...");			break;		case NOTIMPLEMENTED:			sprintf(errstr, "Not implemented");			break;		case USERBREAK:			sprintf(errstr, "User break");			break;		case INTERNAL:			sprintf(errstr, "Internal error");			break;		case INVALIDOBJECT:			sprintf(errstr, "Invalid object");			break;		case JOBTIMEOUT:			sprintf(errstr, "Job timed out");			break;		case OPENPORT:			sprintf(errstr, "Cannot open port // ... for several resons");			break;		case NODATA:			sprintf(errstr, "Received no data");			break;		case NOPORT:			sprintf(errstr, "No port to handle this request");			break;		case NOTCACHED:			sprintf(errstr, "Document not cached");			break;		case BADCACHETYPE:			sprintf(errstr, "Bad cache type");			break;		case OPENCACHE_WRITE:			sprintf(errstr, "Cannot write to cache");			break;		case OPENCACHE_READ:			sprintf(errstr, "Cannot read from cache // same");			break;		case NOSOURCE:			sprintf(errstr, "Do not know what to read");			break;		case CLOSECACHE:			sprintf(errstr, "Could not insert into cache");			break;		case CONNECTREMOTE:			sprintf(errstr, "Could not connect to remote server");			break;		case LOCKREFUSED:			sprintf(errstr, "Lock refused // could not lock the stores");			break;		default:			sprintf(errstr, "Unknown error: %d", ptr->lasterror);		}	RETURN_STRING(errstr, 1);}/* }}} *//* {{{ proto int hw_root(void)   Returns object id of root collection */PHP_FUNCTION(hw_root){	if (ZEND_NUM_ARGS() != 0) {		WRONG_PARAM_COUNT;	}	Z_LVAL_P(return_value) = 0;	Z_TYPE_P(return_value) = IS_LONG;}/* }}} *//* {{{ php_hw_command */char *php_hw_command(INTERNAL_FUNCTION_PARAMETERS, int comm) {	pval **arg1;	int link, type;	hw_connection *ptr;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {		return NULL;	}	convert_to_long_ex(arg1);	link=Z_LVAL_PP(arg1);	ptr = zend_list_find(link, &type);	if(!ptr || (type!=le_socketp && type!=le_psocketp)) {		php_error(E_WARNING, "%s(): Unable to find file identifier %d", get_active_function_name(TSRMLS_C), link);		return NULL;	}	set_swap(ptr->swap_on);	{	char *object = NULL;	if (0 != (ptr->lasterror = send_command(ptr->socket, comm, &object)))		return NULL;	return object;	}}/* }}} *//* {{{ proto string hw_stat(int link)   Returns status string */PHP_FUNCTION(hw_stat){        char *object;	object = php_hw_command(INTERNAL_FUNCTION_PARAM_PASSTHRU, STAT_COMMAND);	if(object == NULL)		RETURN_FALSE;	Z_STRVAL_P(return_value) = object;	Z_STRLEN_P(return_value) = strlen(object);	Z_TYPE_P(return_value) = IS_STRING;}/* }}} *//* {{{ proto array hw_who(int link)   Returns names and info of users loged in */PHP_FUNCTION(hw_who){	zval *user_arr;        char *object, *ptr, *temp, *attrname;	int i;	char *strtok_buf;	object = php_hw_command(INTERNAL_FUNCTION_PARAM_PASSTHRU, WHO_COMMAND);	if(object == NULL)		RETURN_FALSE;	ptr = object;php_printf("%s\n", ptr);	/* Skip first two lines, they just contain:        Users in Database        */        while((*ptr != '\0') && (*ptr != '\n'))		ptr++;        while((*ptr != '\0') && (*ptr != '\n'))		ptr++;	if(*ptr == '\0') {		efree(object);		RETURN_FALSE;	}	if (array_init(return_value) == FAILURE) {		efree(object);		RETURN_FALSE;	}	temp = estrdup(ptr);	attrname = php_strtok_r(temp, "\n", &strtok_buf);	i = 0;	while(attrname != NULL) {		char *name;		ALLOC_ZVAL(user_arr);		if (array_init(user_arr) == FAILURE) {			efree(object);			RETURN_FALSE;		}		ptr = attrname;		if(*ptr++ == '*')			add_assoc_long(user_arr, "self", 1);		else			add_assoc_long(user_arr, "self", 0);					ptr++;		name = ptr;		while((*ptr != '\0') && (*ptr != ' '))			ptr++;		*ptr = '\0';		add_assoc_string(user_arr, "id", name, 1);		ptr++;		name = ptr;		while((*ptr != '\0') && (*ptr != ' '))			ptr++;		*ptr = '\0';		add_assoc_string(user_arr, "name", name, 1);		ptr++;		while((*ptr != '\0') && (*ptr == ' '))			ptr++;

⌨️ 快捷键说明

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