From 78c3cebc389a2b0d426d74900a65b8656edb426d Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 26 Oct 2026 18:13:27 +0100 Subject: Third run of making variable and function names more readable, integer scans and ip parsers --- ot_scan.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'ot_scan.h') diff --git a/ot_scan.h b/ot_scan.h index 860a088..ca3bbbd 100644 --- a/ot_scan.h +++ b/ot_scan.h @@ -6,16 +6,22 @@ #ifndef OT_SCAN_H__ #define OT_SCAN_H__ +#include #include #include /* 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); +size_t scan_uint(const char *src, uint64_t *dest, uint64_t max); -/* As scan_udec, but following the bencode integer grammar, which permits a +/* As scan_uint, 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); +size_t scan_uint_bencode(const char *src, uint64_t *dest, uint64_t max); + +/* Read a signed decimal number that has to take up exactly len characters, + which is how a value lifted out of a query string arrives. Returns 0, or + -1 leaving dest untouched. */ +int scan_int(const char *src, size_t len, int64_t *dest); #endif -- cgit v1.3