Allow enabling of dummy error_strerror() to support some use-cases
Enable a dummy error function to make use of error_strerror() in
third party libraries easier.
Disable if you run into name conflicts and want to really remove the
error_strerror()
(cherry picked from commit 8fe40dcd7d3b46193f74032361efb674112ee9e5)
Conflicts:
ChangeLog
programs/util/strerror.c
diff --git a/ChangeLog b/ChangeLog
index 1d39489..6753726 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
PolarSSL ChangeLog
+= Branch 1.1
+Changes
+ * Allow enabling of dummy error_strerror() to support some use-cases
+
= Version 1.1.5 released on 2013-01-16
Bugfix
* Fixed MPI assembly for SPARC64 platform
diff --git a/include/polarssl/config.h b/include/polarssl/config.h
index bb2e232..110e3b4 100644
--- a/include/polarssl/config.h
+++ b/include/polarssl/config.h
@@ -139,6 +139,17 @@
#define POLARSSL_DEBUG_MSG
/**
+ * \def POLARSSL_ERROR_STRERROR_DUMMY
+ *
+ * Enable a dummy error function to make use of error_strerror() in
+ * third party libraries easier.
+ *
+ * Disable if you run into name conflicts and want to really remove the
+ * error_strerror()
+ */
+#define POLARSSL_ERROR_STRERROR_DUMMY
+
+/**
* \def POLARSSL_GENPRIME
*
* Requires: POLARSSL_BIGNUM_C, POLARSSL_RSA_C
diff --git a/library/error.c b/library/error.c
index 792b902..452f458 100644
--- a/library/error.c
+++ b/library/error.c
@@ -509,4 +509,22 @@
snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
}
+#else /* POLARSSL_ERROR_C */
+
+#if defined(POLARSSL_ERROR_STRERROR_DUMMY)
+
+#include <string.h>
+
+/*
+ * Provide an non-function in case POLARSSL_ERROR_C is not defined
+ */
+void error_strerror( int ret, char *buf, size_t buflen )
+{
+ ((void) ret);
+
+ if( buflen > 0 )
+ buf[0] = '\0';
+}
+
+#endif /* POLARSSL_ERROR_STRERROR_DUMMY */
#endif /* POLARSSL_ERROR_C */