cvs: php4 /ext/standard crc32.c crypt.c html.c
| From: | Andrei Zmievski | Date: | Fri, 26 Oct 2001 21:08:00 +0000 |
| Subject: | cvs: php4 /ext/standard crc32.c crypt.c html.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-7985@lists.php.net to get a copy of this message | ||
andrei Fri Oct 26 17:08:00 2001 EDT
Modified files:
/php4/ext/standard crc32.c crypt.c html.c
Log:
Convert to use new parameter parsing API.
Index: php4/ext/standard/crc32.c
diff -u php4/ext/standard/crc32.c:1.8 php4/ext/standard/crc32.c:1.9
--- php4/ext/standard/crc32.c:1.8 Tue Sep 25 17:58:22 2001
+++ php4/ext/standard/crc32.c Fri Oct 26 17:07:59 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: crc32.c,v 1.8 2001/09/25 21:58:22 jeroen Exp $ */
+/* $Id: crc32.c,v 1.9 2001/10/26 21:07:59 andrei Exp $ */
#include "php.h"
#include "basic_functions.h"
@@ -106,19 +106,15 @@
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);
}
Index: php4/ext/standard/crypt.c
diff -u php4/ext/standard/crypt.c:1.52 php4/ext/standard/crypt.c:1.53
--- php4/ext/standard/crypt.c:1.52 Sat Oct 20 23:01:17 2001
+++ php4/ext/standard/crypt.c Fri Oct 26 17:07:59 2001
@@ -17,7 +17,7 @@
| Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
-/* $Id: crypt.c,v 1.52 2001/10/21 03:01:17 sniper Exp $ */
+/* $Id: crypt.c,v 1.53 2001/10/26 21:07:59 andrei Exp $ */
#include <stdlib.h>
#include "php.h"
@@ -128,31 +128,22 @@
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 @@
#endif
}
- RETVAL_STRING(crypt(Z_STRVAL_PP(arg1), salt), 1);
+ RETVAL_STRING(crypt(str, salt), 1);
}
/* }}} */
#endif
Index: php4/ext/standard/html.c
diff -u php4/ext/standard/html.c:1.37 php4/ext/standard/html.c:1.38
--- php4/ext/standard/html.c:1.37 Tue Sep 25 17:58:23 2001
+++ php4/ext/standard/html.c Fri Oct 26 17:07:59 2001
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: html.c,v 1.37 2001/09/25 21:58:23 jeroen Exp $ */
+/* $Id: html.c,v 1.38 2001/10/26 21:07:59 andrei Exp $ */
#include "php.h"
#include "reg.h"
@@ -387,7 +387,7 @@
/* {{{ 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 @@
*/
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 @@
}
/* }}} */
-/* {{{ 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);