diff options
author | Simon Josefsson <simon@josefsson.org> | 2008-11-06 10:32:49 +0100 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2008-11-06 10:32:49 +0100 |
commit | b1405c1bd8ca63ee7031e27b2e9b98613f2a1a6e (patch) | |
tree | eb50320204ddbe45150e5c66b88e04d371e03da3 | |
parent | 927856fa3007e7b225a408878159f28968400cb4 (diff) | |
download | libtasn1-b1405c1bd8ca63ee7031e27b2e9b98613f2a1a6e.tar.gz libtasn1-b1405c1bd8ca63ee7031e27b2e9b98613f2a1a6e.tar.bz2 libtasn1-b1405c1bd8ca63ee7031e27b2e9b98613f2a1a6e.zip |
Fix error function namespace.
-rw-r--r-- | NEWS | 10 | ||||
-rw-r--r-- | doc/reference/libtasn1-docs.sgml | 7 | ||||
-rw-r--r-- | lib/errors.c | 120 | ||||
-rw-r--r-- | lib/libtasn1.h | 23 |
4 files changed, 91 insertions, 69 deletions
@@ -1,6 +1,8 @@ Version 1.6 (unreleased) - Fixed namespace violation for MAX_NAME_SIZE and MAX_ERROR_DESCRIPTION_SIZE. The new names are ASN1_MAX_NAME_SIZE and ASN1_MAX_ERROR_DESCRIPTION_SIZE. +- Fixed namespace violation for libtasn1_perror and libtasn1_strerror. + The new names are asn1_perror and asn1_strerror. - Optimized tree generation. - Decoder can now decode BER encoded octet strings. - doc: Change license on the manual to GFDLv1.3+. @@ -10,8 +12,12 @@ Version 1.6 (unreleased) - Remove libtasn1-config and libtasn1.m4, use standard AC_CHECK_FUNCS autoconf tests or pkg-config instead. - API and ABI changes since last version: - asn1_get_length_ber: New function - struct node_asn_struct: Removed, was never documented nor meant for export + asn1_get_length_ber: New function. + asn1_strerror: New function, replaces libtasn1_strerror. + asn1_perror: New function, replaces libtasn1_perror. + libtasn1_strerror: Marked as deprecated. + libtasn1_perror: Marked as deprecated. + struct node_asn_struct: Removed, was never documented nor meant for export. Version 1.5 (released 2008-07-29) - Update gnulib files. diff --git a/doc/reference/libtasn1-docs.sgml b/doc/reference/libtasn1-docs.sgml index 7d63ecd..9ead9d6 100644 --- a/doc/reference/libtasn1-docs.sgml +++ b/doc/reference/libtasn1-docs.sgml @@ -26,7 +26,10 @@ <index> <title>Index</title> </index> - <index role="2.0"> - <title>Index of new symbols in 2.0</title> + <index role="1.6"> + <title>Index of new symbols in 1.6</title> + </index> + <index role="deprecated"> + <title>Index of deprecated symbols</title> </index> </book> diff --git a/lib/errors.c b/lib/errors.c index 0d3e4a2..f4ed364 100644 --- a/lib/errors.c +++ b/lib/errors.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Free Software Foundation, Inc. + * Copyright (C) 2006, 2008 Free Software Foundation, Inc. * Copyright (C) 2002, 2005 Fabio Fiorina * * This file is part of LIBTASN1. @@ -26,9 +26,7 @@ # include <stdarg.h> #endif - -#define LIBTASN1_ERROR_ENTRY(name) \ - { #name, name } +#define LIBTASN1_ERROR_ENTRY(name) { #name, name } struct libtasn1_error_entry { @@ -59,77 +57,77 @@ static const libtasn1_error_entry error_algorithms[] = { {0} }; -#define LIBTASN1_ERROR_LOOP(b) \ - const libtasn1_error_entry *p; \ - for(p = error_algorithms; p->name != NULL; p++) { b ; } - -#define LIBTASN1_ERROR_ALG_LOOP(a) \ - LIBTASN1_ERROR_LOOP( if(p->number == error) { a; break; } ) - - - /** - * libtasn1_perror - prints a string to stderr with a description of an error - * @error: is an error returned by a libtasn1 function. - * - * This function is like perror(). The only difference is that it - * accepts an error returned by a libtasn1 function. - **/ + * asn1_perror - prints a string to stderr with a description of an error + * @error: is an error returned by a libtasn1 function. + * + * This function is like perror(). The only difference is that it + * accepts an error returned by a libtasn1 function. + * + * Since: 1.6 + **/ void -libtasn1_perror (asn1_retCode error) +asn1_perror (asn1_retCode error) { - const char *ret = NULL; - - /* avoid prefix */ - LIBTASN1_ERROR_ALG_LOOP (ret = p->name + sizeof ("ASN1_") - 1); - - fprintf (stderr, "LIBTASN1 ERROR: %s\n", ret); - + const char *str = asn1_strerror (error); + fprintf (stderr, "LIBTASN1 ERROR: %s\n", str ? str : "(null)"); } - /** - * libtasn1_strerror - Returns a string with a description of an error - * @error: is an error returned by a libtasn1 function. - * - * This function is similar to strerror(). The only difference is - * that it accepts an error (number) returned by a libtasn1 function. - * - * Returns: Pointer to static zero-terminated string describing error - * code. - **/ + * asn1_strerror - Returns a string with a description of an error + * @error: is an error returned by a libtasn1 function. + * + * This function is similar to strerror(). The only difference is + * that it accepts an error (number) returned by a libtasn1 function. + * + * Returns: Pointer to static zero-terminated string describing error + * code. + * + * Since: 1.6 + **/ const char * -libtasn1_strerror (asn1_retCode error) +asn1_strerror (asn1_retCode error) { - const char *ret = NULL; + const libtasn1_error_entry *p; - /* avoid prefix */ - LIBTASN1_ERROR_ALG_LOOP (ret = p->name + sizeof ("ASN1_") - 1); + for (p = error_algorithms; p->name != NULL; p++) + if (p->number == error) + return p->name + sizeof ("ASN1_") - 1; - return ret; + return NULL; } -/* this function will output a message. - */ -#ifdef LIBTASN1_DEBUG +/* Compatibility mappings to preserve ABI. */ + +/** + * libtasn1_perror - prints a string to stderr with a description of an error + * @error: is an error returned by a libtasn1 function. + * + * This function is like perror(). The only difference is that it + * accepts an error returned by a libtasn1 function. + * + * Deprecated: Use asn1_perror() instead. + **/ void -_libtasn1_log (const char *fmt, ...) +libtasn1_perror (asn1_retCode error) { - va_list args; - char str[MAX_LOG_SIZE]; - - va_start (args, fmt); - vsprintf (str, fmt, args); /* Flawfinder: ignore */ - va_end (args); - - fprintf (stderr, str); - - return; + asn1_perror (error); } -#else /* not DEBUG */ -void -_libtasn1_log (const char *fmt, ...) + +/** + * libtasn1_strerror - Returns a string with a description of an error + * @error: is an error returned by a libtasn1 function. + * + * This function is similar to strerror(). The only difference is + * that it accepts an error (number) returned by a libtasn1 function. + * + * Returns: Pointer to static zero-terminated string describing error + * code. + * + * Deprecated: Use asn1_strerror() instead. + **/ +const char * +libtasn1_strerror (asn1_retCode error) { - return; + return asn1_strerror (error); } -#endif /* DEBUG */ diff --git a/lib/libtasn1.h b/lib/libtasn1.h index 81418f2..8fc08d9 100644 --- a/lib/libtasn1.h +++ b/lib/libtasn1.h @@ -31,7 +31,7 @@ extern "C" { #endif -#define LIBTASN1_VERSION "2.0" +#define LIBTASN1_VERSION "1.6" #include <sys/types.h> #include <time.h> @@ -203,9 +203,8 @@ extern "C" const char *asn1_check_version (const char *req_version); - const char *libtasn1_strerror (asn1_retCode error); - - void libtasn1_perror (asn1_retCode error); + const char *asn1_strerror (asn1_retCode error); + void asn1_perror (asn1_retCode error); /* DER utility functions. */ @@ -241,6 +240,22 @@ extern "C" asn1_retCode asn1_copy_node (ASN1_TYPE dst, const char *dst_name, ASN1_TYPE src, const char *src_name); + + /* Deprecated functions. */ + +#define _GNUTLS_GCC_VERSION \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + +#if _GNUTLS_GCC_VERSION >= 30100 +# define ASN1_DEPRECATED __attribute__ ((__deprecated__)) +#endif + + /* Use asn1_strerror instead. */ + const char *libtasn1_strerror (asn1_retCode error) ASN1_DEPRECATED; + + /* Use asn1_perror instead. */ + void libtasn1_perror (asn1_retCode error) ASN1_DEPRECATED; + #ifdef __cplusplus } #endif |