xref: /onnv-gate/usr/src/common/openssl/crypto/ui/ui.h (revision 2139:6243c3338933)
10Sstevel@tonic-gate /* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */
20Sstevel@tonic-gate /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
30Sstevel@tonic-gate  * project 2001.
40Sstevel@tonic-gate  */
50Sstevel@tonic-gate /* ====================================================================
60Sstevel@tonic-gate  * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
90Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
100Sstevel@tonic-gate  * are met:
110Sstevel@tonic-gate  *
120Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
130Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
140Sstevel@tonic-gate  *
150Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
160Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in
170Sstevel@tonic-gate  *    the documentation and/or other materials provided with the
180Sstevel@tonic-gate  *    distribution.
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this
210Sstevel@tonic-gate  *    software must display the following acknowledgment:
220Sstevel@tonic-gate  *    "This product includes software developed by the OpenSSL Project
230Sstevel@tonic-gate  *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
240Sstevel@tonic-gate  *
250Sstevel@tonic-gate  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
260Sstevel@tonic-gate  *    endorse or promote products derived from this software without
270Sstevel@tonic-gate  *    prior written permission. For written permission, please contact
280Sstevel@tonic-gate  *    openssl-core@openssl.org.
290Sstevel@tonic-gate  *
300Sstevel@tonic-gate  * 5. Products derived from this software may not be called "OpenSSL"
310Sstevel@tonic-gate  *    nor may "OpenSSL" appear in their names without prior written
320Sstevel@tonic-gate  *    permission of the OpenSSL Project.
330Sstevel@tonic-gate  *
340Sstevel@tonic-gate  * 6. Redistributions of any form whatsoever must retain the following
350Sstevel@tonic-gate  *    acknowledgment:
360Sstevel@tonic-gate  *    "This product includes software developed by the OpenSSL Project
370Sstevel@tonic-gate  *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
380Sstevel@tonic-gate  *
390Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
400Sstevel@tonic-gate  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
410Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
420Sstevel@tonic-gate  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
430Sstevel@tonic-gate  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
440Sstevel@tonic-gate  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
450Sstevel@tonic-gate  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
460Sstevel@tonic-gate  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
470Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
480Sstevel@tonic-gate  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
490Sstevel@tonic-gate  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
500Sstevel@tonic-gate  * OF THE POSSIBILITY OF SUCH DAMAGE.
510Sstevel@tonic-gate  * ====================================================================
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * This product includes cryptographic software written by Eric Young
540Sstevel@tonic-gate  * (eay@cryptsoft.com).  This product includes software written by Tim
550Sstevel@tonic-gate  * Hudson (tjh@cryptsoft.com).
560Sstevel@tonic-gate  *
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #ifndef HEADER_UI_H
600Sstevel@tonic-gate #define HEADER_UI_H
610Sstevel@tonic-gate 
62*2139Sjp161948 #ifndef OPENSSL_NO_DEPRECATED
630Sstevel@tonic-gate #include <openssl/crypto.h>
64*2139Sjp161948 #endif
650Sstevel@tonic-gate #include <openssl/safestack.h>
66*2139Sjp161948 #include <openssl/ossl_typ.h>
670Sstevel@tonic-gate 
680Sstevel@tonic-gate #ifdef  __cplusplus
690Sstevel@tonic-gate extern "C" {
700Sstevel@tonic-gate #endif
710Sstevel@tonic-gate 
72*2139Sjp161948 /* Declared already in ossl_typ.h */
73*2139Sjp161948 /* typedef struct ui_st UI; */
74*2139Sjp161948 /* typedef struct ui_method_st UI_METHOD; */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate 
770Sstevel@tonic-gate /* All the following functions return -1 or NULL on error and in some cases
780Sstevel@tonic-gate    (UI_process()) -2 if interrupted or in some other way cancelled.
790Sstevel@tonic-gate    When everything is fine, they return 0, a positive value or a non-NULL
800Sstevel@tonic-gate    pointer, all depending on their purpose. */
810Sstevel@tonic-gate 
820Sstevel@tonic-gate /* Creators and destructor.   */
830Sstevel@tonic-gate UI *UI_new(void);
840Sstevel@tonic-gate UI *UI_new_method(const UI_METHOD *method);
850Sstevel@tonic-gate void UI_free(UI *ui);
860Sstevel@tonic-gate 
870Sstevel@tonic-gate /* The following functions are used to add strings to be printed and prompt
880Sstevel@tonic-gate    strings to prompt for data.  The names are UI_{add,dup}_<function>_string
890Sstevel@tonic-gate    and UI_{add,dup}_input_boolean.
900Sstevel@tonic-gate 
910Sstevel@tonic-gate    UI_{add,dup}_<function>_string have the following meanings:
920Sstevel@tonic-gate 	add	add a text or prompt string.  The pointers given to these
930Sstevel@tonic-gate 		functions are used verbatim, no copying is done.
940Sstevel@tonic-gate 	dup	make a copy of the text or prompt string, then add the copy
950Sstevel@tonic-gate 		to the collection of strings in the user interface.
960Sstevel@tonic-gate 	<function>
970Sstevel@tonic-gate 		The function is a name for the functionality that the given
980Sstevel@tonic-gate 		string shall be used for.  It can be one of:
990Sstevel@tonic-gate 			input	use the string as data prompt.
1000Sstevel@tonic-gate 			verify	use the string as verification prompt.  This
1010Sstevel@tonic-gate 				is used to verify a previous input.
1020Sstevel@tonic-gate 			info	use the string for informational output.
1030Sstevel@tonic-gate 			error	use the string for error output.
1040Sstevel@tonic-gate    Honestly, there's currently no difference between info and error for the
1050Sstevel@tonic-gate    moment.
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate    UI_{add,dup}_input_boolean have the same semantics for "add" and "dup",
1080Sstevel@tonic-gate    and are typically used when one wants to prompt for a yes/no response.
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate    All of the functions in this group take a UI and a prompt string.
1120Sstevel@tonic-gate    The string input and verify addition functions also take a flag argument,
1130Sstevel@tonic-gate    a buffer for the result to end up with, a minimum input size and a maximum
1140Sstevel@tonic-gate    input size (the result buffer MUST be large enough to be able to contain
1150Sstevel@tonic-gate    the maximum number of characters).  Additionally, the verify addition
1160Sstevel@tonic-gate    functions takes another buffer to compare the result against.
1170Sstevel@tonic-gate    The boolean input functions take an action description string (which should
1180Sstevel@tonic-gate    be safe to ignore if the expected user action is obvious, for example with
1190Sstevel@tonic-gate    a dialog box with an OK button and a Cancel button), a string of acceptable
1200Sstevel@tonic-gate    characters to mean OK and to mean Cancel.  The two last strings are checked
1210Sstevel@tonic-gate    to make sure they don't have common characters.  Additionally, the same
1220Sstevel@tonic-gate    flag argument as for the string input is taken, as well as a result buffer.
1230Sstevel@tonic-gate    The result buffer is required to be at least one byte long.  Depending on
1240Sstevel@tonic-gate    the answer, the first character from the OK or the Cancel character strings
1250Sstevel@tonic-gate    will be stored in the first byte of the result buffer.  No NUL will be
1260Sstevel@tonic-gate    added, so the result is *not* a string.
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate    On success, the all return an index of the added information.  That index
1290Sstevel@tonic-gate    is usefull when retrieving results with UI_get0_result(). */
1300Sstevel@tonic-gate int UI_add_input_string(UI *ui, const char *prompt, int flags,
1310Sstevel@tonic-gate 	char *result_buf, int minsize, int maxsize);
1320Sstevel@tonic-gate int UI_dup_input_string(UI *ui, const char *prompt, int flags,
1330Sstevel@tonic-gate 	char *result_buf, int minsize, int maxsize);
1340Sstevel@tonic-gate int UI_add_verify_string(UI *ui, const char *prompt, int flags,
1350Sstevel@tonic-gate 	char *result_buf, int minsize, int maxsize, const char *test_buf);
1360Sstevel@tonic-gate int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
1370Sstevel@tonic-gate 	char *result_buf, int minsize, int maxsize, const char *test_buf);
1380Sstevel@tonic-gate int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
1390Sstevel@tonic-gate 	const char *ok_chars, const char *cancel_chars,
1400Sstevel@tonic-gate 	int flags, char *result_buf);
1410Sstevel@tonic-gate int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
1420Sstevel@tonic-gate 	const char *ok_chars, const char *cancel_chars,
1430Sstevel@tonic-gate 	int flags, char *result_buf);
1440Sstevel@tonic-gate int UI_add_info_string(UI *ui, const char *text);
1450Sstevel@tonic-gate int UI_dup_info_string(UI *ui, const char *text);
1460Sstevel@tonic-gate int UI_add_error_string(UI *ui, const char *text);
1470Sstevel@tonic-gate int UI_dup_error_string(UI *ui, const char *text);
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate /* These are the possible flags.  They can be or'ed together. */
1500Sstevel@tonic-gate /* Use to have echoing of input */
1510Sstevel@tonic-gate #define UI_INPUT_FLAG_ECHO		0x01
1520Sstevel@tonic-gate /* Use a default password.  Where that password is found is completely
1530Sstevel@tonic-gate    up to the application, it might for example be in the user data set
1540Sstevel@tonic-gate    with UI_add_user_data().  It is not recommended to have more than
1550Sstevel@tonic-gate    one input in each UI being marked with this flag, or the application
1560Sstevel@tonic-gate    might get confused. */
1570Sstevel@tonic-gate #define UI_INPUT_FLAG_DEFAULT_PWD	0x02
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate /* The user of these routines may want to define flags of their own.  The core
1600Sstevel@tonic-gate    UI won't look at those, but will pass them on to the method routines.  They
1610Sstevel@tonic-gate    must use higher bits so they don't get confused with the UI bits above.
1620Sstevel@tonic-gate    UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use.  A good
1630Sstevel@tonic-gate    example of use is this:
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate 	#define MY_UI_FLAG1	(0x01 << UI_INPUT_FLAG_USER_BASE)
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate */
1680Sstevel@tonic-gate #define UI_INPUT_FLAG_USER_BASE	16
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate 
1710Sstevel@tonic-gate /* The following function helps construct a prompt.  object_desc is a
1720Sstevel@tonic-gate    textual short description of the object, for example "pass phrase",
1730Sstevel@tonic-gate    and object_name is the name of the object (might be a card name or
1740Sstevel@tonic-gate    a file name.
1750Sstevel@tonic-gate    The returned string shall always be allocated on the heap with
1760Sstevel@tonic-gate    OPENSSL_malloc(), and need to be free'd with OPENSSL_free().
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate    If the ui_method doesn't contain a pointer to a user-defined prompt
1790Sstevel@tonic-gate    constructor, a default string is built, looking like this:
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate 	"Enter {object_desc} for {object_name}:"
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate    So, if object_desc has the value "pass phrase" and object_name has
1840Sstevel@tonic-gate    the value "foo.key", the resulting string is:
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate 	"Enter pass phrase for foo.key:"
1870Sstevel@tonic-gate */
1880Sstevel@tonic-gate char *UI_construct_prompt(UI *ui_method,
1890Sstevel@tonic-gate 	const char *object_desc, const char *object_name);
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate /* The following function is used to store a pointer to user-specific data.
1930Sstevel@tonic-gate    Any previous such pointer will be returned and replaced.
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate    For callback purposes, this function makes a lot more sense than using
1960Sstevel@tonic-gate    ex_data, since the latter requires that different parts of OpenSSL or
1970Sstevel@tonic-gate    applications share the same ex_data index.
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate    Note that the UI_OpenSSL() method completely ignores the user data.
2000Sstevel@tonic-gate    Other methods may not, however.  */
2010Sstevel@tonic-gate void *UI_add_user_data(UI *ui, void *user_data);
2020Sstevel@tonic-gate /* We need a user data retrieving function as well.  */
2030Sstevel@tonic-gate void *UI_get0_user_data(UI *ui);
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate /* Return the result associated with a prompt given with the index i. */
2060Sstevel@tonic-gate const char *UI_get0_result(UI *ui, int i);
2070Sstevel@tonic-gate 
2080Sstevel@tonic-gate /* When all strings have been added, process the whole thing. */
2090Sstevel@tonic-gate int UI_process(UI *ui);
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate /* Give a user interface parametrised control commands.  This can be used to
2120Sstevel@tonic-gate    send down an integer, a data pointer or a function pointer, as well as
2130Sstevel@tonic-gate    be used to get information from a UI. */
214*2139Sjp161948 int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void));
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate /* The commands */
2170Sstevel@tonic-gate /* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the
2180Sstevel@tonic-gate    OpenSSL error stack before printing any info or added error messages and
2190Sstevel@tonic-gate    before any prompting. */
2200Sstevel@tonic-gate #define UI_CTRL_PRINT_ERRORS		1
2210Sstevel@tonic-gate /* Check if a UI_process() is possible to do again with the same instance of
2220Sstevel@tonic-gate    a user interface.  This makes UI_ctrl() return 1 if it is redoable, and 0
2230Sstevel@tonic-gate    if not. */
2240Sstevel@tonic-gate #define UI_CTRL_IS_REDOABLE		2
2250Sstevel@tonic-gate 
2260Sstevel@tonic-gate 
2270Sstevel@tonic-gate /* Some methods may use extra data */
2280Sstevel@tonic-gate #define UI_set_app_data(s,arg)         UI_set_ex_data(s,0,arg)
2290Sstevel@tonic-gate #define UI_get_app_data(s)             UI_get_ex_data(s,0)
2300Sstevel@tonic-gate int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
2310Sstevel@tonic-gate 	CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
2320Sstevel@tonic-gate int UI_set_ex_data(UI *r,int idx,void *arg);
2330Sstevel@tonic-gate void *UI_get_ex_data(UI *r, int idx);
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate /* Use specific methods instead of the built-in one */
2360Sstevel@tonic-gate void UI_set_default_method(const UI_METHOD *meth);
2370Sstevel@tonic-gate const UI_METHOD *UI_get_default_method(void);
2380Sstevel@tonic-gate const UI_METHOD *UI_get_method(UI *ui);
2390Sstevel@tonic-gate const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);
2400Sstevel@tonic-gate 
2410Sstevel@tonic-gate /* The method with all the built-in thingies */
2420Sstevel@tonic-gate UI_METHOD *UI_OpenSSL(void);
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate /* ---------- For method writers ---------- */
2460Sstevel@tonic-gate /* A method contains a number of functions that implement the low level
2470Sstevel@tonic-gate    of the User Interface.  The functions are:
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate 	an opener	This function starts a session, maybe by opening
2500Sstevel@tonic-gate 			a channel to a tty, or by opening a window.
2510Sstevel@tonic-gate 	a writer	This function is called to write a given string,
2520Sstevel@tonic-gate 			maybe to the tty, maybe as a field label in a
2530Sstevel@tonic-gate 			window.
2540Sstevel@tonic-gate 	a flusher	This function is called to flush everything that
2550Sstevel@tonic-gate 			has been output so far.  It can be used to actually
2560Sstevel@tonic-gate 			display a dialog box after it has been built.
2570Sstevel@tonic-gate 	a reader	This function is called to read a given prompt,
2580Sstevel@tonic-gate 			maybe from the tty, maybe from a field in a
2590Sstevel@tonic-gate 			window.  Note that it's called wth all string
2600Sstevel@tonic-gate 			structures, not only the prompt ones, so it must
2610Sstevel@tonic-gate 			check such things itself.
2620Sstevel@tonic-gate 	a closer	This function closes the session, maybe by closing
2630Sstevel@tonic-gate 			the channel to the tty, or closing the window.
2640Sstevel@tonic-gate 
2650Sstevel@tonic-gate    All these functions are expected to return:
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate 	0	on error.
2680Sstevel@tonic-gate 	1	on success.
2690Sstevel@tonic-gate 	-1	on out-of-band events, for example if some prompting has
2700Sstevel@tonic-gate 		been canceled (by pressing Ctrl-C, for example).  This is
2710Sstevel@tonic-gate 		only checked when returned by the flusher or the reader.
2720Sstevel@tonic-gate 
2730Sstevel@tonic-gate    The way this is used, the opener is first called, then the writer for all
2740Sstevel@tonic-gate    strings, then the flusher, then the reader for all strings and finally the
2750Sstevel@tonic-gate    closer.  Note that if you want to prompt from a terminal or other command
2760Sstevel@tonic-gate    line interface, the best is to have the reader also write the prompts
2770Sstevel@tonic-gate    instead of having the writer do it.  If you want to prompt from a dialog
2780Sstevel@tonic-gate    box, the writer can be used to build up the contents of the box, and the
2790Sstevel@tonic-gate    flusher to actually display the box and run the event loop until all data
2800Sstevel@tonic-gate    has been given, after which the reader only grabs the given data and puts
2810Sstevel@tonic-gate    them back into the UI strings.
2820Sstevel@tonic-gate 
2830Sstevel@tonic-gate    All method functions take a UI as argument.  Additionally, the writer and
2840Sstevel@tonic-gate    the reader take a UI_STRING.
2850Sstevel@tonic-gate */
2860Sstevel@tonic-gate 
2870Sstevel@tonic-gate /* The UI_STRING type is the data structure that contains all the needed info
2880Sstevel@tonic-gate    about a string or a prompt, including test data for a verification prompt.
2890Sstevel@tonic-gate */
2900Sstevel@tonic-gate DECLARE_STACK_OF(UI_STRING)
2910Sstevel@tonic-gate typedef struct ui_string_st UI_STRING;
2920Sstevel@tonic-gate 
2930Sstevel@tonic-gate /* The different types of strings that are currently supported.
2940Sstevel@tonic-gate    This is only needed by method authors. */
2950Sstevel@tonic-gate enum UI_string_types
2960Sstevel@tonic-gate 	{
2970Sstevel@tonic-gate 	UIT_NONE=0,
2980Sstevel@tonic-gate 	UIT_PROMPT,		/* Prompt for a string */
2990Sstevel@tonic-gate 	UIT_VERIFY,		/* Prompt for a string and verify */
3000Sstevel@tonic-gate 	UIT_BOOLEAN,		/* Prompt for a yes/no response */
3010Sstevel@tonic-gate 	UIT_INFO,		/* Send info to the user */
3020Sstevel@tonic-gate 	UIT_ERROR		/* Send an error message to the user */
3030Sstevel@tonic-gate 	};
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate /* Create and manipulate methods */
3060Sstevel@tonic-gate UI_METHOD *UI_create_method(char *name);
3070Sstevel@tonic-gate void UI_destroy_method(UI_METHOD *ui_method);
3080Sstevel@tonic-gate int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui));
3090Sstevel@tonic-gate int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis));
3100Sstevel@tonic-gate int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui));
3110Sstevel@tonic-gate int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis));
3120Sstevel@tonic-gate int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui));
3130Sstevel@tonic-gate int (*UI_method_get_opener(UI_METHOD *method))(UI*);
3140Sstevel@tonic-gate int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*);
3150Sstevel@tonic-gate int (*UI_method_get_flusher(UI_METHOD *method))(UI*);
3160Sstevel@tonic-gate int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*);
3170Sstevel@tonic-gate int (*UI_method_get_closer(UI_METHOD *method))(UI*);
3180Sstevel@tonic-gate 
3190Sstevel@tonic-gate /* The following functions are helpers for method writers to access relevant
3200Sstevel@tonic-gate    data from a UI_STRING. */
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate /* Return type of the UI_STRING */
3230Sstevel@tonic-gate enum UI_string_types UI_get_string_type(UI_STRING *uis);
3240Sstevel@tonic-gate /* Return input flags of the UI_STRING */
3250Sstevel@tonic-gate int UI_get_input_flags(UI_STRING *uis);
3260Sstevel@tonic-gate /* Return the actual string to output (the prompt, info or error) */
3270Sstevel@tonic-gate const char *UI_get0_output_string(UI_STRING *uis);
3280Sstevel@tonic-gate /* Return the optional action string to output (the boolean promtp instruction) */
3290Sstevel@tonic-gate const char *UI_get0_action_string(UI_STRING *uis);
3300Sstevel@tonic-gate /* Return the result of a prompt */
3310Sstevel@tonic-gate const char *UI_get0_result_string(UI_STRING *uis);
3320Sstevel@tonic-gate /* Return the string to test the result against.  Only useful with verifies. */
3330Sstevel@tonic-gate const char *UI_get0_test_string(UI_STRING *uis);
3340Sstevel@tonic-gate /* Return the required minimum size of the result */
3350Sstevel@tonic-gate int UI_get_result_minsize(UI_STRING *uis);
3360Sstevel@tonic-gate /* Return the required maximum size of the result */
3370Sstevel@tonic-gate int UI_get_result_maxsize(UI_STRING *uis);
3380Sstevel@tonic-gate /* Set the result of a UI_STRING. */
3390Sstevel@tonic-gate int UI_set_result(UI *ui, UI_STRING *uis, const char *result);
3400Sstevel@tonic-gate 
3410Sstevel@tonic-gate 
3420Sstevel@tonic-gate /* A couple of popular utility functions */
3430Sstevel@tonic-gate int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify);
3440Sstevel@tonic-gate int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate 
3470Sstevel@tonic-gate /* BEGIN ERROR CODES */
3480Sstevel@tonic-gate /* The following lines are auto generated by the script mkerr.pl. Any changes
3490Sstevel@tonic-gate  * made after this point may be overwritten when the script is next run.
3500Sstevel@tonic-gate  */
3510Sstevel@tonic-gate void ERR_load_UI_strings(void);
3520Sstevel@tonic-gate 
3530Sstevel@tonic-gate /* Error codes for the UI functions. */
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate /* Function codes. */
3560Sstevel@tonic-gate #define UI_F_GENERAL_ALLOCATE_BOOLEAN			 108
3570Sstevel@tonic-gate #define UI_F_GENERAL_ALLOCATE_PROMPT			 109
3580Sstevel@tonic-gate #define UI_F_GENERAL_ALLOCATE_STRING			 100
3590Sstevel@tonic-gate #define UI_F_UI_CTRL					 111
3600Sstevel@tonic-gate #define UI_F_UI_DUP_ERROR_STRING			 101
3610Sstevel@tonic-gate #define UI_F_UI_DUP_INFO_STRING				 102
3620Sstevel@tonic-gate #define UI_F_UI_DUP_INPUT_BOOLEAN			 110
3630Sstevel@tonic-gate #define UI_F_UI_DUP_INPUT_STRING			 103
3640Sstevel@tonic-gate #define UI_F_UI_DUP_VERIFY_STRING			 106
3650Sstevel@tonic-gate #define UI_F_UI_GET0_RESULT				 107
3660Sstevel@tonic-gate #define UI_F_UI_NEW_METHOD				 104
3670Sstevel@tonic-gate #define UI_F_UI_SET_RESULT				 105
3680Sstevel@tonic-gate 
3690Sstevel@tonic-gate /* Reason codes. */
3700Sstevel@tonic-gate #define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS		 104
3710Sstevel@tonic-gate #define UI_R_INDEX_TOO_LARGE				 102
3720Sstevel@tonic-gate #define UI_R_INDEX_TOO_SMALL				 103
3730Sstevel@tonic-gate #define UI_R_NO_RESULT_BUFFER				 105
3740Sstevel@tonic-gate #define UI_R_RESULT_TOO_LARGE				 100
3750Sstevel@tonic-gate #define UI_R_RESULT_TOO_SMALL				 101
3760Sstevel@tonic-gate #define UI_R_UNKNOWN_CONTROL_COMMAND			 106
3770Sstevel@tonic-gate 
3780Sstevel@tonic-gate #ifdef  __cplusplus
3790Sstevel@tonic-gate }
3800Sstevel@tonic-gate #endif
3810Sstevel@tonic-gate #endif
382