iban.c (1136B)
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 */ 10 static enum GNUNET_GenericReturnValue 11 extract_code (const char *wire_subject, 12 uint64_t *code) 13 { 14 unsigned long long c; 15 const char *pos; 16 17 if (NULL == 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 }