1 /* 2 +----------------------------------------------------------------------+ 3 | This source file is subject to version 3.01 of the PHP license, | 4 | that is bundled with this package in the file LICENSE, and is | 5 | available through the world-wide-web at the following url: | 6 | https://www.php.net/license/3_01.txt | 7 | If you did not receive a copy of the PHP license and are unable to | 8 | obtain it through the world-wide-web, please send a note to | 9 | license@php.net so we can mail you a copy immediately. | 10 +----------------------------------------------------------------------+ 11 | Authors: Vadim Savchuk <vsavchuk@productengine.com> | 12 | Dmitry Lakhtyuk <dlakhtyuk@productengine.com> | 13 +----------------------------------------------------------------------+ 14 */ 15 16 #ifdef HAVE_CONFIG_H 17 #include "config.h" 18 #endif 19 20 #include "php_intl.h" 21 #include "intl_error.h" 22 23 /* {{{ Get code of the last occurred error. */ PHP_FUNCTION(intl_get_error_code)24PHP_FUNCTION( intl_get_error_code ) 25 { 26 if (zend_parse_parameters_none() == FAILURE) { 27 RETURN_THROWS(); 28 } 29 30 RETURN_LONG( intl_error_get_code( NULL ) ); 31 } 32 /* }}} */ 33 34 /* {{{ Get text description of the last occurred error. */ PHP_FUNCTION(intl_get_error_message)35PHP_FUNCTION( intl_get_error_message ) 36 { 37 if (zend_parse_parameters_none() == FAILURE) { 38 RETURN_THROWS(); 39 } 40 41 RETURN_STR(intl_error_get_message( NULL )); 42 } 43 /* }}} */ 44 45 /* {{{ Check whether the given error code indicates a failure. 46 * Returns true if it does, and false if the code 47 * indicates success or a warning. 48 */ PHP_FUNCTION(intl_is_failure)49PHP_FUNCTION( intl_is_failure ) 50 { 51 zend_long err_code; 52 53 /* Parse parameters. */ 54 if( zend_parse_parameters( ZEND_NUM_ARGS(), "l", 55 &err_code ) == FAILURE ) 56 { 57 RETURN_THROWS(); 58 } 59 60 RETURN_BOOL( U_FAILURE( err_code ) ); 61 } 62 /* }}} */ 63 64 /* {{{ Return a string for a given error code. 65 * The string will be the same as the name of the error code constant. 66 */ PHP_FUNCTION(intl_error_name)67PHP_FUNCTION( intl_error_name ) 68 { 69 zend_long err_code; 70 71 /* Parse parameters. */ 72 if( zend_parse_parameters( ZEND_NUM_ARGS(), "l", 73 &err_code ) == FAILURE ) 74 { 75 RETURN_THROWS(); 76 } 77 78 RETURN_STRING( (char*)u_errorName( err_code ) ); 79 } 80 /* }}} */ 81