This source file includes following definitions.
- PHP_FUNCTION
- PHP_FUNCTION
- PHP_FUNCTION
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20
21 #include "php_intl.h"
22 #include "msgformat_class.h"
23 #include "msgformat_attr.h"
24 #include "intl_convert.h"
25
26 #include <unicode/ustring.h>
27
28
29
30
31
32
33
34 PHP_FUNCTION( msgfmt_get_pattern )
35 {
36 MSG_FORMAT_METHOD_INIT_VARS;
37
38
39 if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "O", &object, MessageFormatter_ce_ptr ) == FAILURE )
40 {
41 intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
42 "msgfmt_get_pattern: unable to parse input params", 0 );
43 RETURN_FALSE;
44 }
45
46
47 MSG_FORMAT_METHOD_FETCH_OBJECT;
48
49 if(mfo->mf_data.orig_format) {
50 RETURN_STRINGL(mfo->mf_data.orig_format, mfo->mf_data.orig_format_len);
51 }
52
53 RETURN_FALSE;
54 }
55
56
57
58
59
60
61
62 PHP_FUNCTION( msgfmt_set_pattern )
63 {
64 char* value = NULL;
65 size_t value_len = 0;
66 int32_t spattern_len = 0;
67 UChar* spattern = NULL;
68 MSG_FORMAT_METHOD_INIT_VARS;
69
70
71 if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Os",
72 &object, MessageFormatter_ce_ptr, &value, &value_len ) == FAILURE )
73 {
74 intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
75 "msgfmt_set_pattern: unable to parse input params", 0);
76 RETURN_FALSE;
77 }
78
79 MSG_FORMAT_METHOD_FETCH_OBJECT;
80
81
82 intl_convert_utf8_to_utf16(&spattern, &spattern_len, value, value_len, &INTL_DATA_ERROR_CODE(mfo));
83 INTL_METHOD_CHECK_STATUS(mfo, "Error converting pattern to UTF-16" );
84
85 #ifdef MSG_FORMAT_QUOTE_APOS
86 if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
87 intl_error_set( NULL, U_INVALID_FORMAT_ERROR,
88 "msgfmt_set_pattern: error converting pattern to quote-friendly format", 0 );
89 RETURN_FALSE;
90 }
91 #endif
92
93
94 umsg_applyPattern(MSG_FORMAT_OBJECT(mfo), spattern, spattern_len, NULL, &INTL_DATA_ERROR_CODE(mfo));
95 if (spattern) {
96 efree(spattern);
97 }
98 INTL_METHOD_CHECK_STATUS(mfo, "Error setting symbol value");
99
100 if(mfo->mf_data.orig_format) {
101 efree(mfo->mf_data.orig_format);
102 }
103 mfo->mf_data.orig_format = estrndup(value, value_len);
104 mfo->mf_data.orig_format_len = value_len;
105
106 if (mfo->mf_data.arg_types) {
107 zend_hash_destroy(mfo->mf_data.arg_types);
108 efree(mfo->mf_data.arg_types);
109 mfo->mf_data.arg_types = NULL;
110 }
111
112 RETURN_TRUE;
113 }
114
115
116
117
118
119
120
121 PHP_FUNCTION( msgfmt_get_locale )
122 {
123 char *loc;
124 MSG_FORMAT_METHOD_INIT_VARS;
125
126
127 if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "O",
128 &object, MessageFormatter_ce_ptr ) == FAILURE )
129 {
130 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
131 "msgfmt_get_locale: unable to parse input params", 0 );
132
133 RETURN_FALSE;
134 }
135
136
137 MSG_FORMAT_METHOD_FETCH_OBJECT;
138
139 loc = (char *)umsg_getLocale(MSG_FORMAT_OBJECT(mfo));
140 RETURN_STRING(loc);
141 }
142
143
144
145
146
147
148
149
150
151