Next step in tidying up the LHASH code.
[openssl.git] / apps / openssl.c
index b7e50c73740dedf0c76ae2639bd58c397e709da9..14cb93ee26af5bfeba289ebc1f1928d3893b8a08 100644 (file)
 #include "s_apps.h"
 #include <openssl/err.h>
 
-static unsigned long MS_CALLBACK hash(FUNCTION *a);
-static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b);
+/* The LHASH callbacks ("hash" & "cmp") have been replaced by functions with the
+ * base prototypes (we cast each variable inside the function to the required
+ * type of "FUNCTION*"). This removes the necessity for macro-generated wrapper
+ * functions. */
+
+/* static unsigned long MS_CALLBACK hash(FUNCTION *a); */
+static unsigned long MS_CALLBACK hash(void *a_void);
+/* static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b); */
+static int MS_CALLBACK cmp(void *a_void,void *b_void);
 static LHASH *prog_init(void );
 static int do_cmd(LHASH *prog,int argc,char *argv[]);
 LHASH *config=NULL;
@@ -85,9 +92,6 @@ char *default_config_file=NULL;
 BIO *bio_err=NULL;
 #endif
 
-static IMPLEMENT_LHASH_HASH_FN(hash,FUNCTION *)
-static IMPLEMENT_LHASH_COMP_FN(cmp,FUNCTION *)
-
 int main(int Argc, char *Argv[])
        {
        ARGS arg;
@@ -354,8 +358,7 @@ static LHASH *prog_init(void)
            ;
        qsort(functions,i,sizeof *functions,SortFnByName);
 
-       if ((ret=lh_new(LHASH_HASH_FN(hash),
-                       LHASH_COMP_FN(cmp))) == NULL)
+       if ((ret=lh_new(hash, cmp)) == NULL)
                return(NULL);
 
        for (f=functions; f->name != NULL; f++)
@@ -363,12 +366,15 @@ static LHASH *prog_init(void)
        return(ret);
        }
 
-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)
        {
-       return(strncmp(a->name,b->name,8));
+       return(strncmp(((FUNCTION *)a_void)->name,
+                       ((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)
        {
-       return(lh_strhash(a->name));
+       return(lh_strhash(((FUNCTION *)a_void)->name));
        }