Add support for shared libraries with OS/2.
[oweals/openssl.git] / crypto / ui / ui_lib.c
index 932658e2b711ffc4297ab7f296550ec3662d93b0..16946cad95b0e4649715027fa29d821df2b529e2 100644 (file)
@@ -1,9 +1,9 @@
 /* crypto/ui/ui_lib.c -*- mode:C; c-file-style: "eay" -*- */
-/* Written by Richard Levitte (levitte@stacken.kth.se) for the OpenSSL
- * project 2000.
+/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
+ * project 2001.
  */
 /* ====================================================================
- * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -66,8 +66,6 @@
 IMPLEMENT_STACK_OF(UI_STRING_ST)
 
 static const UI_METHOD *default_UI_meth=NULL;
-static int ui_meth_num=0;
-static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ui_meth=NULL;
 
 UI *UI_new(void)
        {
@@ -91,7 +89,7 @@ UI *UI_new_method(const UI_METHOD *method)
 
        ret->strings=NULL;
        ret->user_data=NULL;
-       CRYPTO_new_ex_data(ui_meth,ret,&ret->ex_data);
+       CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data);
        return ret;
        }
 
@@ -119,6 +117,7 @@ void UI_free(UI *ui)
        if (ui == NULL)
                return;
        sk_UI_STRING_pop_free(ui->strings,free_string);
+       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_UI, ui, &ui->ex_data);
        OPENSSL_free(ui);
        }
 
@@ -574,9 +573,8 @@ int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)())
 int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
             CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
         {
-       ui_meth_num++;
-       return(CRYPTO_get_ex_new_index(ui_meth_num-1,
-               &ui_meth,argl,argp,new_func,dup_func,free_func));
+       return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp,
+                               new_func, dup_func, free_func);
         }
 
 int UI_set_ex_data(UI *r, int idx, void *arg)
@@ -706,6 +704,14 @@ int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*)
                return NULL;
        }
 
+int (*UI_method_get_flusher(UI_METHOD *method))(UI*)
+       {
+       if (method)
+               return method->ui_flush;
+       else
+               return NULL;
+       }
+
 int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*)
        {
        if (method)