diff options
author | Simon Josefsson <simon@josefsson.org> | 2008-08-29 10:14:36 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2008-08-29 10:14:36 +0200 |
commit | 85a6854988e715bc325ee8687b271d190165499b (patch) | |
tree | bdb34c8155cf94e44881f49567053f6d856ce700 /lib/gnutls_errors.c | |
parent | 60673f5fe9911a4735ff9f1bef6071c96b1896e4 (diff) | |
download | gnutls-85a6854988e715bc325ee8687b271d190165499b.tar.gz |
Add gnutls_strerror_name.
Diffstat (limited to 'lib/gnutls_errors.c')
-rw-r--r-- | lib/gnutls_errors.c | 40 |
1 files changed, 33 insertions, 7 deletions
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) { |