mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Convert to use new parameter parsing API.
This commit is contained in:
parent
475796a0d7
commit
5da651fcd2
3 changed files with 25 additions and 61 deletions
|
@ -106,19 +106,15 @@ static const unsigned int crc32tab[256] = {
|
|||
Calculate the crc32 polynomial of a string */
|
||||
PHP_NAMED_FUNCTION(php_if_crc32)
|
||||
{
|
||||
pval **arg;
|
||||
unsigned int crc = ~0;
|
||||
char *p ;
|
||||
int len, nr ;
|
||||
char *p;
|
||||
int len, nr;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &p, &nr) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
convert_to_string_ex(arg);
|
||||
|
||||
len = 0 ;
|
||||
nr=Z_STRLEN_PP(arg);
|
||||
p = Z_STRVAL_PP(arg);
|
||||
for (len += nr; nr--; ++p) {
|
||||
CRC32(crc, *p);
|
||||
}
|
||||
|
|
|
@ -128,31 +128,22 @@ static void php_to64(char *s, long v, int n)
|
|||
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) {
|
||||
|
@ -167,7 +158,7 @@ PHP_FUNCTION(crypt)
|
|||
#endif
|
||||
}
|
||||
|
||||
RETVAL_STRING(crypt(Z_STRVAL_PP(arg1), salt), 1);
|
||||
RETVAL_STRING(crypt(str, salt), 1);
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
|
|
@ -387,7 +387,7 @@ static enum entity_charset determine_charset(char * charset_hint)
|
|||
|
||||
/* {{{ 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;
|
||||
|
@ -479,28 +479,16 @@ PHPAPI char *php_escape_html_entities(unsigned char *old, int oldlen, int *newle
|
|||
*/
|
||||
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);
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -536,28 +524,17 @@ PHP_FUNCTION(htmlentities)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue