PHP_FUNCTION(crypt)
{
char salt[PHP_MAX_SALT_LEN+1];
- pval **arg1, **arg2;
+ char *str, *salt_in = NULL;
+ int str_len, salt_in_len;
salt[0]=salt[PHP_MAX_SALT_LEN]='\0';
/* This will produce suitable results if people depend on DES-encryption
available (passing always 2-character salt). At least for glibc6.1 */
memset(&salt[1], '$', PHP_MAX_SALT_LEN-1);
- switch (ZEND_NUM_ARGS()) {
- case 1:
- if (zend_get_parameters_ex(1, &arg1)==FAILURE) {
- RETURN_FALSE;
- }
- break;
- case 2:
- if (zend_get_parameters_ex(2, &arg1, &arg2)==FAILURE) {
- RETURN_FALSE;
- }
- convert_to_string_ex(arg2);
- memcpy(salt, Z_STRVAL_PP(arg2), MIN(PHP_MAX_SALT_LEN, Z_STRLEN_PP(arg2)));
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len,
+ &salt_in, &salt_in_len) == FAILURE) {
+ return;
+ }
+
+ if (salt_in) {
+ memcpy(salt, salt_in, MIN(PHP_MAX_SALT_LEN, salt_in_len));
}
- convert_to_string_ex(arg1);
/* The automatic salt generation only covers standard DES and md5-crypt */
if(!*salt) {
#endif
}
- RETVAL_STRING(crypt(Z_STRVAL_PP(arg1), salt), 1);
+ RETVAL_STRING(crypt(str, salt), 1);
}
/* }}} */
#endif
/* {{{ php_escape_html_entities
*/
-PHPAPI char *php_escape_html_entities(unsigned char *old, int oldlen, int *newlen, int all, int quote_style, char * hint_charset)
+PHPAPI char *php_escape_html_entities(unsigned char *old, int oldlen, int *newlen, int all, int quote_style, char *hint_charset)
{
int i, maxlen, len;
char *new;
*/
static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
{
- zval **arg, **quotes, **charset;
- int len, quote_style = ENT_COMPAT;
- int ac = ZEND_NUM_ARGS();
- char *hint_charset = NULL;
+ char *str, *hint_charset = NULL;
+ int str_len, hint_charset_len, len, quote_style = ENT_COMPAT;
char *new;
- if (ac < 1 || ac > 3 || zend_get_parameters_ex(ac, &arg, "es, &charset) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len,
+ "e_style, &hint_charset, &hint_charset_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(arg);
- if(ac==2) {
- convert_to_long_ex(quotes);
- quote_style = Z_LVAL_PP(quotes);
- }
- if (ac == 3) {
- convert_to_string_ex(charset);
- hint_charset = Z_STRVAL_PP(charset);
- }
-
-
- new = php_escape_html_entities(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &len, all, quote_style, hint_charset);
+ new = php_escape_html_entities(str, str_len, &len, all, quote_style, hint_charset);
RETVAL_STRINGL(new, len, 0);
}
/* }}} */
}
/* }}} */
-/* {{{ proto array get_html_translation_table([int table [, int quote_style][, string charset]])
+/* {{{ proto array get_html_translation_table([int table [, int quote_style]])
Returns the internal translation table used by htmlspecialchars and htmlentities */
PHP_FUNCTION(get_html_translation_table)
{
- zval **whichone, **quotes;
int which = HTML_SPECIALCHARS, quote_style = ENT_COMPAT;
- int ac = ZEND_NUM_ARGS();
int i, j;
- char ind[ 2 ];
+ char ind[2];
enum entity_charset charset = determine_charset(NULL);
- if (ac < 0 || ac > 2 || zend_get_parameters_ex(ac, &whichone, "es) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (ac > 0) {
- convert_to_long_ex(whichone);
- which = Z_LVAL_PP(whichone);
- }
- if (ac == 2) {
- convert_to_long_ex(quotes);
- quote_style = Z_LVAL_PP(quotes);
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &which, "e_style) == FAILURE) {
+ return;
}
array_init(return_value);