This repository has been archived by the owner on Nov 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
string.h
125 lines (100 loc) · 5.76 KB
/
string.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
+------------------------------------------------------------------------+
| Zephir Language |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to [email protected] so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <[email protected]> |
| Eduar Carvajal <[email protected]> |
| Vladimir Kolesnikov <[email protected]> |
+------------------------------------------------------------------------+
*/
#ifndef ZEPHIR_KERNEL_STRING_H
#define ZEPHIR_KERNEL_STRING_H
#include <Zend/zend.h>
#define ZEPHIR_TRIM_LEFT 1
#define ZEPHIR_TRIM_RIGHT 2
#define ZEPHIR_TRIM_BOTH 3
/** Fast char position */
int zephir_memnstr(const zval *haystack, const zval *needle ZEPHIR_DEBUG_PARAMS);
int zephir_memnstr_str(const zval *haystack, char *needle, unsigned int needle_length ZEPHIR_DEBUG_PARAMS);
/** Function replacement */
void zephir_fast_strlen(zval *return_value, zval *str);
int zephir_fast_strlen_ev(zval *str);
void zephir_fast_strtolower(zval *return_value, zval *str);
void zephir_strtolower_inplace(zval *s);
void zephir_fast_join(zval *result, zval *glue, zval *pieces TSRMLS_DC);
void zephir_fast_join_str(zval *result, char *glue, unsigned int glue_length, zval *pieces TSRMLS_DC);
void zephir_fast_explode(zval *result, zval *delimiter, zval *str, long limit TSRMLS_DC);
void zephir_fast_explode_str(zval *result, const char *delimiter, int delimiter_length, zval *str, long limit TSRMLS_DC);
void zephir_fast_strpos(zval *return_value, const zval *haystack, const zval *needle, unsigned int offset);
void zephir_fast_strpos_str(zval *return_value, const zval *haystack, char *needle, unsigned int needle_length);
void zephir_fast_stripos_str(zval *return_value, zval *haystack, char *needle, unsigned int needle_length);
void zephir_fast_str_replace(zval *return_value, zval *search, zval *replace, zval *subject);
void zephir_fast_trim(zval *return_value, zval *str, zval *charlist, int where TSRMLS_DC);
void zephir_fast_strip_tags(zval *return_value, zval *str);
void zephir_fast_strtoupper(zval *return_value, zval *str);
/** Camelize/Uncamelize */
void zephir_camelize(zval *return_value, const zval *str);
void zephir_uncamelize(zval *return_value, const zval *str);
/** Starts/Ends with */
int zephir_start_with(const zval *str, const zval *compared, zval *case_sensitive);
int zephir_start_with_str(const zval *str, char *compared, unsigned int compared_length);
int zephir_start_with_str_str(char *str, unsigned int str_length, char *compared, unsigned int compared_length);
int zephir_end_with(const zval *str, const zval *compared, zval *case_sensitive);
int zephir_end_with_str(const zval *str, char *compared, unsigned int compared_length);
/** Random string */
void zephir_random_string(zval *return_value, const zval *type, const zval *length TSRMLS_DC);
/* Strips extra slashes */
void zephir_remove_extra_slashes(zval *return_value, const zval *str);
/** Generates a unique key for an array/object */
void zephir_unique_key(zval *return_value, zval *prefix, zval *value TSRMLS_DC);
/** spprintf */
int zephir_spprintf(char **message, int max_len, char *format, ...);
/* Substr */
void zephir_substr(zval *return_value, zval *str, long from, long length);
/** EOL */
zval *zephir_eol(int eol TSRMLS_DC);
/** Preg-Match */
void zephir_preg_match(zval *return_value, zval **return_value_ptr, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC);
/** Base64 */
void zephir_base64_encode(zval *return_value, zval *data);
void zephir_base64_decode(zval *return_value, zval *data);
/** Hash */
void zephir_md5(zval *return_value, zval *str);
/** JSON */
int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int opts TSRMLS_DC);
int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zend_bool assoc TSRMLS_DC);
/***/
void zephir_lcfirst(zval *return_value, zval *s);
void zephir_ucfirst(zval *return_value, zval *s);
int zephir_http_build_query(zval *return_value, zval *params, char *sep TSRMLS_DC);
void zephir_htmlspecialchars(zval *return_value, zval *string, zval *quoting, zval *charset TSRMLS_DC);
void zephir_htmlentities(zval *return_value, zval *string, zval *quoting, zval *charset TSRMLS_DC);
void zephir_strval(zval *return_value, zval *v);
void zephir_date(zval *return_value, zval *format, zval *timestamp TSRMLS_DC);
void zephir_addslashes(zval *return_value, zval *str TSRMLS_DC);
void zephir_stripslashes(zval *return_value, zval *str TSRMLS_DC);
void zephir_stripcslashes(zval *return_value, zval *str TSRMLS_DC);
#if PHP_VERSION_ID < 50400
const char* zend_new_interned_string(const char *arKey, int nKeyLength, int free_src TSRMLS_DC);
#define ZEPHIR_ZVAL_MAYBE_INTERNED_STRING(pz, string) ZVAL_STRING(pz, string, 1);
#else
#define ZEPHIR_ZVAL_MAYBE_INTERNED_STRING(pz, string) \
do { \
if (IS_INTERNED(string)) { \
ZVAL_STRINGL(pz, string, INTERNED_LEN(string)-1, 0); \
} \
else { \
ZVAL_STRING(pz, string, 1); \
} \
} while (0)
#endif /* PHP_VERSION_ID < 50400 */
#endif /* ZEPHIR_KERNEL_STRING_H */