summaryrefslogtreecommitdiff
path: root/ot_scan.h
blob: 860a0885ee06e6bd4af70e05ed4a5197c42c4f95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
   It is considered beerware. Prost. Skol. Cheers or whatever.

   $id$ */

#ifndef OT_SCAN_H__
#define OT_SCAN_H__

#include <stddef.h>
#include <stdint.h>

/* Read an unsigned decimal number from src into dest and return how many
   characters were consumed. Returns zero and leaves dest untouched when src
   does not begin with a digit, or when the value would exceed max. */
size_t scan_udec(const char *src, uint64_t *dest, uint64_t max);

/* As scan_udec, but following the bencode integer grammar, which permits a
   leading zero on zero alone. */
size_t scan_udec_bencode(const char *src, uint64_t *dest, uint64_t max);

#endif