-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sascha Schumann
committed
May 16, 1999
1 parent
4e08c66
commit db6ce2f
Showing
6 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# $Id$ | ||
|
||
INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend | ||
noinst_LIBRARIES=libphpext_mhash.a | ||
libphpext_mhash_a_SOURCES=mhash.c | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* define if you want to use the mhash extension */ | ||
#undef HAVE_LIBMHASH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
dnl $Id$ | ||
dnl config.m4 for extension mhash | ||
dnl don't forget to call PHP_EXTENSION(mhash) | ||
|
||
AC_MSG_CHECKING(for mhash support) | ||
AC_ARG_WITH(mhash, | ||
[ --with-mhash[=DIR] Include mhash support. DIR is the mhash | ||
install directory.], | ||
[ | ||
if test "$withval" != "no"; then | ||
for i in /usr/local /usr $withval; do | ||
if test -f $i/include/mhash.h; then | ||
MHASH_DIR=$i | ||
fi | ||
done | ||
if test "$MHASH_DIR" = ""; then | ||
AC_MSG_ERROR(Please reinstall libmhash - I cannot find mhash.h) | ||
fi | ||
INCLUDES="$INCLUDES -I$MHASH_DIR/include" | ||
EXTRA_LIBS="$EXTRA_LIBS -L$MHASH_DIR/lib -lmhash" | ||
AC_DEFINE(HAVE_LIBMHASH) | ||
AC_MSG_RESULT(yes) | ||
PHP_EXTENSION(mhash) | ||
else | ||
AC_MSG_RESULT(no) | ||
fi | ||
],[ | ||
AC_MSG_RESULT(no) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| PHP HTML Embedded Scripting Language Version 4.0 | | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) 1999 PHP Development Team (See Credits file) | | ||
+----------------------------------------------------------------------+ | ||
| This program is free software; you can redistribute it and/or modify | | ||
| it under the terms of one of the following licenses: | | ||
| | | ||
| A) the GNU General Public License as published by the Free Software | | ||
| Foundation; either version 2 of the License, or (at your option) | | ||
| any later version. | | ||
| | | ||
| B) the PHP License as published by the PHP Development Team and | | ||
| included in the distribution in the file: LICENSE | | ||
| | | ||
| This program is distributed in the hope that it will be useful, | | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | ||
| GNU General Public License for more details. | | ||
| | | ||
| You should have received a copy of both licenses referred to here. | | ||
| If you did not, or have any questions about PHP licensing, please | | ||
| contact core@php.net. | | ||
+----------------------------------------------------------------------+ | ||
| Authors: Sascha Schumann <sascha@schumann.2ns.de> | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
#include "php.h" | ||
|
||
#if HAVE_LIBMHASH | ||
|
||
#include "php_mhash.h" | ||
|
||
#include "mhash.h" | ||
|
||
function_entry mhash_functions[] = { | ||
PHP_FE(mhash_get_block_size, NULL) | ||
PHP_FE(mhash, NULL) | ||
{0}, | ||
}; | ||
|
||
static int php_minit_mhash(INIT_FUNC_ARGS); | ||
|
||
zend_module_entry mhash_module_entry = { | ||
"mhash", | ||
mhash_functions, | ||
php_minit_mhash, NULL, | ||
NULL, NULL, | ||
NULL, | ||
STANDARD_MODULE_PROPERTIES, | ||
}; | ||
|
||
#define MHASH_FAILED "mhash initialization failed" | ||
|
||
#define MHASH_ENTRY(a) REGISTER_LONG_CONSTANT("MHASH_" #a, a, 0) | ||
|
||
static int php_minit_mhash(INIT_FUNC_ARGS) | ||
{ | ||
/* hashes */ | ||
MHASH_ENTRY(CRC32); | ||
MHASH_ENTRY(MD5); | ||
MHASH_ENTRY(SHA1); | ||
|
||
return SUCCESS; | ||
} | ||
|
||
/* proto mhash_get_block_size(int hash) | ||
get the block size of hash */ | ||
PHP_FUNCTION(mhash_get_block_size) | ||
{ | ||
pval *hash; | ||
|
||
if(ARG_COUNT(ht) != 1 || getParameters(ht, 1, &hash) == FAILURE) { | ||
WRONG_PARAM_COUNT; | ||
} | ||
|
||
convert_to_long(hash); | ||
|
||
RETURN_LONG(mhash_get_block_size(hash->value.lval)); | ||
} | ||
|
||
/* proto mhash(int hash, string data) | ||
hash data with hash */ | ||
PHP_FUNCTION(mhash) | ||
{ | ||
pval *hash, *data; | ||
int td; | ||
int bsize; | ||
unsigned char *hash_data; | ||
int i; | ||
|
||
if(ARG_COUNT(ht) != 2 || getParameters(ht, 2, &hash, &data) == FAILURE) { | ||
WRONG_PARAM_COUNT; | ||
} | ||
|
||
convert_to_long(hash); | ||
convert_to_string(data); | ||
|
||
bsize = mhash_get_block_size(hash->value.lval); | ||
td = init_mhash(hash->value.lval); | ||
if(td == -1) { | ||
php3_error(E_WARNING, MHASH_FAILED); | ||
RETURN_FALSE; | ||
} | ||
|
||
mhash(td, data->value.str.val, data->value.str.len); | ||
|
||
hash_data = (char *) end_mhash(td); | ||
|
||
RETVAL_STRINGL(hash_data, bsize, 1); | ||
|
||
free(hash_data); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef PHP_MHASH_H | ||
#define PHP_MHASH_H | ||
|
||
#if HAVE_LIBMHASH | ||
|
||
#if PHP_API_VERSION < 19990421 | ||
#define zend_module_entry php3_module_entry | ||
#include "modules.h" | ||
#include "internal_functions.h" | ||
#endif | ||
|
||
extern zend_module_entry mhash_module_entry; | ||
#define mhash_module_ptr &mhash_module_entry | ||
|
||
PHP_FUNCTION(mhash_get_block_size); | ||
PHP_FUNCTION(mhash); | ||
|
||
#else | ||
#define mhash_module_ptr NULL | ||
#endif | ||
|
||
#define phpext_mhash_ptr mhash_module_ptr | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# $Source$ | ||
# $Id$ | ||
|
||
define_option with-mhash 'mhash support?' yesnodir no \ | ||
' Whether to build the mhash extension.' | ||
|