Hello!
Please consider exposing the wonderful bin_to_readable function.
Thanks,
Rodric
--- release/php-5.0.2/ext/session/php_session.h 2004-11-02 16:32:48.606283463 -0800
+++ php-5.0.2/ext/session/php_session.h 2004-11-02 16:38:55.086850260 -0800
@@ -149,6 +149,7 @@
PHP_FUNCTION(session_set_cookie_params);
PHP_FUNCTION(session_get_cookie_params);
PHP_FUNCTION(session_write_close);
+PHP_FUNCTION(session_bin2readable);
#ifdef ZTS
#define PS(v) TSRMG(ps_globals_id, php_ps_globals *, v)
--- release/php-5.0.2/ext/session/session.c 2004-11-02 16:32:48.568292112 -0800
+++ php-5.0.2/ext/session/session.c 2004-11-02 17:13:00.792147738 -0800
@@ -76,6 +76,7 @@
PHP_FE(session_set_cookie_params, NULL)
PHP_FE(session_get_cookie_params, NULL)
PHP_FE(session_write_close, NULL)
+ PHP_FE(session_bin2readable, NULL)
PHP_FALIAS(session_commit, session_write_close, NULL)
{NULL, NULL, NULL}
};
@@ -1715,6 +1716,37 @@
}
}
+/* {{{ proto string session_bin2readable(string bin, [ int hash_bits_per_char ])
+ Convert binary to a URL safe string */
+PHP_FUNCTION(session_bin2readable)
+{
+ int j, n;
+ zval **bin, **hash_bits;
+ char *buf;
+
+ if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2 ||
+ zend_get_parameters_ex(ZEND_NUM_ARGS(), &bin, &hash_bits) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ convert_to_string_ex(bin);
+
+ if (ZEND_NUM_ARGS() == 2) {
+ convert_to_long_ex(hash_bits);
+ n = Z_BVAL_PP(hash_bits);
+ }
+
+ if (ZEND_NUM_ARGS() == 1 || (n < 4 || n > 6)) {
+ n = 6;
+ }
+
+ buf = emalloc(Z_STRLEN_PP(bin)*(8-n));
+
+ j = (int) (bin_to_readable(Z_STRVAL_PP(bin), Z_STRLEN_PP(bin), buf, n) - buf);
+
+ RETVAL_STRING(buf,j);
+}
+/* }}} */
+
/* {{{ proto void session_write_close(void)
Write session data and end session */
PHP_FUNCTION(session_write_close)
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php