diff options
author | Jani Taskinen <jani@php.net> | 2007-11-05 12:44:52 +0000 |
---|---|---|
committer | Jani Taskinen <jani@php.net> | 2007-11-05 12:44:52 +0000 |
commit | 9e235c62ef5e728069abac77d0d36f145d1597c3 (patch) | |
tree | 24767d4bea700fca13cde59fb7e6b2e0a43eb683 | |
parent | 910972fc934c20af7b85d28d9fa5812de3cd92bc (diff) | |
download | php-git-9e235c62ef5e728069abac77d0d36f145d1597c3.tar.gz |
MFH
-rw-r--r-- | ext/standard/crypt.c | 53 | ||||
-rw-r--r-- | ext/standard/css.c | 5 | ||||
-rw-r--r-- | ext/standard/cyr_convert.c | 21 |
3 files changed, 36 insertions, 43 deletions
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c index a8e01d2d1e..618929e97c 100644 --- a/ext/standard/crypt.c +++ b/ext/standard/crypt.c @@ -16,8 +16,10 @@ | Zeev Suraski <zeev@zend.com> | | Rasmus Lerdorf <rasmus@php.net> | +----------------------------------------------------------------------+ - */ +*/ + /* $Id$ */ + #include <stdlib.h> #include "php.h" @@ -53,12 +55,11 @@ extern char *crypt(char *__key, char *__salt); #include "php_crypt.h" #include "php_rand.h" -/* - The capabilities of the crypt() function is determined by the test programs - run by configure from aclocal.m4. They will set PHP_STD_DES_CRYPT, - PHP_EXT_DES_CRYPT, PHP_MD5_CRYPT and PHP_BLOWFISH_CRYPT as appropriate - for the target platform -*/ +/* The capabilities of the crypt() function is determined by the test programs + * run by configure from aclocal.m4. They will set PHP_STD_DES_CRYPT, + * PHP_EXT_DES_CRYPT, PHP_MD5_CRYPT and PHP_BLOWFISH_CRYPT as appropriate + * for the target platform. */ + #if PHP_STD_DES_CRYPT #define PHP_MAX_SALT_LEN 2 #endif @@ -78,10 +79,8 @@ extern char *crypt(char *__key, char *__salt); #define PHP_MAX_SALT_LEN 60 #endif - /* - * If the configure-time checks fail, we provide DES. - * XXX: This is a hack. Fix the real problem - */ +/* If the configure-time checks fail, we provide DES. + * XXX: This is a hack. Fix the real problem! */ #ifndef PHP_MAX_SALT_LEN #define PHP_MAX_SALT_LEN 2 @@ -89,10 +88,9 @@ extern char *crypt(char *__key, char *__salt); #define PHP_STD_DES_CRYPT 1 #endif - #define PHP_CRYPT_RAND php_rand(TSRMLS_C) -PHP_MINIT_FUNCTION(crypt) +PHP_MINIT_FUNCTION(crypt) /* {{{ */ { REGISTER_LONG_CONSTANT("CRYPT_SALT_LENGTH", PHP_MAX_SALT_LEN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CRYPT_STD_DES", PHP_STD_DES_CRYPT, CONST_CS | CONST_PERSISTENT); @@ -102,33 +100,34 @@ PHP_MINIT_FUNCTION(crypt) return SUCCESS; } - +/* }}} */ static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; -static void php_to64(char *s, long v, int n) +static void php_to64(char *s, long v, int n) /* {{{ */ { while (--n >= 0) { - *s++ = itoa64[v&0x3f]; + *s++ = itoa64[v&0x3f]; v >>= 6; - } -} + } +} +/* }}} */ /* {{{ proto string crypt(string str [, string salt]) - Encrypt a string */ + Hash a string */ PHP_FUNCTION(crypt) { - char salt[PHP_MAX_SALT_LEN+1]; + char salt[PHP_MAX_SALT_LEN + 1]; char *str, *salt_in = NULL; int str_len, salt_in_len; - salt[0]=salt[PHP_MAX_SALT_LEN]='\0'; + 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); + * available (passing always 2-character salt). At least for glibc6.1 */ + memset(&salt[1], '$', PHP_MAX_SALT_LEN - 1); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, - &salt_in, &salt_in_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &salt_in, &salt_in_len) == FAILURE) { return; } @@ -137,7 +136,7 @@ PHP_FUNCTION(crypt) } /* The automatic salt generation only covers standard DES and md5-crypt */ - if(!*salt) { + if (!*salt) { #if PHP_MD5_CRYPT strcpy(salt, "$1$"); php_to64(&salt[3], PHP_CRYPT_RAND, 4); @@ -155,7 +154,7 @@ PHP_FUNCTION(crypt) memset(&buffer, 0, sizeof(buffer)); #elif defined(CRYPT_R_CRYPTD) CRYPTD buffer; -#else +#else #error Data struct used by crypt_r() is unknown. Please report. #endif diff --git a/ext/standard/css.c b/ext/standard/css.c index 603be3f303..680c3e103f 100644 --- a/ext/standard/css.c +++ b/ext/standard/css.c @@ -21,10 +21,7 @@ #include "php.h" #include "info.h" - -/* {{{ php_info_print_css - */ -PHPAPI void php_info_print_css(TSRMLS_D) +PHPAPI void php_info_print_css(TSRMLS_D) /* {{{ */ { PUTS("body {background-color: #ffffff; color: #000000;}\n"); PUTS("body, td, th, h1, h2 {font-family: sans-serif;}\n"); diff --git a/ext/standard/cyr_convert.c b/ext/standard/cyr_convert.c index f9095e97e1..62c15e00c2 100644 --- a/ext/standard/cyr_convert.c +++ b/ext/standard/cyr_convert.c @@ -187,7 +187,7 @@ _cyr_mac = { }; /* }}} */ -/* {{{ php_convert_cyr_string +/* {{{ static char * php_convert_cyr_string(unsigned char *str, int length, char from, char to TSRMLS_DC) * This is the function that performs real in-place conversion of the string * between charsets. * Parameters: @@ -271,20 +271,17 @@ static char * php_convert_cyr_string(unsigned char *str, int length, char from, Convert from one Cyrillic character set to another */ PHP_FUNCTION(convert_cyr_string) { - zval **str_arg, **fr_cs, **to_cs; + char *input, *fr_cs, *to_cs; + int input_len, fr_cs_len, to_cs_len; unsigned char *str; - if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3,&str_arg,&fr_cs, &to_cs)==FAILURE) - { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(str_arg); - convert_to_string_ex(fr_cs); - convert_to_string_ex(to_cs); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &input, &input_len, &fr_cs, &fr_cs_len, &to_cs, &to_cs_len) == FAILURE) { + return; + } - str = (unsigned char*) estrndup(Z_STRVAL_PP(str_arg), Z_STRLEN_PP(str_arg)); - - php_convert_cyr_string(str, Z_STRLEN_PP(str_arg), Z_STRVAL_PP(fr_cs)[0], Z_STRVAL_PP(to_cs)[0] TSRMLS_CC); + str = (unsigned char*) estrndup(input, input_len); + + php_convert_cyr_string(str, input_len, fr_cs[0], to_cs[0] TSRMLS_CC); RETVAL_STRING((char *)str, 0) } /* }}} */ |