Skip to content

Commit

Permalink
Provide zend_string wrappers for php_base64_(en|de)code
Browse files Browse the repository at this point in the history
Also pull existing php_base64_decode() proxy out to an inline.
Bump PHP_API_VERSION for ABI change.
  • Loading branch information
sgolemon committed Jul 16, 2017
1 parent 90ae2ae commit 3de82a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 0 additions & 6 deletions ext/standard/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ void php_base64_init(void)
*/
/* }}} */

PHPAPI zend_string *php_base64_decode(const unsigned char *str, size_t length) /* {{{ */
{
return php_base64_decode_ex(str, length, 0);
}
/* }}} */

PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length, zend_bool strict) /* {{{ */
{
const unsigned char *current = str;
Expand Down
12 changes: 11 additions & 1 deletion ext/standard/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ PHP_FUNCTION(base64_decode);
PHP_FUNCTION(base64_encode);

PHPAPI extern zend_string *php_base64_encode(const unsigned char *, size_t);
static inline zend_string *php_base64_encode_str(const zend_string *str) {
return php_base64_encode((const unsigned char*)(ZSTR_VAL(str)), ZSTR_LEN(str));
}

PHPAPI extern zend_string *php_base64_decode_ex(const unsigned char *, size_t, zend_bool);
PHPAPI extern zend_string *php_base64_decode(const unsigned char *, size_t);

static inline zend_string *php_base64_decode(const unsigned char *str, size_t len) {
return php_base64_decode_ex(str, len, 0);
}
static inline zend_string *php_base64_decode_str(const zend_string *str) {
return php_base64_decode_ex((const unsigned char*)(ZSTR_VAL(str)), ZSTR_LEN(str), 0);
}

#endif /* BASE64_H */

Expand Down
2 changes: 1 addition & 1 deletion main/php.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <dmalloc.h>
#endif

#define PHP_API_VERSION 20160731
#define PHP_API_VERSION 20170715
#define PHP_HAVE_STREAMS
#define YYDEBUG 0
#define PHP_DEFAULT_CHARSET "UTF-8"
Expand Down

0 comments on commit 3de82a0

Please sign in to comment.