1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1 christos UI_STRING, UI_string_types, UI_get_string_type, 6 1.1 christos UI_get_input_flags, UI_get0_output_string, 7 1.1 christos UI_get0_action_string, UI_get0_result_string, UI_get_result_string_length, 8 1.1 christos UI_get0_test_string, UI_get_result_minsize, 9 1.1 christos UI_get_result_maxsize, UI_set_result, UI_set_result_ex 10 1.1 christos - User interface string parsing 11 1.1 christos 12 1.1 christos =head1 SYNOPSIS 13 1.1 christos 14 1.1 christos #include <openssl/ui.h> 15 1.1 christos 16 1.1 christos typedef struct ui_string_st UI_STRING; 17 1.1 christos 18 1.1 christos enum UI_string_types { 19 1.1 christos UIT_NONE = 0, 20 1.1 christos UIT_PROMPT, /* Prompt for a string */ 21 1.1 christos UIT_VERIFY, /* Prompt for a string and verify */ 22 1.1 christos UIT_BOOLEAN, /* Prompt for a yes/no response */ 23 1.1 christos UIT_INFO, /* Send info to the user */ 24 1.1 christos UIT_ERROR /* Send an error message to the user */ 25 1.1 christos }; 26 1.1 christos 27 1.1 christos enum UI_string_types UI_get_string_type(UI_STRING *uis); 28 1.1 christos int UI_get_input_flags(UI_STRING *uis); 29 1.1 christos const char *UI_get0_output_string(UI_STRING *uis); 30 1.1 christos const char *UI_get0_action_string(UI_STRING *uis); 31 1.1 christos const char *UI_get0_result_string(UI_STRING *uis); 32 1.1 christos int UI_get_result_string_length(UI_STRING *uis); 33 1.1 christos const char *UI_get0_test_string(UI_STRING *uis); 34 1.1 christos int UI_get_result_minsize(UI_STRING *uis); 35 1.1 christos int UI_get_result_maxsize(UI_STRING *uis); 36 1.1 christos int UI_set_result(UI *ui, UI_STRING *uis, const char *result); 37 1.1 christos int UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len); 38 1.1 christos 39 1.1 christos =head1 DESCRIPTION 40 1.1 christos 41 1.1 christos The B<UI_STRING> gets created internally and added to a B<UI> whenever 42 1.1 christos one of the functions UI_add_input_string(), UI_dup_input_string(), 43 1.1 christos UI_add_verify_string(), UI_dup_verify_string(), 44 1.1 christos UI_add_input_boolean(), UI_dup_input_boolean(), UI_add_info_string(), 45 1.1 christos UI_dup_info_string(), UI_add_error_string() or UI_dup_error_string() 46 1.1 christos is called. 47 1.1 christos For a B<UI_METHOD> user, there's no need to know more. 48 1.1 christos For a B<UI_METHOD> creator, it is of interest to fetch text from these 49 1.1 christos B<UI_STRING> objects as well as adding results to some of them. 50 1.1 christos 51 1.1 christos UI_get_string_type() is used to retrieve the type of the given 52 1.1 christos B<UI_STRING>. 53 1.1 christos 54 1.1 christos UI_get_input_flags() is used to retrieve the flags associated with the 55 1.1 christos given B<UI_STRING>. 56 1.1 christos 57 1.1 christos UI_get0_output_string() is used to retrieve the actual string to 58 1.1 christos output (prompt, info, error, ...). 59 1.1 christos 60 1.1 christos UI_get0_action_string() is used to retrieve the action description 61 1.1 christos associated with a B<UIT_BOOLEAN> type B<UI_STRING>. 62 1.1 christos For all other B<UI_STRING> types, NULL is returned. 63 1.1 christos See L<UI_add_input_boolean(3)>. 64 1.1 christos 65 1.1 christos UI_get0_result_string() and UI_get_result_string_length() are used to 66 1.1 christos retrieve the result of a prompt and its length. 67 1.1 christos This is only useful for B<UIT_PROMPT> and B<UIT_VERIFY> type strings. 68 1.1 christos For all other B<UI_STRING> types, UI_get0_result_string() returns NULL 69 1.1 christos and UI_get_result_string_length() returns -1. 70 1.1 christos 71 1.1 christos UI_get0_test_string() is used to retrieve the string to compare the 72 1.1 christos prompt result with. 73 1.1 christos This is only useful for B<UIT_VERIFY> type strings. 74 1.1 christos For all other B<UI_STRING> types, NULL is returned. 75 1.1 christos 76 1.1 christos UI_get_result_minsize() and UI_get_result_maxsize() are used to 77 1.1 christos retrieve the minimum and maximum required size of the result. 78 1.1 christos This is only useful for B<UIT_PROMPT> and B<UIT_VERIFY> type strings. 79 1.1 christos For all other B<UI_STRING> types, -1 is returned. 80 1.1 christos 81 1.1 christos UI_set_result_ex() is used to set the result value of a prompt and its length. 82 1.1 christos For B<UIT_PROMPT> and B<UIT_VERIFY> type UI strings, this sets the 83 1.1 christos result retrievable with UI_get0_result_string() by copying the 84 1.1 christos contents of B<result> if its length fits the minimum and maximum size 85 1.1 christos requirements. 86 1.1 christos For B<UIT_BOOLEAN> type UI strings, this sets the first character of 87 1.1 christos the result retrievable with UI_get0_result_string() to the first 88 1.1 christos B<ok_char> given with UI_add_input_boolean() or UI_dup_input_boolean() 89 1.1 christos if the B<result> matched any of them, or the first of the 90 1.1 christos B<cancel_chars> if the B<result> matched any of them, otherwise it's 91 1.1 christos set to the NUL char C<\0>. 92 1.1 christos See L<UI_add_input_boolean(3)> for more information on B<ok_chars> and 93 1.1 christos B<cancel_chars>. 94 1.1 christos 95 1.1 christos UI_set_result() does the same thing as UI_set_result_ex(), but calculates 96 1.1 christos its length internally. 97 1.1 christos It expects the string to be terminated with a NUL byte, and is therefore 98 1.1 christos only useful with normal C strings. 99 1.1 christos 100 1.1 christos =head1 RETURN VALUES 101 1.1 christos 102 1.1 christos UI_get_string_type() returns the UI string type. 103 1.1 christos 104 1.1 christos UI_get_input_flags() returns the UI string flags. 105 1.1 christos 106 1.1 christos UI_get0_output_string() returns the UI string output string. 107 1.1 christos 108 1.1 christos UI_get0_action_string() returns the UI string action description 109 1.1 christos string for B<UIT_BOOLEAN> type UI strings, NULL for any other type. 110 1.1 christos 111 1.1 christos UI_get0_result_string() returns the UI string result buffer for 112 1.1 christos B<UIT_PROMPT> and B<UIT_VERIFY> type UI strings, NULL for any other 113 1.1 christos type. 114 1.1 christos 115 1.1 christos UI_get_result_string_length() returns the UI string result buffer's 116 1.1 christos content length for B<UIT_PROMPT> and B<UIT_VERIFY> type UI strings, 117 1.1 christos -1 for any other type. 118 1.1 christos 119 1.1 christos UI_get0_test_string() returns the UI string action description 120 1.1 christos string for B<UIT_VERIFY> type UI strings, NULL for any other type. 121 1.1 christos 122 1.1 christos UI_get_result_minsize() returns the minimum allowed result size for 123 1.1 christos the UI string for B<UIT_PROMPT> and B<UIT_VERIFY> type strings, 124 1.1 christos -1 for any other type. 125 1.1 christos 126 1.1 christos UI_get_result_maxsize() returns the minimum allowed result size for 127 1.1 christos the UI string for B<UIT_PROMPT> and B<UIT_VERIFY> type strings, 128 1.1 christos -1 for any other type. 129 1.1 christos 130 1.1 christos UI_set_result() returns 0 on success or when the UI string is of any 131 1.1 christos type other than B<UIT_PROMPT>, B<UIT_VERIFY> or B<UIT_BOOLEAN>, -1 on 132 1.1 christos error. 133 1.1 christos 134 1.1 christos =head1 SEE ALSO 135 1.1 christos 136 1.1 christos L<UI(3)> 137 1.1 christos 138 1.1 christos =head1 COPYRIGHT 139 1.1 christos 140 1.1 christos Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved. 141 1.1 christos 142 1.1.1.2 christos Licensed under the Apache License 2.0 (the "License"). You may not use 143 1.1 christos this file except in compliance with the License. You can obtain a copy 144 1.1 christos in the file LICENSE in the source distribution or at 145 1.1 christos L<https://www.openssl.org/source/license.html>. 146 1.1 christos 147 1.1 christos =cut 148 1.1 christos 149