Skip to content

Commit

Permalink
Convert to use new parameter parsing API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Zmievski committed Oct 26, 2001
1 parent 475796a commit 5da651f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 61 deletions.
12 changes: 4 additions & 8 deletions ext/standard/crc32.c
Expand Up @@ -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);
}
Expand Down
29 changes: 10 additions & 19 deletions ext/standard/crypt.c
Expand Up @@ -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) {
Expand All @@ -167,7 +158,7 @@ PHP_FUNCTION(crypt)
#endif
}

RETVAL_STRING(crypt(Z_STRVAL_PP(arg1), salt), 1);
RETVAL_STRING(crypt(str, salt), 1);
}
/* }}} */
#endif
Expand Down
45 changes: 11 additions & 34 deletions ext/standard/html.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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, &quotes, &charset) == FAILURE) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len,
&quote_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);
}
/* }}} */
Expand Down Expand Up @@ -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, &quotes) == 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, &quote_style) == FAILURE) {
return;
}

array_init(return_value);
Expand Down

0 comments on commit 5da651f

Please sign in to comment.