}
static UI_STRING *
-general_allocate_prompt(UI *ui, const char *prompt,
- int prompt_freeable, enum UI_string_types type, int input_flags,
- char *result_buf)
+general_allocate_prompt(UI *ui, const char *prompt, int prompt_freeable,
+ enum UI_string_types type, int input_flags, char *result_buf)
{
UI_STRING *ret = NULL;
if (prompt == NULL) {
- UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER);
+ UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,
+ ERR_R_PASSED_NULL_PARAMETER);
} else if ((type == UIT_PROMPT || type == UIT_VERIFY ||
type == UIT_BOOLEAN) && result_buf == NULL) {
UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER);
}
static int
-general_allocate_string(UI *ui, const char *prompt,
- int prompt_freeable, enum UI_string_types type, int input_flags,
- char *result_buf, int minsize, int maxsize, const char *test_buf)
+general_allocate_string(UI *ui, const char *prompt, int prompt_freeable,
+ enum UI_string_types type, int input_flags, char *result_buf, int minsize,
+ int maxsize, const char *test_buf)
{
int ret = -1;
UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable,
}
static int
-general_allocate_boolean(UI *ui,
- const char *prompt, const char *action_desc,
- const char *ok_chars, const char *cancel_chars,
- int prompt_freeable, enum UI_string_types type, int input_flags,
- char *result_buf)
+general_allocate_boolean(UI *ui, const char *prompt, const char *action_desc,
+ const char *ok_chars, const char *cancel_chars, int prompt_freeable,
+ enum UI_string_types type, int input_flags, char *result_buf)
{
int ret = -1;
UI_STRING *s;
const char *p;
if (ok_chars == NULL) {
- UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER);
+ UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,
+ ERR_R_PASSED_NULL_PARAMETER);
} else if (cancel_chars == NULL) {
- UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER);
+ UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,
+ ERR_R_PASSED_NULL_PARAMETER);
} else {
for (p = ok_chars; *p; p++) {
if (strchr(cancel_chars, *p)) {
/* Returns the index to the place in the stack or -1 for error. Uses a
direct reference to the prompt. */
int
-UI_add_input_string(UI *ui, const char *prompt, int flags,
- char *result_buf, int minsize, int maxsize)
+UI_add_input_string(UI *ui, const char *prompt, int flags, char *result_buf,
+ int minsize, int maxsize)
{
- return general_allocate_string(ui, prompt, 0,
- UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL);
+ return general_allocate_string(ui, prompt, 0, UIT_PROMPT, flags,
+ result_buf, minsize, maxsize, NULL);
}
/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
int
-UI_dup_input_string(UI *ui, const char *prompt, int flags,
- char *result_buf, int minsize, int maxsize)
+UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf,
+ int minsize, int maxsize)
{
char *prompt_copy = NULL;
return 0;
}
}
- return general_allocate_string(ui, prompt_copy, 1,
- UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL);
+ return general_allocate_string(ui, prompt_copy, 1, UIT_PROMPT, flags,
+ result_buf, minsize, maxsize, NULL);
}
int
-UI_add_verify_string(UI *ui, const char *prompt, int flags,
- char *result_buf, int minsize, int maxsize, const char *test_buf)
+UI_add_verify_string(UI *ui, const char *prompt, int flags, char *result_buf,
+ int minsize, int maxsize, const char *test_buf)
{
- return general_allocate_string(ui, prompt, 0,
- UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
+ return general_allocate_string(ui, prompt, 0, UIT_VERIFY, flags,
+ result_buf, minsize, maxsize, test_buf);
}
int
return -1;
}
}
- return general_allocate_string(ui, prompt_copy, 1,
- UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
+ return general_allocate_string(ui, prompt_copy, 1, UIT_VERIFY, flags,
+ result_buf, minsize, maxsize, test_buf);
}
int
UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
- 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)
{
- return general_allocate_boolean(ui, prompt, action_desc,
- ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf);
+ return general_allocate_boolean(ui, prompt, action_desc, ok_chars,
+ cancel_chars, 0, UIT_BOOLEAN, flags, result_buf);
}
int
UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
- 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;
UI_add_user_data(UI *ui, void *user_data)
{
void *old_data = ui->user_data;
+
ui->user_data = user_data;
return old_data;
}
}
}
}
+
err:
if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui))
return -1;
UI_METHOD *
UI_create_method(char *name)
{
- UI_METHOD *ui_method = (UI_METHOD *) malloc(sizeof(UI_METHOD));
+ UI_METHOD *ui_method = (UI_METHOD *)malloc(sizeof(UI_METHOD));
if (ui_method) {
memset(ui_method, 0, sizeof(*ui_method));
fprintf(tty_out, "Verifying - %s",
UI_get0_output_string(uis));
fflush(tty_out);
- if ((ok = read_string_inner(ui, uis,
- UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0)
+ if ((ok = read_string_inner(ui, uis, UI_get_input_flags(uis) &
+ UI_INPUT_FLAG_ECHO, 1)) <= 0)
return ok;
if (strcmp(UI_get0_result_string(uis),
UI_get0_test_string(uis)) != 0) {
}
static UI_STRING *
-general_allocate_prompt(UI *ui, const char *prompt,
- int prompt_freeable, enum UI_string_types type, int input_flags,
- char *result_buf)
+general_allocate_prompt(UI *ui, const char *prompt, int prompt_freeable,
+ enum UI_string_types type, int input_flags, char *result_buf)
{
UI_STRING *ret = NULL;
if (prompt == NULL) {
- UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER);
+ UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,
+ ERR_R_PASSED_NULL_PARAMETER);
} else if ((type == UIT_PROMPT || type == UIT_VERIFY ||
type == UIT_BOOLEAN) && result_buf == NULL) {
UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER);
}
static int
-general_allocate_string(UI *ui, const char *prompt,
- int prompt_freeable, enum UI_string_types type, int input_flags,
- char *result_buf, int minsize, int maxsize, const char *test_buf)
+general_allocate_string(UI *ui, const char *prompt, int prompt_freeable,
+ enum UI_string_types type, int input_flags, char *result_buf, int minsize,
+ int maxsize, const char *test_buf)
{
int ret = -1;
UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable,
}
static int
-general_allocate_boolean(UI *ui,
- const char *prompt, const char *action_desc,
- const char *ok_chars, const char *cancel_chars,
- int prompt_freeable, enum UI_string_types type, int input_flags,
- char *result_buf)
+general_allocate_boolean(UI *ui, const char *prompt, const char *action_desc,
+ const char *ok_chars, const char *cancel_chars, int prompt_freeable,
+ enum UI_string_types type, int input_flags, char *result_buf)
{
int ret = -1;
UI_STRING *s;
const char *p;
if (ok_chars == NULL) {
- UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER);
+ UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,
+ ERR_R_PASSED_NULL_PARAMETER);
} else if (cancel_chars == NULL) {
- UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER);
+ UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,
+ ERR_R_PASSED_NULL_PARAMETER);
} else {
for (p = ok_chars; *p; p++) {
if (strchr(cancel_chars, *p)) {
/* Returns the index to the place in the stack or -1 for error. Uses a
direct reference to the prompt. */
int
-UI_add_input_string(UI *ui, const char *prompt, int flags,
- char *result_buf, int minsize, int maxsize)
+UI_add_input_string(UI *ui, const char *prompt, int flags, char *result_buf,
+ int minsize, int maxsize)
{
- return general_allocate_string(ui, prompt, 0,
- UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL);
+ return general_allocate_string(ui, prompt, 0, UIT_PROMPT, flags,
+ result_buf, minsize, maxsize, NULL);
}
/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
int
-UI_dup_input_string(UI *ui, const char *prompt, int flags,
- char *result_buf, int minsize, int maxsize)
+UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf,
+ int minsize, int maxsize)
{
char *prompt_copy = NULL;
return 0;
}
}
- return general_allocate_string(ui, prompt_copy, 1,
- UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL);
+ return general_allocate_string(ui, prompt_copy, 1, UIT_PROMPT, flags,
+ result_buf, minsize, maxsize, NULL);
}
int
-UI_add_verify_string(UI *ui, const char *prompt, int flags,
- char *result_buf, int minsize, int maxsize, const char *test_buf)
+UI_add_verify_string(UI *ui, const char *prompt, int flags, char *result_buf,
+ int minsize, int maxsize, const char *test_buf)
{
- return general_allocate_string(ui, prompt, 0,
- UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
+ return general_allocate_string(ui, prompt, 0, UIT_VERIFY, flags,
+ result_buf, minsize, maxsize, test_buf);
}
int
return -1;
}
}
- return general_allocate_string(ui, prompt_copy, 1,
- UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
+ return general_allocate_string(ui, prompt_copy, 1, UIT_VERIFY, flags,
+ result_buf, minsize, maxsize, test_buf);
}
int
UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
- 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)
{
- return general_allocate_boolean(ui, prompt, action_desc,
- ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf);
+ return general_allocate_boolean(ui, prompt, action_desc, ok_chars,
+ cancel_chars, 0, UIT_BOOLEAN, flags, result_buf);
}
int
UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
- 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;
UI_add_user_data(UI *ui, void *user_data)
{
void *old_data = ui->user_data;
+
ui->user_data = user_data;
return old_data;
}
}
}
}
+
err:
if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui))
return -1;
UI_METHOD *
UI_create_method(char *name)
{
- UI_METHOD *ui_method = (UI_METHOD *) malloc(sizeof(UI_METHOD));
+ UI_METHOD *ui_method = (UI_METHOD *)malloc(sizeof(UI_METHOD));
if (ui_method) {
memset(ui_method, 0, sizeof(*ui_method));
fprintf(tty_out, "Verifying - %s",
UI_get0_output_string(uis));
fflush(tty_out);
- if ((ok = read_string_inner(ui, uis,
- UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0)
+ if ((ok = read_string_inner(ui, uis, UI_get_input_flags(uis) &
+ UI_INPUT_FLAG_ECHO, 1)) <= 0)
return ok;
if (strcmp(UI_get0_result_string(uis),
UI_get0_test_string(uis)) != 0) {