Fix error function namespace.
authorSimon Josefsson <simon@josefsson.org>
Thu, 6 Nov 2008 09:32:49 +0000 (10:32 +0100)
committerSimon Josefsson <simon@josefsson.org>
Thu, 6 Nov 2008 09:32:49 +0000 (10:32 +0100)
NEWS
doc/reference/libtasn1-docs.sgml
lib/errors.c
lib/libtasn1.h

diff --git a/NEWS b/NEWS
index c3f71c0..84a52dc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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.
index 7d63ecd..9ead9d6 100644 (file)
   <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>
index 0d3e4a2..f4ed364 100644 (file)
@@ -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 */
index 81418f2..8fc08d9 100644 (file)
@@ -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