Build fixes
[openssl.git] / crypto / engine / eng_dyn.c
index 5803c0123a0a22637a6fd6c685c24ec3ce2f503e..01db4556aaa0af52d3bf32519c6ddd3b2ef17ee6 100644 (file)
  */
 
 
-#include <stdio.h>
-#include <openssl/crypto.h>
-#include "cryptlib.h"
 #include "eng_int.h"
-#include <openssl/engine.h>
 #include <openssl/dso.h>
 
 /* Shared libraries implementing ENGINEs for use by the "dynamic" ENGINE loader
@@ -70,7 +66,7 @@
 /* Our ENGINE handlers */
 static int dynamic_init(ENGINE *e);
 static int dynamic_finish(ENGINE *e);
-static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
+static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void));
 /* Predeclare our context type */
 typedef struct st_dynamic_data_ctx dynamic_data_ctx;
 /* The implementation for the important control command */
@@ -118,9 +114,6 @@ static const ENGINE_CMD_DEFN dynamic_cmd_defns[] = {
                ENGINE_CMD_FLAG_NO_INPUT},
        {0, NULL, NULL, 0}
        };
-static const ENGINE_CMD_DEFN dynamic_cmd_defns_empty[] = {
-       {0, NULL, NULL, 0}
-       };
 
 /* Loading code stores state inside the ENGINE structure via the "ex_data"
  * element. We load all our state into a single structure and use that as a
@@ -150,14 +143,14 @@ struct st_dynamic_data_ctx
         * 'dirs' for loading. Default is to use 'dirs' as a fallback. */
        int dir_load;
        /* A stack of directories from which ENGINEs could be loaded */
-       STACK *dirs;
+       STACK_OF(OPENSSL_STRING) *dirs;
        };
 
 /* This is the "ex_data" index we obtain and reserve for use with our context
  * structure. */
 static int dynamic_ex_data_idx = -1;
 
-static void int_free_str(void *s) { OPENSSL_free(s); }
+static void int_free_str(char *s) { OPENSSL_free(s); }
 /* Because our ex_data element may or may not get allocated depending on whether
  * a "first-use" occurs before the ENGINE is freed, we have a memory leak
  * problem to solve. We can't declare a "new" handler for the ex_data as we
@@ -178,7 +171,7 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr,
                if(ctx->engine_id)
                        OPENSSL_free((void*)ctx->engine_id);
                if(ctx->dirs)
-                       sk_pop_free(ctx->dirs, int_free_str);
+                       sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str);
                OPENSSL_free(ctx);
                }
        }
@@ -193,7 +186,7 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
        c = OPENSSL_malloc(sizeof(dynamic_data_ctx));
        if(!c)
                {
-               ENGINEerr(ENGINE_F_SET_DATA_CTX,ERR_R_MALLOC_FAILURE);
+               ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX,ERR_R_MALLOC_FAILURE);
                return 0;
                }
        memset(c, 0, sizeof(dynamic_data_ctx));
@@ -207,10 +200,10 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
        c->DYNAMIC_F1 = "v_check";
        c->DYNAMIC_F2 = "bind_engine";
        c->dir_load = 1;
-       c->dirs = sk_new_null();
+       c->dirs = sk_OPENSSL_STRING_new_null();
        if(!c->dirs)
                {
-               ENGINEerr(ENGINE_F_SET_DATA_CTX,ERR_R_MALLOC_FAILURE);
+               ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX,ERR_R_MALLOC_FAILURE);
                OPENSSL_free(c);
                return 0;
                }
@@ -316,7 +309,7 @@ static int dynamic_finish(ENGINE *e)
        return 0;
        }
 
-static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
+static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
        {
        dynamic_data_ctx *ctx = dynamic_get_data_ctx(e);
        int initialised;
@@ -397,7 +390,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
                                ERR_R_MALLOC_FAILURE);
                        return 0;
                        }
-               sk_insert(ctx->dirs, tmp_str, -1);
+               sk_OPENSSL_STRING_insert(ctx->dirs, tmp_str, -1);
                }
                return 1;
        default:
@@ -415,11 +408,11 @@ static int int_load(dynamic_data_ctx *ctx)
                                ctx->DYNAMIC_LIBNAME, NULL, 0)) != NULL)
                return 1;
        /* If we're not allowed to use 'dirs' or we have none, fail */
-       if(!ctx->dir_load || ((num = sk_num(ctx->dirs)) < 1))
+       if(!ctx->dir_load || (num = sk_OPENSSL_STRING_num(ctx->dirs)) < 1)
                return 0;
        for(loop = 0; loop < num; loop++)
                {
-               const char *s = sk_value(ctx->dirs, loop);
+               const char *s = sk_OPENSSL_STRING_value(ctx->dirs, loop);
                char *merge = DSO_merge(ctx->dynamic_dso, ctx->DYNAMIC_LIBNAME, s);
                if(!merge)
                        return 0;
@@ -500,6 +493,7 @@ static int dynamic_load(ENGINE *e, dynamic_data_ctx *ctx)
         * engine.h, much of this would be simplified if each area of code
         * provided its own "summary" structure of all related callbacks. It
         * would also increase opaqueness. */
+       fns.static_state = ENGINE_get_static_state();
        fns.err_fns = ERR_get_implementation();
        fns.ex_data_fns = CRYPTO_get_ex_data_implementation();
        CRYPTO_get_mem_functions(&fns.mem_fns.malloc_cb,