summaryrefslogtreecommitdiff
path: root/p11-kit/p11-kit-uri.c
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-05-25 11:44:40 +0200
committerStef Walter <stefw@collabora.co.uk>2011-05-25 11:44:40 +0200
commit7c2a8a5b3ad134b6e3093761d617936dcbd21adf (patch)
tree20061e7726a61ca86a211b8549315d97d3f138d4 /p11-kit/p11-kit-uri.c
parenta01f4351e34fee946d1ffb81baa31a756e2851be (diff)
Add p11_kit_uri_message() function.
Gets messages for p11-kit error codes.
Diffstat (limited to 'p11-kit/p11-kit-uri.c')
-rw-r--r--p11-kit/p11-kit-uri.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/p11-kit/p11-kit-uri.c b/p11-kit/p11-kit-uri.c
index 5004ba1..0e9010c 100644
--- a/p11-kit/p11-kit-uri.c
+++ b/p11-kit/p11-kit-uri.c
@@ -34,6 +34,8 @@
#include "config.h"
+#define DEBUG_FLAG DEBUG_URI
+#include "debug.h"
#include "pkcs11.h"
#include "p11-kit-uri.h"
#include "util.h"
@@ -1193,3 +1195,39 @@ p11_kit_uri_free (P11KitUri *uri)
free (uri);
}
+
+/**
+ * p11_kit_uri_message:
+ * @code: The error code
+ *
+ * Lookup a message for the uri error code. These codes are the P11_KIT_URI_XXX
+ * error codes that can be returned from p11_kit_uri_parse() or
+ * p11_kit_uri_format(). As a special case %NULL, will be returned for
+ * %P11_KIT_URI_OK.
+ *
+ * Returns: The message for the error code. This string is owned by the p11-kit
+ * library.
+ */
+const char*
+p11_kit_uri_message (int code)
+{
+ switch (code) {
+ case P11_KIT_URI_OK:
+ return NULL;
+ case P11_KIT_URI_NO_MEMORY:
+ return "Out of memory";
+ case P11_KIT_URI_BAD_SCHEME:
+ return "URI scheme must be 'pkcs11:'";
+ case P11_KIT_URI_BAD_ENCODING:
+ return "URI encoding invalid or corrupted";
+ case P11_KIT_URI_BAD_SYNTAX:
+ return "URI syntax is invalid";
+ case P11_KIT_URI_BAD_VERSION:
+ return "URI version component is invalid";
+ case P11_KIT_URI_NOT_FOUND:
+ return "The URI component was not found";
+ default:
+ debug ("unknown error code: %d", code);
+ return "Unknown error";
+ }
+}