From 85a6854988e715bc325ee8687b271d190165499b Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Fri, 29 Aug 2008 10:14:36 +0200 Subject: Add gnutls_strerror_name. --- lib/gnutls_errors.c | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'lib/gnutls_errors.c') diff --git a/lib/gnutls_errors.c b/lib/gnutls_errors.c index a9a1f3a741..9bba830f53 100644 --- a/lib/gnutls_errors.c +++ b/lib/gnutls_errors.c @@ -324,13 +324,17 @@ gnutls_perror (int error) /** - * gnutls_strerror - Returns a string with a description of an error - * @error: is an error returned by a gnutls function. Error is always a negative value. - * - * This function is similar to strerror(). Differences: it accepts an error - * number returned by a gnutls function; In case of an unknown error - * a descriptive string is sent instead of NULL. - **/ + * gnutls_strerror - Returns a string with a description of an error + * @error: is an error returned by a gnutls function. + * + * This function is similar to strerror(). Differences: it accepts an + * error number returned by a gnutls function; In case of an unknown + * error a descriptive string is sent instead of NULL. + * + * Error codes are always a negative value. + * + * Returns: A string explaining the GnuTLS error message. + **/ const char * gnutls_strerror (int error) { @@ -343,6 +347,28 @@ gnutls_strerror (int error) return _(ret); } +/** + * gnutls_strerror_name: + * @error: is an error returned by a gnutls function. + * + * Return the GnuTLS error code define as a string. For example, + * gnutls_strerror_name (GNUTLS_E_DH_PRIME_UNACCEPTABLE) will return + * the string "GNUTLS_E_DH_PRIME_UNACCEPTABLE". + * + * Returns: A string corresponding to the symbol name of the error + * code. + **/ +const char * +gnutls_strerror_name (int error) +{ + const char *ret = NULL; + + /* avoid prefix */ + GNUTLS_ERROR_ALG_LOOP (ret = p->_name); + + return _(ret); +} + int _gnutls_asn2err (int asn_err) { -- cgit v1.2.1