summaryrefslogtreecommitdiff
path: root/ot_scan.h
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-26 18:13:27 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-10-26 18:13:27 +0100
commit78c3cebc389a2b0d426d74900a65b8656edb426d (patch)
tree122003fecc6b53c2dde6393896a852e3689900ff /ot_scan.h
parent6837c5ac80e3624c6dc3a82d03e50d68b2f5a989 (diff)
Third run of making variable and function names more readable, integer scans and ip parsers
Diffstat (limited to 'ot_scan.h')
-rw-r--r--ot_scan.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/ot_scan.h b/ot_scan.h
index 860a088..ca3bbbd 100644
--- a/ot_scan.h
+++ b/ot_scan.h
@@ -7,15 +7,21 @@
7#define OT_SCAN_H__ 7#define OT_SCAN_H__
8 8
9#include <stddef.h> 9#include <stddef.h>
10#include <stddef.h>
10#include <stdint.h> 11#include <stdint.h>
11 12
12/* Read an unsigned decimal number from src into dest and return how many 13/* 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 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. */ 15 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); 16size_t scan_uint(const char *src, uint64_t *dest, uint64_t max);
16 17
17/* As scan_udec, but following the bencode integer grammar, which permits a 18/* As scan_uint, but following the bencode integer grammar, which permits a
18 leading zero on zero alone. */ 19 leading zero on zero alone. */
19size_t scan_udec_bencode(const char *src, uint64_t *dest, uint64_t max); 20size_t scan_uint_bencode(const char *src, uint64_t *dest, uint64_t max);
21
22/* Read a signed decimal number that has to take up exactly len characters,
23 which is how a value lifted out of a query string arrives. Returns 0, or
24 -1 leaving dest untouched. */
25int scan_int(const char *src, size_t len, int64_t *dest);
20 26
21#endif 27#endif