Constification of the data of a hash table. This means the callback

functions need to be constified, and therefore meant a number of easy
changes a little everywhere.

Now, if someone could explain to me why OBJ_dup() cheats...
This commit is contained in:
Richard Levitte
2000-12-13 17:15:03 +00:00
parent 53b407da84
commit 8d28d5f81b
13 changed files with 92 additions and 87 deletions

View File

@@ -79,9 +79,9 @@
* functions. */ * functions. */
/* static unsigned long MS_CALLBACK hash(FUNCTION *a); */ /* static unsigned long MS_CALLBACK hash(FUNCTION *a); */
static unsigned long MS_CALLBACK hash(void *a_void); static unsigned long MS_CALLBACK hash(const void *a_void);
/* static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b); */ /* static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b); */
static int MS_CALLBACK cmp(void *a_void,void *b_void); static int MS_CALLBACK cmp(const void *a_void,const void *b_void);
static LHASH *prog_init(void ); static LHASH *prog_init(void );
static int do_cmd(LHASH *prog,int argc,char *argv[]); static int do_cmd(LHASH *prog,int argc,char *argv[]);
LHASH *config=NULL; LHASH *config=NULL;
@@ -367,14 +367,14 @@ static LHASH *prog_init(void)
} }
/* static int MS_CALLBACK cmp(FUNCTION *a, FUNCTION *b) */ /* static int MS_CALLBACK cmp(FUNCTION *a, FUNCTION *b) */
static int MS_CALLBACK cmp(void *a_void, void *b_void) static int MS_CALLBACK cmp(const void *a_void, const void *b_void)
{ {
return(strncmp(((FUNCTION *)a_void)->name, return(strncmp(((FUNCTION *)a_void)->name,
((FUNCTION *)b_void)->name,8)); ((FUNCTION *)b_void)->name,8));
} }
/* static unsigned long MS_CALLBACK hash(FUNCTION *a) */ /* static unsigned long MS_CALLBACK hash(FUNCTION *a) */
static unsigned long MS_CALLBACK hash(void *a_void) static unsigned long MS_CALLBACK hash(const void *a_void)
{ {
return(lh_strhash(((FUNCTION *)a_void)->name)); return(lh_strhash(((FUNCTION *)a_void)->name));
} }

View File

@@ -302,7 +302,7 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
} }
ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
char *sn, char *ln) const char *sn, const char *ln)
{ {
ASN1_OBJECT o; ASN1_OBJECT o;

View File

@@ -758,7 +758,7 @@ int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a);
int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num); int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num);
ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len, ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len,
char *sn, char *ln); const char *sn, const char *ln);
int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
long ASN1_INTEGER_get(ASN1_INTEGER *a); long ASN1_INTEGER_get(ASN1_INTEGER *a);

View File

@@ -73,9 +73,9 @@ static void value_free_stack(CONF_VALUE *a,LHASH *conf);
/* We don't use function pointer casting or wrapper functions - but cast each /* We don't use function pointer casting or wrapper functions - but cast each
* callback parameter inside the callback functions. */ * callback parameter inside the callback functions. */
/* static unsigned long hash(CONF_VALUE *v); */ /* static unsigned long hash(CONF_VALUE *v); */
static unsigned long hash(void *v_void); static unsigned long hash(const void *v_void);
/* static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); */ /* static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); */
static int cmp_conf(void *a_void,void *b_void); static int cmp_conf(const void *a_void,const void *b_void);
/* Up until OpenSSL 0.9.5a, this was get_section */ /* Up until OpenSSL 0.9.5a, this was get_section */
CONF_VALUE *_CONF_get_section(CONF *conf, char *section) CONF_VALUE *_CONF_get_section(CONF *conf, char *section)
@@ -239,14 +239,14 @@ static void value_free_stack(CONF_VALUE *a, LHASH *conf)
} }
/* static unsigned long hash(CONF_VALUE *v) */ /* static unsigned long hash(CONF_VALUE *v) */
static unsigned long hash(void *v_void) static unsigned long hash(const void *v_void)
{ {
CONF_VALUE *v = (CONF_VALUE *)v_void; CONF_VALUE *v = (CONF_VALUE *)v_void;
return((lh_strhash(v->section)<<2)^lh_strhash(v->name)); return((lh_strhash(v->section)<<2)^lh_strhash(v->name));
} }
/* static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) */ /* static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) */
static int cmp_conf(void *a_void, void *b_void) static int cmp_conf(const void *a_void,const void *b_void)
{ {
int i; int i;
CONF_VALUE *a = (CONF_VALUE *)a_void; CONF_VALUE *a = (CONF_VALUE *)a_void;

View File

@@ -124,13 +124,13 @@ static LHASH *error_hash=NULL;
static LHASH *thread_hash=NULL; static LHASH *thread_hash=NULL;
/* static unsigned long err_hash(ERR_STRING_DATA *a); */ /* static unsigned long err_hash(ERR_STRING_DATA *a); */
static unsigned long err_hash(void *a_void); static unsigned long err_hash(const void *a_void);
/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); */ /* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); */
static int err_cmp(void *a_void, void *b_void); static int err_cmp(const void *a_void, const void *b_void);
/* static unsigned long pid_hash(ERR_STATE *pid); */ /* static unsigned long pid_hash(ERR_STATE *pid); */
static unsigned long pid_hash(void *pid_void); static unsigned long pid_hash(const void *pid_void);
/* static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); */ /* static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); */
static int pid_cmp(void *a_void,void *pid_void); static int pid_cmp(const void *a_void,const void *pid_void);
static unsigned long get_error_values(int inc,const char **file,int *line, static unsigned long get_error_values(int inc,const char **file,int *line,
const char **data,int *flags); const char **data,int *flags);
@@ -626,7 +626,7 @@ const char *ERR_reason_error_string(unsigned long e)
} }
/* static unsigned long err_hash(ERR_STRING_DATA *a) */ /* static unsigned long err_hash(ERR_STRING_DATA *a) */
static unsigned long err_hash(void *a_void) static unsigned long err_hash(const void *a_void)
{ {
unsigned long ret,l; unsigned long ret,l;
@@ -636,20 +636,20 @@ static unsigned long err_hash(void *a_void)
} }
/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) */ /* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) */
static int err_cmp(void *a_void, void *b_void) static int err_cmp(const void *a_void, const void *b_void)
{ {
return((int)(((ERR_STRING_DATA *)a_void)->error - return((int)(((ERR_STRING_DATA *)a_void)->error -
((ERR_STRING_DATA *)b_void)->error)); ((ERR_STRING_DATA *)b_void)->error));
} }
/* static unsigned long pid_hash(ERR_STATE *a) */ /* static unsigned long pid_hash(ERR_STATE *a) */
static unsigned long pid_hash(void *a_void) static unsigned long pid_hash(const void *a_void)
{ {
return(((ERR_STATE *)a_void)->pid*13); return(((ERR_STATE *)a_void)->pid*13);
} }
/* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */ /* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */
static int pid_cmp(void *a_void, void *b_void) static int pid_cmp(const void *a_void, const void *b_void)
{ {
return((int)((long)((ERR_STATE *)a_void)->pid - return((int)((long)((ERR_STATE *)a_void)->pid -
(long)((ERR_STATE *)b_void)->pid)); (long)((ERR_STATE *)b_void)->pid));

View File

@@ -109,7 +109,7 @@ const char *lh_version="lhash" OPENSSL_VERSION_PTEXT;
static void expand(LHASH *lh); static void expand(LHASH *lh);
static void contract(LHASH *lh); static void contract(LHASH *lh);
static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash); static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash);
LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c) LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c)
{ {
@@ -176,11 +176,11 @@ void lh_free(LHASH *lh)
OPENSSL_free(lh); OPENSSL_free(lh);
} }
void *lh_insert(LHASH *lh, void *data) void *lh_insert(LHASH *lh, const void *data)
{ {
unsigned long hash; unsigned long hash;
LHASH_NODE *nn,**rn; LHASH_NODE *nn,**rn;
void *ret; const void *ret;
lh->error=0; lh->error=0;
if (lh->up_load <= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)) if (lh->up_load <= (lh->num_items*LH_LOAD_MULT/lh->num_nodes))
@@ -211,14 +211,14 @@ void *lh_insert(LHASH *lh, void *data)
(*rn)->data=data; (*rn)->data=data;
lh->num_replace++; lh->num_replace++;
} }
return(ret); return((void *)ret);
} }
void *lh_delete(LHASH *lh, void *data) void *lh_delete(LHASH *lh, const void *data)
{ {
unsigned long hash; unsigned long hash;
LHASH_NODE *nn,**rn; LHASH_NODE *nn,**rn;
void *ret; const void *ret;
lh->error=0; lh->error=0;
rn=getrn(lh,data,&hash); rn=getrn(lh,data,&hash);
@@ -242,14 +242,14 @@ void *lh_delete(LHASH *lh, void *data)
(lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes))) (lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)))
contract(lh); contract(lh);
return(ret); return((void *)ret);
} }
void *lh_retrieve(LHASH *lh, void *data) void *lh_retrieve(LHASH *lh, const void *data)
{ {
unsigned long hash; unsigned long hash;
LHASH_NODE **rn; LHASH_NODE **rn;
void *ret; const void *ret;
lh->error=0; lh->error=0;
rn=getrn(lh,data,&hash); rn=getrn(lh,data,&hash);
@@ -264,7 +264,7 @@ void *lh_retrieve(LHASH *lh, void *data)
ret= (*rn)->data; ret= (*rn)->data;
lh->num_retrieve++; lh->num_retrieve++;
} }
return(ret); return((void *)ret);
} }
void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func) void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func)
@@ -279,7 +279,7 @@ void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func)
lh_doall_arg(lh, (LHASH_DOALL_ARG_FN_TYPE)func, NULL); lh_doall_arg(lh, (LHASH_DOALL_ARG_FN_TYPE)func, NULL);
} }
void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg) void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, const void *arg)
{ {
int i; int i;
LHASH_NODE *a,*n; LHASH_NODE *a,*n;
@@ -395,7 +395,7 @@ static void contract(LHASH *lh)
} }
} }
static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash) static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash)
{ {
LHASH_NODE **ret,*n1; LHASH_NODE **ret,*n1;
unsigned long hash,nn; unsigned long hash,nn;

View File

@@ -77,17 +77,17 @@ extern "C" {
typedef struct lhash_node_st typedef struct lhash_node_st
{ {
void *data; const void *data;
struct lhash_node_st *next; struct lhash_node_st *next;
#ifndef NO_HASH_COMP #ifndef NO_HASH_COMP
unsigned long hash; unsigned long hash;
#endif #endif
} LHASH_NODE; } LHASH_NODE;
typedef int (*LHASH_COMP_FN_TYPE)(void *, void *); typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
typedef unsigned long (*LHASH_HASH_FN_TYPE)(void *); typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
typedef void (*LHASH_DOALL_FN_TYPE)(void *); typedef void (*LHASH_DOALL_FN_TYPE)(const void *);
typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *); typedef void (*LHASH_DOALL_ARG_FN_TYPE)(const void *, const void *);
/* Macros for declaring and implementing type-safe wrappers for LHASH callbacks. /* Macros for declaring and implementing type-safe wrappers for LHASH callbacks.
* This way, callbacks can be provided to LHASH structures without function * This way, callbacks can be provided to LHASH structures without function
@@ -98,18 +98,18 @@ typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *);
/* First: "hash" functions */ /* First: "hash" functions */
#define DECLARE_LHASH_HASH_FN(f_name,o_type) \ #define DECLARE_LHASH_HASH_FN(f_name,o_type) \
unsigned long f_name##_LHASH_HASH(void *); unsigned long f_name##_LHASH_HASH(const void *);
#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \ #define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \
unsigned long f_name##_LHASH_HASH(void *arg) { \ unsigned long f_name##_LHASH_HASH(const void *arg) { \
o_type a = (o_type)arg; \ o_type a = (o_type)arg; \
return f_name(a); } return f_name(a); }
#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH #define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH
/* Second: "compare" functions */ /* Second: "compare" functions */
#define DECLARE_LHASH_COMP_FN(f_name,o_type) \ #define DECLARE_LHASH_COMP_FN(f_name,o_type) \
int f_name##_LHASH_COMP(void *, void *); int f_name##_LHASH_COMP(const void *, const void *);
#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \ #define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \
int f_name##_LHASH_COMP(void *arg1, void *arg2) { \ int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \
o_type a = (o_type)arg1; \ o_type a = (o_type)arg1; \
o_type b = (o_type)arg2; \ o_type b = (o_type)arg2; \
return f_name(a,b); } return f_name(a,b); }
@@ -153,11 +153,11 @@ typedef struct lhash_st
LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
void lh_free(LHASH *lh); void lh_free(LHASH *lh);
void *lh_insert(LHASH *lh, void *data); void *lh_insert(LHASH *lh, const void *data);
void *lh_delete(LHASH *lh, void *data); void *lh_delete(LHASH *lh, const void *data);
void *lh_retrieve(LHASH *lh, void *data); void *lh_retrieve(LHASH *lh, const void *data);
void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func);
void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg); void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, const void *arg);
unsigned long lh_strhash(const char *c); unsigned long lh_strhash(const char *c);
unsigned long lh_num_items(const LHASH *lh); unsigned long lh_num_items(const LHASH *lh);

View File

@@ -181,8 +181,8 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line)
malloc_debug_func(NULL, num, file, line, 0); malloc_debug_func(NULL, num, file, line, 0);
} }
ret = malloc_locked_func(num); ret = malloc_locked_func(num);
#ifdef LEVITTE_DEBUG #ifdef LEVITTE_DEBUG_MEM
fprintf(stderr, "LEVITTE_DEBUG: > 0x%p (%d)\n", ret, num); fprintf(stderr, "LEVITTE_DEBUG_MEM: > 0x%p (%d)\n", ret, num);
#endif #endif
if (malloc_debug_func != NULL) if (malloc_debug_func != NULL)
malloc_debug_func(ret, num, file, line, 1); malloc_debug_func(ret, num, file, line, 1);
@@ -194,8 +194,8 @@ void CRYPTO_free_locked(void *str)
{ {
if (free_debug_func != NULL) if (free_debug_func != NULL)
free_debug_func(str, 0); free_debug_func(str, 0);
#ifdef LEVITTE_DEBUG #ifdef LEVITTE_DEBUG_MEM
fprintf(stderr, "LEVITTE_DEBUG: < 0x%p\n", str); fprintf(stderr, "LEVITTE_DEBUG_MEM: < 0x%p\n", str);
#endif #endif
free_locked_func(str); free_locked_func(str);
if (free_debug_func != NULL) if (free_debug_func != NULL)
@@ -213,8 +213,8 @@ void *CRYPTO_malloc(int num, const char *file, int line)
malloc_debug_func(NULL, num, file, line, 0); malloc_debug_func(NULL, num, file, line, 0);
} }
ret = malloc_func(num); ret = malloc_func(num);
#ifdef LEVITTE_DEBUG #ifdef LEVITTE_DEBUG_MEM
fprintf(stderr, "LEVITTE_DEBUG: > 0x%p (%d)\n", ret, num); fprintf(stderr, "LEVITTE_DEBUG_MEM: > 0x%p (%d)\n", ret, num);
#endif #endif
if (malloc_debug_func != NULL) if (malloc_debug_func != NULL)
malloc_debug_func(ret, num, file, line, 1); malloc_debug_func(ret, num, file, line, 1);
@@ -229,8 +229,8 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
if (realloc_debug_func != NULL) if (realloc_debug_func != NULL)
realloc_debug_func(str, NULL, num, file, line, 0); realloc_debug_func(str, NULL, num, file, line, 0);
ret = realloc_func(str,num); ret = realloc_func(str,num);
#ifdef LEVITTE_DEBUG #ifdef LEVITTE_DEBUG_MEM
fprintf(stderr, "LEVITTE_DEBUG: | 0x%p -> 0x%p (%d)\n", str, ret, num); fprintf(stderr, "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", str, ret, num);
#endif #endif
if (realloc_debug_func != NULL) if (realloc_debug_func != NULL)
realloc_debug_func(str, ret, num, file, line, 1); realloc_debug_func(str, ret, num, file, line, 1);
@@ -242,8 +242,8 @@ void CRYPTO_free(void *str)
{ {
if (free_debug_func != NULL) if (free_debug_func != NULL)
free_debug_func(str, 0); free_debug_func(str, 0);
#ifdef LEVITTE_DEBUG #ifdef LEVITTE_DEBUG_MEM
fprintf(stderr, "LEVITTE_DEBUG: < 0x%p\n", str); fprintf(stderr, "LEVITTE_DEBUG_MEM: < 0x%p\n", str);
#endif #endif
free_func(str); free_func(str);
if (free_debug_func != NULL) if (free_debug_func != NULL)

View File

@@ -220,34 +220,36 @@ long CRYPTO_dbg_get_options(void)
} }
/* static int mem_cmp(MEM *a, MEM *b) */ /* static int mem_cmp(MEM *a, MEM *b) */
static int mem_cmp(void *a_void, void *b_void) static int mem_cmp(const void *a_void, const void *b_void)
{ {
return((char *)((MEM *)a_void)->addr - (char *)((MEM *)b_void)->addr); return((const char *)((MEM *)a_void)->addr
- (const char *)((MEM *)b_void)->addr);
} }
/* static unsigned long mem_hash(MEM *a) */ /* static unsigned long mem_hash(MEM *a) */
static unsigned long mem_hash(void *a_void) static unsigned long mem_hash(const void *a_void)
{ {
unsigned long ret; unsigned long ret;
ret=(unsigned long)((MEM *)a_void)->addr; ret=(unsigned long)((const MEM *)a_void)->addr;
ret=ret*17851+(ret>>14)*7+(ret>>4)*251; ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
return(ret); return(ret);
} }
/* static int app_info_cmp(APP_INFO *a, APP_INFO *b) */ /* static int app_info_cmp(APP_INFO *a, APP_INFO *b) */
static int app_info_cmp(void *a_void, void *b_void) static int app_info_cmp(const void *a_void, const void *b_void)
{ {
return(((APP_INFO *)a_void)->thread != ((APP_INFO *)b_void)->thread); return(((const APP_INFO *)a_void)->thread
!= ((const APP_INFO *)b_void)->thread);
} }
/* static unsigned long app_info_hash(APP_INFO *a) */ /* static unsigned long app_info_hash(APP_INFO *a) */
static unsigned long app_info_hash(void *a_void) static unsigned long app_info_hash(const void *a_void)
{ {
unsigned long ret; unsigned long ret;
ret=(unsigned long)((APP_INFO *)a_void)->thread; ret=(unsigned long)((const APP_INFO *)a_void)->thread;
ret=ret*17851+(ret>>14)*7+(ret>>4)*251; ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
return(ret); return(ret);

View File

@@ -29,9 +29,9 @@ static STACK_OF(NAME_FUNCS) *name_funcs_stack;
* need for macro-generated wrapper functions. */ * need for macro-generated wrapper functions. */
/* static unsigned long obj_name_hash(OBJ_NAME *a); */ /* static unsigned long obj_name_hash(OBJ_NAME *a); */
static unsigned long obj_name_hash(void *a_void); static unsigned long obj_name_hash(const void *a_void);
/* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */ /* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */
static int obj_name_cmp(void *a_void,void *b_void); static int obj_name_cmp(const void *a_void,const void *b_void);
int OBJ_NAME_init(void) int OBJ_NAME_init(void)
{ {
@@ -88,7 +88,7 @@ int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
} }
/* static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) */ /* static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) */
static int obj_name_cmp(void *a_void, void *b_void) static int obj_name_cmp(const void *a_void, const void *b_void)
{ {
int ret; int ret;
OBJ_NAME *a = (OBJ_NAME *)a_void; OBJ_NAME *a = (OBJ_NAME *)a_void;
@@ -110,7 +110,7 @@ static int obj_name_cmp(void *a_void, void *b_void)
} }
/* static unsigned long obj_name_hash(OBJ_NAME *a) */ /* static unsigned long obj_name_hash(OBJ_NAME *a) */
static unsigned long obj_name_hash(void *a_void) static unsigned long obj_name_hash(const void *a_void)
{ {
unsigned long ret; unsigned long ret;
OBJ_NAME *a = (OBJ_NAME *)a_void; OBJ_NAME *a = (OBJ_NAME *)a_void;

View File

@@ -109,9 +109,9 @@ static int ln_cmp(const void *a, const void *b)
} }
/* static unsigned long add_hash(ADDED_OBJ *ca) */ /* static unsigned long add_hash(ADDED_OBJ *ca) */
static unsigned long add_hash(void *ca_void) static unsigned long add_hash(const void *ca_void)
{ {
ASN1_OBJECT *a; const ASN1_OBJECT *a;
int i; int i;
unsigned long ret=0; unsigned long ret=0;
unsigned char *p; unsigned char *p;
@@ -145,7 +145,7 @@ static unsigned long add_hash(void *ca_void)
} }
/* static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) */ /* static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) */
static int add_cmp(void *ca_void, void *cb_void) static int add_cmp(const void *ca_void, const void *cb_void)
{ {
ASN1_OBJECT *a,*b; ASN1_OBJECT *a,*b;
int i; int i;
@@ -224,7 +224,7 @@ int OBJ_new_nid(int num)
return(i); return(i);
} }
int OBJ_add_object(ASN1_OBJECT *obj) int OBJ_add_object(const ASN1_OBJECT *obj)
{ {
ASN1_OBJECT *o; ASN1_OBJECT *o;
ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop; ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop;
@@ -360,7 +360,7 @@ const char *OBJ_nid2ln(int n)
} }
} }
int OBJ_obj2nid(ASN1_OBJECT *a) int OBJ_obj2nid(const ASN1_OBJECT *a)
{ {
ASN1_OBJECT **op; ASN1_OBJECT **op;
ADDED_OBJ ad,*adp; ADDED_OBJ ad,*adp;
@@ -373,7 +373,7 @@ int OBJ_obj2nid(ASN1_OBJECT *a)
if (added != NULL) if (added != NULL)
{ {
ad.type=ADDED_DATA; ad.type=ADDED_DATA;
ad.obj=a; ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
adp=(ADDED_OBJ *)lh_retrieve(added,&ad); adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
if (adp != NULL) return (adp->obj->nid); if (adp != NULL) return (adp->obj->nid);
} }
@@ -427,7 +427,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
return op; return op;
} }
int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name) int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
{ {
int i,idx=0,n=0,len,nid; int i,idx=0,n=0,len,nid;
unsigned long l; unsigned long l;
@@ -493,7 +493,7 @@ int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name)
return(n); return(n);
} }
int OBJ_txt2nid(char *s) int OBJ_txt2nid(const char *s)
{ {
ASN1_OBJECT *obj; ASN1_OBJECT *obj;
int nid; int nid;
@@ -552,10 +552,11 @@ static int obj_cmp(const void *ap, const void *bp)
return(memcmp(a->data,b->data,a->length)); return(memcmp(a->data,b->data,a->length));
} }
char *OBJ_bsearch(char *key, char *base, int num, int size, int (*cmp)(const void *, const void *)) const char *OBJ_bsearch(const char *key, const char *base, int num, int size,
int (*cmp)(const void *, const void *))
{ {
int l,h,i,c; int l,h,i,c;
char *p; const char *p;
if (num == 0) return(NULL); if (num == 0) return(NULL);
l=0; l=0;
@@ -634,7 +635,7 @@ int OBJ_create_objects(BIO *in)
/* return(num); */ /* return(num); */
} }
int OBJ_create(char *oid, char *sn, char *ln) int OBJ_create(const char *oid, const char *sn, const char *ln)
{ {
int ok=0; int ok=0;
ASN1_OBJECT *op=NULL; ASN1_OBJECT *op=NULL;

View File

@@ -62,7 +62,7 @@
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/buffer.h> #include <openssl/buffer.h>
ASN1_OBJECT *OBJ_dup(ASN1_OBJECT *o) ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o)
{ {
ASN1_OBJECT *r; ASN1_OBJECT *r;
int i; int i;
@@ -70,7 +70,8 @@ ASN1_OBJECT *OBJ_dup(ASN1_OBJECT *o)
if (o == NULL) return(NULL); if (o == NULL) return(NULL);
if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC)) if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC))
return(o); return((ASN1_OBJECT *)o); /* XXX: ugh! Why? What kind of
duplication is this??? */
r=ASN1_OBJECT_new(); r=ASN1_OBJECT_new();
if (r == NULL) if (r == NULL)
@@ -116,7 +117,7 @@ err:
return(NULL); return(NULL);
} }
int OBJ_cmp(ASN1_OBJECT *a, ASN1_OBJECT *b) int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b)
{ {
int ret; int ret;

View File

@@ -997,24 +997,25 @@ void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),
void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg), void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
void *arg); void *arg);
ASN1_OBJECT * OBJ_dup(ASN1_OBJECT *o); ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
ASN1_OBJECT * OBJ_nid2obj(int n); ASN1_OBJECT * OBJ_nid2obj(int n);
const char * OBJ_nid2ln(int n); const char * OBJ_nid2ln(int n);
const char * OBJ_nid2sn(int n); const char * OBJ_nid2sn(int n);
int OBJ_obj2nid(ASN1_OBJECT *o); int OBJ_obj2nid(const ASN1_OBJECT *o);
ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name);
int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name); int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
int OBJ_txt2nid(char *s); int OBJ_txt2nid(const char *s);
int OBJ_ln2nid(const char *s); int OBJ_ln2nid(const char *s);
int OBJ_sn2nid(const char *s); int OBJ_sn2nid(const char *s);
int OBJ_cmp(ASN1_OBJECT *a,ASN1_OBJECT *b); int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b);
char * OBJ_bsearch(char *key,char *base,int num,int size,int (*cmp)(const void *, const void *)); const char * OBJ_bsearch(const char *key,const char *base,int num,int size,
int (*cmp)(const void *, const void *));
void ERR_load_OBJ_strings(void ); void ERR_load_OBJ_strings(void );
int OBJ_new_nid(int num); int OBJ_new_nid(int num);
int OBJ_add_object(ASN1_OBJECT *obj); int OBJ_add_object(const ASN1_OBJECT *obj);
int OBJ_create(char *oid,char *sn,char *ln); int OBJ_create(const char *oid,const char *sn,const char *ln);
void OBJ_cleanup(void ); void OBJ_cleanup(void );
int OBJ_create_objects(BIO *in); int OBJ_create_objects(BIO *in);