CVS update: php3/functions
| From: | sas | Date: | Sat, 22 May 1999 22:34:56 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-5887@lists.php.net to get a copy of this message | ||
Date: Saturday May 22, 1999 @ 18:34
Author: sas
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv5521/functions
Modified Files:
basic_functions.c php3_string.h string.c
Added Files:
mhash.c php_mhash.h
Log Message:
- add bin2hex
- add mhash support
- some documentation updates
Index: php3/functions/basic_functions.c
diff -u php3/functions/basic_functions.c:1.262 php3/functions/basic_functions.c:1.263
--- php3/functions/basic_functions.c:1.262 Sun May 16 14:55:07 1999
+++ php3/functions/basic_functions.c Sat May 22 18:34:56 1999
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.262 1999/05/16 18:55:07 jim Exp $ */
+/* $Id: basic_functions.c,v 1.263 1999/05/22 22:34:56 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
@@ -268,6 +268,7 @@
{"decbin", php3_decbin, NULL},
{"decoct", php3_decoct, NULL},
{"dechex", php3_dechex, NULL},
+ PHP_FE(bin2hex, NULL)
{"base_convert",php3_base_convert, NULL},
{"number_format", php3_number_format, NULL},
Index: php3/functions/php3_string.h
diff -u php3/functions/php3_string.h:1.42 php3/functions/php3_string.h:1.43
--- php3/functions/php3_string.h:1.42 Thu Apr 22 09:19:50 1999
+++ php3/functions/php3_string.h Sat May 22 18:34:56 1999
@@ -29,7 +29,7 @@
*/
-/* $Id: php3_string.h,v 1.42 1999/04/22 13:19:50 ssb Exp $ */
+/* $Id: php3_string.h,v 1.43 1999/05/22 22:34:56 sas Exp $ */
#ifndef _PHPSTRING_H
#define _PHPSTRING_H
@@ -38,6 +38,7 @@
extern char *strtok_string;
#endif
+PHP_FUNCTION(bin2hex);
extern void php3_strlen(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_strcmp(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_strspn(INTERNAL_FUNCTION_PARAMETERS);
Index: php3/functions/string.c
diff -u php3/functions/string.c:1.191 php3/functions/string.c:1.192
--- php3/functions/string.c:1.191 Mon May 17 16:08:17 1999
+++ php3/functions/string.c Sat May 22 18:34:56 1999
@@ -30,7 +30,7 @@
*/
-/* $Id: string.c,v 1.191 1999/05/17 20:08:17 rasmus Exp $ */
+/* $Id: string.c,v 1.192 1999/05/22 22:34:56 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
@@ -43,6 +43,52 @@
#if HAVE_SETLOCALE
#include <locale.h>
#endif
+
+static char hexconvtab[] = "0123456789abcdef";
+
+static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t *newlen)
+{
+ unsigned char *new = NULL;
+ int i, j;
+
+ new = (char *) emalloc(oldlen * 2 * sizeof(char));
+ if(!new) {
+ return new;
+ }
+
+ for(i = j = 0; i < oldlen; i++) {
+ new[j++] = hexconvtab[old[i] >> 4];
+ new[j++] = hexconvtab[old[i] & 15];
+ }
+
+ if(newlen) *newlen = oldlen * 2 * sizeof(char);
+
+ return new;
+}
+
+/* proto bin2hex(string data)
+ converts the binary representation of data to hex */
+PHP_FUNCTION(bin2hex)
+{
+ pval *data;
+ char *new;
+ size_t newlen;
+
+ if(ARG_COUNT(ht) != 1 || getParameters(ht, 1, &data) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string(data);
+
+ new = php_bin2hex(data->value.str.val, data->value.str.len, &newlen);
+
+ if(!new) {
+ RETURN_FALSE;
+ }
+
+ RETURN_STRINGL(new, newlen, 0);
+}
+
/* {{{ proto int strlen(string str)
Get string length */
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net