1 /* error.c error handling functions
2 * Copyright (C) 2002 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 shishi_strerror_details (Shishi
* handle
)
27 return handle
->error
? handle
->
29 "Internal application error: shishi_strerror() called without an "
35 * @err: shishi error code
37 * Return value: Returns a pointer to a statically allocated string
38 * containing a description of the error with the error value
39 * @var{err}. This string can be used to output a diagnostic message
43 shishi_strerror (int err
)
50 p
= _("Shishi success");
53 case SHISHI_MALLOC_ERROR
:
54 p
= _("Memory allocation error in shishi library.");
57 case SHISHI_BASE64_ERROR
:
58 p
= _("Base64 encoding or decoding failed. This usually means the "
62 case SHISHI_FOPEN_ERROR
:
63 p
= _("Could not open file.");
66 case SHISHI_FCLOSE_ERROR
:
67 p
= _("Could not close file.");
70 case SHISHI_GCRYPT_ERROR
:
71 p
= _("Internal libgcrypt error.");
74 case SHISHI_NONCE_MISMATCH
:
76 _("Replay protection value (nonce) differ between request and reply.");
79 case SHISHI_REALM_MISMATCH
:
80 p
= _("Client realm value differ between request and reply.");
83 case SHISHI_CNAME_MISMATCH
:
84 p
= _("Client name value differ between request and reply.");
87 case SHISHI_ASN1_ERROR
:
88 p
= _("Error in ASN.1 data, probably due to corrupt data.");
91 case SHISHI_CRYPTO_ERROR
:
94 ("Low-level cryptographic primitive failed. This usually indicates "
95 "bad password or data corruption.");
98 case SHISHI_KDC_TIMEOUT
:
99 p
= _("Timedout talking to KDC. This usually indicates a network "
100 "or KDC address problem.");
103 case SHISHI_KDC_NOT_KNOWN_FOR_REALM
:
104 p
= _("No KDC for realm known.");
107 case SHISHI_SOCKET_ERROR
:
108 p
= _("The system call socket() failed. This usually indicates that "
109 "your system does not support the socket type.");
112 case SHISHI_BIND_ERROR
:
113 p
= _("The system call bind() failed. This usually indicates "
114 "insufficient permissions.");
117 case SHISHI_SENDTO_ERROR
:
118 p
= _("The system call sendto() failed.");
121 case SHISHI_CLOSE_ERROR
:
122 p
= _("The system call close() failed.");
125 case SHISHI_GOT_KRBERROR
:
126 p
= _("Server replied with an error message to request.");
129 case SHISHI_INVALID_TICKETSET
:
130 p
= _("Ticketset not initialized. This usually indicates an internal "
131 "application error.");
135 shishi_asprintf (&p
, _("Unknown shishi error (%d)"), err
);
144 shishi_error_clear (Shishi
* handle
)
146 handle
->error
[0] = '\0';
150 shishi_error_set (Shishi
* handle
, const char *error
)
153 strncpy (handle
->error
, error
, sizeof (handle
->error
));
155 shishi_error_clear (handle
);
159 shishi_error_printf (Shishi
* handle
, char *format
, ...)
163 va_start (ap
, format
);
165 vsnprintf (handle
->error
, sizeof (handle
->error
), format
, ap
);