Defining __USE_XOPEN_EXTENDED was the wrong thing. Instead, define
[openssl.git] / crypto / ui / ui_lib.c
index 132236fe65095edaa3fce4e18328ee1ac54f4268..f55a79c740c7b29bcb9cf5ff9095ac952d7bdf16 100644 (file)
  *
  */
 
+#include <openssl/e_os2.h>
+/* The following defines enable the declaration of strdup(), which is an
+   extended function according to X/Open. */
+#ifdef OPENSSL_SYS_VMS_DECC
+# define _XOPEN_SOURCE_EXTENDED
+#endif
+#ifdef OPENSSL_SYS_UNIX
+# define _XOPEN_SOURCE
+# define _XOPEN_SOURCE_EXTENDED        /* For Linux and probably anything GNU */
+#endif
 #include <string.h>
 
 #include <openssl/ui.h>
@@ -92,9 +102,8 @@ UI *UI_new_method(const UI_METHOD *method)
        return ret;
        }
 
-static void free_string(void *data)
+static void free_string(UI_STRING *uis)
        {
-       UI_STRING *uis = (UI_STRING *)data;
        if (uis->flags & OUT_STRING_FREEABLE)
                OPENSSL_free((char *)uis->out_string);
        OPENSSL_free(uis);
@@ -248,6 +257,18 @@ int UI_dup_error_string(UI *ui, const char *text)
                NULL);
        }
 
+void *UI_add_user_data(UI *ui, void *user_data)
+       {
+       void *old_data = ui->user_data;
+       ui->user_data = user_data;
+       return old_data;
+       }
+
+void *UI_get0_user_data(UI *ui)
+       {
+       return ui->user_data;
+       }
+
 const char *UI_get0_result(UI *ui, int i)
        {
        if (i < 0)