ui_lib.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
* project 2001.
*/
/* ====================================================================
* 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
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* openssl-core@openssl.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
#include <string.h>
#include "ui_locl.h"
#include "cryptlib.h"
{
return(UI_new_method(NULL));
}
{
{
return NULL;
}
else
return ret;
}
{
{
{
case UIT_BOOLEAN:
break;
default:
break;
}
}
}
{
return;
}
{
{
{
return -1;
}
}
return 0;
}
char *result_buf)
{
{
}
{
}
{
}
return ret;
}
{
int ret = -1;
if (s)
{
if (allocate_string_stack(ui) >= 0)
{
/* sk_push() returns 0 on error. Let's addapt that */
}
else
free_string(s);
}
return ret;
}
const char *prompt, const char *action_desc,
const char *ok_chars, const char *cancel_chars,
char *result_buf)
{
int ret = -1;
UI_STRING *s;
const char *p;
{
}
else if (cancel_chars == NULL)
{
}
else
{
for(p = ok_chars; *p; p++)
{
if (strchr(cancel_chars, *p))
{
}
}
if (s)
{
if (allocate_string_stack(ui) >= 0)
{
/* sk_push() returns 0 on error.
Let's addapt that */
}
else
free_string(s);
}
}
return ret;
}
/* Returns the index to the place in the stack or -1 for error. Uses a
direct reference to the prompt. */
{
}
/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
{
char *prompt_copy=NULL;
if (prompt)
{
if (prompt_copy == NULL)
{
return 0;
}
}
}
{
}
{
char *prompt_copy=NULL;
if (prompt)
{
if (prompt_copy == NULL)
{
return -1;
}
}
}
const char *ok_chars, const char *cancel_chars,
int flags, char *result_buf)
{
}
const char *ok_chars, const char *cancel_chars,
int flags, char *result_buf)
{
char *prompt_copy = NULL;
char *action_desc_copy = NULL;
char *ok_chars_copy = NULL;
char *cancel_chars_copy = NULL;
if (prompt)
{
if (prompt_copy == NULL)
{
goto err;
}
}
if (action_desc)
{
if (action_desc_copy == NULL)
{
goto err;
}
}
if (ok_chars)
{
if (ok_chars_copy == NULL)
{
goto err;
}
}
if (cancel_chars)
{
if (cancel_chars_copy == NULL)
{
goto err;
}
}
err:
return -1;
}
{
NULL);
}
{
if (text)
{
{
return -1;
}
}
0, 0, NULL);
}
{
NULL);
}
{
if (text)
{
{
return -1;
}
}
0, 0, NULL);
}
const char *object_name)
{
else
{
char prompt1[] = "Enter ";
char prompt2[] = " for ";
char prompt3[] = ":";
int len = 0;
if (object_desc == NULL)
return NULL;
if (object_name)
if (object_name)
{
}
}
return prompt;
}
{
return old_data;
}
{
}
{
if (i < 0)
{
return NULL;
}
{
return NULL;
}
}
{
return -1;
return 0;
}
{
int i, ok=0;
return -1;
(int (*)(const char *, size_t, void *))print_error,
(void *)ui);
{
{
ok=-1;
goto err;
}
}
{
ok = -2;
goto err;
case 0: /* Errors */
ok = -1;
goto err;
default: /* Success */
ok = 0;
break;
}
{
{
{
ok = -2;
goto err;
case 0: /* Errors */
ok = -1;
goto err;
default: /* Success */
ok = 0;
break;
}
}
}
err:
return -1;
return ok;
}
{
{
return -1;
}
switch(cmd)
{
case UI_CTRL_PRINT_ERRORS:
{
if (i)
else
return save_flag;
}
case UI_CTRL_IS_REDOABLE:
default:
break;
}
return -1;
}
{
}
{
}
{
}
{
}
const UI_METHOD *UI_get_default_method(void)
{
if (default_UI_meth == NULL)
{
}
return default_UI_meth;
}
{
}
{
}
{
if (ui_method)
return ui_method;
}
/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method
(that is, it hasn't been allocated using UI_create_method(), you deserve
anything Murphy can throw at you and more! You have been warned. */
{
}
{
if (method)
{
return 0;
}
else
return -1;
}
{
if (method)
{
return 0;
}
else
return -1;
}
{
if (method)
{
return 0;
}
else
return -1;
}
{
if (method)
{
return 0;
}
else
return -1;
}
{
if (method)
{
return 0;
}
else
return -1;
}
{
if (method)
return method->ui_open_session;
else
return NULL;
}
{
if (method)
return method->ui_write_string;
else
return NULL;
}
{
if (method)
else
return NULL;
}
{
if (method)
return method->ui_read_string;
else
return NULL;
}
{
if (method)
return method->ui_close_session;
else
return NULL;
}
{
if (!uis)
return UIT_NONE;
}
{
if (!uis)
return 0;
return uis->input_flags;
}
{
if (!uis)
return NULL;
return uis->out_string;
}
{
if (!uis)
return NULL;
{
case UIT_PROMPT:
case UIT_BOOLEAN:
default:
return NULL;
}
}
{
if (!uis)
return NULL;
{
case UIT_PROMPT:
case UIT_VERIFY:
return uis->result_buf;
default:
return NULL;
}
}
{
if (!uis)
return NULL;
{
case UIT_VERIFY:
default:
return NULL;
}
}
{
if (!uis)
return -1;
{
case UIT_PROMPT:
case UIT_VERIFY:
default:
return -1;
}
}
{
if (!uis)
return -1;
{
case UIT_PROMPT:
case UIT_VERIFY:
default:
return -1;
}
}
{
if (!uis)
return -1;
{
case UIT_PROMPT:
case UIT_VERIFY:
{
{
return -1;
}
{
return -1;
}
}
if (!uis->result_buf)
{
return -1;
}
break;
case UIT_BOOLEAN:
{
const char *p;
if (!uis->result_buf)
{
return -1;
}
for(p = result; *p; p++)
{
{
uis->result_buf[0] =
break;
}
{
uis->result_buf[0] =
break;
}
}
default:
break;
}
}
return 0;
}