Kaynağa Gözat

LHASH revamp. make depend.

Ben Laurie 16 yıl önce
ebeveyn
işleme
3c1d6bbc92

+ 4 - 0
CHANGES

@@ -4,6 +4,10 @@
 
 
  Changes between 0.9.8g and 0.9.9  [xx XXX xxxx]
  Changes between 0.9.8g and 0.9.9  [xx XXX xxxx]
 
 
+  *) Revamp of LHASH to provide stronger type-checking. Still to come:
+     STACK, TXT_DB, bsearch, qsort.
+     [Ben Laurie]
+
   *) Not all of this is true any longer.
   *) Not all of this is true any longer.
      Will have to be updated to reflect all subsequent changes to cryptlib.c.
      Will have to be updated to reflect all subsequent changes to cryptlib.c.
                                                                        --bodo
                                                                        --bodo

+ 157 - 148
apps/Makefile

@@ -238,19 +238,20 @@ ciphers.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h
 ciphers.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 ciphers.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 ciphers.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 ciphers.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 ciphers.o: ../include/openssl/err.h ../include/openssl/evp.h
 ciphers.o: ../include/openssl/err.h ../include/openssl/evp.h
-ciphers.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
-ciphers.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-ciphers.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
-ciphers.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-ciphers.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-ciphers.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
-ciphers.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-ciphers.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
-ciphers.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
-ciphers.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-ciphers.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
-ciphers.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
-ciphers.o: ../include/openssl/x509v3.h apps.h ciphers.c
+ciphers.o: ../include/openssl/hmac.h ../include/openssl/kssl.h
+ciphers.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
+ciphers.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
+ciphers.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+ciphers.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+ciphers.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+ciphers.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h
+ciphers.o: ../include/openssl/sha.h ../include/openssl/ssl.h
+ciphers.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
+ciphers.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
+ciphers.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+ciphers.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
+ciphers.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
+ciphers.o: ciphers.c
 cms.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 cms.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 cms.o: ../include/openssl/buffer.h ../include/openssl/cms.h
 cms.o: ../include/openssl/buffer.h ../include/openssl/cms.h
 cms.o: ../include/openssl/conf.h ../include/openssl/crypto.h
 cms.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -419,19 +420,20 @@ engine.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h
 engine.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 engine.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 engine.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 engine.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 engine.o: ../include/openssl/err.h ../include/openssl/evp.h
 engine.o: ../include/openssl/err.h ../include/openssl/evp.h
-engine.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
-engine.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-engine.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
-engine.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-engine.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-engine.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
-engine.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-engine.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
-engine.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
-engine.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-engine.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
-engine.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
-engine.o: ../include/openssl/x509v3.h apps.h engine.c
+engine.o: ../include/openssl/hmac.h ../include/openssl/kssl.h
+engine.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
+engine.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
+engine.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+engine.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+engine.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+engine.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h
+engine.o: ../include/openssl/sha.h ../include/openssl/ssl.h
+engine.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
+engine.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
+engine.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+engine.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
+engine.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
+engine.o: engine.c
 errstr.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 errstr.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 errstr.o: ../include/openssl/buffer.h ../include/openssl/comp.h
 errstr.o: ../include/openssl/buffer.h ../include/openssl/comp.h
 errstr.o: ../include/openssl/conf.h ../include/openssl/crypto.h
 errstr.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -439,19 +441,20 @@ errstr.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h
 errstr.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 errstr.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 errstr.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 errstr.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 errstr.o: ../include/openssl/err.h ../include/openssl/evp.h
 errstr.o: ../include/openssl/err.h ../include/openssl/evp.h
-errstr.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
-errstr.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-errstr.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
-errstr.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-errstr.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-errstr.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
-errstr.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-errstr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
-errstr.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
-errstr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-errstr.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
-errstr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
-errstr.o: ../include/openssl/x509v3.h apps.h errstr.c
+errstr.o: ../include/openssl/hmac.h ../include/openssl/kssl.h
+errstr.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
+errstr.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
+errstr.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+errstr.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+errstr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+errstr.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h
+errstr.o: ../include/openssl/sha.h ../include/openssl/ssl.h
+errstr.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
+errstr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
+errstr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+errstr.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
+errstr.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
+errstr.o: errstr.c
 gendh.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 gendh.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 gendh.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 gendh.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 gendh.o: ../include/openssl/conf.h ../include/openssl/crypto.h
 gendh.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -545,19 +548,20 @@ ocsp.o: ../include/openssl/crypto.h ../include/openssl/dtls1.h
 ocsp.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
 ocsp.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
 ocsp.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
 ocsp.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
 ocsp.o: ../include/openssl/engine.h ../include/openssl/err.h
 ocsp.o: ../include/openssl/engine.h ../include/openssl/err.h
-ocsp.o: ../include/openssl/evp.h ../include/openssl/kssl.h
-ocsp.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-ocsp.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
-ocsp.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
-ocsp.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
-ocsp.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
-ocsp.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h
-ocsp.o: ../include/openssl/sha.h ../include/openssl/ssl.h
-ocsp.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
-ocsp.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
-ocsp.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
-ocsp.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
-ocsp.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h ocsp.c
+ocsp.o: ../include/openssl/evp.h ../include/openssl/hmac.h
+ocsp.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
+ocsp.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+ocsp.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
+ocsp.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+ocsp.o: ../include/openssl/pem.h ../include/openssl/pem2.h
+ocsp.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
+ocsp.o: ../include/openssl/safestack.h ../include/openssl/sha.h
+ocsp.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
+ocsp.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
+ocsp.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
+ocsp.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
+ocsp.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
+ocsp.o: ../include/openssl/x509v3.h apps.h ocsp.c
 openssl.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 openssl.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 openssl.o: ../include/openssl/buffer.h ../include/openssl/comp.h
 openssl.o: ../include/openssl/buffer.h ../include/openssl/comp.h
 openssl.o: ../include/openssl/conf.h ../include/openssl/crypto.h
 openssl.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -565,19 +569,20 @@ openssl.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h
 openssl.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 openssl.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 openssl.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 openssl.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 openssl.o: ../include/openssl/err.h ../include/openssl/evp.h
 openssl.o: ../include/openssl/err.h ../include/openssl/evp.h
-openssl.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
-openssl.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-openssl.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
-openssl.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-openssl.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-openssl.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
-openssl.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-openssl.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
-openssl.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
-openssl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-openssl.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
-openssl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
-openssl.o: ../include/openssl/x509v3.h apps.h openssl.c progs.h s_apps.h
+openssl.o: ../include/openssl/hmac.h ../include/openssl/kssl.h
+openssl.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
+openssl.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
+openssl.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+openssl.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+openssl.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+openssl.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h
+openssl.o: ../include/openssl/sha.h ../include/openssl/ssl.h
+openssl.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
+openssl.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
+openssl.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+openssl.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
+openssl.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
+openssl.o: openssl.c progs.h s_apps.h
 passwd.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 passwd.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 passwd.o: ../include/openssl/buffer.h ../include/openssl/conf.h
 passwd.o: ../include/openssl/buffer.h ../include/openssl/conf.h
 passwd.o: ../include/openssl/crypto.h ../include/openssl/des.h
 passwd.o: ../include/openssl/crypto.h ../include/openssl/des.h
@@ -779,19 +784,20 @@ s_cb.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h
 s_cb.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 s_cb.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 s_cb.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 s_cb.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 s_cb.o: ../include/openssl/err.h ../include/openssl/evp.h
 s_cb.o: ../include/openssl/err.h ../include/openssl/evp.h
-s_cb.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
-s_cb.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-s_cb.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
-s_cb.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-s_cb.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-s_cb.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
-s_cb.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-s_cb.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
-s_cb.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
-s_cb.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-s_cb.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
-s_cb.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
-s_cb.o: ../include/openssl/x509v3.h apps.h s_apps.h s_cb.c
+s_cb.o: ../include/openssl/hmac.h ../include/openssl/kssl.h
+s_cb.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
+s_cb.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
+s_cb.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+s_cb.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+s_cb.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+s_cb.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h
+s_cb.o: ../include/openssl/sha.h ../include/openssl/ssl.h
+s_cb.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
+s_cb.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
+s_cb.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+s_cb.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
+s_cb.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
+s_cb.o: s_apps.h s_cb.c
 s_client.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 s_client.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 s_client.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 s_client.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 s_client.o: ../include/openssl/comp.h ../include/openssl/conf.h
 s_client.o: ../include/openssl/comp.h ../include/openssl/conf.h
@@ -799,20 +805,21 @@ s_client.o: ../include/openssl/crypto.h ../include/openssl/dtls1.h
 s_client.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
 s_client.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
 s_client.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
 s_client.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
 s_client.o: ../include/openssl/engine.h ../include/openssl/err.h
 s_client.o: ../include/openssl/engine.h ../include/openssl/err.h
-s_client.o: ../include/openssl/evp.h ../include/openssl/kssl.h
-s_client.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-s_client.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
-s_client.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
-s_client.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
-s_client.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
-s_client.o: ../include/openssl/pqueue.h ../include/openssl/rand.h
-s_client.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-s_client.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
-s_client.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
-s_client.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-s_client.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
-s_client.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
-s_client.o: ../include/openssl/x509v3.h apps.h s_apps.h s_client.c timeouts.h
+s_client.o: ../include/openssl/evp.h ../include/openssl/hmac.h
+s_client.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
+s_client.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+s_client.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
+s_client.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+s_client.o: ../include/openssl/pem.h ../include/openssl/pem2.h
+s_client.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
+s_client.o: ../include/openssl/rand.h ../include/openssl/safestack.h
+s_client.o: ../include/openssl/sha.h ../include/openssl/ssl.h
+s_client.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
+s_client.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
+s_client.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+s_client.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
+s_client.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
+s_client.o: s_apps.h s_client.c timeouts.h
 s_server.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 s_server.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 s_server.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 s_server.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 s_server.o: ../include/openssl/comp.h ../include/openssl/conf.h
 s_server.o: ../include/openssl/comp.h ../include/openssl/conf.h
@@ -821,42 +828,42 @@ s_server.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h
 s_server.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
 s_server.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
 s_server.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
 s_server.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
 s_server.o: ../include/openssl/engine.h ../include/openssl/err.h
 s_server.o: ../include/openssl/engine.h ../include/openssl/err.h
-s_server.o: ../include/openssl/evp.h ../include/openssl/kssl.h
-s_server.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-s_server.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
-s_server.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
-s_server.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
-s_server.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
-s_server.o: ../include/openssl/pqueue.h ../include/openssl/rand.h
-s_server.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
-s_server.o: ../include/openssl/sha.h ../include/openssl/ssl.h
-s_server.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
-s_server.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
-s_server.o: ../include/openssl/store.h ../include/openssl/symhacks.h
-s_server.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
-s_server.o: ../include/openssl/ui.h ../include/openssl/x509.h
-s_server.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
-s_server.o: s_apps.h s_server.c timeouts.h
+s_server.o: ../include/openssl/evp.h ../include/openssl/hmac.h
+s_server.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
+s_server.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+s_server.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
+s_server.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+s_server.o: ../include/openssl/pem.h ../include/openssl/pem2.h
+s_server.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
+s_server.o: ../include/openssl/rand.h ../include/openssl/rsa.h
+s_server.o: ../include/openssl/safestack.h ../include/openssl/sha.h
+s_server.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
+s_server.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
+s_server.o: ../include/openssl/stack.h ../include/openssl/store.h
+s_server.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+s_server.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
+s_server.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
+s_server.o: ../include/openssl/x509v3.h apps.h s_apps.h s_server.c timeouts.h
 s_socket.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 s_socket.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 s_socket.o: ../include/openssl/buffer.h ../include/openssl/comp.h
 s_socket.o: ../include/openssl/buffer.h ../include/openssl/comp.h
 s_socket.o: ../include/openssl/conf.h ../include/openssl/crypto.h
 s_socket.o: ../include/openssl/conf.h ../include/openssl/crypto.h
 s_socket.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h
 s_socket.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h
 s_socket.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 s_socket.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 s_socket.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 s_socket.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
-s_socket.o: ../include/openssl/evp.h ../include/openssl/kssl.h
-s_socket.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-s_socket.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
-s_socket.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
-s_socket.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
-s_socket.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
-s_socket.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h
-s_socket.o: ../include/openssl/sha.h ../include/openssl/ssl.h
-s_socket.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
-s_socket.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
-s_socket.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
-s_socket.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
-s_socket.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
-s_socket.o: s_apps.h s_socket.c
+s_socket.o: ../include/openssl/evp.h ../include/openssl/hmac.h
+s_socket.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
+s_socket.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+s_socket.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
+s_socket.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+s_socket.o: ../include/openssl/pem.h ../include/openssl/pem2.h
+s_socket.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
+s_socket.o: ../include/openssl/safestack.h ../include/openssl/sha.h
+s_socket.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
+s_socket.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
+s_socket.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
+s_socket.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
+s_socket.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
+s_socket.o: ../include/openssl/x509v3.h apps.h s_apps.h s_socket.c
 s_time.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 s_time.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 s_time.o: ../include/openssl/buffer.h ../include/openssl/comp.h
 s_time.o: ../include/openssl/buffer.h ../include/openssl/comp.h
 s_time.o: ../include/openssl/conf.h ../include/openssl/crypto.h
 s_time.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -864,19 +871,20 @@ s_time.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h
 s_time.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 s_time.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 s_time.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 s_time.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 s_time.o: ../include/openssl/err.h ../include/openssl/evp.h
 s_time.o: ../include/openssl/err.h ../include/openssl/evp.h
-s_time.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
-s_time.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-s_time.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
-s_time.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-s_time.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-s_time.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
-s_time.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-s_time.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
-s_time.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
-s_time.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-s_time.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
-s_time.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
-s_time.o: ../include/openssl/x509v3.h apps.h s_apps.h s_time.c
+s_time.o: ../include/openssl/hmac.h ../include/openssl/kssl.h
+s_time.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
+s_time.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
+s_time.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+s_time.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+s_time.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+s_time.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h
+s_time.o: ../include/openssl/sha.h ../include/openssl/ssl.h
+s_time.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
+s_time.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
+s_time.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+s_time.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
+s_time.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
+s_time.o: s_apps.h s_time.c
 sess_id.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 sess_id.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 sess_id.o: ../include/openssl/buffer.h ../include/openssl/comp.h
 sess_id.o: ../include/openssl/buffer.h ../include/openssl/comp.h
 sess_id.o: ../include/openssl/conf.h ../include/openssl/crypto.h
 sess_id.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -884,19 +892,20 @@ sess_id.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h
 sess_id.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 sess_id.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 sess_id.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 sess_id.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 sess_id.o: ../include/openssl/err.h ../include/openssl/evp.h
 sess_id.o: ../include/openssl/err.h ../include/openssl/evp.h
-sess_id.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
-sess_id.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-sess_id.o: ../include/openssl/ocsp.h ../include/openssl/opensslconf.h
-sess_id.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-sess_id.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-sess_id.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
-sess_id.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-sess_id.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
-sess_id.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
-sess_id.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-sess_id.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
-sess_id.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
-sess_id.o: ../include/openssl/x509v3.h apps.h sess_id.c
+sess_id.o: ../include/openssl/hmac.h ../include/openssl/kssl.h
+sess_id.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
+sess_id.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
+sess_id.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+sess_id.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+sess_id.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+sess_id.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h
+sess_id.o: ../include/openssl/sha.h ../include/openssl/ssl.h
+sess_id.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
+sess_id.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
+sess_id.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+sess_id.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
+sess_id.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
+sess_id.o: sess_id.c
 smime.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 smime.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 smime.o: ../include/openssl/buffer.h ../include/openssl/conf.h
 smime.o: ../include/openssl/buffer.h ../include/openssl/conf.h
 smime.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
 smime.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h

+ 13 - 14
apps/apps.c

@@ -1477,7 +1477,7 @@ char *make_config_name()
 	return p;
 	return p;
 	}
 	}
 
 
-static unsigned long index_serial_hash(const char **a)
+static unsigned long index_serial_hash(const STRING *a)
 	{
 	{
 	const char *n;
 	const char *n;
 
 
@@ -1486,7 +1486,7 @@ static unsigned long index_serial_hash(const char **a)
 	return(lh_strhash(n));
 	return(lh_strhash(n));
 	}
 	}
 
 
-static int index_serial_cmp(const char **a, const char **b)
+static int index_serial_cmp(const STRING *a, const STRING *b)
 	{
 	{
 	const char *aa,*bb;
 	const char *aa,*bb;
 
 
@@ -1498,17 +1498,16 @@ static int index_serial_cmp(const char **a, const char **b)
 static int index_name_qual(char **a)
 static int index_name_qual(char **a)
 	{ return(a[0][0] == 'V'); }
 	{ return(a[0][0] == 'V'); }
 
 
-static unsigned long index_name_hash(const char **a)
+static unsigned long index_name_hash(const STRING *a)
 	{ return(lh_strhash(a[DB_name])); }
 	{ return(lh_strhash(a[DB_name])); }
 
 
-int index_name_cmp(const char **a, const char **b)
-	{ return(strcmp(a[DB_name],
-	     b[DB_name])); }
+int index_name_cmp(const STRING *a, const STRING *b)
+	{ return(strcmp(a[DB_name], b[DB_name])); }
 
 
-static IMPLEMENT_LHASH_HASH_FN(index_serial_hash,const char **)
-static IMPLEMENT_LHASH_COMP_FN(index_serial_cmp,const char **)
-static IMPLEMENT_LHASH_HASH_FN(index_name_hash,const char **)
-static IMPLEMENT_LHASH_COMP_FN(index_name_cmp,const char **)
+static IMPLEMENT_LHASH_HASH_FN(index_serial, STRING)
+static IMPLEMENT_LHASH_COMP_FN(index_serial, STRING)
+static IMPLEMENT_LHASH_HASH_FN(index_name, STRING)
+static IMPLEMENT_LHASH_COMP_FN(index_name, STRING)
 
 
 #undef BSIZE
 #undef BSIZE
 #define BSIZE 256
 #define BSIZE 256
@@ -1802,8 +1801,8 @@ CA_DB *load_index(char *dbfile, DB_ATTR *db_attr)
 int index_index(CA_DB *db)
 int index_index(CA_DB *db)
 	{
 	{
 	if (!TXT_DB_create_index(db->db, DB_serial, NULL,
 	if (!TXT_DB_create_index(db->db, DB_serial, NULL,
-				LHASH_HASH_FN(index_serial_hash),
-				LHASH_COMP_FN(index_serial_cmp)))
+				LHASH_HASH_FN(index_serial),
+				LHASH_COMP_FN(index_serial)))
 		{
 		{
 		BIO_printf(bio_err,
 		BIO_printf(bio_err,
 		  "error creating serial number index:(%ld,%ld,%ld)\n",
 		  "error creating serial number index:(%ld,%ld,%ld)\n",
@@ -1813,8 +1812,8 @@ int index_index(CA_DB *db)
 
 
 	if (db->attributes.unique_subject
 	if (db->attributes.unique_subject
 		&& !TXT_DB_create_index(db->db, DB_name, index_name_qual,
 		&& !TXT_DB_create_index(db->db, DB_name, index_name_qual,
-			LHASH_HASH_FN(index_name_hash),
-			LHASH_COMP_FN(index_name_cmp)))
+			LHASH_HASH_FN(index_name),
+			LHASH_COMP_FN(index_name)))
 		{
 		{
 		BIO_printf(bio_err,"error creating name index:(%ld,%ld,%ld)\n",
 		BIO_printf(bio_err,"error creating name index:(%ld,%ld,%ld)\n",
 			db->db->error,db->db->arg1,db->db->arg2);
 			db->db->error,db->db->arg1,db->db->arg2);

+ 1 - 1
apps/apps.h

@@ -294,7 +294,7 @@ int index_index(CA_DB *db);
 int save_index(const char *dbfile, const char *suffix, CA_DB *db);
 int save_index(const char *dbfile, const char *suffix, CA_DB *db);
 int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix);
 int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix);
 void free_index(CA_DB *db);
 void free_index(CA_DB *db);
-int index_name_cmp(const char **a, const char **b);
+int index_name_cmp(const STRING *a, const STRING *b);
 int parse_yesno(const char *str, int def);
 int parse_yesno(const char *str, int def);
 
 
 X509_NAME *parse_name(char *str, long chtype, int multirdn);
 X509_NAME *parse_name(char *str, long chtype, int multirdn);

+ 8 - 4
apps/ca.c

@@ -1678,7 +1678,9 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
 	int ok= -1,i,j,last,nid;
 	int ok= -1,i,j,last,nid;
 	const char *p;
 	const char *p;
 	CONF_VALUE *cv;
 	CONF_VALUE *cv;
-	char *row[DB_NUMBER],**rrow=NULL,**irow=NULL;
+	STRING row[DB_NUMBER];
+	STRING *irow=NULL;
+	STRING *rrow=NULL;
 	char buf[25];
 	char buf[25];
 
 
 	tmptm=ASN1_UTCTIME_new();
 	tmptm=ASN1_UTCTIME_new();
@@ -1920,7 +1922,9 @@ again2:
 
 
 	if (db->attributes.unique_subject)
 	if (db->attributes.unique_subject)
 		{
 		{
-		rrow=TXT_DB_get_by_index(db->db,DB_name,row);
+		STRING *crow=row;
+
+		rrow=TXT_DB_get_by_index(db->db,DB_name,crow);
 		if (rrow != NULL)
 		if (rrow != NULL)
 			{
 			{
 			BIO_printf(bio_err,
 			BIO_printf(bio_err,
@@ -2221,7 +2225,7 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
 	     unsigned long nameopt, int default_op, int ext_copy)
 	     unsigned long nameopt, int default_op, int ext_copy)
 	{
 	{
 	STACK_OF(CONF_VALUE) *sk=NULL;
 	STACK_OF(CONF_VALUE) *sk=NULL;
-	LHASH *parms=NULL;
+	LHASH_OF(CONF_VALUE) *parms=NULL;
 	X509_REQ *req=NULL;
 	X509_REQ *req=NULL;
 	CONF_VALUE *cv=NULL;
 	CONF_VALUE *cv=NULL;
 	NETSCAPE_SPKI *spki = NULL;
 	NETSCAPE_SPKI *spki = NULL;
@@ -2477,7 +2481,7 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
 		goto err;
 		goto err;
 
 
 		}
 		}
-	else if (index_name_cmp((const char **)row,(const char **)rrow))
+	else if (index_name_cmp(row,rrow))
 		{
 		{
 		BIO_printf(bio_err,"ERROR:name does not match %s\n",
 		BIO_printf(bio_err,"ERROR:name does not match %s\n",
 			   row[DB_name]);
 			   row[DB_name]);

+ 6 - 4
apps/errstr.c

@@ -97,10 +97,12 @@ int MAIN(int argc, char **argv)
 			out = BIO_push(tmpbio, out);
 			out = BIO_push(tmpbio, out);
 			}
 			}
 #endif
 #endif
-			lh_node_stats_bio((LHASH *)ERR_get_string_table(),out);
-			lh_stats_bio((LHASH *)ERR_get_string_table(),out);
-			lh_node_usage_stats_bio((LHASH *)
-				ERR_get_string_table(),out);
+			lh_ERR_STRING_DATA_node_stats_bio(
+						  ERR_get_string_table(), out);
+			lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(),
+						     out);
+			lh_ERR_STRING_DATA_node_usage_stats_bio(
+						    ERR_get_string_table(),out);
 			}
 			}
 		if (out != NULL) BIO_free_all(out);
 		if (out != NULL) BIO_free_all(out);
 		argc--;
 		argc--;

+ 24 - 28
apps/openssl.c

@@ -135,12 +135,8 @@
  * type of "FUNCTION*"). This removes the necessity for macro-generated wrapper
  * type of "FUNCTION*"). This removes the necessity for macro-generated wrapper
  * functions. */
  * functions. */
 
 
-/* static unsigned long MS_CALLBACK hash(FUNCTION *a); */
-static unsigned long MS_CALLBACK hash(const void *a_void);
-/* static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b); */
-static int MS_CALLBACK cmp(const void *a_void,const void *b_void);
-static LHASH *prog_init(void );
-static int do_cmd(LHASH *prog,int argc,char *argv[]);
+static LHASH_OF(FUNCTION) *prog_init(void );
+static int do_cmd(LHASH_OF(FUNCTION) *prog,int argc,char *argv[]);
 static void list_pkey(BIO *out);
 static void list_pkey(BIO *out);
 static void list_cipher(BIO *out);
 static void list_cipher(BIO *out);
 static void list_md(BIO *out);
 static void list_md(BIO *out);
@@ -229,7 +225,7 @@ int main(int Argc, char *Argv[])
 	int n,i,ret=0;
 	int n,i,ret=0;
 	int argc;
 	int argc;
 	char **argv,*p;
 	char **argv,*p;
-	LHASH *prog=NULL;
+	LHASH_OF(FUNCTION) *prog=NULL;
 	long errline;
 	long errline;
  
  
 	arg.data=NULL;
 	arg.data=NULL;
@@ -287,7 +283,7 @@ int main(int Argc, char *Argv[])
 	program_name(Argv[0],pname,sizeof pname);
 	program_name(Argv[0],pname,sizeof pname);
 
 
 	f.name=pname;
 	f.name=pname;
-	fp=(FUNCTION *)lh_retrieve(prog,&f);
+	fp=lh_FUNCTION_retrieve(prog,&f);
 	if (fp != NULL)
 	if (fp != NULL)
 		{
 		{
 		Argv[0]=pname;
 		Argv[0]=pname;
@@ -353,7 +349,7 @@ end:
 		NCONF_free(config);
 		NCONF_free(config);
 		config=NULL;
 		config=NULL;
 		}
 		}
-	if (prog != NULL) lh_free(prog);
+	if (prog != NULL) lh_FUNCTION_free(prog);
 	if (arg.data != NULL) OPENSSL_free(arg.data);
 	if (arg.data != NULL) OPENSSL_free(arg.data);
 
 
 	apps_shutdown();
 	apps_shutdown();
@@ -375,7 +371,7 @@ end:
 #define LIST_PUBLIC_KEY_ALGORITHMS "list-public-key-algorithms"
 #define LIST_PUBLIC_KEY_ALGORITHMS "list-public-key-algorithms"
 
 
 
 
-static int do_cmd(LHASH *prog, int argc, char *argv[])
+static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
 	{
 	{
 	FUNCTION f,*fp;
 	FUNCTION f,*fp;
 	int i,ret=1,tp,nl;
 	int i,ret=1,tp,nl;
@@ -383,7 +379,7 @@ static int do_cmd(LHASH *prog, int argc, char *argv[])
 	if ((argc <= 0) || (argv[0] == NULL))
 	if ((argc <= 0) || (argv[0] == NULL))
 		{ ret=0; goto end; }
 		{ ret=0; goto end; }
 	f.name=argv[0];
 	f.name=argv[0];
-	fp=(FUNCTION *)lh_retrieve(prog,&f);
+	fp=lh_FUNCTION_retrieve(prog,&f);
 	if (fp != NULL)
 	if (fp != NULL)
 		{
 		{
 		ret=fp->func(argc,argv);
 		ret=fp->func(argc,argv);
@@ -398,7 +394,7 @@ static int do_cmd(LHASH *prog, int argc, char *argv[])
 		}
 		}
 #endif
 #endif
 		f.name=argv[0]+3;
 		f.name=argv[0]+3;
-		ret = (lh_retrieve(prog,&f) != NULL);
+		ret = (lh_FUNCTION_retrieve(prog,&f) != NULL);
 		if (!ret)
 		if (!ret)
 			BIO_printf(bio_stdout, "%s\n", argv[0]);
 			BIO_printf(bio_stdout, "%s\n", argv[0]);
 		else
 		else
@@ -595,9 +591,21 @@ static void list_md(BIO *out)
 	EVP_MD_do_all_sorted(list_md_fn, out);
 	EVP_MD_do_all_sorted(list_md_fn, out);
 	}
 	}
 
 
-static LHASH *prog_init(void)
+static int MS_CALLBACK function_cmp(const FUNCTION *a, const FUNCTION *b)
 	{
 	{
-	LHASH *ret;
+	return strncmp(a->name,b->name,8);
+	}
+static IMPLEMENT_LHASH_COMP_FN(function, FUNCTION);
+
+static unsigned long MS_CALLBACK function_hash(const FUNCTION *a)
+	{
+	return lh_strhash(a->name);
+	}	
+static IMPLEMENT_LHASH_HASH_FN(function, FUNCTION);
+
+static LHASH_OF(FUNCTION) *prog_init(void)
+	{
+	LHASH_OF(FUNCTION) *ret;
 	FUNCTION *f;
 	FUNCTION *f;
 	size_t i;
 	size_t i;
 
 
@@ -606,23 +614,11 @@ static LHASH *prog_init(void)
 	    ;
 	    ;
 	qsort(functions,i,sizeof *functions,SortFnByName);
 	qsort(functions,i,sizeof *functions,SortFnByName);
 
 
-	if ((ret=lh_new(hash, cmp)) == NULL)
+	if ((ret=lh_FUNCTION_new()) == NULL)
 		return(NULL);
 		return(NULL);
 
 
 	for (f=functions; f->name != NULL; f++)
 	for (f=functions; f->name != NULL; f++)
-		lh_insert(ret,f);
+		lh_FUNCTION_insert(ret,f);
 	return(ret);
 	return(ret);
 	}
 	}
 
 
-/* static int MS_CALLBACK cmp(FUNCTION *a, FUNCTION *b) */
-static int MS_CALLBACK cmp(const void *a_void, const void *b_void)
-	{
-	return(strncmp(((const FUNCTION *)a_void)->name,
-			((const FUNCTION *)b_void)->name,8));
-	}
-
-/* static unsigned long MS_CALLBACK hash(FUNCTION *a) */
-static unsigned long MS_CALLBACK hash(const void *a_void)
-	{
-	return(lh_strhash(((const FUNCTION *)a_void)->name));
-	}

+ 1 - 0
apps/progs.h

@@ -59,6 +59,7 @@ typedef struct {
 	const char *name;
 	const char *name;
 	int (*func)(int argc,char *argv[]);
 	int (*func)(int argc,char *argv[]);
 	} FUNCTION;
 	} FUNCTION;
+DECLARE_LHASH_OF(FUNCTION);
 
 
 FUNCTION functions[] = {
 FUNCTION functions[] = {
 	{FUNC_TYPE_GENERAL,"verify",verify_main},
 	{FUNC_TYPE_GENERAL,"verify",verify_main},

+ 18 - 12
crypto/conf/conf.h

@@ -78,7 +78,8 @@ typedef struct
 	char *value;
 	char *value;
 	} CONF_VALUE;
 	} CONF_VALUE;
 
 
-DECLARE_STACK_OF(CONF_VALUE)
+DECLARE_STACK_OF(CONF_VALUE);
+DECLARE_LHASH_OF(CONF_VALUE);
 
 
 struct conf_st;
 struct conf_st;
 struct conf_method_st;
 struct conf_method_st;
@@ -118,18 +119,23 @@ typedef void conf_finish_func(CONF_IMODULE *md);
 #define CONF_MFLAGS_DEFAULT_SECTION	0x20
 #define CONF_MFLAGS_DEFAULT_SECTION	0x20
 
 
 int CONF_set_default_method(CONF_METHOD *meth);
 int CONF_set_default_method(CONF_METHOD *meth);
-void CONF_set_nconf(CONF *conf,LHASH *hash);
-LHASH *CONF_load(LHASH *conf,const char *file,long *eline);
+void CONF_set_nconf(CONF *conf,LHASH_OF(CONF_VALUE) *hash);
+LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf,const char *file,
+				long *eline);
 #ifndef OPENSSL_NO_FP_API
 #ifndef OPENSSL_NO_FP_API
-LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline);
+LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
+				   long *eline);
 #endif
 #endif
-LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline);
-STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section);
-char *CONF_get_string(LHASH *conf,const char *group,const char *name);
-long CONF_get_number(LHASH *conf,const char *group,const char *name);
-void CONF_free(LHASH *conf);
-int CONF_dump_fp(LHASH *conf, FILE *out);
-int CONF_dump_bio(LHASH *conf, BIO *out);
+LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,long *eline);
+STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
+				       const char *section);
+char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf,const char *group,
+		      const char *name);
+long CONF_get_number(LHASH_OF(CONF_VALUE) *conf,const char *group,
+		     const char *name);
+void CONF_free(LHASH_OF(CONF_VALUE) *conf);
+int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
+int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
 
 
 void OPENSSL_config(const char *config_name);
 void OPENSSL_config(const char *config_name);
 void OPENSSL_no_config(void);
 void OPENSSL_no_config(void);
@@ -141,7 +147,7 @@ struct conf_st
 	{
 	{
 	CONF_METHOD *meth;
 	CONF_METHOD *meth;
 	void *meth_data;
 	void *meth_data;
-	LHASH *data;
+	LHASH_OF(CONF_VALUE) *data;
 	};
 	};
 
 
 CONF *NCONF_new(CONF_METHOD *meth);
 CONF *NCONF_new(CONF_METHOD *meth);

+ 55 - 59
crypto/conf/conf_api.c

@@ -69,16 +69,14 @@
 #include <openssl/conf_api.h>
 #include <openssl/conf_api.h>
 #include "e_os.h"
 #include "e_os.h"
 
 
-static void value_free_hash(CONF_VALUE *a, LHASH *conf);
-static void value_free_stack(CONF_VALUE *a,LHASH *conf);
-static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE *, LHASH *)
-static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_stack, CONF_VALUE *, LHASH *)
-/* We don't use function pointer casting or wrapper functions - but cast each
- * callback parameter inside the callback functions. */
-/* static unsigned long hash(CONF_VALUE *v); */
-static unsigned long hash(const void *v_void);
-/* static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); */
-static int cmp_conf(const void *a_void,const void *b_void);
+static void value_free_hash_doall_arg(CONF_VALUE *a,
+				      LHASH_OF(CONF_VALUE) *conf);
+static void value_free_stack_doall_arg(CONF_VALUE *a,
+				       LHASH_OF(CONF_VALUE) *conf);
+static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE,
+				    LHASH_OF(CONF_VALUE))
+static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_stack, CONF_VALUE,
+				    LHASH_OF(CONF_VALUE))
 
 
 /* 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(const CONF *conf, const char *section)
 CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section)
@@ -88,7 +86,7 @@ CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section)
 	if ((conf == NULL) || (section == NULL)) return(NULL);
 	if ((conf == NULL) || (section == NULL)) return(NULL);
 	vv.name=NULL;
 	vv.name=NULL;
 	vv.section=(char *)section;
 	vv.section=(char *)section;
-	v=(CONF_VALUE *)lh_retrieve(conf->data,&vv);
+	v=lh_CONF_VALUE_retrieve(conf->data,&vv);
 	return(v);
 	return(v);
 	}
 	}
 
 
@@ -118,7 +116,7 @@ int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value)
 		return 0;
 		return 0;
 		}
 		}
 
 
-	v = (CONF_VALUE *)lh_insert(conf->data, value);
+	v = lh_CONF_VALUE_insert(conf->data, value);
 	if (v != NULL)
 	if (v != NULL)
 		{
 		{
 		(void)sk_CONF_VALUE_delete_ptr(ts,v);
 		(void)sk_CONF_VALUE_delete_ptr(ts,v);
@@ -141,7 +139,7 @@ char *_CONF_get_string(const CONF *conf, const char *section, const char *name)
 			{
 			{
 			vv.name=(char *)name;
 			vv.name=(char *)name;
 			vv.section=(char *)section;
 			vv.section=(char *)section;
-			v=(CONF_VALUE *)lh_retrieve(conf->data,&vv);
+			v=lh_CONF_VALUE_retrieve(conf->data,&vv);
 			if (v != NULL) return(v->value);
 			if (v != NULL) return(v->value);
 			if (strcmp(section,"ENV") == 0)
 			if (strcmp(section,"ENV") == 0)
 				{
 				{
@@ -151,7 +149,7 @@ char *_CONF_get_string(const CONF *conf, const char *section, const char *name)
 			}
 			}
 		vv.section="default";
 		vv.section="default";
 		vv.name=(char *)name;
 		vv.name=(char *)name;
-		v=(CONF_VALUE *)lh_retrieve(conf->data,&vv);
+		v=lh_CONF_VALUE_retrieve(conf->data,&vv);
 		if (v != NULL)
 		if (v != NULL)
 			return(v->value);
 			return(v->value);
 		else
 		else
@@ -182,6 +180,34 @@ long _CONF_get_number(CONF *conf, char *section, char *name)
 	}
 	}
 #endif
 #endif
 
 
+static unsigned long conf_value_hash(const CONF_VALUE *v)
+	{
+	return (lh_strhash(v->section)<<2)^lh_strhash(v->name);
+	}
+static IMPLEMENT_LHASH_HASH_FN(conf_value, CONF_VALUE)
+
+static int conf_value_cmp(const CONF_VALUE *a, const CONF_VALUE *b)
+	{
+	int i;
+
+	if (a->section != b->section)
+		{
+		i=strcmp(a->section,b->section);
+		if (i) return(i);
+		}
+
+	if ((a->name != NULL) && (b->name != NULL))
+		{
+		i=strcmp(a->name,b->name);
+		return(i);
+		}
+	else if (a->name == b->name)
+		return(0);
+	else
+		return((a->name == NULL)?-1:1);
+	}
+static IMPLEMENT_LHASH_COMP_FN(conf_value, CONF_VALUE)
+
 int _CONF_new_data(CONF *conf)
 int _CONF_new_data(CONF *conf)
 	{
 	{
 	if (conf == NULL)
 	if (conf == NULL)
@@ -189,7 +215,7 @@ int _CONF_new_data(CONF *conf)
 		return 0;
 		return 0;
 		}
 		}
 	if (conf->data == NULL)
 	if (conf->data == NULL)
-		if ((conf->data = lh_new(hash, cmp_conf)) == NULL)
+		if ((conf->data = lh_CONF_VALUE_new()) == NULL)
 			{
 			{
 			return 0;
 			return 0;
 			}
 			}
@@ -200,28 +226,29 @@ void _CONF_free_data(CONF *conf)
 	{
 	{
 	if (conf == NULL || conf->data == NULL) return;
 	if (conf == NULL || conf->data == NULL) return;
 
 
-	conf->data->down_load=0; /* evil thing to make sure the 'OPENSSL_free()'
-				  * works as expected */
-	lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash),
-			conf->data);
+	lh_CONF_VALUE_down_load(conf->data)=0; /* evil thing to make
+				  * sure the 'OPENSSL_free()' works as
+				  * expected */
+	lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash),
+				LHASH_OF(CONF_VALUE), conf->data);
 
 
 	/* We now have only 'section' entries in the hash table.
 	/* We now have only 'section' entries in the hash table.
 	 * Due to problems with */
 	 * Due to problems with */
 
 
-	lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_stack),
-			conf->data);
-	lh_free(conf->data);
+	lh_CONF_VALUE_doall_arg(conf->data,
+				LHASH_DOALL_ARG_FN(value_free_stack),
+				LHASH_OF(CONF_VALUE), conf->data);
+	lh_CONF_VALUE_free(conf->data);
 	}
 	}
 
 
-static void value_free_hash(CONF_VALUE *a, LHASH *conf)
+static void value_free_hash_doall_arg(CONF_VALUE *a, LHASH_OF(CONF_VALUE) *conf)
 	{
 	{
 	if (a->name != NULL)
 	if (a->name != NULL)
-		{
-		a=(CONF_VALUE *)lh_delete(conf,a);
-		}
+		lh_CONF_VALUE_delete(conf,a);
 	}
 	}
 
 
-static void value_free_stack(CONF_VALUE *a, LHASH *conf)
+static void value_free_stack_doall_arg(CONF_VALUE *a,
+				       LHASH_OF(CONF_VALUE) *conf)
 	{
 	{
 	CONF_VALUE *vv;
 	CONF_VALUE *vv;
 	STACK *sk;
 	STACK *sk;
@@ -242,37 +269,6 @@ static void value_free_stack(CONF_VALUE *a, LHASH *conf)
 	OPENSSL_free(a);
 	OPENSSL_free(a);
 	}
 	}
 
 
-/* static unsigned long hash(CONF_VALUE *v) */
-static unsigned long hash(const void *v_void)
-	{
-	CONF_VALUE *v = (CONF_VALUE *)v_void;
-	return((lh_strhash(v->section)<<2)^lh_strhash(v->name));
-	}
-
-/* static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) */
-static int cmp_conf(const void *a_void,const  void *b_void)
-	{
-	int i;
-	CONF_VALUE *a = (CONF_VALUE *)a_void;
-	CONF_VALUE *b = (CONF_VALUE *)b_void;
-
-	if (a->section != b->section)
-		{
-		i=strcmp(a->section,b->section);
-		if (i) return(i);
-		}
-
-	if ((a->name != NULL) && (b->name != NULL))
-		{
-		i=strcmp(a->name,b->name);
-		return(i);
-		}
-	else if (a->name == b->name)
-		return(0);
-	else
-		return((a->name == NULL)?-1:1);
-	}
-
 /* Up until OpenSSL 0.9.5a, this was new_section */
 /* Up until OpenSSL 0.9.5a, this was new_section */
 CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
 CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
 	{
 	{
@@ -292,7 +288,7 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
 	v->name=NULL;
 	v->name=NULL;
 	v->value=(char *)sk;
 	v->value=(char *)sk;
 	
 	
-	vv=(CONF_VALUE *)lh_insert(conf->data,v);
+	vv=lh_CONF_VALUE_insert(conf->data,v);
 	assert(vv == NULL);
 	assert(vv == NULL);
 	ok=1;
 	ok=1;
 err:
 err:

+ 6 - 5
crypto/conf/conf_def.c

@@ -129,7 +129,7 @@ static CONF *def_create(CONF_METHOD *meth)
 	{
 	{
 	CONF *ret;
 	CONF *ret;
 
 
-	ret = (CONF *)OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *));
+	ret = OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *));
 	if (ret)
 	if (ret)
 		if (meth->init(ret) == 0)
 		if (meth->init(ret) == 0)
 			{
 			{
@@ -145,7 +145,7 @@ static int def_init_default(CONF *conf)
 		return 0;
 		return 0;
 
 
 	conf->meth = &default_method;
 	conf->meth = &default_method;
-	conf->meth_data = (void *)CONF_type_default;
+	conf->meth_data = CONF_type_default;
 	conf->data = NULL;
 	conf->data = NULL;
 
 
 	return 1;
 	return 1;
@@ -722,7 +722,7 @@ static char *scan_dquote(CONF *conf, char *p)
 	return(p);
 	return(p);
 	}
 	}
 
 
-static void dump_value(CONF_VALUE *a, BIO *out)
+static void dump_value_doall_arg(CONF_VALUE *a, BIO *out)
 	{
 	{
 	if (a->name)
 	if (a->name)
 		BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value);
 		BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value);
@@ -730,11 +730,12 @@ static void dump_value(CONF_VALUE *a, BIO *out)
 		BIO_printf(out, "[[%s]]\n", a->section);
 		BIO_printf(out, "[[%s]]\n", a->section);
 	}
 	}
 
 
-static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE *, BIO *)
+static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE, BIO)
 
 
 static int def_dump(const CONF *conf, BIO *out)
 static int def_dump(const CONF *conf, BIO *out)
 	{
 	{
-	lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), out);
+	lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value),
+				BIO, out);
 	return 1;
 	return 1;
 	}
 	}
 
 

+ 18 - 12
crypto/conf/conf_lib.c

@@ -69,7 +69,7 @@ static CONF_METHOD *default_CONF_method=NULL;
 
 
 /* Init a 'CONF' structure from an old LHASH */
 /* Init a 'CONF' structure from an old LHASH */
 
 
-void CONF_set_nconf(CONF *conf, LHASH *hash)
+void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash)
 	{
 	{
 	if (default_CONF_method == NULL)
 	if (default_CONF_method == NULL)
 		default_CONF_method = NCONF_default();
 		default_CONF_method = NCONF_default();
@@ -87,9 +87,10 @@ int CONF_set_default_method(CONF_METHOD *meth)
 	return 1;
 	return 1;
 	}
 	}
 
 
-LHASH *CONF_load(LHASH *conf, const char *file, long *eline)
+LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
+				long *eline)
 	{
 	{
-	LHASH *ltmp;
+	LHASH_OF(CONF_VALUE) *ltmp;
 	BIO *in=NULL;
 	BIO *in=NULL;
 
 
 #ifdef OPENSSL_SYS_VMS
 #ifdef OPENSSL_SYS_VMS
@@ -110,10 +111,11 @@ LHASH *CONF_load(LHASH *conf, const char *file, long *eline)
 	}
 	}
 
 
 #ifndef OPENSSL_NO_FP_API
 #ifndef OPENSSL_NO_FP_API
-LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline)
+LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
+				   long *eline)
 	{
 	{
 	BIO *btmp;
 	BIO *btmp;
-	LHASH *ltmp;
+	LHASH_OF(CONF_VALUE) *ltmp;
 	if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) {
 	if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) {
 		CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB);
 		CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB);
 		return NULL;
 		return NULL;
@@ -124,7 +126,8 @@ LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline)
 	}
 	}
 #endif
 #endif
 
 
-LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline)
+LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,
+				    long *eline)
 	{
 	{
 	CONF ctmp;
 	CONF ctmp;
 	int ret;
 	int ret;
@@ -137,7 +140,8 @@ LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline)
 	return NULL;
 	return NULL;
 	}
 	}
 
 
-STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section)
+STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
+				       const char *section)
 	{
 	{
 	if (conf == NULL)
 	if (conf == NULL)
 		{
 		{
@@ -151,7 +155,8 @@ STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section)
 		}
 		}
 	}
 	}
 
 
-char *CONF_get_string(LHASH *conf,const char *group,const char *name)
+char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf,const char *group,
+		      const char *name)
 	{
 	{
 	if (conf == NULL)
 	if (conf == NULL)
 		{
 		{
@@ -165,7 +170,8 @@ char *CONF_get_string(LHASH *conf,const char *group,const char *name)
 		}
 		}
 	}
 	}
 
 
-long CONF_get_number(LHASH *conf,const char *group,const char *name)
+long CONF_get_number(LHASH_OF(CONF_VALUE) *conf,const char *group,
+		     const char *name)
 	{
 	{
 	int status;
 	int status;
 	long result = 0;
 	long result = 0;
@@ -189,7 +195,7 @@ long CONF_get_number(LHASH *conf,const char *group,const char *name)
 	return result;
 	return result;
 	}
 	}
 
 
-void CONF_free(LHASH *conf)
+void CONF_free(LHASH_OF(CONF_VALUE) *conf)
 	{
 	{
 	CONF ctmp;
 	CONF ctmp;
 	CONF_set_nconf(&ctmp, conf);
 	CONF_set_nconf(&ctmp, conf);
@@ -197,7 +203,7 @@ void CONF_free(LHASH *conf)
 	}
 	}
 
 
 #ifndef OPENSSL_NO_FP_API
 #ifndef OPENSSL_NO_FP_API
-int CONF_dump_fp(LHASH *conf, FILE *out)
+int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out)
 	{
 	{
 	BIO *btmp;
 	BIO *btmp;
 	int ret;
 	int ret;
@@ -212,7 +218,7 @@ int CONF_dump_fp(LHASH *conf, FILE *out)
 	}
 	}
 #endif
 #endif
 
 
-int CONF_dump_bio(LHASH *conf, BIO *out)
+int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out)
 	{
 	{
 	CONF ctmp;
 	CONF ctmp;
 	CONF_set_nconf(&ctmp, conf);
 	CONF_set_nconf(&ctmp, conf);

+ 30 - 21
crypto/engine/eng_table.c

@@ -70,10 +70,12 @@ typedef struct st_engine_pile
 	int uptodate;
 	int uptodate;
 	} ENGINE_PILE;
 	} ENGINE_PILE;
 
 
+DECLARE_LHASH_OF(ENGINE_PILE);
+
 /* The type exposed in eng_int.h */
 /* The type exposed in eng_int.h */
 struct st_engine_table
 struct st_engine_table
 	{
 	{
-	LHASH piles;
+	LHASH_OF(ENGINE_PILE) piles;
 	}; /* ENGINE_TABLE */
 	}; /* ENGINE_TABLE */
 
 
 
 
@@ -92,6 +94,7 @@ unsigned int ENGINE_get_table_flags(void)
 	{
 	{
 	return table_flags;
 	return table_flags;
 	}
 	}
+
 void ENGINE_set_table_flags(unsigned int flags)
 void ENGINE_set_table_flags(unsigned int flags)
 	{
 	{
 	table_flags = flags;
 	table_flags = flags;
@@ -102,19 +105,21 @@ static unsigned long engine_pile_hash(const ENGINE_PILE *c)
 	{
 	{
 	return c->nid;
 	return c->nid;
 	}
 	}
+
 static int engine_pile_cmp(const ENGINE_PILE *a, const ENGINE_PILE *b)
 static int engine_pile_cmp(const ENGINE_PILE *a, const ENGINE_PILE *b)
 	{
 	{
 	return a->nid - b->nid;
 	return a->nid - b->nid;
 	}
 	}
-static IMPLEMENT_LHASH_HASH_FN(engine_pile_hash, const ENGINE_PILE *)
-static IMPLEMENT_LHASH_COMP_FN(engine_pile_cmp, const ENGINE_PILE *)
+static IMPLEMENT_LHASH_HASH_FN(engine_pile, const ENGINE_PILE)
+static IMPLEMENT_LHASH_COMP_FN(engine_pile, const ENGINE_PILE)
+
 static int int_table_check(ENGINE_TABLE **t, int create)
 static int int_table_check(ENGINE_TABLE **t, int create)
 	{
 	{
-	LHASH *lh;
+	LHASH_OF(ENGINE_PILE) *lh;
+
 	if(*t) return 1;
 	if(*t) return 1;
 	if(!create) return 0;
 	if(!create) return 0;
-	if((lh = lh_new(LHASH_HASH_FN(engine_pile_hash),
-			LHASH_COMP_FN(engine_pile_cmp))) == NULL)
+	if((lh = lh_ENGINE_PILE_new()) == NULL)
 		return 0;
 		return 0;
 	*t = (ENGINE_TABLE *)lh;
 	*t = (ENGINE_TABLE *)lh;
 	return 1;
 	return 1;
@@ -138,7 +143,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
 	while(num_nids--)
 	while(num_nids--)
 		{
 		{
 		tmplate.nid = *nids;
 		tmplate.nid = *nids;
-		fnd = lh_retrieve(&(*table)->piles, &tmplate);
+		fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate);
 		if(!fnd)
 		if(!fnd)
 			{
 			{
 			fnd = OPENSSL_malloc(sizeof(ENGINE_PILE));
 			fnd = OPENSSL_malloc(sizeof(ENGINE_PILE));
@@ -152,7 +157,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
 				goto end;
 				goto end;
 				}
 				}
 			fnd->funct = NULL;
 			fnd->funct = NULL;
-			lh_insert(&(*table)->piles, fnd);
+			lh_ENGINE_PILE_insert(&(*table)->piles, fnd);
 			}
 			}
 		/* A registration shouldn't add duplciate entries */
 		/* A registration shouldn't add duplciate entries */
 		(void)sk_ENGINE_delete_ptr(fnd->sk, e);
 		(void)sk_ENGINE_delete_ptr(fnd->sk, e);
@@ -181,7 +186,7 @@ end:
 	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
 	return ret;
 	return ret;
 	}
 	}
-static void int_unregister_cb(ENGINE_PILE *pile, ENGINE *e)
+static void int_unregister_cb_doall_arg(ENGINE_PILE *pile, ENGINE *e)
 	{
 	{
 	int n;
 	int n;
 	/* Iterate the 'c->sk' stack removing any occurance of 'e' */
 	/* Iterate the 'c->sk' stack removing any occurance of 'e' */
@@ -196,31 +201,35 @@ static void int_unregister_cb(ENGINE_PILE *pile, ENGINE *e)
 		pile->funct = NULL;
 		pile->funct = NULL;
 		}
 		}
 	}
 	}
-static IMPLEMENT_LHASH_DOALL_ARG_FN(int_unregister_cb,ENGINE_PILE *,ENGINE *)
+static IMPLEMENT_LHASH_DOALL_ARG_FN(int_unregister_cb, ENGINE_PILE, ENGINE)
+
 void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e)
 void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e)
 	{
 	{
 	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
 	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
 	if(int_table_check(table, 0))
 	if(int_table_check(table, 0))
-		lh_doall_arg(&(*table)->piles,
-			LHASH_DOALL_ARG_FN(int_unregister_cb), e);
+		lh_ENGINE_PILE_doall_arg(&(*table)->piles,
+					 LHASH_DOALL_ARG_FN(int_unregister_cb),
+					 ENGINE, e);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
 	}
 	}
 
 
-static void int_cleanup_cb(ENGINE_PILE *p)
+static void int_cleanup_cb_doall(ENGINE_PILE *p)
 	{
 	{
 	sk_ENGINE_free(p->sk);
 	sk_ENGINE_free(p->sk);
 	if(p->funct)
 	if(p->funct)
 		engine_unlocked_finish(p->funct, 0);
 		engine_unlocked_finish(p->funct, 0);
 	OPENSSL_free(p);
 	OPENSSL_free(p);
 	}
 	}
-static IMPLEMENT_LHASH_DOALL_FN(int_cleanup_cb,ENGINE_PILE *)
+static IMPLEMENT_LHASH_DOALL_FN(int_cleanup_cb, ENGINE_PILE)
+
 void engine_table_cleanup(ENGINE_TABLE **table)
 void engine_table_cleanup(ENGINE_TABLE **table)
 	{
 	{
 	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
 	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
 	if(*table)
 	if(*table)
 		{
 		{
-		lh_doall(&(*table)->piles, LHASH_DOALL_FN(int_cleanup_cb));
-		lh_free(&(*table)->piles);
+		lh_ENGINE_PILE_doall(&(*table)->piles,
+				     LHASH_DOALL_FN(int_cleanup_cb));
+		lh_ENGINE_PILE_free(&(*table)->piles);
 		*table = NULL;
 		*table = NULL;
 		}
 		}
 	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
@@ -250,7 +259,7 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, in
 	 * operations. But don't worry about a fprintf(stderr). */
 	 * operations. But don't worry about a fprintf(stderr). */
 	if(!int_table_check(table, 0)) goto end;
 	if(!int_table_check(table, 0)) goto end;
 	tmplate.nid = nid;
 	tmplate.nid = nid;
-	fnd = lh_retrieve(&(*table)->piles, &tmplate);
+	fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate);
 	if(!fnd) goto end;
 	if(!fnd) goto end;
 	if(fnd->funct && engine_unlocked_init(fnd->funct))
 	if(fnd->funct && engine_unlocked_init(fnd->funct))
 		{
 		{
@@ -324,18 +333,18 @@ end:
 
 
 /* Table enumeration */
 /* Table enumeration */
 
 
-static void int_doall_cb(ENGINE_PILE *pile, ENGINE_PILE_DOALL *dall)
+static void int_cb_doall_arg(ENGINE_PILE *pile, ENGINE_PILE_DOALL *dall)
 	{
 	{
 	dall->cb(pile->nid, pile->sk, pile->funct, dall->arg);
 	dall->cb(pile->nid, pile->sk, pile->funct, dall->arg);
 	}
 	}
+static IMPLEMENT_LHASH_DOALL_ARG_FN(int_cb, ENGINE_PILE,ENGINE_PILE_DOALL)
 
 
-static IMPLEMENT_LHASH_DOALL_ARG_FN(int_doall_cb,ENGINE_PILE *,ENGINE_PILE_DOALL *)
 void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
 void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
 								void *arg)
 								void *arg)
 	{
 	{
 	ENGINE_PILE_DOALL dall;
 	ENGINE_PILE_DOALL dall;
 	dall.cb = cb;
 	dall.cb = cb;
 	dall.arg = arg;
 	dall.arg = arg;
-	lh_doall_arg(&table->piles,
-			LHASH_DOALL_ARG_FN(int_doall_cb), &dall);
+	lh_ENGINE_PILE_doall_arg(&table->piles, LHASH_DOALL_ARG_FN(int_cb),
+				 ENGINE_PILE_DOALL, &dall);
 	}
 	}

+ 65 - 71
crypto/err/err.c

@@ -119,6 +119,9 @@
 #include <openssl/bio.h>
 #include <openssl/bio.h>
 #include <openssl/err.h>
 #include <openssl/err.h>
 
 
+DECLARE_LHASH_OF(ERR_STRING_DATA);
+DECLARE_LHASH_OF(ERR_STATE);
+
 static void err_load_strings(int lib, ERR_STRING_DATA *str);
 static void err_load_strings(int lib, ERR_STRING_DATA *str);
 
 
 static void ERR_STATE_free(ERR_STATE *s);
 static void ERR_STATE_free(ERR_STATE *s);
@@ -223,14 +226,14 @@ static ERR_STRING_DATA ERR_str_reasons[]=
 struct st_ERR_FNS
 struct st_ERR_FNS
 	{
 	{
 	/* Works on the "error_hash" string table */
 	/* Works on the "error_hash" string table */
-	LHASH *(*cb_err_get)(int create);
+	LHASH_OF(ERR_STRING_DATA) *(*cb_err_get)(int create);
 	void (*cb_err_del)(void);
 	void (*cb_err_del)(void);
 	ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *);
 	ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *);
 	ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *);
 	ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *);
 	ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *);
 	ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *);
 	/* Works on the "thread_hash" error-state table */
 	/* Works on the "thread_hash" error-state table */
-	LHASH *(*cb_thread_get)(int create);
-	void (*cb_thread_release)(LHASH **hash);
+	LHASH_OF(ERR_STATE) *(*cb_thread_get)(int create);
+	void (*cb_thread_release)(LHASH_OF(ERR_STATE) **hash);
 	ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *);
 	ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *);
 	ERR_STATE *(*cb_thread_set_item)(ERR_STATE *);
 	ERR_STATE *(*cb_thread_set_item)(ERR_STATE *);
 	void (*cb_thread_del_item)(const ERR_STATE *);
 	void (*cb_thread_del_item)(const ERR_STATE *);
@@ -239,13 +242,13 @@ struct st_ERR_FNS
 	};
 	};
 
 
 /* Predeclarations of the "err_defaults" functions */
 /* Predeclarations of the "err_defaults" functions */
-static LHASH *int_err_get(int create);
+static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create);
 static void int_err_del(void);
 static void int_err_del(void);
 static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
 static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
 static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *);
 static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *);
 static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *);
 static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *);
-static LHASH *int_thread_get(int create);
-static void int_thread_release(LHASH **hash);
+static LHASH_OF(ERR_STATE) *int_thread_get(int create);
+static void int_thread_release(LHASH_OF(ERR_STATE) **hash);
 static ERR_STATE *int_thread_get_item(const ERR_STATE *);
 static ERR_STATE *int_thread_get_item(const ERR_STATE *);
 static ERR_STATE *int_thread_set_item(ERR_STATE *);
 static ERR_STATE *int_thread_set_item(ERR_STATE *);
 static void int_thread_del_item(const ERR_STATE *);
 static void int_thread_del_item(const ERR_STATE *);
@@ -277,8 +280,8 @@ static const ERR_FNS *err_fns = NULL;
  * "err_defaults" functions. This way, a linked module can completely defer all
  * "err_defaults" functions. This way, a linked module can completely defer all
  * ERR state operation (together with requisite locking) to the implementations
  * ERR state operation (together with requisite locking) to the implementations
  * and state in the loading application. */
  * and state in the loading application. */
-static LHASH *int_error_hash = NULL;
-static LHASH *int_thread_hash = NULL;
+static LHASH_OF(ERR_STRING_DATA) *int_error_hash = NULL;
+static LHASH_OF(ERR_STATE) *int_thread_hash = NULL;
 static int int_thread_hash_references = 0;
 static int int_thread_hash_references = 0;
 static int int_err_library_number= ERR_LIB_USER;
 static int int_err_library_number= ERR_LIB_USER;
 
 
@@ -321,28 +324,37 @@ int ERR_set_implementation(const ERR_FNS *fns)
 /* These are the callbacks provided to "lh_new()" when creating the LHASH tables
 /* These are the callbacks provided to "lh_new()" when creating the LHASH tables
  * internal to the "err_defaults" implementation. */
  * internal to the "err_defaults" implementation. */
 
 
-/* static unsigned long err_hash(ERR_STRING_DATA *a); */
-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(const void *a_void, const void *b_void);
-/* static unsigned long pid_hash(ERR_STATE *pid); */
-static unsigned long pid_hash(const void *pid_void);
-/* static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); */
-static int pid_cmp(const void *a_void,const void *pid_void);
 static unsigned long get_error_values(int inc,int top,const char **file,int *line,
 static unsigned long get_error_values(int inc,int top,const char **file,int *line,
 				      const char **data,int *flags);
 				      const char **data,int *flags);
 
 
 /* The internal functions used in the "err_defaults" implementation */
 /* The internal functions used in the "err_defaults" implementation */
 
 
-static LHASH *int_err_get(int create)
+static unsigned long err_string_data_hash(const ERR_STRING_DATA *a)
 	{
 	{
-	LHASH *ret = NULL;
+	unsigned long ret,l;
+
+	l=a->error;
+	ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
+	return(ret^ret%19*13);
+	}
+static IMPLEMENT_LHASH_HASH_FN(err_string_data, ERR_STRING_DATA);
+
+static int err_string_data_cmp(const ERR_STRING_DATA *a,
+			       const ERR_STRING_DATA *b)
+	{
+	return (int)(a->error - b->error);
+	}
+static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA);
+
+static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create)
+	{
+	LHASH_OF(ERR_STRING_DATA) *ret = NULL;
 
 
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
 	if (!int_error_hash && create)
 	if (!int_error_hash && create)
 		{
 		{
 		CRYPTO_push_info("int_err_get (err.c)");
 		CRYPTO_push_info("int_err_get (err.c)");
-		int_error_hash = lh_new(err_hash, err_cmp);
+		int_error_hash = lh_ERR_STRING_DATA_new();
 		CRYPTO_pop_info();
 		CRYPTO_pop_info();
 		}
 		}
 	if (int_error_hash)
 	if (int_error_hash)
@@ -357,7 +369,7 @@ static void int_err_del(void)
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
 	if (int_error_hash)
 	if (int_error_hash)
 		{
 		{
-		lh_free(int_error_hash);
+		lh_ERR_STRING_DATA_free(int_error_hash);
 		int_error_hash = NULL;
 		int_error_hash = NULL;
 		}
 		}
 	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
@@ -366,7 +378,7 @@ static void int_err_del(void)
 static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
 static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
 	{
 	{
 	ERR_STRING_DATA *p;
 	ERR_STRING_DATA *p;
-	LHASH *hash;
+	LHASH_OF(ERR_STRING_DATA) *hash;
 
 
 	err_fns_check();
 	err_fns_check();
 	hash = ERRFN(err_get)(0);
 	hash = ERRFN(err_get)(0);
@@ -374,7 +386,7 @@ static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
 		return NULL;
 		return NULL;
 
 
 	CRYPTO_r_lock(CRYPTO_LOCK_ERR);
 	CRYPTO_r_lock(CRYPTO_LOCK_ERR);
-	p = (ERR_STRING_DATA *)lh_retrieve(hash, d);
+	p = lh_ERR_STRING_DATA_retrieve(hash, d);
 	CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
 	CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
 
 
 	return p;
 	return p;
@@ -383,7 +395,7 @@ static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
 static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d)
 static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d)
 	{
 	{
 	ERR_STRING_DATA *p;
 	ERR_STRING_DATA *p;
-	LHASH *hash;
+	LHASH_OF(ERR_STRING_DATA) *hash;
 
 
 	err_fns_check();
 	err_fns_check();
 	hash = ERRFN(err_get)(1);
 	hash = ERRFN(err_get)(1);
@@ -391,7 +403,7 @@ static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d)
 		return NULL;
 		return NULL;
 
 
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
-	p = (ERR_STRING_DATA *)lh_insert(hash, d);
+	p = lh_ERR_STRING_DATA_insert(hash, d);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
 
 
 	return p;
 	return p;
@@ -400,7 +412,7 @@ static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d)
 static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
 static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
 	{
 	{
 	ERR_STRING_DATA *p;
 	ERR_STRING_DATA *p;
-	LHASH *hash;
+	LHASH_OF(ERR_STRING_DATA) *hash;
 
 
 	err_fns_check();
 	err_fns_check();
 	hash = ERRFN(err_get)(0);
 	hash = ERRFN(err_get)(0);
@@ -408,21 +420,33 @@ static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
 		return NULL;
 		return NULL;
 
 
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
-	p = (ERR_STRING_DATA *)lh_delete(hash, d);
+	p = lh_ERR_STRING_DATA_delete(hash, d);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
 
 
 	return p;
 	return p;
 	}
 	}
 
 
-static LHASH *int_thread_get(int create)
+static unsigned long err_state_hash(const ERR_STATE *a)
+	{
+	return CRYPTO_THREADID_hash(&a->tid);
+	}
+static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE);
+
+static int err_state_cmp(const ERR_STATE *a, const ERR_STATE *b)
+	{
+	return CRYPTO_THREADID_cmp(&a->tid, &b->tid);
+	}
+static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE);
+
+static LHASH_OF(ERR_STATE) *int_thread_get(int create)
 	{
 	{
-	LHASH *ret = NULL;
+	LHASH_OF(ERR_STATE) *ret = NULL;
 
 
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
 	if (!int_thread_hash && create)
 	if (!int_thread_hash && create)
 		{
 		{
 		CRYPTO_push_info("int_thread_get (err.c)");
 		CRYPTO_push_info("int_thread_get (err.c)");
-		int_thread_hash = lh_new(pid_hash, pid_cmp);
+		int_thread_hash = lh_ERR_STATE_new();
 		CRYPTO_pop_info();
 		CRYPTO_pop_info();
 		}
 		}
 	if (int_thread_hash)
 	if (int_thread_hash)
@@ -434,7 +458,7 @@ static LHASH *int_thread_get(int create)
 	return ret;
 	return ret;
 	}
 	}
 
 
-static void int_thread_release(LHASH **hash)
+static void int_thread_release(LHASH_OF(ERR_STATE) **hash)
 	{
 	{
 	int i;
 	int i;
 
 
@@ -460,7 +484,7 @@ static void int_thread_release(LHASH **hash)
 static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
 static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
 	{
 	{
 	ERR_STATE *p;
 	ERR_STATE *p;
-	LHASH *hash;
+	LHASH_OF(ERR_STATE) *hash;
 
 
 	err_fns_check();
 	err_fns_check();
 	hash = ERRFN(thread_get)(0);
 	hash = ERRFN(thread_get)(0);
@@ -468,7 +492,7 @@ static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
 		return NULL;
 		return NULL;
 
 
 	CRYPTO_r_lock(CRYPTO_LOCK_ERR);
 	CRYPTO_r_lock(CRYPTO_LOCK_ERR);
-	p = (ERR_STATE *)lh_retrieve(hash, d);
+	p = lh_ERR_STATE_retrieve(hash, d);
 	CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
 	CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
 
 
 	ERRFN(thread_release)(&hash);
 	ERRFN(thread_release)(&hash);
@@ -478,7 +502,7 @@ static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
 static ERR_STATE *int_thread_set_item(ERR_STATE *d)
 static ERR_STATE *int_thread_set_item(ERR_STATE *d)
 	{
 	{
 	ERR_STATE *p;
 	ERR_STATE *p;
-	LHASH *hash;
+	LHASH_OF(ERR_STATE) *hash;
 
 
 	err_fns_check();
 	err_fns_check();
 	hash = ERRFN(thread_get)(1);
 	hash = ERRFN(thread_get)(1);
@@ -486,7 +510,7 @@ static ERR_STATE *int_thread_set_item(ERR_STATE *d)
 		return NULL;
 		return NULL;
 
 
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
-	p = (ERR_STATE *)lh_insert(hash, d);
+	p = lh_ERR_STATE_insert(hash, d);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
 
 
 	ERRFN(thread_release)(&hash);
 	ERRFN(thread_release)(&hash);
@@ -496,7 +520,7 @@ static ERR_STATE *int_thread_set_item(ERR_STATE *d)
 static void int_thread_del_item(const ERR_STATE *d)
 static void int_thread_del_item(const ERR_STATE *d)
 	{
 	{
 	ERR_STATE *p;
 	ERR_STATE *p;
-	LHASH *hash;
+	LHASH_OF(ERR_STATE) *hash;
 
 
 	err_fns_check();
 	err_fns_check();
 	hash = ERRFN(thread_get)(0);
 	hash = ERRFN(thread_get)(0);
@@ -504,12 +528,12 @@ static void int_thread_del_item(const ERR_STATE *d)
 		return;
 		return;
 
 
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
-	p = (ERR_STATE *)lh_delete(hash, d);
+	p = lh_ERR_STATE_delete(hash, d);
 	/* make sure we don't leak memory */
 	/* make sure we don't leak memory */
 	if (int_thread_hash_references == 1
 	if (int_thread_hash_references == 1
-		&& int_thread_hash && (lh_num_items(int_thread_hash) == 0))
+	    && int_thread_hash && lh_ERR_STATE_num_items(int_thread_hash) == 0)
 		{
 		{
-		lh_free(int_thread_hash);
+		lh_ERR_STATE_free(int_thread_hash);
 		int_thread_hash = NULL;
 		int_thread_hash = NULL;
 		}
 		}
 	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
 	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
@@ -894,19 +918,19 @@ char *ERR_error_string(unsigned long e, char *ret)
 	return ret;
 	return ret;
 	}
 	}
 
 
-LHASH *ERR_get_string_table(void)
+LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void)
 	{
 	{
 	err_fns_check();
 	err_fns_check();
 	return ERRFN(err_get)(0);
 	return ERRFN(err_get)(0);
 	}
 	}
 
 
-LHASH *ERR_get_err_state_table(void)
+LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void)
 	{
 	{
 	err_fns_check();
 	err_fns_check();
 	return ERRFN(thread_get)(0);
 	return ERRFN(thread_get)(0);
 	}
 	}
 
 
-void ERR_release_err_state_table(LHASH **hash)
+void ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash)
 	{
 	{
 	err_fns_check();
 	err_fns_check();
 	ERRFN(thread_release)(hash);
 	ERRFN(thread_release)(hash);
@@ -955,36 +979,6 @@ const char *ERR_reason_error_string(unsigned long e)
 	return((p == NULL)?NULL:p->string);
 	return((p == NULL)?NULL:p->string);
 	}
 	}
 
 
-/* static unsigned long err_hash(ERR_STRING_DATA *a) */
-static unsigned long err_hash(const void *a_void)
-	{
-	unsigned long ret,l;
-
-	l=((const ERR_STRING_DATA *)a_void)->error;
-	ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
-	return(ret^ret%19*13);
-	}
-
-/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) */
-static int err_cmp(const void *a_void, const void *b_void)
-	{
-	return((int)(((const ERR_STRING_DATA *)a_void)->error -
-			((const ERR_STRING_DATA *)b_void)->error));
-	}
-
-/* static unsigned long pid_hash(ERR_STATE *a) */
-static unsigned long pid_hash(const void *a_void)
-	{
-	return CRYPTO_THREADID_hash(&((const ERR_STATE *)a_void)->tid);
-	}
-
-/* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */
-static int pid_cmp(const void *a_void, const void *b_void)
-	{
-	return CRYPTO_THREADID_cmp(&((const ERR_STATE *)a_void)->tid,
-				&((const ERR_STATE *)b_void)->tid);
-	}
-
 void ERR_remove_thread_state(CRYPTO_THREADID *tid)
 void ERR_remove_thread_state(CRYPTO_THREADID *tid)
 	{
 	{
 	ERR_STATE tmp;
 	ERR_STATE tmp;

+ 3 - 3
crypto/err/err.h

@@ -358,9 +358,9 @@ void ERR_remove_state(unsigned long pid); /* if zero we look it up */
 ERR_STATE *ERR_get_state(void);
 ERR_STATE *ERR_get_state(void);
 
 
 #ifndef OPENSSL_NO_LHASH
 #ifndef OPENSSL_NO_LHASH
-LHASH *ERR_get_string_table(void);
-LHASH *ERR_get_err_state_table(void);
-void ERR_release_err_state_table(LHASH **hash);
+LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void);
+LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void);
+void ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash);
 #endif
 #endif
 
 
 int ERR_get_next_error_library(void);
 int ERR_get_next_error_library(void);

+ 15 - 11
crypto/ex_data.c

@@ -245,18 +245,21 @@ typedef struct st_ex_class_item {
 static int ex_class = CRYPTO_EX_INDEX_USER;
 static int ex_class = CRYPTO_EX_INDEX_USER;
 
 
 /* The global hash table of EX_CLASS_ITEM items */
 /* The global hash table of EX_CLASS_ITEM items */
-static LHASH *ex_data = NULL;
+DECLARE_LHASH_OF(EX_CLASS_ITEM);
+static LHASH_OF(EX_CLASS_ITEM) *ex_data = NULL;
 
 
 /* The callbacks required in the "ex_data" hash table */
 /* The callbacks required in the "ex_data" hash table */
-static unsigned long ex_hash_cb(const void *a_void)
+static unsigned long ex_class_item_hash(const EX_CLASS_ITEM *a)
 	{
 	{
-	return ((const EX_CLASS_ITEM *)a_void)->class_index;
+	return a->class_index;
 	}
 	}
-static int ex_cmp_cb(const void *a_void, const void *b_void)
+static IMPLEMENT_LHASH_HASH_FN(ex_class_item, EX_CLASS_ITEM);
+
+static int ex_class_item_cmp(const EX_CLASS_ITEM *a, const EX_CLASS_ITEM *b)
 	{
 	{
-	return (((const EX_CLASS_ITEM *)a_void)->class_index -
-		((const EX_CLASS_ITEM *)b_void)->class_index);
+	return a->class_index - b->class_index;
 	}
 	}
+static IMPLEMENT_LHASH_COMP_FN(ex_class_item, EX_CLASS_ITEM);
 
 
 /* Internal functions used by the "impl_default" implementation to access the
 /* Internal functions used by the "impl_default" implementation to access the
  * state */
  * state */
@@ -265,7 +268,8 @@ static int ex_data_check(void)
 	{
 	{
 	int toret = 1;
 	int toret = 1;
 	CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
 	CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
-	if(!ex_data && ((ex_data = lh_new(ex_hash_cb, ex_cmp_cb)) == NULL))
+	if(!ex_data
+	   && (ex_data = lh_EX_CLASS_ITEM_new()) == NULL)
 		toret = 0;
 		toret = 0;
 	CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
 	CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
 	return toret;
 	return toret;
@@ -298,7 +302,7 @@ static EX_CLASS_ITEM *def_get_class(int class_index)
 	EX_DATA_CHECK(return NULL;)
 	EX_DATA_CHECK(return NULL;)
 	d.class_index = class_index;
 	d.class_index = class_index;
 	CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
 	CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
-	p = lh_retrieve(ex_data, &d);
+	p = lh_EX_CLASS_ITEM_retrieve(ex_data, &d);
 	if(!p)
 	if(!p)
 		{
 		{
 		gen = OPENSSL_malloc(sizeof(EX_CLASS_ITEM));
 		gen = OPENSSL_malloc(sizeof(EX_CLASS_ITEM));
@@ -313,7 +317,7 @@ static EX_CLASS_ITEM *def_get_class(int class_index)
 				{
 				{
 				/* Because we're inside the ex_data lock, the
 				/* Because we're inside the ex_data lock, the
 				 * return value from the insert will be NULL */
 				 * return value from the insert will be NULL */
-				lh_insert(ex_data, gen);
+				lh_EX_CLASS_ITEM_insert(ex_data, gen);
 				p = gen;
 				p = gen;
 				}
 				}
 			}
 			}
@@ -375,8 +379,8 @@ static int int_new_class(void)
 static void int_cleanup(void)
 static void int_cleanup(void)
 	{
 	{
 	EX_DATA_CHECK(return;)
 	EX_DATA_CHECK(return;)
-	lh_doall(ex_data, def_cleanup_cb);
-	lh_free(ex_data);
+	lh_EX_CLASS_ITEM_doall(ex_data, def_cleanup_cb);
+	lh_EX_CLASS_ITEM_free(ex_data);
 	ex_data = NULL;
 	ex_data = NULL;
 	impl = NULL;
 	impl = NULL;
 	}
 	}

+ 6 - 6
crypto/lhash/lh_stats.c

@@ -139,7 +139,7 @@ void lh_node_usage_stats(LHASH *lh, FILE *out)
 #else
 #else
 
 
 #ifndef OPENSSL_NO_FP_API
 #ifndef OPENSSL_NO_FP_API
-void lh_stats(const LHASH *lh, FILE *fp)
+void lh_stats(const _LHASH *lh, FILE *fp)
 	{
 	{
 	BIO *bp;
 	BIO *bp;
 
 
@@ -151,7 +151,7 @@ void lh_stats(const LHASH *lh, FILE *fp)
 end:;
 end:;
 	}
 	}
 
 
-void lh_node_stats(const LHASH *lh, FILE *fp)
+void lh_node_stats(const _LHASH *lh, FILE *fp)
 	{
 	{
 	BIO *bp;
 	BIO *bp;
 
 
@@ -163,7 +163,7 @@ void lh_node_stats(const LHASH *lh, FILE *fp)
 end:;
 end:;
 	}
 	}
 
 
-void lh_node_usage_stats(const LHASH *lh, FILE *fp)
+void lh_node_usage_stats(const _LHASH *lh, FILE *fp)
 	{
 	{
 	BIO *bp;
 	BIO *bp;
 
 
@@ -177,7 +177,7 @@ end:;
 
 
 #endif
 #endif
 
 
-void lh_stats_bio(const LHASH *lh, BIO *out)
+void lh_stats_bio(const _LHASH *lh, BIO *out)
 	{
 	{
 	BIO_printf(out,"num_items             = %lu\n",lh->num_items);
 	BIO_printf(out,"num_items             = %lu\n",lh->num_items);
 	BIO_printf(out,"num_nodes             = %u\n",lh->num_nodes);
 	BIO_printf(out,"num_nodes             = %u\n",lh->num_nodes);
@@ -205,7 +205,7 @@ void lh_stats_bio(const LHASH *lh, BIO *out)
 #endif
 #endif
 	}
 	}
 
 
-void lh_node_stats_bio(const LHASH *lh, BIO *out)
+void lh_node_stats_bio(const _LHASH *lh, BIO *out)
 	{
 	{
 	LHASH_NODE *n;
 	LHASH_NODE *n;
 	unsigned int i,num;
 	unsigned int i,num;
@@ -218,7 +218,7 @@ void lh_node_stats_bio(const LHASH *lh, BIO *out)
 		}
 		}
 	}
 	}
 
 
-void lh_node_usage_stats_bio(const LHASH *lh, BIO *out)
+void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out)
 	{
 	{
 	LHASH_NODE *n;
 	LHASH_NODE *n;
 	unsigned long num;
 	unsigned long num;

+ 20 - 18
crypto/lhash/lhash.c

@@ -107,18 +107,18 @@ const char lh_version[]="lhash" OPENSSL_VERSION_PTEXT;
 #define UP_LOAD		(2*LH_LOAD_MULT) /* load times 256  (default 2) */
 #define UP_LOAD		(2*LH_LOAD_MULT) /* load times 256  (default 2) */
 #define DOWN_LOAD	(LH_LOAD_MULT)   /* load times 256  (default 1) */
 #define DOWN_LOAD	(LH_LOAD_MULT)   /* load times 256  (default 1) */
 
 
-static void expand(LHASH *lh);
-static void contract(LHASH *lh);
-static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash);
+static void expand(_LHASH *lh);
+static void contract(_LHASH *lh);
+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)
 	{
 	{
-	LHASH *ret;
+	_LHASH *ret;
 	int i;
 	int i;
 
 
-	if ((ret=(LHASH *)OPENSSL_malloc(sizeof(LHASH))) == NULL)
+	if ((ret=OPENSSL_malloc(sizeof(_LHASH))) == NULL)
 		goto err0;
 		goto err0;
-	if ((ret->b=(LHASH_NODE **)OPENSSL_malloc(sizeof(LHASH_NODE *)*MIN_NODES)) == NULL)
+	if ((ret->b=OPENSSL_malloc(sizeof(LHASH_NODE *)*MIN_NODES)) == NULL)
 		goto err1;
 		goto err1;
 	for (i=0; i<MIN_NODES; i++)
 	for (i=0; i<MIN_NODES; i++)
 		ret->b[i]=NULL;
 		ret->b[i]=NULL;
@@ -154,7 +154,7 @@ err0:
 	return(NULL);
 	return(NULL);
 	}
 	}
 
 
-void lh_free(LHASH *lh)
+void lh_free(_LHASH *lh)
 	{
 	{
 	unsigned int i;
 	unsigned int i;
 	LHASH_NODE *n,*nn;
 	LHASH_NODE *n,*nn;
@@ -176,7 +176,7 @@ void lh_free(LHASH *lh)
 	OPENSSL_free(lh);
 	OPENSSL_free(lh);
 	}
 	}
 
 
-void *lh_insert(LHASH *lh, void *data)
+void *lh_insert(_LHASH *lh, void *data)
 	{
 	{
 	unsigned long hash;
 	unsigned long hash;
 	LHASH_NODE *nn,**rn;
 	LHASH_NODE *nn,**rn;
@@ -214,7 +214,7 @@ void *lh_insert(LHASH *lh, void *data)
 	return(ret);
 	return(ret);
 	}
 	}
 
 
-void *lh_delete(LHASH *lh, const void *data)
+void *lh_delete(_LHASH *lh, const void *data)
 	{
 	{
 	unsigned long hash;
 	unsigned long hash;
 	LHASH_NODE *nn,**rn;
 	LHASH_NODE *nn,**rn;
@@ -245,7 +245,7 @@ void *lh_delete(LHASH *lh, const void *data)
 	return(ret);
 	return(ret);
 	}
 	}
 
 
-void *lh_retrieve(LHASH *lh, const void *data)
+void *lh_retrieve(_LHASH *lh, const void *data)
 	{
 	{
 	unsigned long hash;
 	unsigned long hash;
 	LHASH_NODE **rn;
 	LHASH_NODE **rn;
@@ -267,7 +267,7 @@ void *lh_retrieve(LHASH *lh, const void *data)
 	return(ret);
 	return(ret);
 	}
 	}
 
 
-static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
+static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
 			  LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
 			  LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
 	{
 	{
 	int i;
 	int i;
@@ -285,6 +285,8 @@ static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
 			{
 			{
 			/* 28/05/91 - eay - n added so items can be deleted
 			/* 28/05/91 - eay - n added so items can be deleted
 			 * via lh_doall */
 			 * via lh_doall */
+			/* 22/05/08 - ben - eh? since a is not passed,
+			 * this should not be needed */
 			n=a->next;
 			n=a->next;
 			if(use_arg)
 			if(use_arg)
 				func_arg(a->data,arg);
 				func_arg(a->data,arg);
@@ -295,17 +297,17 @@ static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
 		}
 		}
 	}
 	}
 
 
-void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func)
+void lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func)
 	{
 	{
 	doall_util_fn(lh, 0, func, (LHASH_DOALL_ARG_FN_TYPE)0, NULL);
 	doall_util_fn(lh, 0, func, (LHASH_DOALL_ARG_FN_TYPE)0, 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, void *arg)
 	{
 	{
 	doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);
 	doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);
 	}
 	}
 
 
-static void expand(LHASH *lh)
+static void expand(_LHASH *lh)
 	{
 	{
 	LHASH_NODE **n,**n1,**n2,*np;
 	LHASH_NODE **n,**n1,**n2,*np;
 	unsigned int p,i,j;
 	unsigned int p,i,j;
@@ -361,7 +363,7 @@ static void expand(LHASH *lh)
 		}
 		}
 	}
 	}
 
 
-static void contract(LHASH *lh)
+static void contract(_LHASH *lh)
 	{
 	{
 	LHASH_NODE **n,*n1,*np;
 	LHASH_NODE **n,*n1,*np;
 
 
@@ -400,7 +402,7 @@ static void contract(LHASH *lh)
 		}
 		}
 	}
 	}
 
 
-static LHASH_NODE **getrn(LHASH *lh, const 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;
@@ -467,7 +469,7 @@ unsigned long lh_strhash(const char *c)
 	return((ret>>16)^ret);
 	return((ret>>16)^ret);
 	}
 	}
 
 
-unsigned long lh_num_items(const LHASH *lh)
+unsigned long lh_num_items(const _LHASH *lh)
 	{
 	{
 	return lh ? lh->num_items : 0;
 	return lh ? lh->num_items : 0;
 	}
 	}

+ 103 - 45
crypto/lhash/lhash.h

@@ -98,42 +98,42 @@ typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *);
  * macros if the functions are strictly internal. */
  * macros if the functions are strictly internal. */
 
 
 /* First: "hash" functions */
 /* First: "hash" functions */
-#define DECLARE_LHASH_HASH_FN(f_name,o_type) \
-	unsigned long f_name##_LHASH_HASH(const void *);
-#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \
-	unsigned long f_name##_LHASH_HASH(const void *arg) { \
-		o_type a = (o_type)arg; \
-		return f_name(a); }
-#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH
+#define DECLARE_LHASH_HASH_FN(name, o_type) \
+	unsigned long name##_LHASH_HASH(const void *);
+#define IMPLEMENT_LHASH_HASH_FN(name, o_type) \
+	unsigned long name##_LHASH_HASH(const void *arg) { \
+		const o_type *a = arg; \
+		return name##_hash(a); }
+#define LHASH_HASH_FN(name) name##_LHASH_HASH
 
 
 /* Second: "compare" functions */
 /* Second: "compare" functions */
-#define DECLARE_LHASH_COMP_FN(f_name,o_type) \
-	int f_name##_LHASH_COMP(const void *, const void *);
-#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \
-	int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \
-		o_type a = (o_type)arg1; \
-		o_type b = (o_type)arg2; \
-		return f_name(a,b); }
-#define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP
+#define DECLARE_LHASH_COMP_FN(name, o_type) \
+	int name##_LHASH_COMP(const void *, const void *);
+#define IMPLEMENT_LHASH_COMP_FN(name, o_type) \
+	int name##_LHASH_COMP(const void *arg1, const void *arg2) { \
+		const o_type *a = arg1;		    \
+		const o_type *b = arg2; \
+		return name##_cmp(a,b); }
+#define LHASH_COMP_FN(name) name##_LHASH_COMP
 
 
 /* Third: "doall" functions */
 /* Third: "doall" functions */
-#define DECLARE_LHASH_DOALL_FN(f_name,o_type) \
-	void f_name##_LHASH_DOALL(void *);
-#define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \
-	void f_name##_LHASH_DOALL(void *arg) { \
-		o_type a = (o_type)arg; \
-		f_name(a); }
-#define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL
+#define DECLARE_LHASH_DOALL_FN(name, o_type) \
+	void name##_LHASH_DOALL(void *);
+#define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \
+	void name##_LHASH_DOALL(void *arg) { \
+		o_type *a = arg; \
+		name##_doall(a); }
+#define LHASH_DOALL_FN(name) name##_LHASH_DOALL
 
 
 /* Fourth: "doall_arg" functions */
 /* Fourth: "doall_arg" functions */
-#define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
-	void f_name##_LHASH_DOALL_ARG(void *, void *);
-#define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
-	void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
-		o_type a = (o_type)arg1; \
-		a_type b = (a_type)arg2; \
-		f_name(a,b); }
-#define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG
+#define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
+	void name##_LHASH_DOALL_ARG(void *, void *);
+#define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
+	void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
+		o_type *a = arg1; \
+		a_type *b = arg2; \
+		name##_doall_arg(a, b); }
+#define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG
 
 
 typedef struct lhash_st
 typedef struct lhash_st
 	{
 	{
@@ -163,7 +163,8 @@ typedef struct lhash_st
 	unsigned long num_hash_comps;
 	unsigned long num_hash_comps;
 
 
 	int error;
 	int error;
-	} LHASH;
+	} _LHASH;	/* Do not use _LHASH directly, use LHASH_OF
+			 * and friends */
 
 
 #define LH_LOAD_MULT	256
 #define LH_LOAD_MULT	256
 
 
@@ -171,27 +172,84 @@ typedef struct lhash_st
  * in lh_insert(). */
  * in lh_insert(). */
 #define lh_error(lh)	((lh)->error)
 #define lh_error(lh)	((lh)->error)
 
 
-LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
-void lh_free(LHASH *lh);
-void *lh_insert(LHASH *lh, void *data);
-void *lh_delete(LHASH *lh, const void *data);
-void *lh_retrieve(LHASH *lh, const void *data);
-void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func);
-void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
+_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
+void lh_free(_LHASH *lh);
+void *lh_insert(_LHASH *lh, void *data);
+void *lh_delete(_LHASH *lh, const void *data);
+void *lh_retrieve(_LHASH *lh, const void *data);
+void lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func);
+void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, 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);
 
 
 #ifndef OPENSSL_NO_FP_API
 #ifndef OPENSSL_NO_FP_API
-void lh_stats(const LHASH *lh, FILE *out);
-void lh_node_stats(const LHASH *lh, FILE *out);
-void lh_node_usage_stats(const LHASH *lh, FILE *out);
+void lh_stats(const _LHASH *lh, FILE *out);
+void lh_node_stats(const _LHASH *lh, FILE *out);
+void lh_node_usage_stats(const _LHASH *lh, FILE *out);
 #endif
 #endif
 
 
 #ifndef OPENSSL_NO_BIO
 #ifndef OPENSSL_NO_BIO
-void lh_stats_bio(const LHASH *lh, BIO *out);
-void lh_node_stats_bio(const LHASH *lh, BIO *out);
-void lh_node_usage_stats_bio(const LHASH *lh, BIO *out);
+void lh_stats_bio(const _LHASH *lh, BIO *out);
+void lh_node_stats_bio(const _LHASH *lh, BIO *out);
+void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);
 #endif
 #endif
+
+// Type checking...
+
+#define LHASH_OF(type) struct lhash_st_##type
+
+#define DECLARE_LHASH_OF(type) LHASH_OF(type) { }
+
+#define CHECKED_LHASH_OF(type,lh) \
+  ((_LHASH *)CHECKED_PTR_OF(LHASH_OF(type),lh))
+
+// Define wrapper functions.
+#define LHM_lh_new(type, name) \
+  ((LHASH_OF(type) *)lh_new(LHASH_HASH_FN(name), LHASH_COMP_FN(name)))
+#define LHM_lh_error(type, lh) \
+  lh_error(CHECKED_LHASH_OF(type,lh))
+#define LHM_lh_insert(type, lh, inst) \
+  ((type *)lh_insert(CHECKED_LHASH_OF(type, lh), \
+		     CHECKED_PTR_OF(type, inst)))
+#define LHM_lh_retrieve(type, lh, inst) \
+  ((type *)lh_retrieve(CHECKED_LHASH_OF(type, lh), \
+		       CHECKED_PTR_OF(type, inst)))
+#define LHM_lh_delete(type, lh, inst) \
+  ((type *)lh_delete(CHECKED_LHASH_OF(type, lh),			\
+		     CHECKED_PTR_OF(type, inst)))
+#define LHM_lh_doall(type, lh,fn) lh_doall(CHECKED_LHASH_OF(type, lh), fn)
+#define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \
+  lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg))
+#define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh))
+#define LHM_lh_down_load(type, lh) (CHECKED_LHASH_OF(type, lh)->down_load)
+#define LHM_lh_node_stats_bio(type, lh, out) \
+  lh_node_stats_bio(CHECKED_LHASH_OF(type, lh), out)
+#define LHM_lh_node_usage_stats_bio(type, lh, out) \
+  lh_node_usage_stats_bio(CHECKED_LHASH_OF(type, lh), out)
+#define LHM_lh_stats_bio(type, lh, out) \
+  lh_stats_bio(CHECKED_LHASH_OF(type, lh), out)
+#define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh))
+
+
+/* Strings are special: normally an lhash entry will point to a single
+ * (somewhat) mutable object. In the case of strings:
+ *
+ * a) Instead of a single char, there is an array of chars, NUL-terminated.
+ * b) The string may have be immutable.
+ *
+ * So, they need their own declarations. Especially important for
+ * type-checking tools, such as Deputy.
+ *
+ * In practice, however, it appears to be hard to have a const
+ * string. For now, I'm settling for dealing with the fact it is a
+ * string at all.
+ */
+typedef char *STRING;
+DECLARE_LHASH_OF(STRING);
+
+typedef const char *CSTRING;
+DECLARE_LHASH_OF(CSTRING);
+
 #ifdef  __cplusplus
 #ifdef  __cplusplus
 }
 }
 #endif
 #endif

+ 46 - 39
crypto/mem_dbg.c

@@ -134,8 +134,11 @@ static int mh_mode=CRYPTO_MEM_CHECK_OFF;
  */
  */
 
 
 static unsigned long order = 0; /* number of memory requests */
 static unsigned long order = 0; /* number of memory requests */
-static LHASH *mh=NULL; /* hash-table of memory requests (address as key);
-                        * access requires MALLOC2 lock */
+
+DECLARE_LHASH_OF(MEM);
+static LHASH_OF(MEM) *mh=NULL; /* hash-table of memory requests
+				* (address as key); access requires
+				* MALLOC2 lock */
 
 
 
 
 typedef struct app_mem_info_st
 typedef struct app_mem_info_st
@@ -157,10 +160,13 @@ typedef struct app_mem_info_st
 
 
 static void app_info_free(APP_INFO *);
 static void app_info_free(APP_INFO *);
 
 
-static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's
-                          * that are at the top of their thread's stack
-                          * (with `thread' as key);
-                          * access requires MALLOC2 lock */
+DECLARE_LHASH_OF(APP_INFO);
+static LHASH_OF(APP_INFO) *amih=NULL; /* hash-table with those
+				       * app_mem_info_st's that are at
+				       * the top of their thread's
+				       * stack (with `thread' as key);
+				       * access requires MALLOC2
+				       * lock */
 
 
 typedef struct mem_st
 typedef struct mem_st
 /* memory-block description */
 /* memory-block description */
@@ -306,31 +312,30 @@ long CRYPTO_dbg_get_options(void)
 	return options;
 	return options;
 	}
 	}
 
 
-/* static int mem_cmp(MEM *a, MEM *b) */
-static int mem_cmp(const void *a_void, const void *b_void)
+static int mem_cmp(const MEM *a, const MEM *b)
 	{
 	{
 #ifdef _WIN64
 #ifdef _WIN64
-	const char *a=(const char *)((const MEM *)a_void)->addr,
-		   *b=(const char *)((const MEM *)b_void)->addr;
+	const char *a=(const char *)a->addr,
+		   *b=(const char *)b->addr;
 	if (a==b)	return 0;
 	if (a==b)	return 0;
 	else if (a>b)	return 1;
 	else if (a>b)	return 1;
 	else		return -1;
 	else		return -1;
 #else
 #else
-	return((const char *)((const MEM *)a_void)->addr
-		- (const char *)((const MEM *)b_void)->addr);
+	return (const char *)a->addr - (const char *)b->addr;
 #endif
 #endif
 	}
 	}
+static IMPLEMENT_LHASH_COMP_FN(mem, MEM)
 
 
-/* static unsigned long mem_hash(MEM *a) */
-static unsigned long mem_hash(const void *a_void)
+static unsigned long mem_hash(const MEM *a)
 	{
 	{
 	unsigned long ret;
 	unsigned long ret;
 
 
-	ret=(unsigned long)((const MEM *)a_void)->addr;
+	ret=(unsigned long)a->addr;
 
 
 	ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
 	ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
 	return(ret);
 	return(ret);
 	}
 	}
+static IMPLEMENT_LHASH_HASH_FN(mem, MEM)
 
 
 /* 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(const void *a_void, const void *b_void)
 static int app_info_cmp(const void *a_void, const void *b_void)
@@ -338,15 +343,16 @@ static int app_info_cmp(const void *a_void, const void *b_void)
 	return CRYPTO_THREADID_cmp(&((const APP_INFO *)a_void)->threadid,
 	return CRYPTO_THREADID_cmp(&((const APP_INFO *)a_void)->threadid,
 				&((const APP_INFO *)b_void)->threadid);
 				&((const APP_INFO *)b_void)->threadid);
 	}
 	}
+static IMPLEMENT_LHASH_COMP_FN(app_info, APP_INFO)
 
 
-/* static unsigned long app_info_hash(APP_INFO *a) */
-static unsigned long app_info_hash(const void *a_void)
+static unsigned long app_info_hash(const APP_INFO *a)
 	{
 	{
 	unsigned long ret;
 	unsigned long ret;
-	ret = CRYPTO_THREADID_hash(&((const APP_INFO *)a_void)->threadid);
+	ret = CRYPTO_THREADID_hash(&a->threadid);
 	ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
 	ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
 	return(ret);
 	return(ret);
 	}
 	}
+static IMPLEMENT_LHASH_HASH_FN(app_info, APP_INFO)
 
 
 static APP_INFO *pop_info(void)
 static APP_INFO *pop_info(void)
 	{
 	{
@@ -356,14 +362,14 @@ static APP_INFO *pop_info(void)
 	if (amih != NULL)
 	if (amih != NULL)
 		{
 		{
 		CRYPTO_THREADID_set(&tmp.threadid);
 		CRYPTO_THREADID_set(&tmp.threadid);
-		if ((ret=(APP_INFO *)lh_delete(amih,&tmp)) != NULL)
+		if ((ret=lh_APP_INFO_delete(amih,&tmp)) != NULL)
 			{
 			{
 			APP_INFO *next=ret->next;
 			APP_INFO *next=ret->next;
 
 
 			if (next != NULL)
 			if (next != NULL)
 				{
 				{
 				next->references++;
 				next->references++;
-				lh_insert(amih,(char *)next);
+				lh_APP_INFO_insert(amih,next);
 				}
 				}
 #ifdef LEVITTE_DEBUG_MEM
 #ifdef LEVITTE_DEBUG_MEM
 			if (CRYPTO_THREADID_cmp(&ret->threadid, &tmp.threadid))
 			if (CRYPTO_THREADID_cmp(&ret->threadid, &tmp.threadid))
@@ -402,7 +408,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
 			}
 			}
 		if (amih == NULL)
 		if (amih == NULL)
 			{
 			{
-			if ((amih=lh_new(app_info_hash, app_info_cmp)) == NULL)
+			if ((amih=lh_APP_INFO_new()) == NULL)
 				{
 				{
 				OPENSSL_free(ami);
 				OPENSSL_free(ami);
 				ret=0;
 				ret=0;
@@ -417,7 +423,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
 		ami->references=1;
 		ami->references=1;
 		ami->next=NULL;
 		ami->next=NULL;
 
 
-		if ((amim=(APP_INFO *)lh_insert(amih,(char *)ami)) != NULL)
+		if ((amim=lh_APP_INFO_insert(amih,ami)) != NULL)
 			{
 			{
 #ifdef LEVITTE_DEBUG_MEM
 #ifdef LEVITTE_DEBUG_MEM
 			if (CRYPTO_THREADID_cmp(&ami->threadid, &amim->threadid))
 			if (CRYPTO_THREADID_cmp(&ami->threadid, &amim->threadid))
@@ -496,7 +502,7 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
 				}
 				}
 			if (mh == NULL)
 			if (mh == NULL)
 				{
 				{
-				if ((mh=lh_new(mem_hash, mem_cmp)) == NULL)
+				if ((mh=lh_MEM_new()) == NULL)
 					{
 					{
 					OPENSSL_free(addr);
 					OPENSSL_free(addr);
 					OPENSSL_free(m);
 					OPENSSL_free(m);
@@ -531,13 +537,13 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
 			CRYPTO_THREADID_set(&m->threadid);
 			CRYPTO_THREADID_set(&m->threadid);
 			m->app_info=NULL;
 			m->app_info=NULL;
 			if (amih != NULL
 			if (amih != NULL
-				&& (amim=(APP_INFO *)lh_retrieve(amih,(char *)&tmp)) != NULL)
+			    && (amim=lh_APP_INFO_retrieve(amih,&tmp)) != NULL)
 				{
 				{
 				m->app_info = amim;
 				m->app_info = amim;
 				amim->references++;
 				amim->references++;
 				}
 				}
 
 
-			if ((mm=(MEM *)lh_insert(mh,(char *)m)) != NULL)
+			if ((mm=lh_MEM_insert(mh, m)) != NULL)
 				{
 				{
 				/* Not good, but don't sweat it */
 				/* Not good, but don't sweat it */
 				if (mm->app_info != NULL)
 				if (mm->app_info != NULL)
@@ -570,7 +576,7 @@ void CRYPTO_dbg_free(void *addr, int before_p)
 			MemCheck_off(); /* make sure we hold MALLOC2 lock */
 			MemCheck_off(); /* make sure we hold MALLOC2 lock */
 
 
 			m.addr=addr;
 			m.addr=addr;
-			mp=(MEM *)lh_delete(mh,(char *)&m);
+			mp=lh_MEM_delete(mh,&m);
 			if (mp != NULL)
 			if (mp != NULL)
 				{
 				{
 #ifdef LEVITTE_DEBUG_MEM
 #ifdef LEVITTE_DEBUG_MEM
@@ -620,7 +626,7 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
 			MemCheck_off(); /* make sure we hold MALLOC2 lock */
 			MemCheck_off(); /* make sure we hold MALLOC2 lock */
 
 
 			m.addr=addr1;
 			m.addr=addr1;
-			mp=(MEM *)lh_delete(mh,(char *)&m);
+			mp=lh_MEM_delete(mh,&m);
 			if (mp != NULL)
 			if (mp != NULL)
 				{
 				{
 #ifdef LEVITTE_DEBUG_MEM
 #ifdef LEVITTE_DEBUG_MEM
@@ -631,7 +637,7 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
 #endif
 #endif
 				mp->addr=addr2;
 				mp->addr=addr2;
 				mp->num=num;
 				mp->num=num;
-				lh_insert(mh,(char *)mp);
+				lh_MEM_insert(mh,mp);
 				}
 				}
 
 
 			MemCheck_on(); /* release MALLOC2 lock
 			MemCheck_on(); /* release MALLOC2 lock
@@ -650,7 +656,7 @@ typedef struct mem_leak_st
 	long bytes;
 	long bytes;
 	} MEM_LEAK;
 	} MEM_LEAK;
 
 
-static void print_leak(const MEM *m, MEM_LEAK *l)
+static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
 	{
 	{
 	char buf[1024];
 	char buf[1024];
 	char *bufp = buf;
 	char *bufp = buf;
@@ -739,7 +745,7 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
 #endif
 #endif
 	}
 	}
 
 
-static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM *, MEM_LEAK *)
+static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM, MEM_LEAK)
 
 
 void CRYPTO_mem_leaks(BIO *b)
 void CRYPTO_mem_leaks(BIO *b)
 	{
 	{
@@ -754,8 +760,8 @@ void CRYPTO_mem_leaks(BIO *b)
 	ml.bytes=0;
 	ml.bytes=0;
 	ml.chunks=0;
 	ml.chunks=0;
 	if (mh != NULL)
 	if (mh != NULL)
-		lh_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak),
-				(char *)&ml);
+		lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak), MEM_LEAK,
+				 &ml);
 	if (ml.chunks != 0)
 	if (ml.chunks != 0)
 		{
 		{
 		BIO_printf(b,"%ld bytes leaked in %d chunks\n",
 		BIO_printf(b,"%ld bytes leaked in %d chunks\n",
@@ -789,14 +795,14 @@ void CRYPTO_mem_leaks(BIO *b)
 
 
 		if (mh != NULL)
 		if (mh != NULL)
 			{
 			{
-			lh_free(mh);
+			lh_MEM_free(mh);
 			mh = NULL;
 			mh = NULL;
 			}
 			}
 		if (amih != NULL)
 		if (amih != NULL)
 			{
 			{
-			if (lh_num_items(amih) == 0) 
+			if (lh_APP_INFO_num_items(amih) == 0) 
 				{
 				{
-				lh_free(amih);
+				lh_APP_INFO_free(amih);
 				amih = NULL;
 				amih = NULL;
 				}
 				}
 			}
 			}
@@ -834,17 +840,18 @@ void CRYPTO_mem_leaks_fp(FILE *fp)
 /* NB: The prototypes have been typedef'd to CRYPTO_MEM_LEAK_CB inside crypto.h
 /* NB: The prototypes have been typedef'd to CRYPTO_MEM_LEAK_CB inside crypto.h
  * If this code is restructured, remove the callback type if it is no longer
  * If this code is restructured, remove the callback type if it is no longer
  * needed. -- Geoff Thorpe */
  * needed. -- Geoff Thorpe */
-static void cb_leak(const MEM *m, CRYPTO_MEM_LEAK_CB **cb)
+static void cb_leak_doall_arg(const MEM *m, CRYPTO_MEM_LEAK_CB *cb)
 	{
 	{
-	(**cb)(m->order,m->file,m->line,m->num,m->addr);
+	cb(m->order,m->file,m->line,m->num,m->addr);
 	}
 	}
 
 
-static IMPLEMENT_LHASH_DOALL_ARG_FN(cb_leak, const MEM *, CRYPTO_MEM_LEAK_CB **)
+static IMPLEMENT_LHASH_DOALL_ARG_FN(cb_leak, const MEM, CRYPTO_MEM_LEAK_CB)
 
 
 void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb)
 void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb)
 	{
 	{
 	if (mh == NULL) return;
 	if (mh == NULL) return;
 	CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
 	CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
-	lh_doall_arg(mh, LHASH_DOALL_ARG_FN(cb_leak), &cb);
+	lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(cb_leak), CRYPTO_MEM_LEAK_CB,
+			 cb);
 	CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
 	CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
 	}
 	}

+ 25 - 22
crypto/objects/o_names.c

@@ -22,7 +22,8 @@
 /* I use the ex_data stuff to manage the identifiers for the obj_name_types
 /* 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.
  * that applications may define.  I only really use the free function field.
  */
  */
-static LHASH *names_lh=NULL;
+DECLARE_LHASH_OF(OBJ_NAME);
+static LHASH_OF(OBJ_NAME) *names_lh=NULL;
 static int names_type_num=OBJ_NAME_TYPE_NUM;
 static int names_type_num=OBJ_NAME_TYPE_NUM;
 
 
 typedef struct name_funcs_st
 typedef struct name_funcs_st
@@ -46,11 +47,14 @@ 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(const void *a_void,const void *b_void);
 static int obj_name_cmp(const void *a_void,const void *b_void);
 
 
+static IMPLEMENT_LHASH_HASH_FN(obj_name, OBJ_NAME)
+static IMPLEMENT_LHASH_COMP_FN(obj_name, OBJ_NAME)
+
 int OBJ_NAME_init(void)
 int OBJ_NAME_init(void)
 	{
 	{
 	if (names_lh != NULL) return(1);
 	if (names_lh != NULL) return(1);
 	MemCheck_off();
 	MemCheck_off();
-	names_lh=lh_new(obj_name_hash, obj_name_cmp);
+	names_lh=lh_OBJ_NAME_new();
 	MemCheck_on();
 	MemCheck_on();
 	return(names_lh != NULL);
 	return(names_lh != NULL);
 	}
 	}
@@ -164,7 +168,7 @@ const char *OBJ_NAME_get(const char *name, int type)
 
 
 	for (;;)
 	for (;;)
 	{
 	{
-		ret=(OBJ_NAME *)lh_retrieve(names_lh,&on);
+		ret=lh_OBJ_NAME_retrieve(names_lh,&on);
 		if (ret == NULL) return(NULL);
 		if (ret == NULL) return(NULL);
 		if ((ret->alias) && !alias)
 		if ((ret->alias) && !alias)
 			{
 			{
@@ -200,7 +204,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
 	onp->type=type;
 	onp->type=type;
 	onp->data=data;
 	onp->data=data;
 
 
-	ret=(OBJ_NAME *)lh_insert(names_lh,onp);
+	ret=lh_OBJ_NAME_insert(names_lh,onp);
 	if (ret != NULL)
 	if (ret != NULL)
 		{
 		{
 		/* free things */
 		/* free things */
@@ -217,7 +221,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
 		}
 		}
 	else
 	else
 		{
 		{
-		if (lh_error(names_lh))
+		if (lh_OBJ_NAME_error(names_lh))
 			{
 			{
 			/* ERROR */
 			/* ERROR */
 			return(0);
 			return(0);
@@ -235,7 +239,7 @@ int OBJ_NAME_remove(const char *name, int type)
 	type&= ~OBJ_NAME_ALIAS;
 	type&= ~OBJ_NAME_ALIAS;
 	on.name=name;
 	on.name=name;
 	on.type=type;
 	on.type=type;
-	ret=(OBJ_NAME *)lh_delete(names_lh,&on);
+	ret=lh_OBJ_NAME_delete(names_lh,&on);
 	if (ret != NULL)
 	if (ret != NULL)
 		{
 		{
 		/* free things */
 		/* free things */
@@ -262,13 +266,13 @@ struct doall
 	void *arg;
 	void *arg;
 	};
 	};
 
 
-static void do_all_fn(const OBJ_NAME *name,struct doall *d)
+static void do_all_fn_doall_arg(const OBJ_NAME *name,struct doall *d)
 	{
 	{
 	if(name->type == d->type)
 	if(name->type == d->type)
 		d->fn(name,d->arg);
 		d->fn(name,d->arg);
 	}
 	}
 
 
-static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME *, struct doall *)
+static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME, struct doall)
 
 
 void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
 void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
 	{
 	{
@@ -278,7 +282,8 @@ void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
 	d.fn=fn;
 	d.fn=fn;
 	d.arg=arg;
 	d.arg=arg;
 
 
-	lh_doall_arg(names_lh,LHASH_DOALL_ARG_FN(do_all_fn),&d);
+	lh_OBJ_NAME_doall_arg(names_lh, LHASH_DOALL_ARG_FN(do_all_fn),
+			      struct doall, &d);
 	}
 	}
 
 
 struct doall_sorted
 struct doall_sorted
@@ -313,7 +318,7 @@ void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
 	int n;
 	int n;
 
 
 	d.type=type;
 	d.type=type;
-	d.names=OPENSSL_malloc(lh_num_items(names_lh)*sizeof *d.names);
+	d.names=OPENSSL_malloc(lh_OBJ_NAME_num_items(names_lh)*sizeof *d.names);
 	d.n=0;
 	d.n=0;
 	OBJ_NAME_do_all(type,do_all_sorted_fn,&d);
 	OBJ_NAME_do_all(type,do_all_sorted_fn,&d);
 
 
@@ -327,18 +332,16 @@ void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
 
 
 static int free_type;
 static int free_type;
 
 
-static void names_lh_free(OBJ_NAME *onp)
-{
-	if(onp == NULL)
+static void names_lh_free_doall(OBJ_NAME *onp)
+	{
+	if (onp == NULL)
 		return;
 		return;
 
 
-	if ((free_type < 0) || (free_type == onp->type))
-		{
+	if (free_type < 0 || free_type == onp->type)
 		OBJ_NAME_remove(onp->name,onp->type);
 		OBJ_NAME_remove(onp->name,onp->type);
-		}
 	}
 	}
 
 
-static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME *)
+static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME)
 
 
 static void name_funcs_free(NAME_FUNCS *ptr)
 static void name_funcs_free(NAME_FUNCS *ptr)
 	{
 	{
@@ -352,18 +355,18 @@ void OBJ_NAME_cleanup(int type)
 	if (names_lh == NULL) return;
 	if (names_lh == NULL) return;
 
 
 	free_type=type;
 	free_type=type;
-	down_load=names_lh->down_load;
-	names_lh->down_load=0;
+	down_load=lh_OBJ_NAME_down_load(names_lh);
+	lh_OBJ_NAME_down_load(names_lh)=0;
 
 
-	lh_doall(names_lh,LHASH_DOALL_FN(names_lh_free));
+	lh_OBJ_NAME_doall(names_lh,LHASH_DOALL_FN(names_lh_free));
 	if (type < 0)
 	if (type < 0)
 		{
 		{
-		lh_free(names_lh);
+		lh_OBJ_NAME_free(names_lh);
 		sk_NAME_FUNCS_pop_free(name_funcs_stack,name_funcs_free);
 		sk_NAME_FUNCS_pop_free(name_funcs_stack,name_funcs_free);
 		names_lh=NULL;
 		names_lh=NULL;
 		name_funcs_stack = NULL;
 		name_funcs_stack = NULL;
 		}
 		}
 	else
 	else
-		names_lh->down_load=down_load;
+		lh_OBJ_NAME_down_load(names_lh)=down_load;
 	}
 	}
 
 

+ 25 - 27
crypto/objects/obj_dat.c

@@ -94,9 +94,10 @@ typedef struct added_obj_st
 	int type;
 	int type;
 	ASN1_OBJECT *obj;
 	ASN1_OBJECT *obj;
 	} ADDED_OBJ;
 	} ADDED_OBJ;
+DECLARE_LHASH_OF(ADDED_OBJ);
 
 
 static int new_nid=NUM_NID;
 static int new_nid=NUM_NID;
-static LHASH *added=NULL;
+static LHASH_OF(ADDED_OBJ) *added=NULL;
 
 
 static int sn_cmp(const void *a, const void *b)
 static int sn_cmp(const void *a, const void *b)
 	{
 	{
@@ -112,14 +113,12 @@ static int ln_cmp(const void *a, const void *b)
 	return(strcmp((*ap)->ln,nid_objs[*bp].ln));
 	return(strcmp((*ap)->ln,nid_objs[*bp].ln));
 	}
 	}
 
 
-/* static unsigned long add_hash(ADDED_OBJ *ca) */
-static unsigned long add_hash(const void *ca_void)
+static unsigned long added_obj_hash(const ADDED_OBJ *ca)
 	{
 	{
 	const 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;
-	const ADDED_OBJ *ca = (const ADDED_OBJ *)ca_void;
 
 
 	a=ca->obj;
 	a=ca->obj;
 	switch (ca->type)
 	switch (ca->type)
@@ -147,14 +146,12 @@ static unsigned long add_hash(const void *ca_void)
 	ret|=ca->type<<30L;
 	ret|=ca->type<<30L;
 	return(ret);
 	return(ret);
 	}
 	}
+static IMPLEMENT_LHASH_HASH_FN(added_obj, ADDED_OBJ)
 
 
-/* static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) */
-static int add_cmp(const void *ca_void, const void *cb_void)
+static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb)
 	{
 	{
 	ASN1_OBJECT *a,*b;
 	ASN1_OBJECT *a,*b;
 	int i;
 	int i;
-	const ADDED_OBJ *ca = (const ADDED_OBJ *)ca_void;
-	const ADDED_OBJ *cb = (const ADDED_OBJ *)cb_void;
 
 
 	i=ca->type-cb->type;
 	i=ca->type-cb->type;
 	if (i) return(i);
 	if (i) return(i);
@@ -181,15 +178,16 @@ static int add_cmp(const void *ca_void, const void *cb_void)
 		return 0;
 		return 0;
 		}
 		}
 	}
 	}
+static IMPLEMENT_LHASH_COMP_FN(added_obj, ADDED_OBJ)
 
 
 static int init_added(void)
 static int init_added(void)
 	{
 	{
 	if (added != NULL) return(1);
 	if (added != NULL) return(1);
-	added=lh_new(add_hash,add_cmp);
+	added=lh_ADDED_OBJ_new();
 	return(added != NULL);
 	return(added != NULL);
 	}
 	}
 
 
-static void cleanup1(ADDED_OBJ *a)
+static void cleanup1_doall(ADDED_OBJ *a)
 	{
 	{
 	a->obj->nid=0;
 	a->obj->nid=0;
 	a->obj->flags|=ASN1_OBJECT_FLAG_DYNAMIC|
 	a->obj->flags|=ASN1_OBJECT_FLAG_DYNAMIC|
@@ -197,19 +195,19 @@ static void cleanup1(ADDED_OBJ *a)
 			ASN1_OBJECT_FLAG_DYNAMIC_DATA;
 			ASN1_OBJECT_FLAG_DYNAMIC_DATA;
 	}
 	}
 
 
-static void cleanup2(ADDED_OBJ *a)
+static void cleanup2_doall(ADDED_OBJ *a)
 	{ a->obj->nid++; }
 	{ a->obj->nid++; }
 
 
-static void cleanup3(ADDED_OBJ *a)
+static void cleanup3_doall(ADDED_OBJ *a)
 	{
 	{
 	if (--a->obj->nid == 0)
 	if (--a->obj->nid == 0)
 		ASN1_OBJECT_free(a->obj);
 		ASN1_OBJECT_free(a->obj);
 	OPENSSL_free(a);
 	OPENSSL_free(a);
 	}
 	}
 
 
-static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ *)
-static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ *)
-static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ *)
+static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ)
+static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ)
+static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ)
 
 
 /* The purpose of obj_cleanup_defer is to avoid EVP_cleanup() attempting
 /* The purpose of obj_cleanup_defer is to avoid EVP_cleanup() attempting
  * to use freed up OIDs. If neccessary the actual freeing up of OIDs is
  * to use freed up OIDs. If neccessary the actual freeing up of OIDs is
@@ -232,11 +230,11 @@ void OBJ_cleanup(void)
 		return ;
 		return ;
 		}
 		}
 	if (added == NULL) return;
 	if (added == NULL) return;
-	added->down_load=0;
-	lh_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */
-	lh_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */
-	lh_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */
-	lh_free(added);
+	lh_ADDED_OBJ_down_load(added) = 0;
+	lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */
+	lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */
+	lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */
+	lh_ADDED_OBJ_free(added);
 	added=NULL;
 	added=NULL;
 	}
 	}
 
 
@@ -272,7 +270,7 @@ int OBJ_add_object(const ASN1_OBJECT *obj)
 			{
 			{
 			ao[i]->type=i;
 			ao[i]->type=i;
 			ao[i]->obj=o;
 			ao[i]->obj=o;
-			aop=(ADDED_OBJ *)lh_insert(added,ao[i]);
+			aop=lh_ADDED_OBJ_insert(added,ao[i]);
 			/* memory leak, buit should not normally matter */
 			/* memory leak, buit should not normally matter */
 			if (aop != NULL)
 			if (aop != NULL)
 				OPENSSL_free(aop);
 				OPENSSL_free(aop);
@@ -312,7 +310,7 @@ ASN1_OBJECT *OBJ_nid2obj(int n)
 		ad.type=ADDED_NID;
 		ad.type=ADDED_NID;
 		ad.obj= &ob;
 		ad.obj= &ob;
 		ob.nid=n;
 		ob.nid=n;
-		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
+		adp=lh_ADDED_OBJ_retrieve(added,&ad);
 		if (adp != NULL)
 		if (adp != NULL)
 			return(adp->obj);
 			return(adp->obj);
 		else
 		else
@@ -344,7 +342,7 @@ const char *OBJ_nid2sn(int n)
 		ad.type=ADDED_NID;
 		ad.type=ADDED_NID;
 		ad.obj= &ob;
 		ad.obj= &ob;
 		ob.nid=n;
 		ob.nid=n;
-		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
+		adp=lh_ADDED_OBJ_retrieve(added,&ad);
 		if (adp != NULL)
 		if (adp != NULL)
 			return(adp->obj->sn);
 			return(adp->obj->sn);
 		else
 		else
@@ -376,7 +374,7 @@ const char *OBJ_nid2ln(int n)
 		ad.type=ADDED_NID;
 		ad.type=ADDED_NID;
 		ad.obj= &ob;
 		ad.obj= &ob;
 		ob.nid=n;
 		ob.nid=n;
-		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
+		adp=lh_ADDED_OBJ_retrieve(added,&ad);
 		if (adp != NULL)
 		if (adp != NULL)
 			return(adp->obj->ln);
 			return(adp->obj->ln);
 		else
 		else
@@ -401,7 +399,7 @@ int OBJ_obj2nid(const ASN1_OBJECT *a)
 		{
 		{
 		ad.type=ADDED_DATA;
 		ad.type=ADDED_DATA;
 		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
 		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
-		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
+		adp=lh_ADDED_OBJ_retrieve(added,&ad);
 		if (adp != NULL) return (adp->obj->nid);
 		if (adp != NULL) return (adp->obj->nid);
 		}
 		}
 	op=(const unsigned int *)OBJ_bsearch((const char *)&a,(const char *)obj_objs,
 	op=(const unsigned int *)OBJ_bsearch((const char *)&a,(const char *)obj_objs,
@@ -636,7 +634,7 @@ int OBJ_ln2nid(const char *s)
 		{
 		{
 		ad.type=ADDED_LNAME;
 		ad.type=ADDED_LNAME;
 		ad.obj= &o;
 		ad.obj= &o;
-		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
+		adp=lh_ADDED_OBJ_retrieve(added,&ad);
 		if (adp != NULL) return (adp->obj->nid);
 		if (adp != NULL) return (adp->obj->nid);
 		}
 		}
 	op=(const unsigned int*)OBJ_bsearch((char *)&oo,(char *)ln_objs, NUM_LN,
 	op=(const unsigned int*)OBJ_bsearch((char *)&oo,(char *)ln_objs, NUM_LN,
@@ -656,7 +654,7 @@ int OBJ_sn2nid(const char *s)
 		{
 		{
 		ad.type=ADDED_SNAME;
 		ad.type=ADDED_SNAME;
 		ad.obj= &o;
 		ad.obj= &o;
-		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
+		adp=lh_ADDED_OBJ_retrieve(added,&ad);
 		if (adp != NULL) return (adp->obj->nid);
 		if (adp != NULL) return (adp->obj->nid);
 		}
 		}
 	op=(const unsigned int *)OBJ_bsearch((char *)&oo,(char *)sn_objs,NUM_SN,
 	op=(const unsigned int *)OBJ_bsearch((char *)&oo,(char *)sn_objs,NUM_SN,

+ 234 - 0
crypto/stack/safestack.h

@@ -2118,6 +2118,240 @@ STACK_OF(type) \
 
 
 #define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \
 #define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \
 	SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))
 	SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))
+
+#define lh_ADDED_OBJ_new() LHM_lh_new(ADDED_OBJ,added_obj)
+#define lh_ADDED_OBJ_insert(lh,inst) LHM_lh_insert(ADDED_OBJ,lh,inst)
+#define lh_ADDED_OBJ_retrieve(lh,inst) LHM_lh_retrieve(ADDED_OBJ,lh,inst)
+#define lh_ADDED_OBJ_delete(lh,inst) LHM_lh_delete(ADDED_OBJ,lh,inst)
+#define lh_ADDED_OBJ_doall(lh,fn) LHM_lh_doall(ADDED_OBJ,lh,fn)
+#define lh_ADDED_OBJ_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(ADDED_OBJ,lh,fn,arg_type,arg)
+#define lh_ADDED_OBJ_error(lh) LHM_lh_error(ADDED_OBJ,lh)
+#define lh_ADDED_OBJ_num_items(lh) LHM_lh_num_items(ADDED_OBJ,lh)
+#define lh_ADDED_OBJ_down_load(lh) LHM_lh_down_load(ADDED_OBJ,lh)
+#define lh_ADDED_OBJ_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(ADDED_OBJ,lh,out)
+#define lh_ADDED_OBJ_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(ADDED_OBJ,lh,out)
+#define lh_ADDED_OBJ_stats_bio(lh,out) \
+  LHM_lh_stats_bio(ADDED_OBJ,lh,out)
+#define lh_ADDED_OBJ_free(lh) LHM_lh_free(ADDED_OBJ,lh)
+
+#define lh_APP_INFO_new() LHM_lh_new(APP_INFO,app_info)
+#define lh_APP_INFO_insert(lh,inst) LHM_lh_insert(APP_INFO,lh,inst)
+#define lh_APP_INFO_retrieve(lh,inst) LHM_lh_retrieve(APP_INFO,lh,inst)
+#define lh_APP_INFO_delete(lh,inst) LHM_lh_delete(APP_INFO,lh,inst)
+#define lh_APP_INFO_doall(lh,fn) LHM_lh_doall(APP_INFO,lh,fn)
+#define lh_APP_INFO_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(APP_INFO,lh,fn,arg_type,arg)
+#define lh_APP_INFO_error(lh) LHM_lh_error(APP_INFO,lh)
+#define lh_APP_INFO_num_items(lh) LHM_lh_num_items(APP_INFO,lh)
+#define lh_APP_INFO_down_load(lh) LHM_lh_down_load(APP_INFO,lh)
+#define lh_APP_INFO_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(APP_INFO,lh,out)
+#define lh_APP_INFO_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(APP_INFO,lh,out)
+#define lh_APP_INFO_stats_bio(lh,out) \
+  LHM_lh_stats_bio(APP_INFO,lh,out)
+#define lh_APP_INFO_free(lh) LHM_lh_free(APP_INFO,lh)
+
+#define lh_CONF_VALUE_new() LHM_lh_new(CONF_VALUE,conf_value)
+#define lh_CONF_VALUE_insert(lh,inst) LHM_lh_insert(CONF_VALUE,lh,inst)
+#define lh_CONF_VALUE_retrieve(lh,inst) LHM_lh_retrieve(CONF_VALUE,lh,inst)
+#define lh_CONF_VALUE_delete(lh,inst) LHM_lh_delete(CONF_VALUE,lh,inst)
+#define lh_CONF_VALUE_doall(lh,fn) LHM_lh_doall(CONF_VALUE,lh,fn)
+#define lh_CONF_VALUE_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(CONF_VALUE,lh,fn,arg_type,arg)
+#define lh_CONF_VALUE_error(lh) LHM_lh_error(CONF_VALUE,lh)
+#define lh_CONF_VALUE_num_items(lh) LHM_lh_num_items(CONF_VALUE,lh)
+#define lh_CONF_VALUE_down_load(lh) LHM_lh_down_load(CONF_VALUE,lh)
+#define lh_CONF_VALUE_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(CONF_VALUE,lh,out)
+#define lh_CONF_VALUE_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(CONF_VALUE,lh,out)
+#define lh_CONF_VALUE_stats_bio(lh,out) \
+  LHM_lh_stats_bio(CONF_VALUE,lh,out)
+#define lh_CONF_VALUE_free(lh) LHM_lh_free(CONF_VALUE,lh)
+
+#define lh_CSTRING_new() LHM_lh_new(CSTRING,cstring)
+#define lh_CSTRING_insert(lh,inst) LHM_lh_insert(CSTRING,lh,inst)
+#define lh_CSTRING_retrieve(lh,inst) LHM_lh_retrieve(CSTRING,lh,inst)
+#define lh_CSTRING_delete(lh,inst) LHM_lh_delete(CSTRING,lh,inst)
+#define lh_CSTRING_doall(lh,fn) LHM_lh_doall(CSTRING,lh,fn)
+#define lh_CSTRING_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(CSTRING,lh,fn,arg_type,arg)
+#define lh_CSTRING_error(lh) LHM_lh_error(CSTRING,lh)
+#define lh_CSTRING_num_items(lh) LHM_lh_num_items(CSTRING,lh)
+#define lh_CSTRING_down_load(lh) LHM_lh_down_load(CSTRING,lh)
+#define lh_CSTRING_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(CSTRING,lh,out)
+#define lh_CSTRING_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(CSTRING,lh,out)
+#define lh_CSTRING_stats_bio(lh,out) \
+  LHM_lh_stats_bio(CSTRING,lh,out)
+#define lh_CSTRING_free(lh) LHM_lh_free(CSTRING,lh)
+
+#define lh_ENGINE_PILE_new() LHM_lh_new(ENGINE_PILE,engine_pile)
+#define lh_ENGINE_PILE_insert(lh,inst) LHM_lh_insert(ENGINE_PILE,lh,inst)
+#define lh_ENGINE_PILE_retrieve(lh,inst) LHM_lh_retrieve(ENGINE_PILE,lh,inst)
+#define lh_ENGINE_PILE_delete(lh,inst) LHM_lh_delete(ENGINE_PILE,lh,inst)
+#define lh_ENGINE_PILE_doall(lh,fn) LHM_lh_doall(ENGINE_PILE,lh,fn)
+#define lh_ENGINE_PILE_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(ENGINE_PILE,lh,fn,arg_type,arg)
+#define lh_ENGINE_PILE_error(lh) LHM_lh_error(ENGINE_PILE,lh)
+#define lh_ENGINE_PILE_num_items(lh) LHM_lh_num_items(ENGINE_PILE,lh)
+#define lh_ENGINE_PILE_down_load(lh) LHM_lh_down_load(ENGINE_PILE,lh)
+#define lh_ENGINE_PILE_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(ENGINE_PILE,lh,out)
+#define lh_ENGINE_PILE_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(ENGINE_PILE,lh,out)
+#define lh_ENGINE_PILE_stats_bio(lh,out) \
+  LHM_lh_stats_bio(ENGINE_PILE,lh,out)
+#define lh_ENGINE_PILE_free(lh) LHM_lh_free(ENGINE_PILE,lh)
+
+#define lh_ERR_STATE_new() LHM_lh_new(ERR_STATE,err_state)
+#define lh_ERR_STATE_insert(lh,inst) LHM_lh_insert(ERR_STATE,lh,inst)
+#define lh_ERR_STATE_retrieve(lh,inst) LHM_lh_retrieve(ERR_STATE,lh,inst)
+#define lh_ERR_STATE_delete(lh,inst) LHM_lh_delete(ERR_STATE,lh,inst)
+#define lh_ERR_STATE_doall(lh,fn) LHM_lh_doall(ERR_STATE,lh,fn)
+#define lh_ERR_STATE_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(ERR_STATE,lh,fn,arg_type,arg)
+#define lh_ERR_STATE_error(lh) LHM_lh_error(ERR_STATE,lh)
+#define lh_ERR_STATE_num_items(lh) LHM_lh_num_items(ERR_STATE,lh)
+#define lh_ERR_STATE_down_load(lh) LHM_lh_down_load(ERR_STATE,lh)
+#define lh_ERR_STATE_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(ERR_STATE,lh,out)
+#define lh_ERR_STATE_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(ERR_STATE,lh,out)
+#define lh_ERR_STATE_stats_bio(lh,out) \
+  LHM_lh_stats_bio(ERR_STATE,lh,out)
+#define lh_ERR_STATE_free(lh) LHM_lh_free(ERR_STATE,lh)
+
+#define lh_ERR_STRING_DATA_new() LHM_lh_new(ERR_STRING_DATA,err_string_data)
+#define lh_ERR_STRING_DATA_insert(lh,inst) LHM_lh_insert(ERR_STRING_DATA,lh,inst)
+#define lh_ERR_STRING_DATA_retrieve(lh,inst) LHM_lh_retrieve(ERR_STRING_DATA,lh,inst)
+#define lh_ERR_STRING_DATA_delete(lh,inst) LHM_lh_delete(ERR_STRING_DATA,lh,inst)
+#define lh_ERR_STRING_DATA_doall(lh,fn) LHM_lh_doall(ERR_STRING_DATA,lh,fn)
+#define lh_ERR_STRING_DATA_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(ERR_STRING_DATA,lh,fn,arg_type,arg)
+#define lh_ERR_STRING_DATA_error(lh) LHM_lh_error(ERR_STRING_DATA,lh)
+#define lh_ERR_STRING_DATA_num_items(lh) LHM_lh_num_items(ERR_STRING_DATA,lh)
+#define lh_ERR_STRING_DATA_down_load(lh) LHM_lh_down_load(ERR_STRING_DATA,lh)
+#define lh_ERR_STRING_DATA_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(ERR_STRING_DATA,lh,out)
+#define lh_ERR_STRING_DATA_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(ERR_STRING_DATA,lh,out)
+#define lh_ERR_STRING_DATA_stats_bio(lh,out) \
+  LHM_lh_stats_bio(ERR_STRING_DATA,lh,out)
+#define lh_ERR_STRING_DATA_free(lh) LHM_lh_free(ERR_STRING_DATA,lh)
+
+#define lh_EX_CLASS_ITEM_new() LHM_lh_new(EX_CLASS_ITEM,ex_class_item)
+#define lh_EX_CLASS_ITEM_insert(lh,inst) LHM_lh_insert(EX_CLASS_ITEM,lh,inst)
+#define lh_EX_CLASS_ITEM_retrieve(lh,inst) LHM_lh_retrieve(EX_CLASS_ITEM,lh,inst)
+#define lh_EX_CLASS_ITEM_delete(lh,inst) LHM_lh_delete(EX_CLASS_ITEM,lh,inst)
+#define lh_EX_CLASS_ITEM_doall(lh,fn) LHM_lh_doall(EX_CLASS_ITEM,lh,fn)
+#define lh_EX_CLASS_ITEM_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(EX_CLASS_ITEM,lh,fn,arg_type,arg)
+#define lh_EX_CLASS_ITEM_error(lh) LHM_lh_error(EX_CLASS_ITEM,lh)
+#define lh_EX_CLASS_ITEM_num_items(lh) LHM_lh_num_items(EX_CLASS_ITEM,lh)
+#define lh_EX_CLASS_ITEM_down_load(lh) LHM_lh_down_load(EX_CLASS_ITEM,lh)
+#define lh_EX_CLASS_ITEM_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(EX_CLASS_ITEM,lh,out)
+#define lh_EX_CLASS_ITEM_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(EX_CLASS_ITEM,lh,out)
+#define lh_EX_CLASS_ITEM_stats_bio(lh,out) \
+  LHM_lh_stats_bio(EX_CLASS_ITEM,lh,out)
+#define lh_EX_CLASS_ITEM_free(lh) LHM_lh_free(EX_CLASS_ITEM,lh)
+
+#define lh_FUNCTION_new() LHM_lh_new(FUNCTION,function)
+#define lh_FUNCTION_insert(lh,inst) LHM_lh_insert(FUNCTION,lh,inst)
+#define lh_FUNCTION_retrieve(lh,inst) LHM_lh_retrieve(FUNCTION,lh,inst)
+#define lh_FUNCTION_delete(lh,inst) LHM_lh_delete(FUNCTION,lh,inst)
+#define lh_FUNCTION_doall(lh,fn) LHM_lh_doall(FUNCTION,lh,fn)
+#define lh_FUNCTION_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(FUNCTION,lh,fn,arg_type,arg)
+#define lh_FUNCTION_error(lh) LHM_lh_error(FUNCTION,lh)
+#define lh_FUNCTION_num_items(lh) LHM_lh_num_items(FUNCTION,lh)
+#define lh_FUNCTION_down_load(lh) LHM_lh_down_load(FUNCTION,lh)
+#define lh_FUNCTION_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(FUNCTION,lh,out)
+#define lh_FUNCTION_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(FUNCTION,lh,out)
+#define lh_FUNCTION_stats_bio(lh,out) \
+  LHM_lh_stats_bio(FUNCTION,lh,out)
+#define lh_FUNCTION_free(lh) LHM_lh_free(FUNCTION,lh)
+
+#define lh_MEM_new() LHM_lh_new(MEM,mem)
+#define lh_MEM_insert(lh,inst) LHM_lh_insert(MEM,lh,inst)
+#define lh_MEM_retrieve(lh,inst) LHM_lh_retrieve(MEM,lh,inst)
+#define lh_MEM_delete(lh,inst) LHM_lh_delete(MEM,lh,inst)
+#define lh_MEM_doall(lh,fn) LHM_lh_doall(MEM,lh,fn)
+#define lh_MEM_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(MEM,lh,fn,arg_type,arg)
+#define lh_MEM_error(lh) LHM_lh_error(MEM,lh)
+#define lh_MEM_num_items(lh) LHM_lh_num_items(MEM,lh)
+#define lh_MEM_down_load(lh) LHM_lh_down_load(MEM,lh)
+#define lh_MEM_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(MEM,lh,out)
+#define lh_MEM_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(MEM,lh,out)
+#define lh_MEM_stats_bio(lh,out) \
+  LHM_lh_stats_bio(MEM,lh,out)
+#define lh_MEM_free(lh) LHM_lh_free(MEM,lh)
+
+#define lh_OBJ_NAME_new() LHM_lh_new(OBJ_NAME,obj_name)
+#define lh_OBJ_NAME_insert(lh,inst) LHM_lh_insert(OBJ_NAME,lh,inst)
+#define lh_OBJ_NAME_retrieve(lh,inst) LHM_lh_retrieve(OBJ_NAME,lh,inst)
+#define lh_OBJ_NAME_delete(lh,inst) LHM_lh_delete(OBJ_NAME,lh,inst)
+#define lh_OBJ_NAME_doall(lh,fn) LHM_lh_doall(OBJ_NAME,lh,fn)
+#define lh_OBJ_NAME_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(OBJ_NAME,lh,fn,arg_type,arg)
+#define lh_OBJ_NAME_error(lh) LHM_lh_error(OBJ_NAME,lh)
+#define lh_OBJ_NAME_num_items(lh) LHM_lh_num_items(OBJ_NAME,lh)
+#define lh_OBJ_NAME_down_load(lh) LHM_lh_down_load(OBJ_NAME,lh)
+#define lh_OBJ_NAME_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(OBJ_NAME,lh,out)
+#define lh_OBJ_NAME_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(OBJ_NAME,lh,out)
+#define lh_OBJ_NAME_stats_bio(lh,out) \
+  LHM_lh_stats_bio(OBJ_NAME,lh,out)
+#define lh_OBJ_NAME_free(lh) LHM_lh_free(OBJ_NAME,lh)
+
+#define lh_SSL_SESSION_new() LHM_lh_new(SSL_SESSION,ssl_session)
+#define lh_SSL_SESSION_insert(lh,inst) LHM_lh_insert(SSL_SESSION,lh,inst)
+#define lh_SSL_SESSION_retrieve(lh,inst) LHM_lh_retrieve(SSL_SESSION,lh,inst)
+#define lh_SSL_SESSION_delete(lh,inst) LHM_lh_delete(SSL_SESSION,lh,inst)
+#define lh_SSL_SESSION_doall(lh,fn) LHM_lh_doall(SSL_SESSION,lh,fn)
+#define lh_SSL_SESSION_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(SSL_SESSION,lh,fn,arg_type,arg)
+#define lh_SSL_SESSION_error(lh) LHM_lh_error(SSL_SESSION,lh)
+#define lh_SSL_SESSION_num_items(lh) LHM_lh_num_items(SSL_SESSION,lh)
+#define lh_SSL_SESSION_down_load(lh) LHM_lh_down_load(SSL_SESSION,lh)
+#define lh_SSL_SESSION_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(SSL_SESSION,lh,out)
+#define lh_SSL_SESSION_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(SSL_SESSION,lh,out)
+#define lh_SSL_SESSION_stats_bio(lh,out) \
+  LHM_lh_stats_bio(SSL_SESSION,lh,out)
+#define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh)
+
+#define lh_STRING_new() LHM_lh_new(STRING,string)
+#define lh_STRING_insert(lh,inst) LHM_lh_insert(STRING,lh,inst)
+#define lh_STRING_retrieve(lh,inst) LHM_lh_retrieve(STRING,lh,inst)
+#define lh_STRING_delete(lh,inst) LHM_lh_delete(STRING,lh,inst)
+#define lh_STRING_doall(lh,fn) LHM_lh_doall(STRING,lh,fn)
+#define lh_STRING_doall_arg(lh,fn,arg_type,arg) \
+  LHM_lh_doall_arg(STRING,lh,fn,arg_type,arg)
+#define lh_STRING_error(lh) LHM_lh_error(STRING,lh)
+#define lh_STRING_num_items(lh) LHM_lh_num_items(STRING,lh)
+#define lh_STRING_down_load(lh) LHM_lh_down_load(STRING,lh)
+#define lh_STRING_node_stats_bio(lh,out) \
+  LHM_lh_node_stats_bio(STRING,lh,out)
+#define lh_STRING_node_usage_stats_bio(lh,out) \
+  LHM_lh_node_usage_stats_bio(STRING,lh,out)
+#define lh_STRING_stats_bio(lh,out) \
+  LHM_lh_stats_bio(STRING,lh,out)
+#define lh_STRING_free(lh) LHM_lh_free(STRING,lh)
 /* End of util/mkstack.pl block, you may now edit :-) */
 /* End of util/mkstack.pl block, you may now edit :-) */
 
 
 #endif /* !defined HEADER_SAFESTACK_H */
 #endif /* !defined HEADER_SAFESTACK_H */

+ 21 - 20
crypto/txt_db/txt_db.c

@@ -90,9 +90,9 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
 	ret->qual=NULL;
 	ret->qual=NULL;
 	if ((ret->data=sk_new_null()) == NULL)
 	if ((ret->data=sk_new_null()) == NULL)
 		goto err;
 		goto err;
-	if ((ret->index=(LHASH **)OPENSSL_malloc(sizeof(LHASH *)*num)) == NULL)
+	if ((ret->index=OPENSSL_malloc(sizeof(*ret->index)*num)) == NULL)
 		goto err;
 		goto err;
-	if ((ret->qual=(int (**)(char **))OPENSSL_malloc(sizeof(int (**)(char **))*num)) == NULL)
+	if ((ret->qual=OPENSSL_malloc(sizeof(*(ret->qual))*num)) == NULL)
 		goto err;
 		goto err;
 	for (i=0; i<num; i++)
 	for (i=0; i<num; i++)
 		{
 		{
@@ -192,10 +192,10 @@ err:
 		return(ret);
 		return(ret);
 	}
 	}
 
 
-char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value)
+STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, STRING *value)
 	{
 	{
-	char **ret;
-	LHASH *lh;
+	STRING *ret;
+	LHASH_OF(STRING) *lh;
 
 
 	if (idx >= db->num_fields)
 	if (idx >= db->num_fields)
 		{
 		{
@@ -208,16 +208,16 @@ char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value)
 		db->error=DB_ERROR_NO_INDEX;
 		db->error=DB_ERROR_NO_INDEX;
 		return(NULL);
 		return(NULL);
 		}
 		}
-	ret=(char **)lh_retrieve(lh,value);
+	ret=lh_STRING_retrieve(lh,value);
 	db->error=DB_ERROR_OK;
 	db->error=DB_ERROR_OK;
 	return(ret);
 	return(ret);
 	}
 	}
 
 
-int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(char **),
-		LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp)
+int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(STRING *),
+			LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp)
 	{
 	{
-	LHASH *idx;
-	char **r;
+	LHASH_OF(STRING) *idx;
+	STRING *r;
 	int i,n;
 	int i,n;
 
 
 	if (field >= db->num_fields)
 	if (field >= db->num_fields)
@@ -225,7 +225,8 @@ int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(char **),
 		db->error=DB_ERROR_INDEX_OUT_OF_RANGE;
 		db->error=DB_ERROR_INDEX_OUT_OF_RANGE;
 		return(0);
 		return(0);
 		}
 		}
-	if ((idx=lh_new(hash,cmp)) == NULL)
+	/* FIXME: we lose type checking at this point */
+	if ((idx=(LHASH_OF(STRING) *)lh_new(hash,cmp)) == NULL)
 		{
 		{
 		db->error=DB_ERROR_MALLOC;
 		db->error=DB_ERROR_MALLOC;
 		return(0);
 		return(0);
@@ -233,18 +234,18 @@ int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(char **),
 	n=sk_num(db->data);
 	n=sk_num(db->data);
 	for (i=0; i<n; i++)
 	for (i=0; i<n; i++)
 		{
 		{
-		r=(char **)sk_value(db->data,i);
+		r=(STRING *)sk_value(db->data,i);
 		if ((qual != NULL) && (qual(r) == 0)) continue;
 		if ((qual != NULL) && (qual(r) == 0)) continue;
-		if ((r=lh_insert(idx,r)) != NULL)
+		if ((r=lh_STRING_insert(idx,r)) != NULL)
 			{
 			{
 			db->error=DB_ERROR_INDEX_CLASH;
 			db->error=DB_ERROR_INDEX_CLASH;
 			db->arg1=sk_find(db->data,(char *)r);
 			db->arg1=sk_find(db->data,(char *)r);
 			db->arg2=i;
 			db->arg2=i;
-			lh_free(idx);
+			lh_STRING_free(idx);
 			return(0);
 			return(0);
 			}
 			}
 		}
 		}
-	if (db->index[field] != NULL) lh_free(db->index[field]);
+	if (db->index[field] != NULL) lh_STRING_free(db->index[field]);
 	db->index[field]=idx;
 	db->index[field]=idx;
 	db->qual[field]=qual;
 	db->qual[field]=qual;
 	return(1);
 	return(1);
@@ -298,10 +299,10 @@ err:
 	return(ret);
 	return(ret);
 	}
 	}
 
 
-int TXT_DB_insert(TXT_DB *db, char **row)
+int TXT_DB_insert(TXT_DB *db, STRING *row)
 	{
 	{
 	int i;
 	int i;
-	char **r;
+	STRING *r;
 
 
 	for (i=0; i<db->num_fields; i++)
 	for (i=0; i<db->num_fields; i++)
 		{
 		{
@@ -309,7 +310,7 @@ int TXT_DB_insert(TXT_DB *db, char **row)
 			{
 			{
 			if ((db->qual[i] != NULL) &&
 			if ((db->qual[i] != NULL) &&
 				(db->qual[i](row) == 0)) continue;
 				(db->qual[i](row) == 0)) continue;
-			r=(char **)lh_retrieve(db->index[i],row);
+			r=lh_STRING_retrieve(db->index[i],row);
 			if (r != NULL)
 			if (r != NULL)
 				{
 				{
 				db->error=DB_ERROR_INDEX_CLASH;
 				db->error=DB_ERROR_INDEX_CLASH;
@@ -332,7 +333,7 @@ int TXT_DB_insert(TXT_DB *db, char **row)
 			{
 			{
 			if ((db->qual[i] != NULL) &&
 			if ((db->qual[i] != NULL) &&
 				(db->qual[i](row) == 0)) continue;
 				(db->qual[i](row) == 0)) continue;
-			lh_insert(db->index[i],row);
+			lh_STRING_insert(db->index[i],row);
 			}
 			}
 		}
 		}
 	return(1);
 	return(1);
@@ -351,7 +352,7 @@ void TXT_DB_free(TXT_DB *db)
 	if (db->index != NULL)
 	if (db->index != NULL)
 		{
 		{
 		for (i=db->num_fields-1; i>=0; i--)
 		for (i=db->num_fields-1; i>=0; i--)
-			if (db->index[i] != NULL) lh_free(db->index[i]);
+			if (db->index[i] != NULL) lh_STRING_free(db->index[i]);
 		OPENSSL_free(db->index);
 		OPENSSL_free(db->index);
 		}
 		}
 	if (db->qual != NULL)
 	if (db->qual != NULL)

+ 7 - 7
crypto/txt_db/txt_db.h

@@ -81,12 +81,12 @@ typedef struct txt_db_st
 	{
 	{
 	int num_fields;
 	int num_fields;
 	STACK /* char ** */ *data;
 	STACK /* char ** */ *data;
-	LHASH **index;
-	int (**qual)(char **);
+	LHASH_OF(STRING) **index;
+	int (**qual)(STRING *);
 	long error;
 	long error;
 	long arg1;
 	long arg1;
 	long arg2;
 	long arg2;
-	char **arg_row;
+	STRING *arg_row;
 	} TXT_DB;
 	} TXT_DB;
 
 
 #ifndef OPENSSL_NO_BIO
 #ifndef OPENSSL_NO_BIO
@@ -96,11 +96,11 @@ long TXT_DB_write(BIO *out, TXT_DB *db);
 TXT_DB *TXT_DB_read(char *in, int num);
 TXT_DB *TXT_DB_read(char *in, int num);
 long TXT_DB_write(char *out, TXT_DB *db);
 long TXT_DB_write(char *out, TXT_DB *db);
 #endif
 #endif
-int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(char **),
-		LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp);
+int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(STRING *),
+			LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp);
 void TXT_DB_free(TXT_DB *db);
 void TXT_DB_free(TXT_DB *db);
-char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value);
-int TXT_DB_insert(TXT_DB *db,char **value);
+STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, STRING *value);
+int TXT_DB_insert(TXT_DB *db, STRING *value);
 
 
 #ifdef  __cplusplus
 #ifdef  __cplusplus
 }
 }

+ 21 - 20
crypto/x509v3/v3_conf.c

@@ -79,7 +79,7 @@ static unsigned char *generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len);
 /* char *name:  Name    */
 /* char *name:  Name    */
 /* char *value:  Value    */
 /* char *value:  Value    */
 X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name,
 X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name,
-	     char *value)
+				 char *value)
 	{
 	{
 	int crit;
 	int crit;
 	int ext_type;
 	int ext_type;
@@ -99,7 +99,7 @@ X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name,
 /* CONF *conf:  Config file    */
 /* CONF *conf:  Config file    */
 /* char *value:  Value    */
 /* char *value:  Value    */
 X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
 X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
-	     char *value)
+				     char *value)
 	{
 	{
 	int crit;
 	int crit;
 	int ext_type;
 	int ext_type;
@@ -113,7 +113,7 @@ X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
 /* CONF *conf:  Config file    */
 /* CONF *conf:  Config file    */
 /* char *value:  Value    */
 /* char *value:  Value    */
 static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid,
 static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid,
-	     int crit, char *value)
+				    int crit, char *value)
 	{
 	{
 	X509V3_EXT_METHOD *method;
 	X509V3_EXT_METHOD *method;
 	X509_EXTENSION *ext;
 	X509_EXTENSION *ext;
@@ -173,7 +173,7 @@ static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid,
 	}
 	}
 
 
 static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid,
 static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid,
-						 int crit, void *ext_struc)
+				  int crit, void *ext_struc)
 	{
 	{
 	unsigned char *ext_der;
 	unsigned char *ext_der;
 	int ext_len;
 	int ext_len;
@@ -258,7 +258,8 @@ static int v3_check_generic(char **value)
 
 
 /* Create a generic extension: for now just handle DER type */
 /* Create a generic extension: for now just handle DER type */
 static X509_EXTENSION *v3_generic_extension(const char *ext, char *value,
 static X509_EXTENSION *v3_generic_extension(const char *ext, char *value,
-	     int crit, int gen_type, X509V3_CTX *ctx)
+					    int crit, int gen_type,
+					    X509V3_CTX *ctx)
 	{
 	{
 	unsigned char *ext_der=NULL;
 	unsigned char *ext_der=NULL;
 	long ext_len;
 	long ext_len;
@@ -322,7 +323,7 @@ static unsigned char *generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len)
 
 
 
 
 int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,
 int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,
-	     STACK_OF(X509_EXTENSION) **sk)
+			    STACK_OF(X509_EXTENSION) **sk)
 	{
 	{
 	X509_EXTENSION *ext;
 	X509_EXTENSION *ext;
 	STACK_OF(CONF_VALUE) *nval;
 	STACK_OF(CONF_VALUE) *nval;
@@ -343,7 +344,7 @@ int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,
 /* Convenience functions to add extensions to a certificate, CRL and request */
 /* Convenience functions to add extensions to a certificate, CRL and request */
 
 
 int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
 int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
-	     X509 *cert)
+			 X509 *cert)
 	{
 	{
 	STACK_OF(X509_EXTENSION) **sk = NULL;
 	STACK_OF(X509_EXTENSION) **sk = NULL;
 	if (cert)
 	if (cert)
@@ -354,7 +355,7 @@ int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
 /* Same as above but for a CRL */
 /* Same as above but for a CRL */
 
 
 int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
 int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
-	     X509_CRL *crl)
+			     X509_CRL *crl)
 	{
 	{
 	STACK_OF(X509_EXTENSION) **sk = NULL;
 	STACK_OF(X509_EXTENSION) **sk = NULL;
 	if (crl)
 	if (crl)
@@ -443,7 +444,7 @@ void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf)
 	}
 	}
 
 
 void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req,
 void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req,
-	     X509_CRL *crl, int flags)
+		    X509_CRL *crl, int flags)
 	{
 	{
 	ctx->issuer_cert = issuer;
 	ctx->issuer_cert = issuer;
 	ctx->subject_cert = subj;
 	ctx->subject_cert = subj;
@@ -454,8 +455,8 @@ void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req,
 
 
 /* Old conf compatibility functions */
 /* Old conf compatibility functions */
 
 
-X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name,
-	     char *value)
+X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
+				char *name, char *value)
 	{
 	{
 	CONF ctmp;
 	CONF ctmp;
 	CONF_set_nconf(&ctmp, conf);
 	CONF_set_nconf(&ctmp, conf);
@@ -464,8 +465,8 @@ X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name,
 
 
 /* LHASH *conf:  Config file    */
 /* LHASH *conf:  Config file    */
 /* char *value:  Value    */
 /* char *value:  Value    */
-X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid,
-	     char *value)
+X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
+				    int ext_nid, char *value)
 	{
 	{
 	CONF ctmp;
 	CONF ctmp;
 	CONF_set_nconf(&ctmp, conf);
 	CONF_set_nconf(&ctmp, conf);
@@ -489,14 +490,14 @@ NULL,
 NULL
 NULL
 };
 };
 
 
-void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash)
+void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash)
 	{
 	{
 	ctx->db_meth = &conf_lhash_method;
 	ctx->db_meth = &conf_lhash_method;
 	ctx->db = lhash;
 	ctx->db = lhash;
 	}
 	}
 
 
-int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
-	     X509 *cert)
+int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
+			char *section, X509 *cert)
 	{
 	{
 	CONF ctmp;
 	CONF ctmp;
 	CONF_set_nconf(&ctmp, conf);
 	CONF_set_nconf(&ctmp, conf);
@@ -505,8 +506,8 @@ int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
 
 
 /* Same as above but for a CRL */
 /* Same as above but for a CRL */
 
 
-int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
-	     X509_CRL *crl)
+int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
+			    char *section, X509_CRL *crl)
 	{
 	{
 	CONF ctmp;
 	CONF ctmp;
 	CONF_set_nconf(&ctmp, conf);
 	CONF_set_nconf(&ctmp, conf);
@@ -515,8 +516,8 @@ int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
 
 
 /* Add extensions to certificate request */
 /* Add extensions to certificate request */
 
 
-int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
-	     X509_REQ *req)
+int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
+			    char *section, X509_REQ *req)
 	{
 	{
 	CONF ctmp;
 	CONF ctmp;
 	CONF_set_nconf(&ctmp, conf);
 	CONF_set_nconf(&ctmp, conf);

+ 12 - 7
crypto/x509v3/x509v3.h

@@ -577,18 +577,23 @@ int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert)
 int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
 int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
 int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
 int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
 
 
-X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value);
-X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value);
-int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert);
-int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
-int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
+X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
+				    int ext_nid, char *value);
+X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
+				char *name, char *value);
+int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
+			char *section, X509 *cert);
+int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
+			    char *section, X509_REQ *req);
+int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
+			    char *section, X509_CRL *crl);
 
 
 int X509V3_add_value_bool_nf(char *name, int asn1_bool,
 int X509V3_add_value_bool_nf(char *name, int asn1_bool,
-						STACK_OF(CONF_VALUE) **extlist);
+			     STACK_OF(CONF_VALUE) **extlist);
 int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);
 int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);
 int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);
 int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);
 void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);
 void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);
-void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash);
+void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);
 #endif
 #endif
 
 
 char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section);
 char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section);

+ 126 - 118
doc/crypto/lhash.pod

@@ -8,18 +8,20 @@ lh_new, lh_free, lh_insert, lh_delete, lh_retrieve, lh_doall, lh_doall_arg, lh_e
 
 
  #include <openssl/lhash.h>
  #include <openssl/lhash.h>
 
 
- LHASH *lh_new(LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE compare);
- void lh_free(LHASH *table);
+ DECLARE_LHASH_OF(<type>);
 
 
- void *lh_insert(LHASH *table, void *data);
- void *lh_delete(LHASH *table, void *data);
- void *lh_retrieve(LHASH *table, void *data);
+ LHASH *lh_<type>_new();
+ void lh_<type>_free(LHASH_OF(<type> *table);
 
 
- void lh_doall(LHASH *table, LHASH_DOALL_FN_TYPE func);
- void lh_doall_arg(LHASH *table, LHASH_DOALL_ARG_FN_TYPE func,
-          void *arg);
+ <type> *lh_<type>_insert(LHASH_OF(<type> *table, <type> *data);
+ <type> *lh_<type>_delete(LHASH_OF(<type> *table, <type> *data);
+ <type> *lh_retrieve(LHASH_OF<type> *table, <type> *data);
 
 
- int lh_error(LHASH *table);
+ void lh_<type>_doall(LHASH_OF(<type> *table, LHASH_DOALL_FN_TYPE func);
+ void lh_<type>_doall_arg(LHASH_OF(<type> *table, LHASH_DOALL_ARG_FN_TYPE func,
+          <type2>, <type2> *arg);
+
+ int lh_<type>_error(LHASH_OF(<type> *table);
 
 
  typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
  typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
  typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
  typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
@@ -28,113 +30,115 @@ lh_new, lh_free, lh_insert, lh_delete, lh_retrieve, lh_doall, lh_doall_arg, lh_e
 
 
 =head1 DESCRIPTION
 =head1 DESCRIPTION
 
 
-This library implements dynamic hash tables. The hash table entries
-can be arbitrary structures. Usually they consist of key and value
-fields.
-
-lh_new() creates a new B<LHASH> structure to store arbitrary data
-entries, and provides the 'hash' and 'compare' callbacks to be used in
-organising the table's entries.  The B<hash> callback takes a pointer
-to a table entry as its argument and returns an unsigned long hash
-value for its key field.  The hash value is normally truncated to a
-power of 2, so make sure that your hash function returns well mixed
-low order bits.  The B<compare> callback takes two arguments (pointers
-to two hash table entries), and returns 0 if their keys are equal,
-non-zero otherwise.  If your hash table will contain items of some
-particular type and the B<hash> and B<compare> callbacks hash/compare
-these types, then the B<DECLARE_LHASH_HASH_FN> and
-B<IMPLEMENT_LHASH_COMP_FN> macros can be used to create callback
-wrappers of the prototypes required by lh_new().  These provide
-per-variable casts before calling the type-specific callbacks written
-by the application author.  These macros, as well as those used for
-the "doall" callbacks, are defined as;
-
- #define DECLARE_LHASH_HASH_FN(f_name,o_type) \
-         unsigned long f_name##_LHASH_HASH(const void *);
- #define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \
-         unsigned long f_name##_LHASH_HASH(const void *arg) { \
-                 o_type a = (o_type)arg; \
-                 return f_name(a); }
- #define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH
-
- #define DECLARE_LHASH_COMP_FN(f_name,o_type) \
-         int f_name##_LHASH_COMP(const void *, const void *);
- #define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \
-         int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \
-                 o_type a = (o_type)arg1; \
-                 o_type b = (o_type)arg2; \
-                 return f_name(a,b); }
- #define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP
-
- #define DECLARE_LHASH_DOALL_FN(f_name,o_type) \
-         void f_name##_LHASH_DOALL(const void *);
- #define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \
-         void f_name##_LHASH_DOALL(const void *arg) { \
-                 o_type a = (o_type)arg; \
-                 f_name(a); }
- #define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL
-
- #define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
-         void f_name##_LHASH_DOALL_ARG(const void *, const void *);
- #define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
-         void f_name##_LHASH_DOALL_ARG(const void *arg1, const void *arg2) { \
-                 o_type a = (o_type)arg1; \
-                 a_type b = (a_type)arg2; \
-                 f_name(a,b); }
- #define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG
-
-An example of a hash table storing (pointers to) structures of type 'STUFF'
-could be defined as follows;
+This library implements type-checked dynamic hash tables. The hash
+table entries can be arbitrary structures. Usually they consist of key
+and value fields.
+
+lh_<type>_new() creates a new B<LHASH_OF(<type>> structure to store
+arbitrary data entries, and provides the 'hash' and 'compare'
+callbacks to be used in organising the table's entries.  The B<hash>
+callback takes a pointer to a table entry as its argument and returns
+an unsigned long hash value for its key field.  The hash value is
+normally truncated to a power of 2, so make sure that your hash
+function returns well mixed low order bits.  The B<compare> callback
+takes two arguments (pointers to two hash table entries), and returns
+0 if their keys are equal, non-zero otherwise.  If your hash table
+will contain items of some particular type and the B<hash> and
+B<compare> callbacks hash/compare these types, then the
+B<DECLARE_LHASH_HASH_FN> and B<IMPLEMENT_LHASH_COMP_FN> macros can be
+used to create callback wrappers of the prototypes required by
+lh_<type>_new().  These provide per-variable casts before calling the
+type-specific callbacks written by the application author.  These
+macros, as well as those used for the "doall" callbacks, are defined
+as;
+
+ #define DECLARE_LHASH_HASH_FN(name, o_type) \
+	 unsigned long name##_LHASH_HASH(const void *);
+ #define IMPLEMENT_LHASH_HASH_FN(name, o_type) \
+	 unsigned long name##_LHASH_HASH(const void *arg) { \
+		 const o_type *a = arg; \
+		 return name##_hash(a); }
+ #define LHASH_HASH_FN(name) name##_LHASH_HASH
+
+ #define DECLARE_LHASH_COMP_FN(name, o_type) \
+	 int name##_LHASH_COMP(const void *, const void *);
+ #define IMPLEMENT_LHASH_COMP_FN(name, o_type) \
+	 int name##_LHASH_COMP(const void *arg1, const void *arg2) { \
+		 const o_type *a = arg1;		    \
+		 const o_type *b = arg2; \
+		 return name##_cmp(a,b); }
+ #define LHASH_COMP_FN(name) name##_LHASH_COMP
+
+ #define DECLARE_LHASH_DOALL_FN(name, o_type) \
+	 void name##_LHASH_DOALL(void *);
+ #define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \
+	 void name##_LHASH_DOALL(void *arg) { \
+		 o_type *a = arg; \
+		 name##_doall(a); }
+ #define LHASH_DOALL_FN(name) name##_LHASH_DOALL
+
+ #define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
+	 void name##_LHASH_DOALL_ARG(void *, void *);
+ #define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
+	 void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
+		 o_type *a = arg1; \
+		 a_type *b = arg2; \
+		 name##_doall_arg(a, b); }
+ #define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG
+
+ An example of a hash table storing (pointers to) structures of type 'STUFF'
+ could be defined as follows;
 
 
  /* Calculates the hash value of 'tohash' (implemented elsewhere) */
  /* Calculates the hash value of 'tohash' (implemented elsewhere) */
  unsigned long STUFF_hash(const STUFF *tohash);
  unsigned long STUFF_hash(const STUFF *tohash);
  /* Orders 'arg1' and 'arg2' (implemented elsewhere) */
  /* Orders 'arg1' and 'arg2' (implemented elsewhere) */
- int STUFF_cmp(const STUFF *arg1, const STUFF *arg2);
+ int stuff_cmp(const STUFF *arg1, const STUFF *arg2);
  /* Create the type-safe wrapper functions for use in the LHASH internals */
  /* Create the type-safe wrapper functions for use in the LHASH internals */
- static IMPLEMENT_LHASH_HASH_FN(STUFF_hash, const STUFF *)
- static IMPLEMENT_LHASH_COMP_FN(STUFF_cmp, const STUFF *);
+ static IMPLEMENT_LHASH_HASH_FN(stuff, STUFF);
+ static IMPLEMENT_LHASH_COMP_FN(stuff, STUFF);
  /* ... */
  /* ... */
  int main(int argc, char *argv[]) {
  int main(int argc, char *argv[]) {
          /* Create the new hash table using the hash/compare wrappers */
          /* Create the new hash table using the hash/compare wrappers */
-         LHASH *hashtable = lh_new(LHASH_HASH_FN(STUFF_hash),
+         LHASH_OF(STUFF) *hashtable = lh_STUFF_new(LHASH_HASH_FN(STUFF_hash),
                                    LHASH_COMP_FN(STUFF_cmp));
                                    LHASH_COMP_FN(STUFF_cmp));
 	 /* ... */
 	 /* ... */
  }
  }
 
 
-lh_free() frees the B<LHASH> structure B<table>. Allocated hash table
-entries will not be freed; consider using lh_doall() to deallocate any
-remaining entries in the hash table (see below).
+lh_<type>_free() frees the B<LHASH_OF(<type>> structure
+B<table>. Allocated hash table entries will not be freed; consider
+using lh_<type>_doall() to deallocate any remaining entries in the
+hash table (see below).
 
 
-lh_insert() inserts the structure pointed to by B<data> into B<table>.
-If there already is an entry with the same key, the old value is
-replaced. Note that lh_insert() stores pointers, the data are not
-copied.
+lh_<type>_insert() inserts the structure pointed to by B<data> into
+B<table>.  If there already is an entry with the same key, the old
+value is replaced. Note that lh_<type>_insert() stores pointers, the
+data are not copied.
 
 
-lh_delete() deletes an entry from B<table>.
+lh_<type>_delete() deletes an entry from B<table>.
 
 
-lh_retrieve() looks up an entry in B<table>. Normally, B<data> is
-a structure with the key field(s) set; the function will return a
+lh_<type>_retrieve() looks up an entry in B<table>. Normally, B<data>
+is a structure with the key field(s) set; the function will return a
 pointer to a fully populated structure.
 pointer to a fully populated structure.
 
 
-lh_doall() will, for every entry in the hash table, call B<func> with
-the data item as its parameter.  For lh_doall() and lh_doall_arg(),
-function pointer casting should be avoided in the callbacks (see
-B<NOTE>) - instead, either declare the callbacks to match the
-prototype required in lh_new() or use the declare/implement macros to
-create type-safe wrappers that cast variables prior to calling your
-type-specific callbacks.  An example of this is illustrated here where
-the callback is used to cleanup resources for items in the hash table
-prior to the hashtable itself being deallocated:
+lh_<type>_doall() will, for every entry in the hash table, call
+B<func> with the data item as its parameter.  For lh_<type>_doall()
+and lh_<type>_doall_arg(), function pointer casting should be avoided
+in the callbacks (see B<NOTE>) - instead use the declare/implement
+macros to create type-checked wrappers that cast variables prior to
+calling your type-specific callbacks.  An example of this is
+illustrated here where the callback is used to cleanup resources for
+items in the hash table prior to the hashtable itself being
+deallocated:
 
 
  /* Cleans up resources belonging to 'a' (this is implemented elsewhere) */
  /* Cleans up resources belonging to 'a' (this is implemented elsewhere) */
- void STUFF_cleanup(STUFF *a);
+ void STUFF_cleanup_doall(STUFF *a);
  /* Implement a prototype-compatible wrapper for "STUFF_cleanup" */
  /* Implement a prototype-compatible wrapper for "STUFF_cleanup" */
- IMPLEMENT_LHASH_DOALL_FN(STUFF_cleanup, STUFF *)
+ IMPLEMENT_LHASH_DOALL_FN(STUFF_cleanup, STUFF)
          /* ... then later in the code ... */
          /* ... then later in the code ... */
  /* So to run "STUFF_cleanup" against all items in a hash table ... */
  /* So to run "STUFF_cleanup" against all items in a hash table ... */
- lh_doall(hashtable, LHASH_DOALL_FN(STUFF_cleanup));
+ lh_STUFF_doall(hashtable, LHASH_DOALL_FN(STUFF_cleanup));
  /* Then the hash table itself can be deallocated */
  /* Then the hash table itself can be deallocated */
- lh_free(hashtable);
+ lh_STUFF_free(hashtable);
 
 
 When doing this, be careful if you delete entries from the hash table
 When doing this, be careful if you delete entries from the hash table
 in your callbacks: the table may decrease in size, moving the item
 in your callbacks: the table may decrease in size, moving the item
@@ -145,51 +149,52 @@ you start (which will stop the hash table ever decreasing in size).
 The best solution is probably to avoid deleting items from the hash
 The best solution is probably to avoid deleting items from the hash
 table inside a "doall" callback!
 table inside a "doall" callback!
 
 
-lh_doall_arg() is the same as lh_doall() except that B<func> will be
-called with B<arg> as the second argument and B<func> should be of
-type B<LHASH_DOALL_ARG_FN_TYPE> (a callback prototype that is passed
-both the table entry and an extra argument).  As with lh_doall(), you
-can instead choose to declare your callback with a prototype matching
-the types you are dealing with and use the declare/implement macros to
-create compatible wrappers that cast variables before calling your
-type-specific callbacks.  An example of this is demonstrated here
-(printing all hash table entries to a BIO that is provided by the
-caller):
+lh_<type>_doall_arg() is the same as lh_<type>_doall() except that
+B<func> will be called with B<arg> as the second argument and B<func>
+should be of type B<LHASH_DOALL_ARG_FN_TYPE> (a callback prototype
+that is passed both the table entry and an extra argument).  As with
+lh_doall(), you can instead choose to declare your callback with a
+prototype matching the types you are dealing with and use the
+declare/implement macros to create compatible wrappers that cast
+variables before calling your type-specific callbacks.  An example of
+this is demonstrated here (printing all hash table entries to a BIO
+that is provided by the caller):
 
 
  /* Prints item 'a' to 'output_bio' (this is implemented elsewhere) */
  /* Prints item 'a' to 'output_bio' (this is implemented elsewhere) */
- void STUFF_print(const STUFF *a, BIO *output_bio);
+ void STUFF_print_doall_arg(const STUFF *a, BIO *output_bio);
  /* Implement a prototype-compatible wrapper for "STUFF_print" */
  /* Implement a prototype-compatible wrapper for "STUFF_print" */
- static IMPLEMENT_LHASH_DOALL_ARG_FN(STUFF_print, const STUFF *, BIO *)
+ static IMPLEMENT_LHASH_DOALL_ARG_FN(STUFF, const STUFF, BIO)
          /* ... then later in the code ... */
          /* ... then later in the code ... */
  /* Print out the entire hashtable to a particular BIO */
  /* Print out the entire hashtable to a particular BIO */
- lh_doall_arg(hashtable, LHASH_DOALL_ARG_FN(STUFF_print), logging_bio);
+ lh_STUFF_doall_arg(hashtable, LHASH_DOALL_ARG_FN(STUFF_print), BIO,
+                    logging_bio);
  
  
-lh_error() can be used to determine if an error occurred in the last
-operation. lh_error() is a macro.
+lh_<type>_error() can be used to determine if an error occurred in the last
+operation. lh_<type>_error() is a macro.
 
 
 =head1 RETURN VALUES
 =head1 RETURN VALUES
 
 
-lh_new() returns B<NULL> on error, otherwise a pointer to the new
+lh_<type>_new() returns B<NULL> on error, otherwise a pointer to the new
 B<LHASH> structure.
 B<LHASH> structure.
 
 
-When a hash table entry is replaced, lh_insert() returns the value
+When a hash table entry is replaced, lh_<type>_insert() returns the value
 being replaced. B<NULL> is returned on normal operation and on error.
 being replaced. B<NULL> is returned on normal operation and on error.
 
 
-lh_delete() returns the entry being deleted.  B<NULL> is returned if
+lh_<type>_delete() returns the entry being deleted.  B<NULL> is returned if
 there is no such value in the hash table.
 there is no such value in the hash table.
 
 
-lh_retrieve() returns the hash table entry if it has been found,
+lh_<type>_retrieve() returns the hash table entry if it has been found,
 B<NULL> otherwise.
 B<NULL> otherwise.
 
 
-lh_error() returns 1 if an error occurred in the last operation, 0
+lh_<type>_error() returns 1 if an error occurred in the last operation, 0
 otherwise.
 otherwise.
 
 
-lh_free(), lh_doall() and lh_doall_arg() return no values.
+lh_<type>_free(), lh_<type>_doall() and lh_<type>_doall_arg() return no values.
 
 
 =head1 NOTE
 =head1 NOTE
 
 
 The various LHASH macros and callback types exist to make it possible
 The various LHASH macros and callback types exist to make it possible
-to write type-safe code without resorting to function-prototype
+to write type-checked code without resorting to function-prototype
 casting - an evil that makes application code much harder to
 casting - an evil that makes application code much harder to
 audit/verify and also opens the window of opportunity for stack
 audit/verify and also opens the window of opportunity for stack
 corruption and other hard-to-find bugs.  It also, apparently, violates
 corruption and other hard-to-find bugs.  It also, apparently, violates
@@ -227,7 +232,7 @@ without any "const" qualifiers.
 
 
 =head1 BUGS
 =head1 BUGS
 
 
-lh_insert() returns B<NULL> both for success and error.
+lh_<type>_insert() returns B<NULL> both for success and error.
 
 
 =head1 INTERNALS
 =head1 INTERNALS
 
 
@@ -272,8 +277,8 @@ lh_strhash() is a demo string hashing function:
  unsigned long lh_strhash(const char *c);
  unsigned long lh_strhash(const char *c);
 
 
 Since the B<LHASH> routines would normally be passed structures, this
 Since the B<LHASH> routines would normally be passed structures, this
-routine would not normally be passed to lh_new(), rather it would be
-used in the function passed to lh_new().
+routine would not normally be passed to lh_<type>_new(), rather it would be
+used in the function passed to lh_<type>_new().
 
 
 =head1 SEE ALSO
 =head1 SEE ALSO
 
 
@@ -291,4 +296,7 @@ were changed for better type safety, and the function types LHASH_COMP_FN_TYPE,
 LHASH_HASH_FN_TYPE, LHASH_DOALL_FN_TYPE and LHASH_DOALL_ARG_FN_TYPE 
 LHASH_HASH_FN_TYPE, LHASH_DOALL_FN_TYPE and LHASH_DOALL_ARG_FN_TYPE 
 became available.
 became available.
 
 
+In OpenSSL 0.9.9, the lhash interface was revamped for even better
+type checking.
+
 =cut
 =cut

+ 6 - 4
engines/Makefile

@@ -226,10 +226,12 @@ e_cswift.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
 e_cswift.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
 e_cswift.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
 e_cswift.o: ../include/openssl/stack.h ../include/openssl/symhacks.h e_cswift.c
 e_cswift.o: ../include/openssl/stack.h ../include/openssl/symhacks.h e_cswift.c
 e_cswift.o: e_cswift_err.c e_cswift_err.h vendor_defns/cswift.h
 e_cswift.o: e_cswift_err.c e_cswift_err.h vendor_defns/cswift.h
-e_gmp.o: ../include/openssl/buffer.h ../include/openssl/crypto.h
-e_gmp.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
-e_gmp.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
-e_gmp.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
+e_gmp.o: ../include/openssl/asn1.h ../include/openssl/bio.h
+e_gmp.o: ../include/openssl/bn.h ../include/openssl/buffer.h
+e_gmp.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
+e_gmp.o: ../include/openssl/engine.h ../include/openssl/opensslconf.h
+e_gmp.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+e_gmp.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
 e_gmp.o: ../include/openssl/stack.h ../include/openssl/symhacks.h e_gmp.c
 e_gmp.o: ../include/openssl/stack.h ../include/openssl/symhacks.h e_gmp.c
 e_nuron.o: ../include/openssl/asn1.h ../include/openssl/bio.h
 e_nuron.o: ../include/openssl/asn1.h ../include/openssl/bio.h
 e_nuron.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 e_nuron.o: ../include/openssl/bn.h ../include/openssl/buffer.h

Dosya farkı çok büyük olduğundan ihmal edildi
+ 413 - 397
ssl/Makefile


+ 5 - 5
ssl/ssl.h

@@ -659,6 +659,7 @@ typedef struct ssl_comp_st
 	} SSL_COMP;
 	} SSL_COMP;
 
 
 DECLARE_STACK_OF(SSL_COMP)
 DECLARE_STACK_OF(SSL_COMP)
+DECLARE_LHASH_OF(SSL_SESSION);
 
 
 struct ssl_ctx_st
 struct ssl_ctx_st
 	{
 	{
@@ -669,7 +670,7 @@ struct ssl_ctx_st
 	STACK_OF(SSL_CIPHER) *cipher_list_by_id;
 	STACK_OF(SSL_CIPHER) *cipher_list_by_id;
 
 
 	struct x509_store_st /* X509_STORE */ *cert_store;
 	struct x509_store_st /* X509_STORE */ *cert_store;
-	struct lhash_st /* LHASH */ *sessions;	/* a set of SSL_SESSIONs */
+	LHASH_OF(SSL_SESSION) *sessions;
 	/* Most session-ids that will be cached, default is
 	/* Most session-ids that will be cached, default is
 	 * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */
 	 * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */
 	unsigned long session_cache_size;
 	unsigned long session_cache_size;
@@ -845,7 +846,7 @@ struct ssl_ctx_st
 #define SSL_SESS_CACHE_NO_INTERNAL \
 #define SSL_SESS_CACHE_NO_INTERNAL \
 	(SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)
 	(SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)
 
 
-  struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx);
+LHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx);
 #define SSL_CTX_sess_number(ctx) \
 #define SSL_CTX_sess_number(ctx) \
 	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)
 	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)
 #define SSL_CTX_sess_connect(ctx) \
 #define SSL_CTX_sess_connect(ctx) \
@@ -1484,9 +1485,8 @@ long	SSL_SESSION_set_timeout(SSL_SESSION *s, long t);
 void	SSL_copy_session_id(SSL *to,const SSL *from);
 void	SSL_copy_session_id(SSL *to,const SSL *from);
 
 
 SSL_SESSION *SSL_SESSION_new(void);
 SSL_SESSION *SSL_SESSION_new(void);
-unsigned long SSL_SESSION_hash(const SSL_SESSION *a);
-int	SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b);
-const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len);
+const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s,
+					unsigned int *len);
 #ifndef OPENSSL_NO_FP_API
 #ifndef OPENSSL_NO_FP_API
 int	SSL_SESSION_print_fp(FILE *fp,const SSL_SESSION *ses);
 int	SSL_SESSION_print_fp(FILE *fp,const SSL_SESSION *ses);
 #endif
 #endif

+ 9 - 10
ssl/ssl_lib.c

@@ -457,7 +457,7 @@ int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
 		}
 		}
 
 
 	CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
 	CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
-	p = (SSL_SESSION *)lh_retrieve(ssl->ctx->sessions, &r);
+	p = lh_SSL_SESSION_retrieve(ssl->ctx->sessions, &r);
 	CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
 	CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
 	return (p != NULL);
 	return (p != NULL);
 	}
 	}
@@ -1062,7 +1062,7 @@ long SSL_callback_ctrl(SSL *s, int cmd, void (*fp)(void))
 		}
 		}
 	}
 	}
 
 
-struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx)
+LHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx)
 	{
 	{
 	return ctx->sessions;
 	return ctx->sessions;
 	}
 	}
@@ -1105,7 +1105,7 @@ long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,void *parg)
 		return(ctx->session_cache_mode);
 		return(ctx->session_cache_mode);
 
 
 	case SSL_CTRL_SESS_NUMBER:
 	case SSL_CTRL_SESS_NUMBER:
-		return(ctx->sessions->num_items);
+		return(lh_SSL_SESSION_num_items(ctx->sessions));
 	case SSL_CTRL_SESS_CONNECT:
 	case SSL_CTRL_SESS_CONNECT:
 		return(ctx->stats.sess_connect);
 		return(ctx->stats.sess_connect);
 	case SSL_CTRL_SESS_CONNECT_GOOD:
 	case SSL_CTRL_SESS_CONNECT_GOOD:
@@ -1410,7 +1410,7 @@ int SSL_get_servername_type(const SSL *s)
 	}
 	}
 #endif
 #endif
 
 
-unsigned long SSL_SESSION_hash(const SSL_SESSION *a)
+static unsigned long ssl_session_hash(const SSL_SESSION *a)
 	{
 	{
 	unsigned long l;
 	unsigned long l;
 
 
@@ -1427,7 +1427,7 @@ unsigned long SSL_SESSION_hash(const SSL_SESSION *a)
  * SSL_CTX_has_matching_session_id() is checked accordingly. It relies on being
  * SSL_CTX_has_matching_session_id() is checked accordingly. It relies on being
  * able to construct an SSL_SESSION that will collide with any existing session
  * able to construct an SSL_SESSION that will collide with any existing session
  * with a matching session ID. */
  * with a matching session ID. */
-int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b)
+static int ssl_session_cmp(const SSL_SESSION *a,const SSL_SESSION *b)
 	{
 	{
 	if (a->ssl_version != b->ssl_version)
 	if (a->ssl_version != b->ssl_version)
 		return(1);
 		return(1);
@@ -1440,8 +1440,8 @@ int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b)
  * SSL_SESSION_hash and SSL_SESSION_cmp for void* types and casting each
  * SSL_SESSION_hash and SSL_SESSION_cmp for void* types and casting each
  * variable. The reason is that the functions aren't static, they're exposed via
  * variable. The reason is that the functions aren't static, they're exposed via
  * ssl.h. */
  * ssl.h. */
-static IMPLEMENT_LHASH_HASH_FN(SSL_SESSION_hash, SSL_SESSION *)
-static IMPLEMENT_LHASH_COMP_FN(SSL_SESSION_cmp, SSL_SESSION *)
+static IMPLEMENT_LHASH_HASH_FN(ssl_session, SSL_SESSION)
+static IMPLEMENT_LHASH_COMP_FN(ssl_session, SSL_SESSION)
 
 
 SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
 SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
 	{
 	{
@@ -1515,8 +1515,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
 	ret->app_gen_cookie_cb=0;
 	ret->app_gen_cookie_cb=0;
 	ret->app_verify_cookie_cb=0;
 	ret->app_verify_cookie_cb=0;
 
 
-	ret->sessions=lh_new(LHASH_HASH_FN(SSL_SESSION_hash),
-			LHASH_COMP_FN(SSL_SESSION_cmp));
+	ret->sessions=lh_SSL_SESSION_new();
 	if (ret->sessions == NULL) goto err;
 	if (ret->sessions == NULL) goto err;
 	ret->cert_store=X509_STORE_new();
 	ret->cert_store=X509_STORE_new();
 	if (ret->cert_store == NULL) goto err;
 	if (ret->cert_store == NULL) goto err;
@@ -1629,7 +1628,7 @@ void SSL_CTX_free(SSL_CTX *a)
 	CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);
 	CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);
 
 
 	if (a->sessions != NULL)
 	if (a->sessions != NULL)
-		lh_free(a->sessions);
+		lh_SSL_SESSION_free(a->sessions);
 
 
 	if (a->cert_store != NULL)
 	if (a->cert_store != NULL)
 		X509_STORE_free(a->cert_store);
 		X509_STORE_free(a->cert_store);

+ 13 - 12
ssl/ssl_sess.c

@@ -451,7 +451,7 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len,
 			return 0;
 			return 0;
 		memcpy(data.session_id,session_id,len);
 		memcpy(data.session_id,session_id,len);
 		CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
 		CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
-		ret=(SSL_SESSION *)lh_retrieve(s->session_ctx->sessions,&data);
+		ret=lh_SSL_SESSION_retrieve(s->session_ctx->sessions,&data);
 		if (ret != NULL)
 		if (ret != NULL)
 		    /* don't allow other threads to steal it: */
 		    /* don't allow other threads to steal it: */
 		    CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION);
 		    CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION);
@@ -589,7 +589,7 @@ int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c)
 	/* if session c is in already in cache, we take back the increment later */
 	/* if session c is in already in cache, we take back the increment later */
 
 
 	CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
 	CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
-	s=(SSL_SESSION *)lh_insert(ctx->sessions,c);
+	s=lh_SSL_SESSION_insert(ctx->sessions,c);
 	
 	
 	/* s != NULL iff we already had a session with the given PID.
 	/* s != NULL iff we already had a session with the given PID.
 	 * In this case, s == c should hold (then we did not really modify
 	 * In this case, s == c should hold (then we did not really modify
@@ -655,10 +655,10 @@ static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
 	if ((c != NULL) && (c->session_id_length != 0))
 	if ((c != NULL) && (c->session_id_length != 0))
 		{
 		{
 		if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
 		if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
-		if ((r = (SSL_SESSION *)lh_retrieve(ctx->sessions,c)) == c)
+		if ((r = lh_SSL_SESSION_retrieve(ctx->sessions,c)) == c)
 			{
 			{
 			ret=1;
 			ret=1;
-			r=(SSL_SESSION *)lh_delete(ctx->sessions,c);
+			r=lh_SSL_SESSION_delete(ctx->sessions,c);
 			SSL_SESSION_list_remove(ctx,c);
 			SSL_SESSION_list_remove(ctx,c);
 			}
 			}
 
 
@@ -835,16 +835,16 @@ typedef struct timeout_param_st
 	{
 	{
 	SSL_CTX *ctx;
 	SSL_CTX *ctx;
 	long time;
 	long time;
-	LHASH *cache;
+	LHASH_OF(SSL_SESSION) *cache;
 	} TIMEOUT_PARAM;
 	} TIMEOUT_PARAM;
 
 
-static void timeout(SSL_SESSION *s, TIMEOUT_PARAM *p)
+static void timeout_doall_arg(SSL_SESSION *s, TIMEOUT_PARAM *p)
 	{
 	{
 	if ((p->time == 0) || (p->time > (s->time+s->timeout))) /* timeout */
 	if ((p->time == 0) || (p->time > (s->time+s->timeout))) /* timeout */
 		{
 		{
 		/* The reason we don't call SSL_CTX_remove_session() is to
 		/* The reason we don't call SSL_CTX_remove_session() is to
 		 * save on locking overhead */
 		 * save on locking overhead */
-		lh_delete(p->cache,s);
+		lh_SSL_SESSION_delete(p->cache,s);
 		SSL_SESSION_list_remove(p->ctx,s);
 		SSL_SESSION_list_remove(p->ctx,s);
 		s->not_resumable=1;
 		s->not_resumable=1;
 		if (p->ctx->remove_session_cb != NULL)
 		if (p->ctx->remove_session_cb != NULL)
@@ -853,7 +853,7 @@ static void timeout(SSL_SESSION *s, TIMEOUT_PARAM *p)
 		}
 		}
 	}
 	}
 
 
-static IMPLEMENT_LHASH_DOALL_ARG_FN(timeout, SSL_SESSION *, TIMEOUT_PARAM *)
+static IMPLEMENT_LHASH_DOALL_ARG_FN(timeout, SSL_SESSION, TIMEOUT_PARAM)
 
 
 void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
 void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
 	{
 	{
@@ -865,10 +865,11 @@ void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
 	if (tp.cache == NULL) return;
 	if (tp.cache == NULL) return;
 	tp.time=t;
 	tp.time=t;
 	CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
 	CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
-	i=tp.cache->down_load;
-	tp.cache->down_load=0;
-	lh_doall_arg(tp.cache, LHASH_DOALL_ARG_FN(timeout), &tp);
-	tp.cache->down_load=i;
+	i=CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load;
+	CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load=0;
+	lh_SSL_SESSION_doall_arg(tp.cache, LHASH_DOALL_ARG_FN(timeout),
+				 TIMEOUT_PARAM, &tp);
+	CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load=i;
 	CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
 	CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
 	}
 	}
 
 

+ 14 - 13
test/Makefile

@@ -623,19 +623,20 @@ ssltest.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h
 ssltest.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
 ssltest.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
 ssltest.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
 ssltest.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
 ssltest.o: ../include/openssl/engine.h ../include/openssl/err.h
 ssltest.o: ../include/openssl/engine.h ../include/openssl/err.h
-ssltest.o: ../include/openssl/evp.h ../include/openssl/kssl.h
-ssltest.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-ssltest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-ssltest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-ssltest.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-ssltest.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
-ssltest.o: ../include/openssl/rand.h ../include/openssl/rsa.h
-ssltest.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-ssltest.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
-ssltest.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
-ssltest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-ssltest.o: ../include/openssl/tls1.h ../include/openssl/x509.h
-ssltest.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h ssltest.c
+ssltest.o: ../include/openssl/evp.h ../include/openssl/hmac.h
+ssltest.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
+ssltest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+ssltest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+ssltest.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+ssltest.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+ssltest.o: ../include/openssl/pqueue.h ../include/openssl/rand.h
+ssltest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
+ssltest.o: ../include/openssl/sha.h ../include/openssl/ssl.h
+ssltest.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
+ssltest.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
+ssltest.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
+ssltest.o: ../include/openssl/x509v3.h ssltest.c
 wp_test.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
 wp_test.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
 wp_test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
 wp_test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
 wp_test.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
 wp_test.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h

+ 33 - 3
util/mkstack.pl

@@ -21,7 +21,7 @@ while (@ARGV) {
 }
 }
 
 
 
 
-@source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>);
+@source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>, <apps/*.[ch]>);
 foreach $file (@source) {
 foreach $file (@source) {
 	next if -l $file;
 	next if -l $file;
 
 
@@ -31,11 +31,16 @@ foreach $file (@source) {
 	while(<IN>) {
 	while(<IN>) {
 		if (/^DECLARE_STACK_OF\(([^)]+)\)/) {
 		if (/^DECLARE_STACK_OF\(([^)]+)\)/) {
 			push @stacklst, $1;
 			push @stacklst, $1;
-		} if (/^DECLARE_ASN1_SET_OF\(([^)]+)\)/) {
+		}
+		if (/^DECLARE_ASN1_SET_OF\(([^)]+)\)/) {
 			push @asn1setlst, $1;
 			push @asn1setlst, $1;
-		} if (/^DECLARE_PKCS12_STACK_OF\(([^)]+)\)/) {
+		}
+		if (/^DECLARE_PKCS12_STACK_OF\(([^)]+)\)/) {
 			push @p12stklst, $1;
 			push @p12stklst, $1;
 		}
 		}
+		if (/^DECLARE_LHASH_OF\(([^)]+)\)/) {
+			push @lhashlst, $1;
+		}
 	}
 	}
 	close(IN);
 	close(IN);
 }
 }
@@ -108,6 +113,31 @@ EOF
 	SKM_PKCS12_decrypt_d2i($type_thing, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))
 	SKM_PKCS12_decrypt_d2i($type_thing, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))
 EOF
 EOF
 	}
 	}
+
+	foreach $type_thing (sort @lhashlst) {
+		my $lc_tt = lc $type_thing;
+		$new_stackfile .= <<EOF;
+
+#define lh_${type_thing}_new() LHM_lh_new(${type_thing},${lc_tt})
+#define lh_${type_thing}_insert(lh,inst) LHM_lh_insert(${type_thing},lh,inst)
+#define lh_${type_thing}_retrieve(lh,inst) LHM_lh_retrieve(${type_thing},lh,inst)
+#define lh_${type_thing}_delete(lh,inst) LHM_lh_delete(${type_thing},lh,inst)
+#define lh_${type_thing}_doall(lh,fn) LHM_lh_doall(${type_thing},lh,fn)
+#define lh_${type_thing}_doall_arg(lh,fn,arg_type,arg) \\
+  LHM_lh_doall_arg(${type_thing},lh,fn,arg_type,arg)
+#define lh_${type_thing}_error(lh) LHM_lh_error(${type_thing},lh)
+#define lh_${type_thing}_num_items(lh) LHM_lh_num_items(${type_thing},lh)
+#define lh_${type_thing}_down_load(lh) LHM_lh_down_load(${type_thing},lh)
+#define lh_${type_thing}_node_stats_bio(lh,out) \\
+  LHM_lh_node_stats_bio(${type_thing},lh,out)
+#define lh_${type_thing}_node_usage_stats_bio(lh,out) \\
+  LHM_lh_node_usage_stats_bio(${type_thing},lh,out)
+#define lh_${type_thing}_stats_bio(lh,out) \\
+  LHM_lh_stats_bio(${type_thing},lh,out)
+#define lh_${type_thing}_free(lh) LHM_lh_free(${type_thing},lh)
+EOF
+	}
+
 	$new_stackfile .= "/* End of util/mkstack.pl block, you may now edit :-) */\n";
 	$new_stackfile .= "/* End of util/mkstack.pl block, you may now edit :-) */\n";
 	$inside_block = 2;
 	$inside_block = 2;
 }
 }

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor