xref: /PHP-8.3/ext/intl/intl_error.h (revision 01b3fc03)
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    |          Stanislav Malyshev <stas@zend.com>                          |
14    +----------------------------------------------------------------------+
15  */
16 
17 #ifndef INTL_ERROR_H
18 #define INTL_ERROR_H
19 
20 #include <unicode/utypes.h>
21 #include <unicode/parseerr.h>
22 #include <zend_smart_str.h>
23 
24 #define INTL_ERROR_CODE(e) (e).code
25 
26 typedef struct _intl_error {
27 	UErrorCode      code;
28 	int             free_custom_error_message;
29 	char*           custom_error_message;
30 } intl_error;
31 
32 intl_error* intl_error_create( void );
33 void        intl_error_init( intl_error* err );
34 void        intl_error_reset( intl_error* err );
35 void        intl_error_set_code( intl_error* err, UErrorCode err_code );
36 void        intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg );
37 void        intl_error_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg );
38 UErrorCode  intl_error_get_code( intl_error* err );
39 zend_string* intl_error_get_message( intl_error* err );
40 
41 // Wrappers to synchonize object's and global error structures.
42 void        intl_errors_reset( intl_error* err );
43 void        intl_errors_set_custom_msg( intl_error* err, const char* msg, int copyMsg );
44 void        intl_errors_set_code( intl_error* err, UErrorCode err_code );
45 void        intl_errors_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg );
46 
47 // Other error helpers
48 smart_str	intl_parse_error_to_string( UParseError* pe );
49 
50 #endif // INTL_ERROR_H
51