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

📄 sablot.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
	zend_list_addref(handle->processor.idx);	ZVAL_STRING(argv[1], (char *) scheme, 1);	ZVAL_STRING(argv[2], (char *) rest, 1);	xslt_call_function("scheme get all", XSLT_SCHEME(handle).sh_get_all, handle->object, 	                   3, argv, &retval);	if (!retval) {		/* return failure */		return 1;	}	if ((Z_TYPE_P(retval) == IS_BOOL && Z_LVAL_P(retval) == 0) || (Z_TYPE_P(retval) == IS_NULL)) {		result = 1;	} else {		/* Convert the return value to string if needed */		if (Z_TYPE_P(retval) != IS_STRING)			convert_to_string_ex(&retval);		/* Save the return value in the buffer (copying it) */		*buffer     = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval));		*byte_count = Z_STRLEN_P(retval);		result = 0;	}	/* Free return value */	zval_ptr_dtor(&retval);			return result;}/* }}} *//* {{{ scheme_handler_is_registered()   Check to see if the scheme handler is registered with the user */static int scheme_handler_is_registered(php_xslt *handle){	/* If one of the functions is exists, then scheme	   handlers are registered */	if (XSLT_SCHEME(handle).sh_get_all  ||	    XSLT_SCHEME(handle).sh_open     ||	    XSLT_SCHEME(handle).sh_get      ||	    XSLT_SCHEME(handle).sh_put      ||	    XSLT_SCHEME(handle).sh_close)	 	return 1;	/* otherwise, no cigar */	else		return 0;}/* }}} *//* {{{ scheme_freememory()   Called when sablotron needs to free memory related to scheme handling */static int scheme_freememory(void *user_data, SablotHandle proc, char *buffer){	/* If we don't have any scheme handler's registered, then emalloc() wasn't	   used, and if emalloc() wasn't then efree shouldn't be used */	if (!scheme_handler_is_registered((php_xslt *) user_data)) {		return 0;	}	/* Free the memory using efree() and remove it from the register */	efree(buffer);		return 0;}/* }}} *//* {{{ scheme_open()   Called when the URI needs to be opened */static int  scheme_open(void *user_data, SablotHandle proc, const char *scheme, const char *rest, int *fd){	zval      *argv[3];                            /* Arguments to the scheme open function */	zval      *retval;                             /* The return value from the scheme open function */	php_xslt  *handle = (php_xslt *) user_data;    /* A PHP-XSLT processor */    TSRMLS_FETCH();    	/* If no open handler exists, let's exit */	if (!XSLT_SCHEME(handle).sh_open) {		return 0;	}	/* Allocate and initialize arguments */	MAKE_STD_ZVAL(argv[0]);	MAKE_STD_ZVAL(argv[1]);	MAKE_STD_ZVAL(argv[2]);	/* Argument 1: XSLT Processor (resource)	   Argument 2: Scheme         (string)	   Argument 3: Rest           (string)	 */	ZVAL_RESOURCE(argv[0], handle->processor.idx);	zend_list_addref(handle->processor.idx);	ZVAL_STRING(argv[1], (char *) scheme, 1);	ZVAL_STRING(argv[2], (char *) rest, 1);		/* Call the function */	xslt_call_function("scheme open", XSLT_SCHEME(handle).sh_open, handle->object,	                   3, argv, &retval);	if (!retval) {		/* return failure */		return 1;	}	/* Return value is a resource pointer to an open file */	*fd = Z_LVAL_P(retval);			/* Free it all up */	zval_ptr_dtor(&retval);	if (!*fd) {		/* return failure - unsupported scheme */		return SH_ERR_UNSUPPORTED_SCHEME;	}	/* return success */	return 0;}/* }}} *//* {{{ scheme_get()   Called when data needs to be fetched from the URI */static int  scheme_get(void *user_data, SablotHandle proc, int fd, char *buffer, int *byte_count){	zval       *argv[3];                           /* Arguments to the scheme get function  */	zval       *retval;                            /* Return value from the scheme get function */	php_xslt   *handle = (php_xslt *) user_data;   /* A PHP-XSLT processor */    TSRMLS_FETCH();    	/* If no get handler exists, let's exit */	if (!XSLT_SCHEME(handle).sh_get) {		return 0;	}	/* Allocate and initialize arguments */	MAKE_STD_ZVAL(argv[0]);	MAKE_STD_ZVAL(argv[1]);	MAKE_STD_ZVAL(argv[2]);	/* Argument 1: XSLT Processor (resource)	   Argument 2: File Pointer   (resource)	   Argument 3: Data           (string)	 */	ZVAL_RESOURCE(argv[0], handle->processor.idx);	zend_list_addref(handle->processor.idx);	ZVAL_RESOURCE(argv[1], fd);	zend_list_addref(fd);	ZVAL_STRINGL(argv[2], buffer, *byte_count, 0);		/* Call the function */	xslt_call_function("scheme get", XSLT_SCHEME(handle).sh_get, handle->object,	                   3, argv, &retval);		if (!retval) {		/* return failure */		return 1;	}		/* Returns the number of bytes read */	*byte_count = Z_LVAL_P(retval);	/* Free things up */	zval_ptr_dtor(&retval);	/* return success */	return 0;}/* }}} *//* {{{ scheme_put()   Called when data needs to be written */static int  scheme_put(void *user_data, SablotHandle proc, int fd, const char *buffer, int *byte_count){	zval       *argv[3];                            /* Arguments to the scheme put function */	zval       *retval;                             /* Return value from the scheme put function */	php_xslt   *handle = (php_xslt *) user_data;    /* A PHP-XSLT processor */    TSRMLS_FETCH();    	/* If no put handler exists, let's exit */	if (!XSLT_SCHEME(handle).sh_put) {		return 0;	}		/* Allocate and initialize arguments */	MAKE_STD_ZVAL(argv[0]);	MAKE_STD_ZVAL(argv[1]);	MAKE_STD_ZVAL(argv[2]);	/* Argument 1: XSLT processor (resource)	   Argument 2: File pointer   (resource)	   Argument 3: Data           (string)	 */	ZVAL_RESOURCE(argv[0], handle->processor.idx);	zend_list_addref(handle->processor.idx);	ZVAL_RESOURCE(argv[1], fd);	zend_list_addref(fd);	ZVAL_STRINGL(argv[2], (char *) buffer, *byte_count, 1);		/* Call the scheme put function already */	xslt_call_function("scheme put", XSLT_SCHEME(handle).sh_put, handle->object,	                   3, argv, &retval);	if (!retval) {		/* return failure */		return 1;	}		/* The return value is the number of bytes written */	*byte_count = Z_LVAL_P(retval);	/* Free everything up */	zval_ptr_dtor(&retval);	/* Return success */	return 0;}/* }}} *//* {{{ scheme_close()   Called when its time to close the fd */static int  scheme_close(void *user_data, SablotHandle proc, int fd){	zval       *argv[2];                           /* Arguments to the scheme close function*/	zval       *retval;                            /* Return value from the scheme close function */	php_xslt   *handle = (php_xslt *) user_data;   /* A PHP-XSLT processor */    TSRMLS_FETCH();    	/* if no close handler exists, exit */	if (!XSLT_SCHEME(handle).sh_close) {		return 0;	}	/* Allocate and initialize arguments */	MAKE_STD_ZVAL(argv[0]);	MAKE_STD_ZVAL(argv[1]);	/* Argument 1: XSLT processor (resource)	   Argument 2: File pointer   (resource)	 */	ZVAL_RESOURCE(argv[0], handle->processor.idx);	zend_list_addref(handle->processor.idx);	ZVAL_RESOURCE(argv[1], fd);	zend_list_addref(fd);		/* Call the scheme handler close function */	xslt_call_function("scheme close", XSLT_SCHEME(handle).sh_close, handle->object,	                   2, argv, &retval);	if (!retval) {		/* return failure */		return 1;	}		/* Free everything up */	zval_ptr_dtor(&retval);	/* Return success */	return 0;}/* }}} *//* {{{ sax_startdoc()   Called when the document starts to be processed */static SAX_RETURN sax_startdoc(void *ctx, SablotHandle processor){	zval       *argv[1];                    /* Arguments to the sax start doc function */	zval       *retval;                     /* Return value from sax start doc function */	php_xslt   *handle = (php_xslt *) ctx;  /* A PHP-XSLT processor */    TSRMLS_FETCH();    	/* if no document start function exists, exit */	if (!XSLT_SAX(handle).doc_start) {		return;	}	/* Allocate and initialize arguments */	MAKE_STD_ZVAL(argv[0]);	/* Argument 1:  XSLT processor (resource) */	ZVAL_RESOURCE(argv[0], handle->processor.idx);	zend_list_addref(handle->processor.idx);		/* Call the Sax start doc function */	xslt_call_function("sax start doc", XSLT_SAX(handle).doc_start, handle->object,	                   1, argv, &retval);	/* Cleanup */	if (retval)		zval_ptr_dtor(&retval);}/* }}} *//* {{{ sax_startelement()   Called when an element is begun to be processed */static SAX_RETURN sax_startelement(void *ctx, SablotHandle processor,                                   const char  *name,                                    const char **attr){	zval       *argv[3];                     /* Arguments to the sax start element function */	zval       *retval;                      /* Return value from the sax start element function */	php_xslt   *handle = (php_xslt *) ctx;   /* A PHP-XSLT processor */	char      **p;                           /* Pointer to attributes */    TSRMLS_FETCH();    	/* If no element start function is found, exit */	if (!XSLT_SAX(handle).element_start) {		return;	}	/* Allocate and initialize arguments */	MAKE_STD_ZVAL(argv[0]);	MAKE_STD_ZVAL(argv[1]);	MAKE_STD_ZVAL(argv[2]);	array_init(argv[2]);	/* Argument 1: XSLT processor (resource)	   Argument 2: Element name   (string)	   Argument 3: Element attributes (array)	 */	ZVAL_RESOURCE(argv[0], handle->processor.idx);	zend_list_addref(handle->processor.idx);	ZVAL_STRING(argv[1], (char *) name, 1);	/* loop through the attributes array, copying it onto our	   php array */	p = (char **) attr;	while (p && *p) {		add_assoc_string(argv[2], *p, *(p + 1), 1);		p += 2;	}	/* Call the sax element start function */	xslt_call_function("sax start element", XSLT_SAX(handle).element_start,  handle->object,	                   3, argv, &retval);		/* Cleanup */	if (retval)		zval_ptr_dtor(&retval);}/* }}} *//* {{{ xslt_sax_endelement()   Called when an ending XML element is encountered */static SAX_RETURN sax_endelement(void *ctx, SablotHandle processor, const char *name){	zval        *argv[2];                   /* Arguments to the sax end element function */	zval        *retval;                    /* Return value from the sax end element function */	php_xslt    *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */    TSRMLS_FETCH();    	/* If no element end function exists, exit */	if (!XSLT_SAX(handle).element_end) {		return;	}		/* Allocate and initialize arguments */	MAKE_STD_ZVAL(argv[0]);	MAKE_STD_ZVAL(argv[1]);	/* Argument 1: XSLT processor (resource)	   Argument 2: Element name   (string)	 */	ZVAL_RESOURCE(argv[0], handle->processor.idx);	zend_list_addref(handle->processor.idx);	ZVAL_STRING(argv[1], (char *) name, 1);	/* Call the sax end element function */	xslt_call_function("sax end element", XSLT_SAX(handle).element_end, handle->object,	                   2, argv, &retval);		/* Cleanup */	if (retval)		zval_ptr_dtor(&retval);}/* }}} *//* {{{ sax_startnamespace()   Called at the beginning of the parsing of a new namespace */static SAX_RETURN sax_startnamespace(void *ctx, SablotHandle processor,                                      const char *prefix,                                      const char *uri){	zval       *argv[3];                    /* Arguments to the sax start namespace function */	zval       *retval;                     /* Return value from the sax start namespace function */	php_xslt   *handle = (php_xslt *) ctx;  /* A PHP-XSLT processor */    TSRMLS_FETCH();    	/* if no namespace start function exists, exit */	if (!XSLT_SAX(handle).namespace_start) {		return;	}		/* Allocate and initialize arguments */	MAKE_STD_ZVAL(argv[0]);	MAKE_STD_ZVAL(argv[1]);	MAKE_STD_ZVAL(argv[2]);	/* Argument 1: XSLT processor (resource)	   Argument 2: Prefix         (string)	   Argument 3: URI            (string)	 */	ZVAL_RESOURCE(argv[0], handle->processor.idx);	zend_list_addref(handle->processor.idx);	ZVAL_STRING(argv[1], (char *) prefix, 1);	ZVAL_STRING(argv[2], (char *) uri, 1);	/* Call the sax start namespace function */	xslt_call_function("sax start namespace", XSLT_SAX(handle).namespace_start, handle->object,	                   3, argv, &retval);	/* Cleanup */	if (retval)		zval_ptr_dtor(&retval);}/* }}} *//* {{{ sax_endnamespace()   Called when a new namespace is finished being parsed */static SAX_RETURN sax_endnamespace(void *ctx, SablotHandle processor, const char *prefix){	zval        *argv[2];                    /* Arguments to the sax end namespace function */	zval        *retval;                     /* Return value from the sax end namespace function */	php_xslt    *handle = (php_xslt *) ctx;  /* A PHP-XSLT processor */    TSRMLS_FETCH();    	/* If no namespace end function exists, exit */	if (!XSLT_SAX(handle).namespace_end) {		return;	}		/* Allocate and initialize arguments */	MAKE_STD_ZVAL(argv[0]);	MAKE_STD_ZVAL(argv[1]);		/* Argument 1: XSLT processor (resource)	   Argument 2: Prefix         (string)	 */	ZVAL_RESOURCE(argv[0], handle->processor.idx);	zend_list_addref(handle->processor.idx);	ZVAL_STRING(argv[1], (char *) prefix, 1);		/* Call the sax end namespace function */	xslt_call_function("sax end namespace", XSLT_SAX(handle).namespace_end, handle->object,	                   2, argv, &retval);		/* Cleanup */	if (retval)		zval_ptr_dtor(&retval);}/* }}} *//* {{{ sax_comment()   Called when a comment is found */static SAX_RETURN sax_comment(void *ctx, SablotHandle processor, const char *contents){	zval        *argv[2];                    /* Arguments to the sax comment function */

⌨️ 快捷键说明

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