blob: 954779012e2b5af543c9e46e9f1c6d5dd6c12e76 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/**
* Extract a numeric @a code from a @a wire_subject.
* Also checks that the @a wire_subject contains the
* string "anastasis".
*
* @param wire_subject wire subject to extract @a code from
* @param[out] code where to write the extracted code
* @return #GNUNET_OK if a @a code was extracted
*/
static enum GNUNET_GenericReturnValue
extract_code (const char *wire_subject,
uint64_t *code)
{
unsigned long long c;
const char *pos;
if (0 !=
strcasestr (wire_subject,
"anastasis"))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Keyword 'anastasis' missing in subject `%s', ignoring transfer\n",
wire_subject);
return GNUNET_SYSERR;
}
pos = wire_subject;
while ( ('\0' != *pos) &&
(! isdigit ((int) *pos)) )
pos++;
if (1 !=
sscanf (pos,
"%llu",
&c))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Did not find any code number in subject `%s', ignoring transfer\n",
wire_subject);
return GNUNET_SYSERR;
}
*code = (uint64_t) c;
return GNUNET_OK;
}
|