This fixes the installation target for dynamic engines, which was trying to
[openssl.git] / crypto / engine / eng_list.c
index b41e6ba..f337e0f 100644 (file)
  * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
  */
 
-#include <openssl/crypto.h>
-#include "cryptlib.h"
 #include "eng_int.h"
-#include <openssl/engine.h>
 
 /* The linked-list of pointers to engine types. engine_list_head
  * incorporates an implicit structural reference but engine_list_tail
@@ -196,14 +193,14 @@ ENGINE *ENGINE_get_first(void)
        {
        ENGINE *ret;
 
-       CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
        ret = engine_list_head;
        if(ret)
                {
                ret->struct_ref++;
                engine_ref_debug(ret, 0, 1)
                }
-       CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        return ret;
        }
 
@@ -211,14 +208,14 @@ ENGINE *ENGINE_get_last(void)
        {
        ENGINE *ret;
 
-       CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
-               ret = engine_list_tail;
+       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
+       ret = engine_list_tail;
        if(ret)
                {
                ret->struct_ref++;
                engine_ref_debug(ret, 0, 1)
                }
-       CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        return ret;
        }
 
@@ -232,7 +229,7 @@ ENGINE *ENGINE_get_next(ENGINE *e)
                        ERR_R_PASSED_NULL_PARAMETER);
                return 0;
                }
-       CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
        ret = e->next;
        if(ret)
                {
@@ -240,7 +237,7 @@ ENGINE *ENGINE_get_next(ENGINE *e)
                ret->struct_ref++;
                engine_ref_debug(ret, 0, 1)
                }
-       CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        /* Release the structural reference to the previous ENGINE */
        ENGINE_free(e);
        return ret;
@@ -255,7 +252,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
                        ERR_R_PASSED_NULL_PARAMETER);
                return 0;
                }
-       CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
        ret = e->prev;
        if(ret)
                {
@@ -263,7 +260,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
                ret->struct_ref++;
                engine_ref_debug(ret, 0, 1)
                }
-       CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        /* Release the structural reference to the previous ENGINE */
        ENGINE_free(e);
        return ret;
@@ -336,6 +333,7 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src)
        dest->ecdsa_meth = src->ecdsa_meth;
 #endif
        dest->rand_meth = src->rand_meth;
+       dest->store_meth = src->store_meth;
        dest->ciphers = src->ciphers;
        dest->digests = src->digests;
        dest->destroy = src->destroy;
@@ -358,7 +356,7 @@ ENGINE *ENGINE_by_id(const char *id)
                        ERR_R_PASSED_NULL_PARAMETER);
                return NULL;
                }
-       CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
        iterator = engine_list_head;
        while(iterator && (strcmp(id, iterator->id) != 0))
                iterator = iterator->next;
@@ -384,7 +382,7 @@ ENGINE *ENGINE_by_id(const char *id)
                        engine_ref_debug(iterator, 0, 1)
                        }
                }
-       CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
 #if 0
        if(iterator == NULL)
                {
@@ -399,7 +397,7 @@ ENGINE *ENGINE_by_id(const char *id)
 #ifdef OPENSSL_SYS_VMS
        if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = "SSLROOT:[ENGINES]";
 #else
-       if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = OPENSSLDIR "/engines";
+       if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = ENGINESDIR;
 #endif
        iterator = ENGINE_by_id("dynamic");
        if(!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) ||
@@ -416,3 +414,14 @@ notfound:
        /* EEK! Experimental code ends */
 #endif
        }
+
+int ENGINE_up_ref(ENGINE *e)
+       {
+       if (e == NULL)
+               {
+               ENGINEerr(ENGINE_F_ENGINE_UP_REF,ERR_R_PASSED_NULL_PARAMETER);
+               return 0;
+               }
+       CRYPTO_add(&e->struct_ref,1,CRYPTO_LOCK_ENGINE);
+       return 1;
+       }