summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2001-10-26 21:07:59 +0000
committerAndrei Zmievski <andrei@php.net>2001-10-26 21:07:59 +0000
commit5da651fcd215dbc67ad40044df9d8ce573f28c90 (patch)
tree1095ef8bd8afaeeb3d352ed03fab3cfcfdf9b44f
parent475796a0d7f7fd6e623a56506f7d8a6eb6493d89 (diff)
downloadphp-git-5da651fcd215dbc67ad40044df9d8ce573f28c90.tar.gz
Convert to use new parameter parsing API.
-rw-r--r--ext/standard/crc32.c12
-rw-r--r--ext/standard/crypt.c29
-rw-r--r--ext/standard/html.c45
3 files changed, 25 insertions, 61 deletions
diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c
index e14c872cbf..b43155b17a 100644
--- a/ext/standard/crc32.c
+++ b/ext/standard/crc32.c
@@ -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);
}
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c
index 91f3168f47..90f6fbdb16 100644
--- a/ext/standard/crypt.c
+++ b/ext/standard/crypt.c
@@ -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
diff --git a/ext/standard/html.c b/ext/standard/html.c
index eb6512c18d..591593c845 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -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, &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);
}
/* }}} */
@@ -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);