1*0Sstevel@tonic-gate /* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ 2*0Sstevel@tonic-gate /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 3*0Sstevel@tonic-gate * project 2001. 4*0Sstevel@tonic-gate */ 5*0Sstevel@tonic-gate /* ==================================================================== 6*0Sstevel@tonic-gate * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 7*0Sstevel@tonic-gate * 8*0Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 9*0Sstevel@tonic-gate * modification, are permitted provided that the following conditions 10*0Sstevel@tonic-gate * are met: 11*0Sstevel@tonic-gate * 12*0Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 13*0Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 14*0Sstevel@tonic-gate * 15*0Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 16*0Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in 17*0Sstevel@tonic-gate * the documentation and/or other materials provided with the 18*0Sstevel@tonic-gate * distribution. 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this 21*0Sstevel@tonic-gate * software must display the following acknowledgment: 22*0Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project 23*0Sstevel@tonic-gate * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 24*0Sstevel@tonic-gate * 25*0Sstevel@tonic-gate * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26*0Sstevel@tonic-gate * endorse or promote products derived from this software without 27*0Sstevel@tonic-gate * prior written permission. For written permission, please contact 28*0Sstevel@tonic-gate * openssl-core@openssl.org. 29*0Sstevel@tonic-gate * 30*0Sstevel@tonic-gate * 5. Products derived from this software may not be called "OpenSSL" 31*0Sstevel@tonic-gate * nor may "OpenSSL" appear in their names without prior written 32*0Sstevel@tonic-gate * permission of the OpenSSL Project. 33*0Sstevel@tonic-gate * 34*0Sstevel@tonic-gate * 6. Redistributions of any form whatsoever must retain the following 35*0Sstevel@tonic-gate * acknowledgment: 36*0Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project 37*0Sstevel@tonic-gate * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 38*0Sstevel@tonic-gate * 39*0Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40*0Sstevel@tonic-gate * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41*0Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42*0Sstevel@tonic-gate * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43*0Sstevel@tonic-gate * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44*0Sstevel@tonic-gate * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45*0Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46*0Sstevel@tonic-gate * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47*0Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48*0Sstevel@tonic-gate * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49*0Sstevel@tonic-gate * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50*0Sstevel@tonic-gate * OF THE POSSIBILITY OF SUCH DAMAGE. 51*0Sstevel@tonic-gate * ==================================================================== 52*0Sstevel@tonic-gate * 53*0Sstevel@tonic-gate * This product includes cryptographic software written by Eric Young 54*0Sstevel@tonic-gate * (eay@cryptsoft.com). This product includes software written by Tim 55*0Sstevel@tonic-gate * Hudson (tjh@cryptsoft.com). 56*0Sstevel@tonic-gate * 57*0Sstevel@tonic-gate */ 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate #ifndef HEADER_UI_H 60*0Sstevel@tonic-gate #define HEADER_UI_H 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate #include <openssl/crypto.h> 63*0Sstevel@tonic-gate #include <openssl/safestack.h> 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate #ifdef __cplusplus 66*0Sstevel@tonic-gate extern "C" { 67*0Sstevel@tonic-gate #endif 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate /* The UI type is a holder for a specific user interface session. It can 70*0Sstevel@tonic-gate contain an illimited number of informational or error strings as well 71*0Sstevel@tonic-gate as things to prompt for, both passwords (noecho mode) and others (echo 72*0Sstevel@tonic-gate mode), and verification of the same. All of these are called strings, 73*0Sstevel@tonic-gate and are further described below. */ 74*0Sstevel@tonic-gate typedef struct ui_st UI; 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate /* All instances of UI have a reference to a method structure, which is a 77*0Sstevel@tonic-gate ordered vector of functions that implement the lower level things to do. 78*0Sstevel@tonic-gate There is an instruction on the implementation further down, in the section 79*0Sstevel@tonic-gate for method implementors. */ 80*0Sstevel@tonic-gate typedef struct ui_method_st UI_METHOD; 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate /* All the following functions return -1 or NULL on error and in some cases 84*0Sstevel@tonic-gate (UI_process()) -2 if interrupted or in some other way cancelled. 85*0Sstevel@tonic-gate When everything is fine, they return 0, a positive value or a non-NULL 86*0Sstevel@tonic-gate pointer, all depending on their purpose. */ 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate /* Creators and destructor. */ 89*0Sstevel@tonic-gate UI *UI_new(void); 90*0Sstevel@tonic-gate UI *UI_new_method(const UI_METHOD *method); 91*0Sstevel@tonic-gate void UI_free(UI *ui); 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gate /* The following functions are used to add strings to be printed and prompt 94*0Sstevel@tonic-gate strings to prompt for data. The names are UI_{add,dup}_<function>_string 95*0Sstevel@tonic-gate and UI_{add,dup}_input_boolean. 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate UI_{add,dup}_<function>_string have the following meanings: 98*0Sstevel@tonic-gate add add a text or prompt string. The pointers given to these 99*0Sstevel@tonic-gate functions are used verbatim, no copying is done. 100*0Sstevel@tonic-gate dup make a copy of the text or prompt string, then add the copy 101*0Sstevel@tonic-gate to the collection of strings in the user interface. 102*0Sstevel@tonic-gate <function> 103*0Sstevel@tonic-gate The function is a name for the functionality that the given 104*0Sstevel@tonic-gate string shall be used for. It can be one of: 105*0Sstevel@tonic-gate input use the string as data prompt. 106*0Sstevel@tonic-gate verify use the string as verification prompt. This 107*0Sstevel@tonic-gate is used to verify a previous input. 108*0Sstevel@tonic-gate info use the string for informational output. 109*0Sstevel@tonic-gate error use the string for error output. 110*0Sstevel@tonic-gate Honestly, there's currently no difference between info and error for the 111*0Sstevel@tonic-gate moment. 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate UI_{add,dup}_input_boolean have the same semantics for "add" and "dup", 114*0Sstevel@tonic-gate and are typically used when one wants to prompt for a yes/no response. 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate All of the functions in this group take a UI and a prompt string. 118*0Sstevel@tonic-gate The string input and verify addition functions also take a flag argument, 119*0Sstevel@tonic-gate a buffer for the result to end up with, a minimum input size and a maximum 120*0Sstevel@tonic-gate input size (the result buffer MUST be large enough to be able to contain 121*0Sstevel@tonic-gate the maximum number of characters). Additionally, the verify addition 122*0Sstevel@tonic-gate functions takes another buffer to compare the result against. 123*0Sstevel@tonic-gate The boolean input functions take an action description string (which should 124*0Sstevel@tonic-gate be safe to ignore if the expected user action is obvious, for example with 125*0Sstevel@tonic-gate a dialog box with an OK button and a Cancel button), a string of acceptable 126*0Sstevel@tonic-gate characters to mean OK and to mean Cancel. The two last strings are checked 127*0Sstevel@tonic-gate to make sure they don't have common characters. Additionally, the same 128*0Sstevel@tonic-gate flag argument as for the string input is taken, as well as a result buffer. 129*0Sstevel@tonic-gate The result buffer is required to be at least one byte long. Depending on 130*0Sstevel@tonic-gate the answer, the first character from the OK or the Cancel character strings 131*0Sstevel@tonic-gate will be stored in the first byte of the result buffer. No NUL will be 132*0Sstevel@tonic-gate added, so the result is *not* a string. 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate On success, the all return an index of the added information. That index 135*0Sstevel@tonic-gate is usefull when retrieving results with UI_get0_result(). */ 136*0Sstevel@tonic-gate int UI_add_input_string(UI *ui, const char *prompt, int flags, 137*0Sstevel@tonic-gate char *result_buf, int minsize, int maxsize); 138*0Sstevel@tonic-gate int UI_dup_input_string(UI *ui, const char *prompt, int flags, 139*0Sstevel@tonic-gate char *result_buf, int minsize, int maxsize); 140*0Sstevel@tonic-gate int UI_add_verify_string(UI *ui, const char *prompt, int flags, 141*0Sstevel@tonic-gate char *result_buf, int minsize, int maxsize, const char *test_buf); 142*0Sstevel@tonic-gate int UI_dup_verify_string(UI *ui, const char *prompt, int flags, 143*0Sstevel@tonic-gate char *result_buf, int minsize, int maxsize, const char *test_buf); 144*0Sstevel@tonic-gate int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, 145*0Sstevel@tonic-gate const char *ok_chars, const char *cancel_chars, 146*0Sstevel@tonic-gate int flags, char *result_buf); 147*0Sstevel@tonic-gate int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, 148*0Sstevel@tonic-gate const char *ok_chars, const char *cancel_chars, 149*0Sstevel@tonic-gate int flags, char *result_buf); 150*0Sstevel@tonic-gate int UI_add_info_string(UI *ui, const char *text); 151*0Sstevel@tonic-gate int UI_dup_info_string(UI *ui, const char *text); 152*0Sstevel@tonic-gate int UI_add_error_string(UI *ui, const char *text); 153*0Sstevel@tonic-gate int UI_dup_error_string(UI *ui, const char *text); 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate /* These are the possible flags. They can be or'ed together. */ 156*0Sstevel@tonic-gate /* Use to have echoing of input */ 157*0Sstevel@tonic-gate #define UI_INPUT_FLAG_ECHO 0x01 158*0Sstevel@tonic-gate /* Use a default password. Where that password is found is completely 159*0Sstevel@tonic-gate up to the application, it might for example be in the user data set 160*0Sstevel@tonic-gate with UI_add_user_data(). It is not recommended to have more than 161*0Sstevel@tonic-gate one input in each UI being marked with this flag, or the application 162*0Sstevel@tonic-gate might get confused. */ 163*0Sstevel@tonic-gate #define UI_INPUT_FLAG_DEFAULT_PWD 0x02 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gate /* The user of these routines may want to define flags of their own. The core 166*0Sstevel@tonic-gate UI won't look at those, but will pass them on to the method routines. They 167*0Sstevel@tonic-gate must use higher bits so they don't get confused with the UI bits above. 168*0Sstevel@tonic-gate UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good 169*0Sstevel@tonic-gate example of use is this: 170*0Sstevel@tonic-gate 171*0Sstevel@tonic-gate #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE) 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gate */ 174*0Sstevel@tonic-gate #define UI_INPUT_FLAG_USER_BASE 16 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gate /* The following function helps construct a prompt. object_desc is a 178*0Sstevel@tonic-gate textual short description of the object, for example "pass phrase", 179*0Sstevel@tonic-gate and object_name is the name of the object (might be a card name or 180*0Sstevel@tonic-gate a file name. 181*0Sstevel@tonic-gate The returned string shall always be allocated on the heap with 182*0Sstevel@tonic-gate OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). 183*0Sstevel@tonic-gate 184*0Sstevel@tonic-gate If the ui_method doesn't contain a pointer to a user-defined prompt 185*0Sstevel@tonic-gate constructor, a default string is built, looking like this: 186*0Sstevel@tonic-gate 187*0Sstevel@tonic-gate "Enter {object_desc} for {object_name}:" 188*0Sstevel@tonic-gate 189*0Sstevel@tonic-gate So, if object_desc has the value "pass phrase" and object_name has 190*0Sstevel@tonic-gate the value "foo.key", the resulting string is: 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate "Enter pass phrase for foo.key:" 193*0Sstevel@tonic-gate */ 194*0Sstevel@tonic-gate char *UI_construct_prompt(UI *ui_method, 195*0Sstevel@tonic-gate const char *object_desc, const char *object_name); 196*0Sstevel@tonic-gate 197*0Sstevel@tonic-gate 198*0Sstevel@tonic-gate /* The following function is used to store a pointer to user-specific data. 199*0Sstevel@tonic-gate Any previous such pointer will be returned and replaced. 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate For callback purposes, this function makes a lot more sense than using 202*0Sstevel@tonic-gate ex_data, since the latter requires that different parts of OpenSSL or 203*0Sstevel@tonic-gate applications share the same ex_data index. 204*0Sstevel@tonic-gate 205*0Sstevel@tonic-gate Note that the UI_OpenSSL() method completely ignores the user data. 206*0Sstevel@tonic-gate Other methods may not, however. */ 207*0Sstevel@tonic-gate void *UI_add_user_data(UI *ui, void *user_data); 208*0Sstevel@tonic-gate /* We need a user data retrieving function as well. */ 209*0Sstevel@tonic-gate void *UI_get0_user_data(UI *ui); 210*0Sstevel@tonic-gate 211*0Sstevel@tonic-gate /* Return the result associated with a prompt given with the index i. */ 212*0Sstevel@tonic-gate const char *UI_get0_result(UI *ui, int i); 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gate /* When all strings have been added, process the whole thing. */ 215*0Sstevel@tonic-gate int UI_process(UI *ui); 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate /* Give a user interface parametrised control commands. This can be used to 218*0Sstevel@tonic-gate send down an integer, a data pointer or a function pointer, as well as 219*0Sstevel@tonic-gate be used to get information from a UI. */ 220*0Sstevel@tonic-gate int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)()); 221*0Sstevel@tonic-gate 222*0Sstevel@tonic-gate /* The commands */ 223*0Sstevel@tonic-gate /* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the 224*0Sstevel@tonic-gate OpenSSL error stack before printing any info or added error messages and 225*0Sstevel@tonic-gate before any prompting. */ 226*0Sstevel@tonic-gate #define UI_CTRL_PRINT_ERRORS 1 227*0Sstevel@tonic-gate /* Check if a UI_process() is possible to do again with the same instance of 228*0Sstevel@tonic-gate a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0 229*0Sstevel@tonic-gate if not. */ 230*0Sstevel@tonic-gate #define UI_CTRL_IS_REDOABLE 2 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate 233*0Sstevel@tonic-gate /* Some methods may use extra data */ 234*0Sstevel@tonic-gate #define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) 235*0Sstevel@tonic-gate #define UI_get_app_data(s) UI_get_ex_data(s,0) 236*0Sstevel@tonic-gate int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 237*0Sstevel@tonic-gate CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 238*0Sstevel@tonic-gate int UI_set_ex_data(UI *r,int idx,void *arg); 239*0Sstevel@tonic-gate void *UI_get_ex_data(UI *r, int idx); 240*0Sstevel@tonic-gate 241*0Sstevel@tonic-gate /* Use specific methods instead of the built-in one */ 242*0Sstevel@tonic-gate void UI_set_default_method(const UI_METHOD *meth); 243*0Sstevel@tonic-gate const UI_METHOD *UI_get_default_method(void); 244*0Sstevel@tonic-gate const UI_METHOD *UI_get_method(UI *ui); 245*0Sstevel@tonic-gate const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); 246*0Sstevel@tonic-gate 247*0Sstevel@tonic-gate /* The method with all the built-in thingies */ 248*0Sstevel@tonic-gate UI_METHOD *UI_OpenSSL(void); 249*0Sstevel@tonic-gate 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate /* ---------- For method writers ---------- */ 252*0Sstevel@tonic-gate /* A method contains a number of functions that implement the low level 253*0Sstevel@tonic-gate of the User Interface. The functions are: 254*0Sstevel@tonic-gate 255*0Sstevel@tonic-gate an opener This function starts a session, maybe by opening 256*0Sstevel@tonic-gate a channel to a tty, or by opening a window. 257*0Sstevel@tonic-gate a writer This function is called to write a given string, 258*0Sstevel@tonic-gate maybe to the tty, maybe as a field label in a 259*0Sstevel@tonic-gate window. 260*0Sstevel@tonic-gate a flusher This function is called to flush everything that 261*0Sstevel@tonic-gate has been output so far. It can be used to actually 262*0Sstevel@tonic-gate display a dialog box after it has been built. 263*0Sstevel@tonic-gate a reader This function is called to read a given prompt, 264*0Sstevel@tonic-gate maybe from the tty, maybe from a field in a 265*0Sstevel@tonic-gate window. Note that it's called wth all string 266*0Sstevel@tonic-gate structures, not only the prompt ones, so it must 267*0Sstevel@tonic-gate check such things itself. 268*0Sstevel@tonic-gate a closer This function closes the session, maybe by closing 269*0Sstevel@tonic-gate the channel to the tty, or closing the window. 270*0Sstevel@tonic-gate 271*0Sstevel@tonic-gate All these functions are expected to return: 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gate 0 on error. 274*0Sstevel@tonic-gate 1 on success. 275*0Sstevel@tonic-gate -1 on out-of-band events, for example if some prompting has 276*0Sstevel@tonic-gate been canceled (by pressing Ctrl-C, for example). This is 277*0Sstevel@tonic-gate only checked when returned by the flusher or the reader. 278*0Sstevel@tonic-gate 279*0Sstevel@tonic-gate The way this is used, the opener is first called, then the writer for all 280*0Sstevel@tonic-gate strings, then the flusher, then the reader for all strings and finally the 281*0Sstevel@tonic-gate closer. Note that if you want to prompt from a terminal or other command 282*0Sstevel@tonic-gate line interface, the best is to have the reader also write the prompts 283*0Sstevel@tonic-gate instead of having the writer do it. If you want to prompt from a dialog 284*0Sstevel@tonic-gate box, the writer can be used to build up the contents of the box, and the 285*0Sstevel@tonic-gate flusher to actually display the box and run the event loop until all data 286*0Sstevel@tonic-gate has been given, after which the reader only grabs the given data and puts 287*0Sstevel@tonic-gate them back into the UI strings. 288*0Sstevel@tonic-gate 289*0Sstevel@tonic-gate All method functions take a UI as argument. Additionally, the writer and 290*0Sstevel@tonic-gate the reader take a UI_STRING. 291*0Sstevel@tonic-gate */ 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate /* The UI_STRING type is the data structure that contains all the needed info 294*0Sstevel@tonic-gate about a string or a prompt, including test data for a verification prompt. 295*0Sstevel@tonic-gate */ 296*0Sstevel@tonic-gate DECLARE_STACK_OF(UI_STRING) 297*0Sstevel@tonic-gate typedef struct ui_string_st UI_STRING; 298*0Sstevel@tonic-gate 299*0Sstevel@tonic-gate /* The different types of strings that are currently supported. 300*0Sstevel@tonic-gate This is only needed by method authors. */ 301*0Sstevel@tonic-gate enum UI_string_types 302*0Sstevel@tonic-gate { 303*0Sstevel@tonic-gate UIT_NONE=0, 304*0Sstevel@tonic-gate UIT_PROMPT, /* Prompt for a string */ 305*0Sstevel@tonic-gate UIT_VERIFY, /* Prompt for a string and verify */ 306*0Sstevel@tonic-gate UIT_BOOLEAN, /* Prompt for a yes/no response */ 307*0Sstevel@tonic-gate UIT_INFO, /* Send info to the user */ 308*0Sstevel@tonic-gate UIT_ERROR /* Send an error message to the user */ 309*0Sstevel@tonic-gate }; 310*0Sstevel@tonic-gate 311*0Sstevel@tonic-gate /* Create and manipulate methods */ 312*0Sstevel@tonic-gate UI_METHOD *UI_create_method(char *name); 313*0Sstevel@tonic-gate void UI_destroy_method(UI_METHOD *ui_method); 314*0Sstevel@tonic-gate int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)); 315*0Sstevel@tonic-gate int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)); 316*0Sstevel@tonic-gate int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)); 317*0Sstevel@tonic-gate int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)); 318*0Sstevel@tonic-gate int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); 319*0Sstevel@tonic-gate int (*UI_method_get_opener(UI_METHOD *method))(UI*); 320*0Sstevel@tonic-gate int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*); 321*0Sstevel@tonic-gate int (*UI_method_get_flusher(UI_METHOD *method))(UI*); 322*0Sstevel@tonic-gate int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*); 323*0Sstevel@tonic-gate int (*UI_method_get_closer(UI_METHOD *method))(UI*); 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gate /* The following functions are helpers for method writers to access relevant 326*0Sstevel@tonic-gate data from a UI_STRING. */ 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate /* Return type of the UI_STRING */ 329*0Sstevel@tonic-gate enum UI_string_types UI_get_string_type(UI_STRING *uis); 330*0Sstevel@tonic-gate /* Return input flags of the UI_STRING */ 331*0Sstevel@tonic-gate int UI_get_input_flags(UI_STRING *uis); 332*0Sstevel@tonic-gate /* Return the actual string to output (the prompt, info or error) */ 333*0Sstevel@tonic-gate const char *UI_get0_output_string(UI_STRING *uis); 334*0Sstevel@tonic-gate /* Return the optional action string to output (the boolean promtp instruction) */ 335*0Sstevel@tonic-gate const char *UI_get0_action_string(UI_STRING *uis); 336*0Sstevel@tonic-gate /* Return the result of a prompt */ 337*0Sstevel@tonic-gate const char *UI_get0_result_string(UI_STRING *uis); 338*0Sstevel@tonic-gate /* Return the string to test the result against. Only useful with verifies. */ 339*0Sstevel@tonic-gate const char *UI_get0_test_string(UI_STRING *uis); 340*0Sstevel@tonic-gate /* Return the required minimum size of the result */ 341*0Sstevel@tonic-gate int UI_get_result_minsize(UI_STRING *uis); 342*0Sstevel@tonic-gate /* Return the required maximum size of the result */ 343*0Sstevel@tonic-gate int UI_get_result_maxsize(UI_STRING *uis); 344*0Sstevel@tonic-gate /* Set the result of a UI_STRING. */ 345*0Sstevel@tonic-gate int UI_set_result(UI *ui, UI_STRING *uis, const char *result); 346*0Sstevel@tonic-gate 347*0Sstevel@tonic-gate 348*0Sstevel@tonic-gate /* A couple of popular utility functions */ 349*0Sstevel@tonic-gate int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify); 350*0Sstevel@tonic-gate int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); 351*0Sstevel@tonic-gate 352*0Sstevel@tonic-gate 353*0Sstevel@tonic-gate /* BEGIN ERROR CODES */ 354*0Sstevel@tonic-gate /* The following lines are auto generated by the script mkerr.pl. Any changes 355*0Sstevel@tonic-gate * made after this point may be overwritten when the script is next run. 356*0Sstevel@tonic-gate */ 357*0Sstevel@tonic-gate void ERR_load_UI_strings(void); 358*0Sstevel@tonic-gate 359*0Sstevel@tonic-gate /* Error codes for the UI functions. */ 360*0Sstevel@tonic-gate 361*0Sstevel@tonic-gate /* Function codes. */ 362*0Sstevel@tonic-gate #define UI_F_GENERAL_ALLOCATE_BOOLEAN 108 363*0Sstevel@tonic-gate #define UI_F_GENERAL_ALLOCATE_PROMPT 109 364*0Sstevel@tonic-gate #define UI_F_GENERAL_ALLOCATE_STRING 100 365*0Sstevel@tonic-gate #define UI_F_UI_CTRL 111 366*0Sstevel@tonic-gate #define UI_F_UI_DUP_ERROR_STRING 101 367*0Sstevel@tonic-gate #define UI_F_UI_DUP_INFO_STRING 102 368*0Sstevel@tonic-gate #define UI_F_UI_DUP_INPUT_BOOLEAN 110 369*0Sstevel@tonic-gate #define UI_F_UI_DUP_INPUT_STRING 103 370*0Sstevel@tonic-gate #define UI_F_UI_DUP_VERIFY_STRING 106 371*0Sstevel@tonic-gate #define UI_F_UI_GET0_RESULT 107 372*0Sstevel@tonic-gate #define UI_F_UI_NEW_METHOD 104 373*0Sstevel@tonic-gate #define UI_F_UI_SET_RESULT 105 374*0Sstevel@tonic-gate 375*0Sstevel@tonic-gate /* Reason codes. */ 376*0Sstevel@tonic-gate #define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104 377*0Sstevel@tonic-gate #define UI_R_INDEX_TOO_LARGE 102 378*0Sstevel@tonic-gate #define UI_R_INDEX_TOO_SMALL 103 379*0Sstevel@tonic-gate #define UI_R_NO_RESULT_BUFFER 105 380*0Sstevel@tonic-gate #define UI_R_RESULT_TOO_LARGE 100 381*0Sstevel@tonic-gate #define UI_R_RESULT_TOO_SMALL 101 382*0Sstevel@tonic-gate #define UI_R_UNKNOWN_CONTROL_COMMAND 106 383*0Sstevel@tonic-gate 384*0Sstevel@tonic-gate #ifdef __cplusplus 385*0Sstevel@tonic-gate } 386*0Sstevel@tonic-gate #endif 387*0Sstevel@tonic-gate #endif 388