Compaq C 6.2 for VMS will complain when we want to convert
[openssl.git] / crypto / objects / o_names.c
index c22530612b2b27fec7b2ae9cc8abdffbd01b2ad8..e4ef2b07bb64a23068307d43a5ab43fcacffd677 100644 (file)
@@ -2,8 +2,38 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "lhash.h"
-#include "objects.h"
+#include <openssl/lhash.h>
+#include <openssl/objects.h>
+
+union cmp_fn_to_char_u
+       {
+       char *char_p;
+       int (*fn_p)(const char *, const char *);
+       };
+
+union hash_fn_to_char_u
+       {
+       char *char_p;
+       unsigned long (*fn_p)(const char *);
+       };
+
+union int_fn_to_char_u
+       {
+       char *char_p;
+       int (*fn_p)();
+       };
+
+union ulong_fn_to_char_u
+       {
+       char *char_p;
+       unsigned long (*fn_p)();
+       };
+
+union void_fn_to_char_u
+       {
+       char *char_p;
+       void (*fn_p)();
+       };
 
 /* I use the ex_data stuff to manage the identifiers for the obj_name_types
  * that applications may define.  I only really use the free function field.
@@ -17,7 +47,7 @@ static STACK *names_free=NULL;
 static unsigned long obj_name_hash(OBJ_NAME *a);
 static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b);
 
-int OBJ_NAME_init()
+int OBJ_NAME_init(void)
        {
        if (names_lh != NULL) return(1);
        MemCheck_off();
@@ -26,13 +56,22 @@ int OBJ_NAME_init()
        return(names_lh != NULL);
        }
 
-int OBJ_NAME_new_index(hash_func,cmp_func,free_func)
-unsigned long (*hash_func)();
-int (*cmp_func)();
-void (*free_func)();
+int OBJ_NAME_new_index(unsigned long (*hash_func)(), int (*cmp_func)(),
+            void (*free_func)())
        {
        int ret;
        int i;
+       union ulong_fn_to_char_u tmp_hash_func;
+       union int_fn_to_char_u tmp_cmp_func;
+       union void_fn_to_char_u tmp_free_func;
+       union cmp_fn_to_char_u tmp_strcmp;
+       union hash_fn_to_char_u tmp_lh_strhash;
+
+       tmp_hash_func.fn_p = hash_func;
+       tmp_cmp_func.fn_p = cmp_func;
+       tmp_free_func.fn_p = free_func;
+       tmp_strcmp.fn_p = (int (*)(const char *, const char *))strcmp;
+       tmp_lh_strhash.fn_p = lh_strhash;
 
        if (names_free == NULL)
                {
@@ -52,34 +91,32 @@ void (*free_func)();
        for (i=sk_num(names_free); i<names_type_num; i++)
                {
                MemCheck_off();
-               sk_push(names_hash,(char *)strcmp);
-               sk_push(names_cmp,(char *)lh_strhash);
+               sk_push(names_hash,tmp_strcmp.char_p);
+               sk_push(names_cmp,tmp_lh_strhash.char_p);
                sk_push(names_free,NULL);
                MemCheck_on();
                }
        if (hash_func != NULL)
-               sk_value(names_hash,ret)=(char *)hash_func;
+               sk_set(names_hash,ret,tmp_hash_func.char_p);
        if (cmp_func != NULL)
-               sk_value(names_cmp,ret)= (char *)cmp_func;
+               sk_set(names_cmp,ret,tmp_cmp_func.char_p);
        if (free_func != NULL)
-               sk_value(names_free,ret)=(char *)free_func;
+               sk_set(names_free,ret,tmp_free_func.char_p);
        return(ret);
        }
 
-static int obj_name_cmp(a,b)
-OBJ_NAME *a;
-OBJ_NAME *b;
+static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b)
        {
        int ret;
-       int (*cmp)();
+       union int_fn_to_char_u cmp;
 
        ret=a->type-b->type;
        if (ret == 0)
                {
                if ((names_cmp != NULL) && (sk_num(names_cmp) > a->type))
                        {
-                       cmp=(int (*)())sk_value(names_cmp,a->type);
-                       ret=cmp(a->name,b->name);
+                       cmp.char_p=sk_value(names_cmp,a->type);
+                       ret=cmp.fn_p(a->name,b->name);
                        }
                else
                        ret=strcmp(a->name,b->name);
@@ -87,16 +124,15 @@ OBJ_NAME *b;
        return(ret);
        }
 
-static unsigned long obj_name_hash(a)
-OBJ_NAME *a;
+static unsigned long obj_name_hash(OBJ_NAME *a)
        {
        unsigned long ret;
-       unsigned long (*hash)();
+       union ulong_fn_to_char_u hash;
 
        if ((names_hash != NULL) && (sk_num(names_hash) > a->type))
                {
-               hash=(unsigned long (*)())sk_value(names_hash,a->type);
-               ret=hash(a->name);
+               hash.char_p=sk_value(names_hash,a->type);
+               ret=hash.fn_p(a->name);
                }
        else
                {
@@ -106,9 +142,7 @@ OBJ_NAME *a;
        return(ret);
        }
 
-const char *OBJ_NAME_get(name,type)
-const char *name;
-int type;
+const char *OBJ_NAME_get(const char *name, int type)
        {
        OBJ_NAME on,*ret;
        int num=0,alias;
@@ -138,12 +172,9 @@ int type;
                }
        }
 
-int OBJ_NAME_add(name,type,data)
-const char *name;
-int type;
-const char *data;
+int OBJ_NAME_add(const char *name, int type, const char *data)
        {
-       void (*f)();
+       union void_fn_to_char_u f;
        OBJ_NAME *onp,*ret;
        int alias;
 
@@ -170,8 +201,8 @@ const char *data;
                /* free things */
                if ((names_free != NULL) && (sk_num(names_free) > ret->type))
                        {
-                       f=(void (*)())sk_value(names_free,ret->type);
-                       f(ret->name,ret->type,ret->data);
+                       f.char_p=sk_value(names_free,ret->type);
+                       f.fn_p(ret->name,ret->type,ret->data);
                        }
                Free((char *)ret);
                }
@@ -186,12 +217,10 @@ const char *data;
        return(1);
        }
 
-int OBJ_NAME_remove(name,type)
-const char *name;
-int type;
+int OBJ_NAME_remove(const char *name, int type)
        {
        OBJ_NAME on,*ret;
-       void (*f)();
+       union void_fn_to_char_u f;
 
        if (names_lh == NULL) return(0);
 
@@ -204,8 +233,8 @@ int type;
                /* free things */
                if ((names_free != NULL) && (sk_num(names_free) > type))
                        {
-                       f=(void (*)())sk_value(names_free,type);
-                       f(ret->name,ret->type,ret->data);
+                       f.char_p=sk_value(names_free,type);
+                       f.fn_p(ret->name,ret->type,ret->data);
                        }
                Free((char *)ret);
                return(1);
@@ -216,9 +245,8 @@ int type;
 
 static int free_type;
 
-static void names_lh_free(onp,type)
-OBJ_NAME *onp;
-       {
+static void names_lh_free(OBJ_NAME *onp, int type)
+{
        if(onp == NULL)
            return;
 
@@ -228,8 +256,7 @@ OBJ_NAME *onp;
                }
        }
 
-void OBJ_NAME_cleanup(type)
-int type;
+void OBJ_NAME_cleanup(int type)
        {
        unsigned long down_load;