@@ -33,26 +33,182 @@ typedef struct php_uri {
3333 zend_string * fragment ;
3434} php_uri ;
3535
36+ /**
37+ * Registers a URI handler. The handler must have a unique name.
38+ *
39+ * @param uri_handler The URI handler
40+ * @return SUCCESS in case of success, FAILURE otherwise
41+ */
42+ PHPAPI zend_result uri_handler_register (const uri_handler_t * uri_handler );
43+
44+ /**
45+ * Returns the registered URI handler based on uri_handler_name.
46+ *
47+ * @param uri_handler_name The URI handler name
48+ * @return The URI handler
49+ */
3650PHPAPI uri_handler_t * php_uri_get_handler (const zend_string * uri_handler_name );
51+
3752ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t * php_uri_parse (const uri_handler_t * uri_handler , const char * uri_str , size_t uri_str_len , bool silent );
53+
54+ /**
55+ * Retrieves the scheme component based on the read_mode and passes it to the zv ZVAL in case of success.
56+ *
57+ * Read_mode can be one of the following:
58+ * - URI_COMPONENT_READ_RAW: Retrieves the raw, non-normalized variant of the URI component
59+ * - URI_COMPONENT_READ_NORMALIZED_ASCII: Retrieves the normalized variant of the requested URI component that must only contain ASCII characters
60+ * - URI_COMPONENT_READ_NORMALIZED_UNICODE: Retrieves the normalized variant of the requested URI component that may contain Unicode codepoints
61+ *
62+ * @param internal_uri The internal URI whose uri member is used to retrieve the component
63+ * @param read_mode The read mode
64+ * @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
65+ * @return SUCCESS in case of success, FAILURE otherwise.
66+ */
3867ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_scheme (const uri_internal_t * internal_uri , uri_component_read_mode_t read_mode , zval * zv );
68+
69+ /**
70+ * Retrieves the username component based on the read_mode and passes it to the zv ZVAL in case of success.
71+ *
72+ * Read_mode can be one of the following:
73+ * - URI_COMPONENT_READ_RAW: Retrieves the raw, non-normalized variant of the URI component
74+ * - URI_COMPONENT_READ_NORMALIZED_ASCII: Retrieves the normalized variant of the requested URI component that must only contain ASCII characters
75+ * - URI_COMPONENT_READ_NORMALIZED_UNICODE: Retrieves the normalized variant of the requested URI component that may contain Unicode codepoints
76+ *
77+ * @param internal_uri The internal URI whose uri member is used to retrieve the component
78+ * @param read_mode The read mode
79+ * @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
80+ * @return SUCCESS in case of success, FAILURE otherwise.
81+ */
3982ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_username (const uri_internal_t * internal_uri , uri_component_read_mode_t read_mode , zval * zv );
83+
84+ /**
85+ * Retrieves the password component based on the read_mode and passes it to the zv ZVAL in case of success.
86+ *
87+ * Read_mode can be one of the following:
88+ * - URI_COMPONENT_READ_RAW: Retrieves the raw, non-normalized variant of the URI component
89+ * - URI_COMPONENT_READ_NORMALIZED_ASCII: Retrieves the normalized variant of the requested URI component that must only contain ASCII characters
90+ * - URI_COMPONENT_READ_NORMALIZED_UNICODE: Retrieves the normalized variant of the requested URI component that may contain Unicode codepoints
91+ *
92+ * @param internal_uri The internal URI whose uri member is used to retrieve the component
93+ * @param read_mode The read mode
94+ * @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
95+ * @return SUCCESS in case of success, FAILURE otherwise.
96+ */
4097ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_password (const uri_internal_t * internal_uri , uri_component_read_mode_t read_mode , zval * zv );
98+
99+ /**
100+ * Retrieves the host component based on the read_mode and passes it to the zv ZVAL in case of success.
101+ *
102+ * Read_mode can be one of the following:
103+ * - URI_COMPONENT_READ_RAW: Retrieves the raw, non-normalized variant of the URI component
104+ * - URI_COMPONENT_READ_NORMALIZED_ASCII: Retrieves the normalized variant of the requested URI component that must only contain ASCII characters
105+ * - URI_COMPONENT_READ_NORMALIZED_UNICODE: Retrieves the normalized variant of the requested URI component that may contain Unicode codepoints
106+ *
107+ * @param internal_uri The internal URI whose uri member is used to retrieve the component
108+ * @param read_mode The read mode
109+ * @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
110+ * @return SUCCESS in case of success, FAILURE otherwise.
111+ */
41112ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_host (const uri_internal_t * internal_uri , uri_component_read_mode_t read_mode , zval * zv );
113+
114+ /**
115+ * Retrieves the port component based on the read_mode and passes it to the zv ZVAL in case of success.
116+ *
117+ * Read_mode can be one of the following:
118+ * - URI_COMPONENT_READ_RAW: Retrieves the raw, non-normalized variant of the URI component
119+ * - URI_COMPONENT_READ_NORMALIZED_ASCII: Retrieves the normalized variant of the requested URI component that must only contain ASCII characters
120+ * - URI_COMPONENT_READ_NORMALIZED_UNICODE: Retrieves the normalized variant of the requested URI component that may contain Unicode codepoints
121+ *
122+ * @param internal_uri The internal URI whose uri member is used to retrieve the component
123+ * @param read_mode The read mode
124+ * @param zv The output parameter containing the retrieved component as a ZVAL (either IS_LONG or IS_NULL).
125+ * @return SUCCESS in case of success, FAILURE otherwise.
126+ */
42127ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_port (const uri_internal_t * internal_uri , uri_component_read_mode_t read_mode , zval * zv );
128+
129+ /**
130+ * Retrieves the path component based on the read_mode and passes it to the zv ZVAL in case of success.
131+ *
132+ * Read_mode can be one of the following:
133+ * - URI_COMPONENT_READ_RAW: Retrieves the raw, non-normalized variant of the URI component
134+ * - URI_COMPONENT_READ_NORMALIZED_ASCII: Retrieves the normalized variant of the requested URI component that must only contain ASCII characters
135+ * - URI_COMPONENT_READ_NORMALIZED_UNICODE: Retrieves the normalized variant of the requested URI component that may contain Unicode codepoints
136+ *
137+ * @param internal_uri The internal URI whose uri member is used to retrieve the component
138+ * @param read_mode The read mode
139+ * @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
140+ * @return SUCCESS in case of success, FAILURE otherwise.
141+ */
43142ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_path (const uri_internal_t * internal_uri , uri_component_read_mode_t read_mode , zval * zv );
143+
144+ /**
145+ * Retrieves the query component based on the read_mode and passes it to the zv ZVAL in case of success.
146+ *
147+ * Read_mode can be one of the following:
148+ * - URI_COMPONENT_READ_RAW: Retrieves the raw, non-normalized variant of the URI component
149+ * - URI_COMPONENT_READ_NORMALIZED_ASCII: Retrieves the normalized variant of the requested URI component that must only contain ASCII characters
150+ * - URI_COMPONENT_READ_NORMALIZED_UNICODE: Retrieves the normalized variant of the requested URI component that may contain Unicode codepoints
151+ *
152+ * @param internal_uri The internal URI whose uri member is used to retrieve the component
153+ * @param read_mode The read mode
154+ * @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
155+ * @return SUCCESS in case of success, FAILURE otherwise.
156+ */
44157ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_query (const uri_internal_t * internal_uri , uri_component_read_mode_t read_mode , zval * zv );
158+
159+ /**
160+ * Retrieves the fragment component based on the read_mode and passes it to the zv ZVAL in case of success.
161+ *
162+ * Read_mode can be one of the following:
163+ * - URI_COMPONENT_READ_RAW: Retrieves the raw, non-normalized variant of the URI component
164+ * - URI_COMPONENT_READ_NORMALIZED_ASCII: Retrieves the normalized variant of the requested URI component that must only contain ASCII characters
165+ * - URI_COMPONENT_READ_NORMALIZED_UNICODE: Retrieves the normalized variant of the requested URI component that may contain Unicode codepoints
166+ *
167+ * @param internal_uri The internal URI whose uri member is used to retrieve the component
168+ * @param read_mode The read mode
169+ * @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
170+ * @return SUCCESS in case of success, FAILURE otherwise.
171+ */
45172ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_fragment (const uri_internal_t * internal_uri , uri_component_read_mode_t read_mode , zval * zv );
173+
174+ /**
175+ * Frees the uri member within the provided internal URI.
176+ *
177+ * @param internal_uri The internal URI
178+ */
46179ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free (uri_internal_t * internal_uri );
180+
181+ /**
182+ * Creates a new php_uri struct containing all the URI components. The components are retrieved based on the read_mode parameter.
183+ *
184+ * Read_mode can be one of the following:
185+ * - URI_COMPONENT_READ_RAW: Retrieves the raw, non-normalized variant of the URI component
186+ * - URI_COMPONENT_READ_NORMALIZED_ASCII: Retrieves the normalized variant of the requested URI component that must only contain ASCII characters
187+ * - URI_COMPONENT_READ_NORMALIZED_UNICODE: Retrieves the normalized variant of the requested URI component that may contain Unicode codepoints
188+ *
189+ * @param uri_handler The URI handler whose parse_uri() handler is called
190+ * @param uri_str The input string that is going to be parsed
191+ * @param uri_str_len Length of the input string
192+ * @param read_mode The read mode based on which components are retrieved
193+ * @param silent Whether to throw a Uri\InvalidUriException in case of failure
194+ * @return The created php_uri struct in case of success, NULL otherwise
195+ */
47196ZEND_ATTRIBUTE_NONNULL PHPAPI php_uri * php_uri_parse_to_struct (
48197 const uri_handler_t * uri_handler , const char * uri_str , size_t uri_str_len , uri_component_read_mode_t read_mode , bool silent
49198);
199+
200+ /**
201+ * Frees the provided php_uri struct.
202+ *
203+ * @param uri The php_uri struct to free
204+ */
50205ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_struct_free (php_uri * uri );
51206
52207ZEND_ATTRIBUTE_NONNULL_ARGS (1 , 2 ) PHPAPI void php_uri_instantiate_uri (
53208 INTERNAL_FUNCTION_PARAMETERS , const uri_handler_t * handler , const zend_string * uri_str , const zend_object * base_url_object ,
54209 bool should_throw , bool should_update_this_object , zval * errors_zv
55210);
211+
56212ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_implementation_set_object_handlers (zend_class_entry * ce , zend_object_handlers * object_handlers );
57213
58214#endif
0 commit comments