summaryrefslogtreecommitdiff
path: root/ot_scan.h
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-24 05:25:05 +0200
committerDirk Engling <erdgeist@erdgeist.org>2026-10-24 05:25:05 +0200
commitd95163270e022fe87ece0c151c2987fd62274ba8 (patch)
tree3cd0a9803462829dd84430bbf8d56f4ef81723ed /ot_scan.h
parenta494c5a170bae9838df2f4ff511bc5f203221fb2 (diff)
Add a dedicated ranged unsigned int scanner and a bencoded variant
Diffstat (limited to 'ot_scan.h')
-rw-r--r--ot_scan.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/ot_scan.h b/ot_scan.h
new file mode 100644
index 0000000..860a088
--- /dev/null
+++ b/ot_scan.h
@@ -0,0 +1,21 @@
1/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever.
3
4 $id$ */
5
6#ifndef OT_SCAN_H__
7#define OT_SCAN_H__
8
9#include <stddef.h>
10#include <stdint.h>
11
12/* Read an unsigned decimal number from src into dest and return how many
13 characters were consumed. Returns zero and leaves dest untouched when src
14 does not begin with a digit, or when the value would exceed max. */
15size_t scan_udec(const char *src, uint64_t *dest, uint64_t max);
16
17/* As scan_udec, but following the bencode integer grammar, which permits a
18 leading zero on zero alone. */
19size_t scan_udec_bencode(const char *src, uint64_t *dest, uint64_t max);
20
21#endif