diff options
Diffstat (limited to 'gnu-taler-error-codes/c.footer')
-rw-r--r-- | gnu-taler-error-codes/c.footer | 33 |
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 @@ | |||
1 | |||
2 | |||
3 | |||
4 | /** | ||
5 | * Returns a hint for a given error code. | ||
6 | * | ||
7 | * @param ec the error code. | ||
8 | * @return the hint if it could be found, otherwise NULL. | ||
9 | */ | ||
10 | const char * | ||
11 | TALER_ErrorCode_get_hint (enum TALER_ErrorCode ec) | ||
12 | { | ||
13 | unsigned int lower = 0; | ||
14 | unsigned int upper = code_hint_pairs_length - 1; | ||
15 | unsigned int mid = upper / 2; | ||
16 | while (lower <= upper) | ||
17 | { | ||
18 | mid = (upper + lower) / 2; | ||
19 | if (code_hint_pairs[mid].ec < ec) | ||
20 | { | ||
21 | lower = mid + 1; | ||
22 | } | ||
23 | else if (code_hint_pairs[mid].ec > ec) | ||
24 | { | ||
25 | upper = mid - 1; | ||
26 | } | ||
27 | else | ||
28 | { | ||
29 | return code_hint_pairs[mid].hint; | ||
30 | } | ||
31 | } | ||
32 | return NULL; | ||
33 | } | ||