Back to index

php5  5.3.10
collator_error.c
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | This source file is subject to version 3.01 of the PHP license,      |
00006    | that is bundled with this package in the file LICENSE, and is        |
00007    | available through the world-wide-web at the following url:           |
00008    | http://www.php.net/license/3_01.txt                                  |
00009    | If you did not receive a copy of the PHP license and are unable to   |
00010    | obtain it through the world-wide-web, please send a note to          |
00011    | license@php.net so we can mail you a copy immediately.               |
00012    +----------------------------------------------------------------------+
00013    | Authors: Vadim Savchuk <vsavchuk@productengine.com>                  |
00014    |          Dmitry Lakhtyuk <dlakhtyuk@productengine.com>               |
00015    +----------------------------------------------------------------------+
00016  */
00017 
00018 #ifdef HAVE_CONFIG_H
00019 #include "config.h"
00020 #endif
00021 
00022 #include "php_intl.h"
00023 #include "collator_class.h"
00024 #include "collator_error.h"
00025 
00026 /* {{{ proto int Collator::getErrorCode( Collator $coll )
00027  * Get collator's last error code. }}} */
00028 /* {{{ proto int collator_get_error_code( Collator $coll )
00029  * Get collator's last error code.
00030  */
00031 PHP_FUNCTION( collator_get_error_code )
00032 {
00033        COLLATOR_METHOD_INIT_VARS
00034 
00035        /* Parse parameters. */
00036        if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
00037               &object, Collator_ce_ptr ) == FAILURE )
00038        {
00039               intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
00040                      "collator_get_error_code: unable to parse input params", 0 TSRMLS_CC );
00041 
00042               RETURN_FALSE;
00043        }
00044 
00045        /* Fetch the object (without resetting its last error code). */
00046        co = (Collator_object *) zend_object_store_get_object(object TSRMLS_CC);
00047        if( co == NULL )
00048               RETURN_FALSE;
00049 
00050        /* Return collator's last error code. */
00051        RETURN_LONG( COLLATOR_ERROR_CODE( co ) );
00052 }
00053 /* }}} */
00054 
00055 /* {{{ proto string Collator::getErrorMessage( Collator $coll )
00056  * Get text description for collator's last error code. }}} */
00057 /* {{{ proto string collator_get_error_message( Collator $coll )
00058  * Get text description for collator's last error code.
00059  */
00060 PHP_FUNCTION( collator_get_error_message )
00061 {
00062        const char* message = NULL;
00063 
00064        COLLATOR_METHOD_INIT_VARS
00065 
00066        /* Parse parameters. */
00067        if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
00068               &object, Collator_ce_ptr ) == FAILURE )
00069        {
00070               intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
00071                      "collator_get_error_message: unable to parse input params", 0 TSRMLS_CC );
00072 
00073               RETURN_FALSE;
00074        }
00075 
00076        /* Fetch the object (without resetting its last error code). */
00077        co = (Collator_object *) zend_object_store_get_object( object TSRMLS_CC );
00078        if( co == NULL )
00079               RETURN_FALSE;
00080 
00081        /* Return last error message. */
00082        message = intl_error_get_message( COLLATOR_ERROR_P( co ) TSRMLS_CC );
00083        RETURN_STRING( (char*)message, FALSE );
00084 }
00085 /* }}} */
00086 
00087 /*
00088  * Local variables:
00089  * tab-width: 4
00090  * c-basic-offset: 4
00091  * End:
00092  * vim600: noet sw=4 ts=4 fdm=marker
00093  * vim<600: noet sw=4 ts=4
00094  */