sl@0: /* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ sl@0: /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL sl@0: * project 2001. sl@0: */ sl@0: /* ==================================================================== sl@0: * Copyright (c) 2001 The OpenSSL Project. All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in sl@0: * the documentation and/or other materials provided with the sl@0: * distribution. sl@0: * sl@0: * 3. All advertising materials mentioning features or use of this sl@0: * software must display the following acknowledgment: sl@0: * "This product includes software developed by the OpenSSL Project sl@0: * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" sl@0: * sl@0: * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to sl@0: * endorse or promote products derived from this software without sl@0: * prior written permission. For written permission, please contact sl@0: * openssl-core@openssl.org. sl@0: * sl@0: * 5. Products derived from this software may not be called "OpenSSL" sl@0: * nor may "OpenSSL" appear in their names without prior written sl@0: * permission of the OpenSSL Project. sl@0: * sl@0: * 6. Redistributions of any form whatsoever must retain the following sl@0: * acknowledgment: sl@0: * "This product includes software developed by the OpenSSL Project sl@0: * for use in the OpenSSL Toolkit (http://www.openssl.org/)" sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY sl@0: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR sl@0: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR sl@0: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, sl@0: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT sl@0: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; sl@0: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, sl@0: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) sl@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED sl@0: * OF THE POSSIBILITY OF SUCH DAMAGE. sl@0: * ==================================================================== sl@0: * sl@0: * This product includes cryptographic software written by Eric Young sl@0: * (eay@cryptsoft.com). This product includes software written by Tim sl@0: * Hudson (tjh@cryptsoft.com). sl@0: * sl@0: */ sl@0: sl@0: #ifndef HEADER_UI_LOCL_H sl@0: #define HEADER_UI_LOCL_H sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #ifdef _ sl@0: #undef _ sl@0: #endif sl@0: sl@0: struct ui_method_st sl@0: { sl@0: char *name; sl@0: sl@0: /* All the functions return 1 or non-NULL for success and 0 or NULL sl@0: for failure */ sl@0: sl@0: /* Open whatever channel for this, be it the console, an X window sl@0: or whatever. sl@0: This function should use the ex_data structure to save sl@0: intermediate data. */ sl@0: int (*ui_open_session)(UI *ui); sl@0: sl@0: int (*ui_write_string)(UI *ui, UI_STRING *uis); sl@0: sl@0: /* Flush the output. If a GUI dialog box is used, this function can sl@0: be used to actually display it. */ sl@0: int (*ui_flush)(UI *ui); sl@0: sl@0: int (*ui_read_string)(UI *ui, UI_STRING *uis); sl@0: sl@0: int (*ui_close_session)(UI *ui); sl@0: sl@0: /* Construct a prompt in a user-defined manner. object_desc is a sl@0: textual short description of the object, for example "pass phrase", sl@0: and object_name is the name of the object (might be a card name or sl@0: a file name. sl@0: The returned string shall always be allocated on the heap with sl@0: OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). */ sl@0: char *(*ui_construct_prompt)(UI *ui, const char *object_desc, sl@0: const char *object_name); sl@0: }; sl@0: sl@0: struct ui_string_st sl@0: { sl@0: enum UI_string_types type; /* Input */ sl@0: const char *out_string; /* Input */ sl@0: int input_flags; /* Flags from the user */ sl@0: sl@0: /* The following parameters are completely irrelevant for UIT_INFO, sl@0: and can therefore be set to 0 or NULL */ sl@0: char *result_buf; /* Input and Output: If not NULL, user-defined sl@0: with size in result_maxsize. Otherwise, it sl@0: may be allocated by the UI routine, meaning sl@0: result_minsize is going to be overwritten.*/ sl@0: union sl@0: { sl@0: struct sl@0: { sl@0: int result_minsize; /* Input: minimum required sl@0: size of the result. sl@0: */ sl@0: int result_maxsize; /* Input: maximum permitted sl@0: size of the result */ sl@0: sl@0: const char *test_buf; /* Input: test string to verify sl@0: against */ sl@0: } string_data; sl@0: struct sl@0: { sl@0: const char *action_desc; /* Input */ sl@0: const char *ok_chars; /* Input */ sl@0: const char *cancel_chars; /* Input */ sl@0: } boolean_data; sl@0: } _; sl@0: sl@0: #define OUT_STRING_FREEABLE 0x01 sl@0: int flags; /* flags for internal use */ sl@0: }; sl@0: sl@0: struct ui_st sl@0: { sl@0: const UI_METHOD *meth; sl@0: STACK_OF(UI_STRING) *strings; /* We might want to prompt for more sl@0: than one thing at a time, and sl@0: with different echoing status. */ sl@0: void *user_data; sl@0: CRYPTO_EX_DATA ex_data; sl@0: sl@0: #define UI_FLAG_REDOABLE 0x0001 sl@0: #define UI_FLAG_PRINT_ERRORS 0x0100 sl@0: int flags; sl@0: }; sl@0: sl@0: #endif