aboutsummaryrefslogtreecommitdiff
path: root/src/authorization/iban.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/authorization/iban.c')
-rw-r--r--src/authorization/iban.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/authorization/iban.c b/src/authorization/iban.c
new file mode 100644
index 0000000..9547790
--- /dev/null
+++ b/src/authorization/iban.c
@@ -0,0 +1,43 @@
1/**
2 * Extract a numeric @a code from a @a wire_subject.
3 * Also checks that the @a wire_subject contains the
4 * string "anastasis".
5 *
6 * @param wire_subject wire subject to extract @a code from
7 * @param[out] code where to write the extracted code
8 * @return #GNUNET_OK if a @a code was extracted
9 */
10static enum GNUNET_GenericReturnValue
11extract_code (const char *wire_subject,
12 uint64_t *code)
13{
14 unsigned long long c;
15 const char *pos;
16
17 if (0 !=
18 strcasestr (wire_subject,
19 "anastasis"))
20 {
21 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
22 "Keyword 'anastasis' missing in subject `%s', ignoring transfer\n",
23 wire_subject);
24 return GNUNET_SYSERR;
25 }
26 pos = wire_subject;
27 while ( ('\0' != *pos) &&
28 (! isdigit ((int) *pos)) )
29 pos++;
30 if (1 !=
31 sscanf (pos,
32 "%llu",
33 &c))
34 {
35 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
36 "Did not find any code number in subject `%s', ignoring transfer\n",
37 wire_subject);
38 return GNUNET_SYSERR;
39 }
40
41 *code = (uint64_t) c;
42 return GNUNET_OK;
43}