fix API of dynamic language helpers
it is easier to handle 'int' than 'long' in the foreign language
This commit is contained in:
parent
b3b93675f5
commit
7842e338bf
@ -51,10 +51,10 @@ int crypt_fsa(void *mp, ...);
|
|||||||
|
|
||||||
/* ---- Dynamic language support ---- */
|
/* ---- Dynamic language support ---- */
|
||||||
int crypt_get_constant(const char* namein, int *valueout);
|
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_get_size(const char* namein, unsigned int *sizeout);
|
||||||
int crypt_list_all_sizes(char *names_list, unsigned long *names_list_size);
|
int crypt_list_all_sizes(char *names_list, unsigned int *names_list_size);
|
||||||
|
|
||||||
#ifdef LTM_DESC
|
#ifdef LTM_DESC
|
||||||
void init_LTM(void);
|
void init_LTM(void);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
const long value;
|
const int value;
|
||||||
} crypt_constant;
|
} crypt_constant;
|
||||||
|
|
||||||
#define _C_STRINGIFY(s) { #s, s }
|
#define _C_STRINGIFY(s) { #s, s }
|
||||||
@ -179,9 +179,9 @@ int crypt_get_constant(const char* namein, int *valueout) {
|
|||||||
* written.
|
* written.
|
||||||
* a -1 return value signifies insufficient space made available
|
* 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;
|
int i;
|
||||||
unsigned long total_len = 0;
|
unsigned int total_len = 0;
|
||||||
char number[32];
|
char number[32];
|
||||||
int number_len;
|
int number_len;
|
||||||
int count = sizeof(_crypt_constants) / sizeof(_crypt_constants[0]);
|
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<count; i++) {
|
for (i=0; i<count; i++) {
|
||||||
total_len += strlen(_crypt_constants[i].name) + 1;
|
total_len += strlen(_crypt_constants[i].name) + 1;
|
||||||
/* the above +1 is for the commas */
|
/* the above +1 is for the commas */
|
||||||
number_len = snprintf(number, sizeof(number), "%ld", _crypt_constants[i].value);
|
number_len = snprintf(number, sizeof(number), "%d", _crypt_constants[i].value);
|
||||||
if ((number_len < 0) ||
|
if ((number_len < 0) ||
|
||||||
((unsigned int)number_len >= sizeof(number)))
|
((unsigned int)number_len >= sizeof(number)))
|
||||||
return -1;
|
return -1;
|
||||||
@ -212,7 +212,7 @@ int crypt_list_all_constants(char *names_list, unsigned long *names_list_size) {
|
|||||||
strcpy(ptr, ",");
|
strcpy(ptr, ",");
|
||||||
ptr += 1;
|
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);
|
strcpy(ptr, number);
|
||||||
ptr += number_len;
|
ptr += number_len;
|
||||||
strcpy(ptr, "\n");
|
strcpy(ptr, "\n");
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
const long size;
|
const unsigned int size;
|
||||||
} crypt_size;
|
} crypt_size;
|
||||||
|
|
||||||
#define _SZ_STRINGIFY_S(s) { #s, sizeof(struct s) }
|
#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
|
* sizeout will be the size (bytes) of the named struct or union
|
||||||
* return -1 if named item not found
|
* 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 i;
|
||||||
int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]);
|
int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]);
|
||||||
for (i=0; i<count; i++) {
|
for (i=0; i<count; i++) {
|
||||||
@ -259,9 +259,9 @@ int crypt_get_size(const char* namein, int *sizeout) {
|
|||||||
* written.
|
* written.
|
||||||
* a -1 return value signifies insufficient space made available
|
* a -1 return value signifies insufficient space made available
|
||||||
*/
|
*/
|
||||||
int crypt_list_all_sizes(char *names_list, unsigned long *names_list_size) {
|
int crypt_list_all_sizes(char *names_list, unsigned int *names_list_size) {
|
||||||
int i;
|
int i;
|
||||||
unsigned long total_len = 0;
|
unsigned int total_len = 0;
|
||||||
char number[32];
|
char number[32];
|
||||||
int number_len;
|
int number_len;
|
||||||
int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]);
|
int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]);
|
||||||
@ -270,7 +270,7 @@ int crypt_list_all_sizes(char *names_list, unsigned long *names_list_size) {
|
|||||||
for (i=0; i<count; i++) {
|
for (i=0; i<count; i++) {
|
||||||
total_len += strlen(_crypt_sizes[i].name) + 1;
|
total_len += strlen(_crypt_sizes[i].name) + 1;
|
||||||
/* the above +1 is for the commas */
|
/* the above +1 is for the commas */
|
||||||
number_len = snprintf(number, sizeof(number), "%ld", _crypt_sizes[i].size);
|
number_len = snprintf(number, sizeof(number), "%u", _crypt_sizes[i].size);
|
||||||
if ((number_len < 0) ||
|
if ((number_len < 0) ||
|
||||||
((unsigned int)number_len >= sizeof(number)))
|
((unsigned int)number_len >= sizeof(number)))
|
||||||
return -1;
|
return -1;
|
||||||
@ -292,7 +292,7 @@ int crypt_list_all_sizes(char *names_list, unsigned long *names_list_size) {
|
|||||||
strcpy(ptr, ",");
|
strcpy(ptr, ",");
|
||||||
ptr += 1;
|
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);
|
strcpy(ptr, number);
|
||||||
ptr += number_len;
|
ptr += number_len;
|
||||||
strcpy(ptr, "\n");
|
strcpy(ptr, "\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user