summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ui/ui_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ui/ui_lib.c')
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c227
1 files changed, 115 insertions, 112 deletions
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index 32fb9d7dbb..fc03d9b7d4 100644
--- a/src/lib/libcrypto/ui/ui_lib.c
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -64,16 +64,16 @@
64#include <openssl/err.h> 64#include <openssl/err.h>
65#include "ui_locl.h" 65#include "ui_locl.h"
66 66
67IMPLEMENT_STACK_OF(UI_STRING_ST) 67IMPLEMENT_STACK_OF(UI_STRING_ST) static const UI_METHOD *default_UI_meth = NULL;
68 static const UI_METHOD *default_UI_meth = NULL;
69 68
70 UI *UI_new(void) 69UI *
70UI_new(void)
71{ 71{
72 return (UI_new_method(NULL)); 72 return (UI_new_method(NULL));
73} 73}
74 74
75UI * 75UI *
76UI_new_method(const UI_METHOD * method) 76UI_new_method(const UI_METHOD *method)
77{ 77{
78 UI *ret; 78 UI *ret;
79 79
@@ -94,16 +94,16 @@ UI_new_method(const UI_METHOD * method)
94 return ret; 94 return ret;
95} 95}
96 96
97static void 97static void
98free_string(UI_STRING * uis) 98free_string(UI_STRING *uis)
99{ 99{
100 if (uis->flags & OUT_STRING_FREEABLE) { 100 if (uis->flags & OUT_STRING_FREEABLE) {
101 free((char *) uis->out_string); 101 free((char *) uis->out_string);
102 switch (uis->type) { 102 switch (uis->type) {
103 case UIT_BOOLEAN: 103 case UIT_BOOLEAN:
104 free((char *) uis->_.boolean_data.action_desc); 104 free((char *)uis->_.boolean_data.action_desc);
105 free((char *) uis->_.boolean_data.ok_chars); 105 free((char *)uis->_.boolean_data.ok_chars);
106 free((char *) uis->_.boolean_data.cancel_chars); 106 free((char *)uis->_.boolean_data.cancel_chars);
107 break; 107 break;
108 default: 108 default:
109 break; 109 break;
@@ -112,8 +112,8 @@ free_string(UI_STRING * uis)
112 free(uis); 112 free(uis);
113} 113}
114 114
115void 115void
116UI_free(UI * ui) 116UI_free(UI *ui)
117{ 117{
118 if (ui == NULL) 118 if (ui == NULL)
119 return; 119 return;
@@ -122,8 +122,8 @@ UI_free(UI * ui)
122 free(ui); 122 free(ui);
123} 123}
124 124
125static int 125static int
126allocate_string_stack(UI * ui) 126allocate_string_stack(UI *ui)
127{ 127{
128 if (ui->strings == NULL) { 128 if (ui->strings == NULL) {
129 ui->strings = sk_UI_STRING_new_null(); 129 ui->strings = sk_UI_STRING_new_null();
@@ -135,7 +135,7 @@ allocate_string_stack(UI * ui)
135} 135}
136 136
137static UI_STRING * 137static UI_STRING *
138general_allocate_prompt(UI * ui, const char *prompt, 138general_allocate_prompt(UI *ui, const char *prompt,
139 int prompt_freeable, enum UI_string_types type, int input_flags, 139 int prompt_freeable, enum UI_string_types type, int input_flags,
140 char *result_buf) 140 char *result_buf)
141{ 141{
@@ -143,8 +143,8 @@ general_allocate_prompt(UI * ui, const char *prompt,
143 143
144 if (prompt == NULL) { 144 if (prompt == NULL) {
145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER); 145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER);
146 } else if ((type == UIT_PROMPT || type == UIT_VERIFY 146 } else if ((type == UIT_PROMPT || type == UIT_VERIFY ||
147 || type == UIT_BOOLEAN) && result_buf == NULL) { 147 type == UIT_BOOLEAN) && result_buf == NULL) {
148 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER); 148 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER);
149 } else if ((ret = (UI_STRING *) malloc(sizeof(UI_STRING)))) { 149 } else if ((ret = (UI_STRING *) malloc(sizeof(UI_STRING)))) {
150 ret->out_string = prompt; 150 ret->out_string = prompt;
@@ -156,8 +156,8 @@ general_allocate_prompt(UI * ui, const char *prompt,
156 return ret; 156 return ret;
157} 157}
158 158
159static int 159static int
160general_allocate_string(UI * ui, const char *prompt, 160general_allocate_string(UI *ui, const char *prompt,
161 int prompt_freeable, enum UI_string_types type, int input_flags, 161 int prompt_freeable, enum UI_string_types type, int input_flags,
162 char *result_buf, int minsize, int maxsize, const char *test_buf) 162 char *result_buf, int minsize, int maxsize, const char *test_buf)
163{ 163{
@@ -180,8 +180,8 @@ general_allocate_string(UI * ui, const char *prompt,
180 return ret; 180 return ret;
181} 181}
182 182
183static int 183static int
184general_allocate_boolean(UI * ui, 184general_allocate_boolean(UI *ui,
185 const char *prompt, const char *action_desc, 185 const char *prompt, const char *action_desc,
186 const char *ok_chars, const char *cancel_chars, 186 const char *ok_chars, const char *cancel_chars,
187 int prompt_freeable, enum UI_string_types type, int input_flags, 187 int prompt_freeable, enum UI_string_types type, int input_flags,
@@ -227,8 +227,8 @@ general_allocate_boolean(UI * ui,
227 227
228/* Returns the index to the place in the stack or -1 for error. Uses a 228/* Returns the index to the place in the stack or -1 for error. Uses a
229 direct reference to the prompt. */ 229 direct reference to the prompt. */
230int 230int
231UI_add_input_string(UI * ui, const char *prompt, int flags, 231UI_add_input_string(UI *ui, const char *prompt, int flags,
232 char *result_buf, int minsize, int maxsize) 232 char *result_buf, int minsize, int maxsize)
233{ 233{
234 return general_allocate_string(ui, prompt, 0, 234 return general_allocate_string(ui, prompt, 0,
@@ -236,8 +236,8 @@ UI_add_input_string(UI * ui, const char *prompt, int flags,
236} 236}
237 237
238/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */ 238/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
239int 239int
240UI_dup_input_string(UI * ui, const char *prompt, int flags, 240UI_dup_input_string(UI *ui, const char *prompt, int flags,
241 char *result_buf, int minsize, int maxsize) 241 char *result_buf, int minsize, int maxsize)
242{ 242{
243 char *prompt_copy = NULL; 243 char *prompt_copy = NULL;
@@ -253,16 +253,16 @@ UI_dup_input_string(UI * ui, const char *prompt, int flags,
253 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); 253 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL);
254} 254}
255 255
256int 256int
257UI_add_verify_string(UI * ui, const char *prompt, int flags, 257UI_add_verify_string(UI *ui, const char *prompt, int flags,
258 char *result_buf, int minsize, int maxsize, const char *test_buf) 258 char *result_buf, int minsize, int maxsize, const char *test_buf)
259{ 259{
260 return general_allocate_string(ui, prompt, 0, 260 return general_allocate_string(ui, prompt, 0,
261 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); 261 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
262} 262}
263 263
264int 264int
265UI_dup_verify_string(UI * ui, const char *prompt, int flags, 265UI_dup_verify_string(UI *ui, const char *prompt, int flags,
266 char *result_buf, int minsize, int maxsize, const char *test_buf) 266 char *result_buf, int minsize, int maxsize, const char *test_buf)
267{ 267{
268 char *prompt_copy = NULL; 268 char *prompt_copy = NULL;
@@ -278,8 +278,8 @@ UI_dup_verify_string(UI * ui, const char *prompt, int flags,
278 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); 278 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
279} 279}
280 280
281int 281int
282UI_add_input_boolean(UI * ui, const char *prompt, const char *action_desc, 282UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
283 const char *ok_chars, const char *cancel_chars, 283 const char *ok_chars, const char *cancel_chars,
284 int flags, char *result_buf) 284 int flags, char *result_buf)
285{ 285{
@@ -287,8 +287,8 @@ UI_add_input_boolean(UI * ui, const char *prompt, const char *action_desc,
287 ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf); 287 ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf);
288} 288}
289 289
290int 290int
291UI_dup_input_boolean(UI * ui, const char *prompt, const char *action_desc, 291UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
292 const char *ok_chars, const char *cancel_chars, 292 const char *ok_chars, const char *cancel_chars,
293 int flags, char *result_buf) 293 int flags, char *result_buf)
294{ 294{
@@ -328,6 +328,7 @@ UI_dup_input_boolean(UI * ui, const char *prompt, const char *action_desc,
328 return general_allocate_boolean(ui, prompt_copy, action_desc_copy, 328 return general_allocate_boolean(ui, prompt_copy, action_desc_copy,
329 ok_chars_copy, cancel_chars_copy, 1, UIT_BOOLEAN, flags, 329 ok_chars_copy, cancel_chars_copy, 1, UIT_BOOLEAN, flags,
330 result_buf); 330 result_buf);
331
331err: 332err:
332 if (prompt_copy) 333 if (prompt_copy)
333 free(prompt_copy); 334 free(prompt_copy);
@@ -340,15 +341,15 @@ err:
340 return -1; 341 return -1;
341} 342}
342 343
343int 344int
344UI_add_info_string(UI * ui, const char *text) 345UI_add_info_string(UI *ui, const char *text)
345{ 346{
346 return general_allocate_string(ui, text, 0, UIT_INFO, 0, NULL, 0, 0, 347 return general_allocate_string(ui, text, 0, UIT_INFO, 0, NULL, 0, 0,
347 NULL); 348 NULL);
348} 349}
349 350
350int 351int
351UI_dup_info_string(UI * ui, const char *text) 352UI_dup_info_string(UI *ui, const char *text)
352{ 353{
353 char *text_copy = NULL; 354 char *text_copy = NULL;
354 355
@@ -363,15 +364,15 @@ UI_dup_info_string(UI * ui, const char *text)
363 0, 0, NULL); 364 0, 0, NULL);
364} 365}
365 366
366int 367int
367UI_add_error_string(UI * ui, const char *text) 368UI_add_error_string(UI *ui, const char *text)
368{ 369{
369 return general_allocate_string(ui, text, 0, UIT_ERROR, 0, NULL, 0, 0, 370 return general_allocate_string(ui, text, 0, UIT_ERROR, 0, NULL, 0, 0,
370 NULL); 371 NULL);
371} 372}
372 373
373int 374int
374UI_dup_error_string(UI * ui, const char *text) 375UI_dup_error_string(UI *ui, const char *text)
375{ 376{
376 char *text_copy = NULL; 377 char *text_copy = NULL;
377 378
@@ -387,8 +388,7 @@ UI_dup_error_string(UI * ui, const char *text)
387} 388}
388 389
389char * 390char *
390UI_construct_prompt(UI * ui, const char *object_desc, 391UI_construct_prompt(UI *ui, const char *object_desc, const char *object_name)
391 const char *object_name)
392{ 392{
393 char *prompt = NULL; 393 char *prompt = NULL;
394 394
@@ -408,7 +408,7 @@ UI_construct_prompt(UI * ui, const char *object_desc,
408 len += sizeof(prompt2) - 1 + strlen(object_name); 408 len += sizeof(prompt2) - 1 + strlen(object_name);
409 len += sizeof(prompt3) - 1; 409 len += sizeof(prompt3) - 1;
410 410
411 prompt = (char *) malloc(len + 1); 411 prompt = (char *)malloc(len + 1);
412 BUF_strlcpy(prompt, prompt1, len + 1); 412 BUF_strlcpy(prompt, prompt1, len + 1);
413 BUF_strlcat(prompt, object_desc, len + 1); 413 BUF_strlcat(prompt, object_desc, len + 1);
414 if (object_name) { 414 if (object_name) {
@@ -421,7 +421,7 @@ UI_construct_prompt(UI * ui, const char *object_desc,
421} 421}
422 422
423void * 423void *
424UI_add_user_data(UI * ui, void *user_data) 424UI_add_user_data(UI *ui, void *user_data)
425{ 425{
426 void *old_data = ui->user_data; 426 void *old_data = ui->user_data;
427 ui->user_data = user_data; 427 ui->user_data = user_data;
@@ -429,13 +429,13 @@ UI_add_user_data(UI * ui, void *user_data)
429} 429}
430 430
431void * 431void *
432UI_get0_user_data(UI * ui) 432UI_get0_user_data(UI *ui)
433{ 433{
434 return ui->user_data; 434 return ui->user_data;
435} 435}
436 436
437const char * 437const char *
438UI_get0_result(UI * ui, int i) 438UI_get0_result(UI *ui, int i)
439{ 439{
440 if (i < 0) { 440 if (i < 0) {
441 UIerr(UI_F_UI_GET0_RESULT, UI_R_INDEX_TOO_SMALL); 441 UIerr(UI_F_UI_GET0_RESULT, UI_R_INDEX_TOO_SMALL);
@@ -448,8 +448,8 @@ UI_get0_result(UI * ui, int i)
448 return UI_get0_result_string(sk_UI_STRING_value(ui->strings, i)); 448 return UI_get0_result_string(sk_UI_STRING_value(ui->strings, i));
449} 449}
450 450
451static int 451static int
452print_error(const char *str, size_t len, UI * ui) 452print_error(const char *str, size_t len, UI *ui)
453{ 453{
454 UI_STRING uis; 454 UI_STRING uis;
455 455
@@ -457,14 +457,14 @@ print_error(const char *str, size_t len, UI * ui)
457 uis.type = UIT_ERROR; 457 uis.type = UIT_ERROR;
458 uis.out_string = str; 458 uis.out_string = str;
459 459
460 if (ui->meth->ui_write_string 460 if (ui->meth->ui_write_string &&
461 && !ui->meth->ui_write_string(ui, &uis)) 461 !ui->meth->ui_write_string(ui, &uis))
462 return -1; 462 return -1;
463 return 0; 463 return 0;
464} 464}
465 465
466int 466int
467UI_process(UI * ui) 467UI_process(UI *ui)
468{ 468{
469 int i, ok = 0; 469 int i, ok = 0;
470 470
@@ -473,12 +473,12 @@ UI_process(UI * ui)
473 473
474 if (ui->flags & UI_FLAG_PRINT_ERRORS) 474 if (ui->flags & UI_FLAG_PRINT_ERRORS)
475 ERR_print_errors_cb( 475 ERR_print_errors_cb(
476 (int (*) (const char *, size_t, void *)) print_error, 476 (int (*)(const char *, size_t, void *)) print_error,
477 (void *) ui); 477 (void *)ui);
478 478
479 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) { 479 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) {
480 if (ui->meth->ui_write_string 480 if (ui->meth->ui_write_string &&
481 && !ui->meth->ui_write_string(ui, 481 !ui->meth->ui_write_string(ui,
482 sk_UI_STRING_value(ui->strings, i))) { 482 sk_UI_STRING_value(ui->strings, i))) {
483 ok = -1; 483 ok = -1;
484 goto err; 484 goto err;
@@ -490,7 +490,7 @@ UI_process(UI * ui)
490 case -1: /* Interrupt/Cancel/something... */ 490 case -1: /* Interrupt/Cancel/something... */
491 ok = -2; 491 ok = -2;
492 goto err; 492 goto err;
493 case 0: /* Errors */ 493 case 0: /* Errors */
494 ok = -1; 494 ok = -1;
495 goto err; 495 goto err;
496 default: /* Success */ 496 default: /* Success */
@@ -501,11 +501,11 @@ UI_process(UI * ui)
501 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) { 501 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) {
502 if (ui->meth->ui_read_string) { 502 if (ui->meth->ui_read_string) {
503 switch (ui->meth->ui_read_string(ui, 503 switch (ui->meth->ui_read_string(ui,
504 sk_UI_STRING_value(ui->strings, i))) { 504 sk_UI_STRING_value(ui->strings, i))) {
505 case -1: /* Interrupt/Cancel/something... */ 505 case -1: /* Interrupt/Cancel/something... */
506 ok = -2; 506 ok = -2;
507 goto err; 507 goto err;
508 case 0:/* Errors */ 508 case 0: /* Errors */
509 ok = -1; 509 ok = -1;
510 goto err; 510 goto err;
511 default: /* Success */ 511 default: /* Success */
@@ -520,8 +520,8 @@ err:
520 return ok; 520 return ok;
521} 521}
522 522
523int 523int
524UI_ctrl(UI * ui, int cmd, long i, void *p, void (*f) (void)) 524UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void))
525{ 525{
526 if (ui == NULL) { 526 if (ui == NULL) {
527 UIerr(UI_F_UI_CTRL, ERR_R_PASSED_NULL_PARAMETER); 527 UIerr(UI_F_UI_CTRL, ERR_R_PASSED_NULL_PARAMETER);
@@ -546,28 +546,28 @@ UI_ctrl(UI * ui, int cmd, long i, void *p, void (*f) (void))
546 return -1; 546 return -1;
547} 547}
548 548
549int 549int
550UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new * new_func, 550UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
551 CRYPTO_EX_dup * dup_func, CRYPTO_EX_free * free_func) 551 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
552{ 552{
553 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp, 553 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp,
554 new_func, dup_func, free_func); 554 new_func, dup_func, free_func);
555} 555}
556 556
557int 557int
558UI_set_ex_data(UI * r, int idx, void *arg) 558UI_set_ex_data(UI *r, int idx, void *arg)
559{ 559{
560 return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); 560 return (CRYPTO_set_ex_data(&r->ex_data, idx, arg));
561} 561}
562 562
563void * 563void *
564UI_get_ex_data(UI * r, int idx) 564UI_get_ex_data(UI *r, int idx)
565{ 565{
566 return (CRYPTO_get_ex_data(&r->ex_data, idx)); 566 return (CRYPTO_get_ex_data(&r->ex_data, idx));
567} 567}
568 568
569void 569void
570UI_set_default_method(const UI_METHOD * meth) 570UI_set_default_method(const UI_METHOD *meth)
571{ 571{
572 default_UI_meth = meth; 572 default_UI_meth = meth;
573} 573}
@@ -582,13 +582,13 @@ UI_get_default_method(void)
582} 582}
583 583
584const UI_METHOD * 584const UI_METHOD *
585UI_get_method(UI * ui) 585UI_get_method(UI *ui)
586{ 586{
587 return ui->meth; 587 return ui->meth;
588} 588}
589 589
590const UI_METHOD * 590const UI_METHOD *
591UI_set_method(UI * ui, const UI_METHOD * meth) 591UI_set_method(UI *ui, const UI_METHOD *meth)
592{ 592{
593 ui->meth = meth; 593 ui->meth = meth;
594 return ui->meth; 594 return ui->meth;
@@ -610,16 +610,16 @@ UI_create_method(char *name)
610/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method 610/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method
611 (that is, it hasn't been allocated using UI_create_method(), you deserve 611 (that is, it hasn't been allocated using UI_create_method(), you deserve
612 anything Murphy can throw at you and more! You have been warned. */ 612 anything Murphy can throw at you and more! You have been warned. */
613void 613void
614UI_destroy_method(UI_METHOD * ui_method) 614UI_destroy_method(UI_METHOD *ui_method)
615{ 615{
616 free(ui_method->name); 616 free(ui_method->name);
617 ui_method->name = NULL; 617 ui_method->name = NULL;
618 free(ui_method); 618 free(ui_method);
619} 619}
620 620
621int 621int
622UI_method_set_opener(UI_METHOD * method, int (*opener) (UI * ui)) 622UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui))
623{ 623{
624 if (method) { 624 if (method) {
625 method->ui_open_session = opener; 625 method->ui_open_session = opener;
@@ -628,8 +628,8 @@ UI_method_set_opener(UI_METHOD * method, int (*opener) (UI * ui))
628 return -1; 628 return -1;
629} 629}
630 630
631int 631int
632UI_method_set_writer(UI_METHOD * method, int (*writer) (UI * ui, UI_STRING * uis)) 632UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis))
633{ 633{
634 if (method) { 634 if (method) {
635 method->ui_write_string = writer; 635 method->ui_write_string = writer;
@@ -638,8 +638,8 @@ UI_method_set_writer(UI_METHOD * method, int (*writer) (UI * ui, UI_STRING * uis
638 return -1; 638 return -1;
639} 639}
640 640
641int 641int
642UI_method_set_flusher(UI_METHOD * method, int (*flusher) (UI * ui)) 642UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui))
643{ 643{
644 if (method) { 644 if (method) {
645 method->ui_flush = flusher; 645 method->ui_flush = flusher;
@@ -648,8 +648,8 @@ UI_method_set_flusher(UI_METHOD * method, int (*flusher) (UI * ui))
648 return -1; 648 return -1;
649} 649}
650 650
651int 651int
652UI_method_set_reader(UI_METHOD * method, int (*reader) (UI * ui, UI_STRING * uis)) 652UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis))
653{ 653{
654 if (method) { 654 if (method) {
655 method->ui_read_string = reader; 655 method->ui_read_string = reader;
@@ -658,8 +658,8 @@ UI_method_set_reader(UI_METHOD * method, int (*reader) (UI * ui, UI_STRING * uis
658 return -1; 658 return -1;
659} 659}
660 660
661int 661int
662UI_method_set_closer(UI_METHOD * method, int (*closer) (UI * ui)) 662UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui))
663{ 663{
664 if (method) { 664 if (method) {
665 method->ui_close_session = closer; 665 method->ui_close_session = closer;
@@ -668,8 +668,10 @@ UI_method_set_closer(UI_METHOD * method, int (*closer) (UI * ui))
668 return -1; 668 return -1;
669} 669}
670 670
671int 671int
672UI_method_set_prompt_constructor(UI_METHOD * method, char *(*prompt_constructor) (UI * ui, const char *object_desc, const char *object_name)) 672UI_method_set_prompt_constructor(UI_METHOD *method,
673 char *(*prompt_constructor)(UI *ui, const char *object_desc,
674 const char *object_name))
673{ 675{
674 if (method) { 676 if (method) {
675 method->ui_construct_prompt = prompt_constructor; 677 method->ui_construct_prompt = prompt_constructor;
@@ -678,8 +680,8 @@ UI_method_set_prompt_constructor(UI_METHOD * method, char *(*prompt_constructor)
678 return -1; 680 return -1;
679} 681}
680 682
681int (* 683int
682 UI_method_get_opener(UI_METHOD * method)) (UI *) 684(*UI_method_get_opener(UI_METHOD * method))(UI *)
683{ 685{
684 if (method) 686 if (method)
685 return method->ui_open_session; 687 return method->ui_open_session;
@@ -687,8 +689,8 @@ int (*
687 return NULL; 689 return NULL;
688} 690}
689 691
690int (* 692int
691 UI_method_get_writer(UI_METHOD * method)) (UI *, UI_STRING *) 693(*UI_method_get_writer(UI_METHOD *method))(UI *, UI_STRING *)
692{ 694{
693 if (method) 695 if (method)
694 return method->ui_write_string; 696 return method->ui_write_string;
@@ -696,8 +698,8 @@ int (*
696 return NULL; 698 return NULL;
697} 699}
698 700
699int (* 701int
700 UI_method_get_flusher(UI_METHOD * method)) (UI *) 702(*UI_method_get_flusher(UI_METHOD *method)) (UI *)
701{ 703{
702 if (method) 704 if (method)
703 return method->ui_flush; 705 return method->ui_flush;
@@ -705,8 +707,8 @@ int (*
705 return NULL; 707 return NULL;
706} 708}
707 709
708int (* 710int
709 UI_method_get_reader(UI_METHOD * method)) (UI *, UI_STRING *) 711(*UI_method_get_reader(UI_METHOD *method))(UI *, UI_STRING *)
710{ 712{
711 if (method) 713 if (method)
712 return method->ui_read_string; 714 return method->ui_read_string;
@@ -714,8 +716,8 @@ int (*
714 return NULL; 716 return NULL;
715} 717}
716 718
717int (* 719int
718 UI_method_get_closer(UI_METHOD * method)) (UI *) 720(*UI_method_get_closer(UI_METHOD *method))(UI *)
719{ 721{
720 if (method) 722 if (method)
721 return method->ui_close_session; 723 return method->ui_close_session;
@@ -723,8 +725,9 @@ int (*
723 return NULL; 725 return NULL;
724} 726}
725 727
726char *(* 728char *
727 UI_method_get_prompt_constructor(UI_METHOD * method)) (UI *, const char *, const char *) 729(*UI_method_get_prompt_constructor(UI_METHOD *method))(UI *, const char *,
730 const char *)
728{ 731{
729 if (method) 732 if (method)
730 return method->ui_construct_prompt; 733 return method->ui_construct_prompt;
@@ -732,16 +735,16 @@ char *(*
732 return NULL; 735 return NULL;
733} 736}
734 737
735enum UI_string_types 738enum UI_string_types
736UI_get_string_type(UI_STRING * uis) 739UI_get_string_type(UI_STRING *uis)
737{ 740{
738 if (!uis) 741 if (!uis)
739 return UIT_NONE; 742 return UIT_NONE;
740 return uis->type; 743 return uis->type;
741} 744}
742 745
743int 746int
744UI_get_input_flags(UI_STRING * uis) 747UI_get_input_flags(UI_STRING *uis)
745{ 748{
746 if (!uis) 749 if (!uis)
747 return 0; 750 return 0;
@@ -749,7 +752,7 @@ UI_get_input_flags(UI_STRING * uis)
749} 752}
750 753
751const char * 754const char *
752UI_get0_output_string(UI_STRING * uis) 755UI_get0_output_string(UI_STRING *uis)
753{ 756{
754 if (!uis) 757 if (!uis)
755 return NULL; 758 return NULL;
@@ -757,7 +760,7 @@ UI_get0_output_string(UI_STRING * uis)
757} 760}
758 761
759const char * 762const char *
760UI_get0_action_string(UI_STRING * uis) 763UI_get0_action_string(UI_STRING *uis)
761{ 764{
762 if (!uis) 765 if (!uis)
763 return NULL; 766 return NULL;
@@ -771,7 +774,7 @@ UI_get0_action_string(UI_STRING * uis)
771} 774}
772 775
773const char * 776const char *
774UI_get0_result_string(UI_STRING * uis) 777UI_get0_result_string(UI_STRING *uis)
775{ 778{
776 if (!uis) 779 if (!uis)
777 return NULL; 780 return NULL;
@@ -785,7 +788,7 @@ UI_get0_result_string(UI_STRING * uis)
785} 788}
786 789
787const char * 790const char *
788UI_get0_test_string(UI_STRING * uis) 791UI_get0_test_string(UI_STRING *uis)
789{ 792{
790 if (!uis) 793 if (!uis)
791 return NULL; 794 return NULL;
@@ -797,8 +800,8 @@ UI_get0_test_string(UI_STRING * uis)
797 } 800 }
798} 801}
799 802
800int 803int
801UI_get_result_minsize(UI_STRING * uis) 804UI_get_result_minsize(UI_STRING *uis)
802{ 805{
803 if (!uis) 806 if (!uis)
804 return -1; 807 return -1;
@@ -811,8 +814,8 @@ UI_get_result_minsize(UI_STRING * uis)
811 } 814 }
812} 815}
813 816
814int 817int
815UI_get_result_maxsize(UI_STRING * uis) 818UI_get_result_maxsize(UI_STRING *uis)
816{ 819{
817 if (!uis) 820 if (!uis)
818 return -1; 821 return -1;
@@ -825,8 +828,8 @@ UI_get_result_maxsize(UI_STRING * uis)
825 } 828 }
826} 829}
827 830
828int 831int
829UI_set_result(UI * ui, UI_STRING * uis, const char *result) 832UI_set_result(UI *ui, UI_STRING *uis, const char *result)
830{ 833{
831 int l = strlen(result); 834 int l = strlen(result);
832 835
@@ -890,7 +893,7 @@ UI_set_result(UI * ui, UI_STRING * uis, const char *result)
890 break; 893 break;
891 } 894 }
892 } 895 }
893 default: 896 default:
894 break; 897 break;
895 } 898 }
896 } 899 }