summaryrefslogtreecommitdiff
path: root/gnu-taler-error-codes/c.footer
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-07-22 01:06:20 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-07-22 01:06:20 -0400
commit007b2a19f8d9bdf926aa584d85beb5bdac32bf9d (patch)
treeb0a7df56e904d7547a90fe57c474510f7b4bcc44 /gnu-taler-error-codes/c.footer
parent05d427aafa7f9e637db969e4933905be2a8d9b9c (diff)
generate c function for looking up ec hints
Diffstat (limited to 'gnu-taler-error-codes/c.footer')
-rw-r--r--gnu-taler-error-codes/c.footer33
1 files changed, 33 insertions, 0 deletions
diff --git a/gnu-taler-error-codes/c.footer b/gnu-taler-error-codes/c.footer
new file mode 100644
index 0000000..c348200
--- /dev/null
+++ b/gnu-taler-error-codes/c.footer
@@ -0,0 +1,33 @@
+
+
+
+/**
+ * Returns a hint for a given error code.
+ *
+ * @param ec the error code.
+ * @return the hint if it could be found, otherwise NULL.
+ */
+const char *
+TALER_ErrorCode_get_hint (enum TALER_ErrorCode ec)
+{
+ unsigned int lower = 0;
+ unsigned int upper = code_hint_pairs_length - 1;
+ unsigned int mid = upper / 2;
+ while (lower <= upper)
+ {
+ mid = (upper + lower) / 2;
+ if (code_hint_pairs[mid].ec < ec)
+ {
+ lower = mid + 1;
+ }
+ else if (code_hint_pairs[mid].ec > ec)
+ {
+ upper = mid - 1;
+ }
+ else
+ {
+ return code_hint_pairs[mid].hint;
+ }
+ }
+ return NULL;
+}