xref: /PHP-8.1/ext/standard/php_string.h (revision 01b3fc03)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
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    | https://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: Rasmus Lerdorf <rasmus@php.net>                             |
14    |          Stig Sæther Bakken <ssb@php.net>                            |
15    +----------------------------------------------------------------------+
16 */
17 
18 #ifndef PHP_STRING_H
19 #define PHP_STRING_H
20 
21 #if defined(ZTS)
22 PHP_MINIT_FUNCTION(localeconv);
23 PHP_MSHUTDOWN_FUNCTION(localeconv);
24 #endif
25 #if HAVE_NL_LANGINFO
26 PHP_MINIT_FUNCTION(nl_langinfo);
27 #endif
28 #if ZEND_INTRIN_SSE4_2_FUNC_PTR
29 PHP_MINIT_FUNCTION(string_intrin);
30 #endif
31 
32 #define strnatcmp(a, b) \
33 	strnatcmp_ex(a, strlen(a), b, strlen(b), 0)
34 #define strnatcasecmp(a, b) \
35 	strnatcmp_ex(a, strlen(a), b, strlen(b), 1)
36 PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len, int fold_case);
37 PHPAPI struct lconv *localeconv_r(struct lconv *out);
38 PHPAPI char *php_strtoupper(char *s, size_t len);
39 PHPAPI char *php_strtolower(char *s, size_t len);
40 PHPAPI zend_string *php_string_toupper(zend_string *s);
41 PHPAPI zend_string *php_string_tolower(zend_string *s);
42 PHPAPI char *php_strtr(char *str, size_t len, const char *str_from, const char *str_to, size_t trlen);
43 PHPAPI zend_string *php_addslashes(zend_string *str);
44 PHPAPI void php_stripslashes(zend_string *str);
45 PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, const char *what, size_t what_len);
46 PHPAPI zend_string *php_addcslashes(zend_string *str, const char *what, size_t what_len);
47 PHPAPI void php_stripcslashes(zend_string *str);
48 PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix, size_t sufflen);
49 PHPAPI size_t php_dirname(char *str, size_t len);
50 PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len);
51 PHPAPI zend_string *php_str_to_str(const char *haystack, size_t length, const char *needle,
52 		size_t needle_len, const char *str, size_t str_len);
53 PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode);
54 PHPAPI size_t php_strip_tags(char *rbuf, size_t len, const char *allow, size_t allow_len);
55 PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, const char *allow, size_t allow_len, bool allow_tag_spaces);
56 PHPAPI void php_implode(const zend_string *delim, HashTable *arr, zval *return_value);
57 PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return_value, zend_long limit);
58 
59 PHPAPI size_t php_strspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end);
60 PHPAPI size_t php_strcspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end);
61 
62 PHPAPI int string_natural_compare_function_ex(zval *result, zval *op1, zval *op2, bool case_insensitive);
63 PHPAPI int string_natural_compare_function(zval *result, zval *op1, zval *op2);
64 PHPAPI int string_natural_case_compare_function(zval *result, zval *op1, zval *op2);
65 
66 #if defined(_REENTRANT)
67 # ifdef PHP_WIN32
68 #  include <wchar.h>
69 # endif
70 # define php_mblen(ptr, len) ((int) mbrlen(ptr, len, &BG(mblen_state)))
71 # define php_mb_reset() memset(&BG(mblen_state), 0, sizeof(BG(mblen_state)))
72 #else
73 # define php_mblen(ptr, len) mblen(ptr, len)
74 # define php_mb_reset() php_ignore_value(mblen(NULL, 0))
75 #endif
76 
77 void register_string_constants(INIT_FUNC_ARGS);
78 
79 #endif /* PHP_STRING_H */
80