1 /* error.c --- Error handling functions for the Shisa library.
2 * Copyright (C) 2002, 2003, 2004, 2006 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 struct shisa_error_msgs
30 static const struct shisa_error_msgs _shisa_error_messages
[] = {
34 N_("Shisa could not be initialized.")},
36 N_("The Shisa configuration file does not exist.")},
38 N_("File I/O error for Shisa configuration file.")},
39 {SHISA_CFG_SYNTAX_ERROR
,
40 N_("Syntax error in Shisa configuration token.")},
42 N_("Shisa database could not be opened.")},
43 {SHISA_ENUMERATE_REALM_ERROR
,
44 N_("Error enumerating realms in database.")},
45 {SHISA_ENUMERATE_PRINCIPAL_ERROR
,
46 N_("Error enumerating principals in database.")},
47 {SHISA_ENUMERATE_KEY_ERROR
,
48 N_("Error enumerating keys in database.")},
50 N_("Supplied realm does not exist.")},
52 N_("Supplied principal does not exist.")},
54 N_("Principal is not associated with any matching key.")},
56 N_("Error finding principal.")},
57 {SHISA_ADD_REALM_EXISTS
,
58 N_("Tried to add a realm that already exist.")},
59 {SHISA_ADD_REALM_ERROR
,
60 N_("Error adding realm to database.")},
61 {SHISA_REMOVE_REALM_NONEMPTY
,
62 N_("Tried to remove a non-empty realm.")},
63 {SHISA_REMOVE_REALM_ERROR
,
64 N_("Error removing realm from database.")},
65 {SHISA_ADD_PRINCIPAL_EXISTS
,
66 N_("Tried to add a principal that already exist.")},
67 {SHISA_ADD_PRINCIPAL_ERROR
,
68 N_("Error adding principal to database.")},
69 {SHISA_REMOVE_PRINCIPAL_ERROR
,
70 N_("Error removing principal from database.")},
72 N_("Error adding key to principal.")},
73 {SHISA_REMOVE_KEY_ERROR
,
74 N_("Error removing key from principal.")},
75 {SHISA_MULTIPLE_KEY_MATCH
,
76 N_("More than one key match given search criteria.")}
81 * @err: shisa error code
83 * Return value: Returns a pointer to a statically allocated string
84 * containing a description of the error with the error value @err.
85 * This string can be used to output a diagnostic message to the user.
88 shisa_strerror (int err
)
92 for (i
= 0; i
< sizeof (_shisa_error_messages
) /
93 sizeof (_shisa_error_messages
[0]); i
++)
94 if (_shisa_error_messages
[i
].errorcode
== err
)
95 return _(_shisa_error_messages
[i
].message
);
97 return _("Unknown Shisa error");
102 * @dbh: Shisa library handle created by shisa().
103 * @format: printf style format string.
104 * @...: print style arguments.
106 * Print informational message to standard error.
109 shisa_info (Shisa
* dbh
, const char *format
, ...)
114 va_start (ap
, format
);
115 vasprintf (&out
, format
, ap
);
117 fprintf (stderr
, _("shisa: %s\n"), out
);