From 7842e338bfa6a13ac6affd3e7b33a84e2a3267d1 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Mon, 29 Sep 2014 23:30:02 +0200 Subject: [PATCH] fix API of dynamic language helpers it is easier to handle 'int' than 'long' in the foreign language --- src/headers/tomcrypt_misc.h | 6 +++--- src/misc/crypt/crypt_constants.c | 10 +++++----- src/misc/crypt/crypt_sizes.c | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/headers/tomcrypt_misc.h b/src/headers/tomcrypt_misc.h index 503447c..ad23c39 100644 --- a/src/headers/tomcrypt_misc.h +++ b/src/headers/tomcrypt_misc.h @@ -51,10 +51,10 @@ int crypt_fsa(void *mp, ...); /* ---- Dynamic language support ---- */ int crypt_get_constant(const char* namein, int *valueout); -int crypt_list_all_constants(char *names_list, unsigned long *names_list_size); +int crypt_list_all_constants(char *names_list, unsigned int *names_list_size); -int crypt_get_size(const char* namein, int *sizeout); -int crypt_list_all_sizes(char *names_list, unsigned long *names_list_size); +int crypt_get_size(const char* namein, unsigned int *sizeout); +int crypt_list_all_sizes(char *names_list, unsigned int *names_list_size); #ifdef LTM_DESC void init_LTM(void); diff --git a/src/misc/crypt/crypt_constants.c b/src/misc/crypt/crypt_constants.c index b0af4dd..03755b0 100755 --- a/src/misc/crypt/crypt_constants.c +++ b/src/misc/crypt/crypt_constants.c @@ -22,7 +22,7 @@ typedef struct { const char *name; - const long value; + const int value; } crypt_constant; #define _C_STRINGIFY(s) { #s, s } @@ -179,9 +179,9 @@ int crypt_get_constant(const char* namein, int *valueout) { * written. * a -1 return value signifies insufficient space made available */ -int crypt_list_all_constants(char *names_list, unsigned long *names_list_size) { +int crypt_list_all_constants(char *names_list, unsigned int *names_list_size) { int i; - unsigned long total_len = 0; + unsigned int total_len = 0; char number[32]; int number_len; int count = sizeof(_crypt_constants) / sizeof(_crypt_constants[0]); @@ -190,7 +190,7 @@ int crypt_list_all_constants(char *names_list, unsigned long *names_list_size) { for (i=0; i= sizeof(number))) return -1; @@ -212,7 +212,7 @@ int crypt_list_all_constants(char *names_list, unsigned long *names_list_size) { strcpy(ptr, ","); ptr += 1; - number_len = snprintf(number, sizeof(number), "%ld", _crypt_constants[i].value); + number_len = snprintf(number, sizeof(number), "%d", _crypt_constants[i].value); strcpy(ptr, number); ptr += number_len; strcpy(ptr, "\n"); diff --git a/src/misc/crypt/crypt_sizes.c b/src/misc/crypt/crypt_sizes.c index c758dbe..1870130 100755 --- a/src/misc/crypt/crypt_sizes.c +++ b/src/misc/crypt/crypt_sizes.c @@ -22,7 +22,7 @@ typedef struct { const char *name; - const long size; + const unsigned int size; } crypt_size; #define _SZ_STRINGIFY_S(s) { #s, sizeof(struct s) } @@ -237,7 +237,7 @@ static const crypt_size _crypt_sizes[] = { * sizeout will be the size (bytes) of the named struct or union * return -1 if named item not found */ -int crypt_get_size(const char* namein, int *sizeout) { +int crypt_get_size(const char* namein, unsigned int *sizeout) { int i; int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]); for (i=0; i= sizeof(number))) return -1; @@ -292,7 +292,7 @@ int crypt_list_all_sizes(char *names_list, unsigned long *names_list_size) { strcpy(ptr, ","); ptr += 1; - number_len = snprintf(number, sizeof(number), "%ld", _crypt_sizes[i].size); + number_len = snprintf(number, sizeof(number), "%u", _crypt_sizes[i].size); strcpy(ptr, number); ptr += number_len; strcpy(ptr, "\n");