1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | http://www.php.net/license/3_01.txt                                  |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Authors: Hans-Peter Oeri (University of St.Gallen) <hp@oeri.ch>      |
14    +----------------------------------------------------------------------+
15  */
16 
17 #ifndef RESOURCEBUNDLE_CLASS_H
18 #define RESOURCEBUNDLE_CLASS_H
19 
20 #include <unicode/ures.h>
21 
22 #include <zend.h>
23 #include "php.h"
24 
25 #include "intl_error.h"
26 
27 typedef struct {
28 	intl_error      error;
29 
30 	UResourceBundle *me;
31 	UResourceBundle *child;
32 	zend_object     zend;
33 } ResourceBundle_object;
34 
php_intl_resourcebundle_fetch_object(zend_object * obj)35 static inline ResourceBundle_object *php_intl_resourcebundle_fetch_object(zend_object *obj) {
36 	return (ResourceBundle_object *)((char*)(obj) - XtOffsetOf(ResourceBundle_object, zend));
37 }
38 #define Z_INTL_RESOURCEBUNDLE_P(zv) php_intl_resourcebundle_fetch_object(Z_OBJ_P(zv))
39 
40 #define RESOURCEBUNDLE_METHOD_INIT_VARS		INTL_METHOD_INIT_VARS(ResourceBundle, rb)
41 #define RESOURCEBUNDLE_METHOD_FETCH_OBJECT_NO_CHECK	INTL_METHOD_FETCH_OBJECT(INTL_RESOURCEBUNDLE, rb)
42 #define RESOURCEBUNDLE_METHOD_FETCH_OBJECT							\
43 	INTL_METHOD_FETCH_OBJECT(INTL_RESOURCEBUNDLE, rb);					\
44 	if (RESOURCEBUNDLE_OBJECT(rb) == NULL) {						\
45 		intl_errors_set(&rb->error, U_ILLEGAL_ARGUMENT_ERROR,		\
46 				"Found unconstructed ResourceBundle", 0);	\
47 		RETURN_FALSE;												\
48 	}
49 
50 
51 #define RESOURCEBUNDLE_OBJECT(rb)			(rb)->me
52 
53 void resourcebundle_register_class( void );
54 extern zend_class_entry *ResourceBundle_ce_ptr;
55 
56 PHP_FUNCTION( resourcebundle_create );
57 PHP_FUNCTION( resourcebundle_get );
58 PHP_FUNCTION( resourcebundle_count );
59 PHP_FUNCTION( resourcebundle_locales );
60 PHP_FUNCTION( resourcebundle_get_error_code );
61 PHP_FUNCTION( resourcebundle_get_error_message );
62 
63 #endif // #ifndef RESOURCEBUNDLE_CLASS_H
64