Skip to content

Commit 77e5a7e

Browse files
committed
- fix a couple of warnings
- export php_hash_fetch_ops() and php_hash_register_ops()
1 parent a864148 commit 77e5a7e

5 files changed

Lines changed: 36 additions & 25 deletions

File tree

ext/hash/hash_haval.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,11 @@ static void PHP_5HAVALTransform(php_uint32 state[8], const unsigned char block[1
250250
/* }}} */
251251

252252
#define PHP_HASH_HAVAL_INIT(p,b) \
253-
php_hash_ops php_hash_##p##haval##b##_ops = { PHP_##p##HAVAL##b##Init, PHP_HAVALUpdate, PHP_HAVAL##b##Final, ((b) / 8), 128, sizeof(PHP_HAVAL_CTX) }; \
253+
php_hash_ops php_hash_##p##haval##b##_ops = { \
254+
(php_hash_init_func_t) PHP_##p##HAVAL##b##Init, \
255+
(php_hash_update_func_t) PHP_HAVALUpdate, \
256+
(php_hash_final_func_t) PHP_HAVAL##b##Final, \
257+
((b) / 8), 128, sizeof(PHP_HAVAL_CTX) }; \
254258
PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *context) \
255259
{ int i; context->count[0] = context->count[1] = 0; \
256260
for(i = 0; i < 8; i++) context->state[i] = D0[i]; \

ext/hash/hash_md.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
#include "php_hash_md.h"
2323

2424
php_hash_ops php_hash_md5_ops = {
25-
PHP_MD5Init,
26-
PHP_MD5Update,
27-
PHP_MD5Final,
25+
(php_hash_init_func_t) PHP_MD5Init,
26+
(php_hash_update_func_t) PHP_MD5Update,
27+
(php_hash_final_func_t) PHP_MD5Final,
2828
16,
2929
64,
3030
sizeof(PHP_MD5_CTX)

ext/hash/hash_ripemd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626
#include "php_hash_ripemd.h"
2727

2828
php_hash_ops php_hash_ripemd128_ops = {
29-
PHP_RIPEMD128Init,
30-
PHP_RIPEMD128Update,
31-
PHP_RIPEMD128Final,
29+
(php_hash_init_func_t) PHP_RIPEMD128Init,
30+
(php_hash_update_func_t) PHP_RIPEMD128Update,
31+
(php_hash_final_func_t) PHP_RIPEMD128Final,
3232
16,
3333
64,
3434
sizeof(PHP_RIPEMD128_CTX)
3535
};
3636

3737
php_hash_ops php_hash_ripemd160_ops = {
38-
PHP_RIPEMD160Init,
39-
PHP_RIPEMD160Update,
40-
PHP_RIPEMD160Final,
38+
(php_hash_init_func_t) PHP_RIPEMD160Init,
39+
(php_hash_update_func_t) PHP_RIPEMD160Update,
40+
(php_hash_final_func_t) PHP_RIPEMD160Final,
4141
20,
4242
64,
4343
sizeof(PHP_RIPEMD160_CTX)

ext/hash/hash_sha.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ static void SHADecode32(php_uint32 *output, const unsigned char *input, unsigned
7777
/* }}} */
7878

7979
php_hash_ops php_hash_sha1_ops = {
80-
PHP_SHA1Init,
81-
PHP_SHA1Update,
82-
PHP_SHA1Final,
80+
(php_hash_init_func_t) PHP_SHA1Init,
81+
(php_hash_update_func_t) PHP_SHA1Update,
82+
(php_hash_final_func_t) PHP_SHA1Final,
8383
20,
8484
64,
8585
sizeof(PHP_SHA1_CTX)
@@ -424,9 +424,9 @@ PHP_HASH_API void PHP_SHA1Final(unsigned char digest[20], PHP_SHA1_CTX * context
424424
/* sha256 */
425425

426426
php_hash_ops php_hash_sha256_ops = {
427-
PHP_SHA256Init,
428-
PHP_SHA256Update,
429-
PHP_SHA256Final,
427+
(php_hash_init_func_t) PHP_SHA256Init,
428+
(php_hash_update_func_t) PHP_SHA256Update,
429+
(php_hash_final_func_t) PHP_SHA256Final,
430430
32,
431431
64,
432432
sizeof(PHP_SHA256_CTX)
@@ -819,9 +819,9 @@ PHP_HASH_API void PHP_SHA384Final(unsigned char digest[48], PHP_SHA384_CTX * con
819819
/* }}} */
820820

821821
php_hash_ops php_hash_sha384_ops = {
822-
PHP_SHA384Init,
823-
PHP_SHA384Update,
824-
PHP_SHA384Final,
822+
(php_hash_init_func_t) PHP_SHA384Init,
823+
(php_hash_update_func_t) PHP_SHA384Update,
824+
(php_hash_final_func_t) PHP_SHA384Final,
825825
48,
826826
128,
827827
sizeof(PHP_SHA384_CTX)
@@ -932,9 +932,9 @@ PHP_HASH_API void PHP_SHA512Final(unsigned char digest[48], PHP_SHA512_CTX * con
932932
/* }}} */
933933

934934
php_hash_ops php_hash_sha512_ops = {
935-
PHP_SHA512Init,
936-
PHP_SHA512Update,
937-
PHP_SHA512Final,
935+
(php_hash_init_func_t) PHP_SHA512Init,
936+
(php_hash_update_func_t) PHP_SHA512Update,
937+
(php_hash_final_func_t) PHP_SHA512Final,
938938
64,
939939
128,
940940
sizeof(PHP_SHA512_CTX)

ext/hash/php_hash.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@
2929

3030
#define PHP_HASH_HMAC 0x0001
3131

32+
typedef int (*php_hash_init_func_t)(void *context);
33+
typedef int (*php_hash_update_func_t)(void *context, const unsigned char *buf, unsigned int count);
34+
typedef int (*php_hash_final_func_t)(unsigned char *digest, void *context);
35+
3236
typedef struct _php_hash_ops {
33-
int (*hash_init)(void *context);
34-
int (*hash_update)(void *context, const unsigned char *buf, unsigned int count);
35-
int (*hash_final)(unsigned char *digest, void *context);
37+
php_hash_init_func_t hash_init;
38+
php_hash_update_func_t hash_update;
39+
php_hash_final_func_t hash_final;
3640

3741
int digest_size;
3842
int block_size;
@@ -88,6 +92,9 @@ extern zend_module_entry hash_module_entry;
8892
#include "TSRM.h"
8993
#endif
9094

95+
PHP_HASH_API php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len);
96+
PHP_HASH_API void php_hash_register_algo(const char *algo, php_hash_ops *ops);
97+
9198
#endif /* PHP_HASH_H */
9299

93100

0 commit comments

Comments
 (0)