xref: /openbsd-src/lib/libcrypto/ui/ui_err.c (revision 3dca75268619b0b918cd1da71f402c2dcd3ceddb)
1*3dca7526Stb /* $OpenBSD: ui_err.c,v 1.13 2024/06/24 06:43:23 tb Exp $ */
2da347917Sbeck /* ====================================================================
30a5d6edeSdjm  * Copyright (c) 1999-2006 The OpenSSL Project.  All rights reserved.
4da347917Sbeck  *
5da347917Sbeck  * Redistribution and use in source and binary forms, with or without
6da347917Sbeck  * modification, are permitted provided that the following conditions
7da347917Sbeck  * are met:
8da347917Sbeck  *
9da347917Sbeck  * 1. Redistributions of source code must retain the above copyright
10da347917Sbeck  *    notice, this list of conditions and the following disclaimer.
11da347917Sbeck  *
12da347917Sbeck  * 2. Redistributions in binary form must reproduce the above copyright
13da347917Sbeck  *    notice, this list of conditions and the following disclaimer in
14da347917Sbeck  *    the documentation and/or other materials provided with the
15da347917Sbeck  *    distribution.
16da347917Sbeck  *
17da347917Sbeck  * 3. All advertising materials mentioning features or use of this
18da347917Sbeck  *    software must display the following acknowledgment:
19da347917Sbeck  *    "This product includes software developed by the OpenSSL Project
20da347917Sbeck  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21da347917Sbeck  *
22da347917Sbeck  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23da347917Sbeck  *    endorse or promote products derived from this software without
24da347917Sbeck  *    prior written permission. For written permission, please contact
25da347917Sbeck  *    openssl-core@OpenSSL.org.
26da347917Sbeck  *
27da347917Sbeck  * 5. Products derived from this software may not be called "OpenSSL"
28da347917Sbeck  *    nor may "OpenSSL" appear in their names without prior written
29da347917Sbeck  *    permission of the OpenSSL Project.
30da347917Sbeck  *
31da347917Sbeck  * 6. Redistributions of any form whatsoever must retain the following
32da347917Sbeck  *    acknowledgment:
33da347917Sbeck  *    "This product includes software developed by the OpenSSL Project
34da347917Sbeck  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35da347917Sbeck  *
36da347917Sbeck  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37da347917Sbeck  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38da347917Sbeck  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39da347917Sbeck  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
40da347917Sbeck  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41da347917Sbeck  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42da347917Sbeck  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43da347917Sbeck  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44da347917Sbeck  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45da347917Sbeck  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46da347917Sbeck  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47da347917Sbeck  * OF THE POSSIBILITY OF SUCH DAMAGE.
48da347917Sbeck  * ====================================================================
49da347917Sbeck  *
50da347917Sbeck  * This product includes cryptographic software written by Eric Young
51da347917Sbeck  * (eay@cryptsoft.com).  This product includes software written by Tim
52da347917Sbeck  * Hudson (tjh@cryptsoft.com).
53da347917Sbeck  *
54da347917Sbeck  */
55da347917Sbeck 
56da347917Sbeck #include <stdio.h>
578cf4d6a6Sjsing 
588cf4d6a6Sjsing #include <openssl/opensslconf.h>
598cf4d6a6Sjsing 
60da347917Sbeck #include <openssl/err.h>
61da347917Sbeck #include <openssl/ui.h>
62da347917Sbeck 
63*3dca7526Stb #include "err_local.h"
64*3dca7526Stb 
65da347917Sbeck #ifndef OPENSSL_NO_ERR
660dd13104Sdjm 
670dd13104Sdjm #define ERR_FUNC(func) ERR_PACK(ERR_LIB_UI,func,0)
680dd13104Sdjm #define ERR_REASON(reason) ERR_PACK(ERR_LIB_UI,0,reason)
690dd13104Sdjm 
70*3dca7526Stb static const ERR_STRING_DATA UI_str_functs[] = {
715067ae9fSbeck 	{ERR_FUNC(0xfff), "CRYPTO_internal"},
72da347917Sbeck 	{0, NULL}
73da347917Sbeck };
74da347917Sbeck 
75*3dca7526Stb static const ERR_STRING_DATA UI_str_reasons[] = {
760dd13104Sdjm 	{ERR_REASON(UI_R_COMMON_OK_AND_CANCEL_CHARACTERS), "common ok and cancel characters"},
770dd13104Sdjm 	{ERR_REASON(UI_R_INDEX_TOO_LARGE), "index too large"},
780dd13104Sdjm 	{ERR_REASON(UI_R_INDEX_TOO_SMALL), "index too small"},
790dd13104Sdjm 	{ERR_REASON(UI_R_NO_RESULT_BUFFER), "no result buffer"},
800dd13104Sdjm 	{ERR_REASON(UI_R_RESULT_TOO_LARGE), "result too large"},
810dd13104Sdjm 	{ERR_REASON(UI_R_RESULT_TOO_SMALL), "result too small"},
820dd13104Sdjm 	{ERR_REASON(UI_R_UNKNOWN_CONTROL_COMMAND), "unknown control command"},
83da347917Sbeck 	{0, NULL}
84da347917Sbeck };
85da347917Sbeck 
86da347917Sbeck #endif
87da347917Sbeck 
88764af611Stedu void
ERR_load_UI_strings(void)89764af611Stedu ERR_load_UI_strings(void)
90da347917Sbeck {
91da347917Sbeck #ifndef OPENSSL_NO_ERR
92764af611Stedu 	if (ERR_func_error_string(UI_str_functs[0].error) == NULL) {
93*3dca7526Stb 		ERR_load_const_strings(UI_str_functs);
94*3dca7526Stb 		ERR_load_const_strings(UI_str_reasons);
95da347917Sbeck 	}
964fcf65c5Sdjm #endif
97da347917Sbeck }
98cedac418Stb LCRYPTO_ALIAS(ERR_load_UI_strings);
99