more like:
Code:
int main( int argc, char **argv )
{
char *strEncryptedKey;
char **ppHashElements;
char *strHashValue;
int rc = 0;
if ( argc < 3 )
{
fprintf( stderr, "Usage: TestHash encryptedKey hashElement...\n" );
return 1;
}
strEncryptedKey = argv[ 1 ];
ppHashElements = &argv[ 2 ];
strHashValue = GenerateHash( ppHashElements, strEncryptedKey );
That works perfectly...
And here what I'm tryin to do:
Code:
PHP_FUNCTION(hsbc_cpi_make_hash)
{
char *strEncryptedKey;
int strEncryptedKey_len;
zval *arr, **data;
HashTable *arr_hash;
HashPosition pointer;
char *ppHashElements;
char *strHashValue;
int rc=0;
int array_count;
int count = 0;
int bcount = 0;
if ( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "as", &arr, &strEncryptedKey, &strEncryptedKey_len) == FAILURE ) {
RETURN_NULL();
}
arr_hash = Z_ARRVAL_P(arr);
array_count = zend_hash_num_elements(arr_hash);
ppHashElements = malloc(2048);
if(!ppHashElements){
RETURN_NULL();
}
memset(ppHashElements, 0, 2048);
for(zend_hash_internal_pointer_reset_ex(arr_hash, &pointer);
zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS;
zend_hash_move_forward_ex(arr_hash, &pointer)){
count++;
zval temp;
temp = **data;
zval_copy_ctor(&temp);
convert_to_string(&temp);
strcat(ppHashElements, Z_STRVAL(temp));
if(count < array_count){
strcat(ppHashElements, ", ");
}
zval_dtor(&temp);
}
strHashValue = GenerateHash(&ppHashElements, strEncryptedKey );
php_printf("%s\n", strEncryptedKey);
php_printf("%s\n", strHashValue);
php_printf("%s\n", ppHashElements);
free(ppHashElements);
if(!strHashValue){
RETURN_FALSE;
}
RETURN_STRING(strHashValue, 1);
}