From ad541c67761b8aa6da1566802c347cac4018d0c2 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 20:50:24 +0100 Subject: Move the build sources into src/ --- src/ot_scan.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/ot_scan.h (limited to 'src/ot_scan.h') diff --git a/src/ot_scan.h b/src/ot_scan.h new file mode 100644 index 0000000..a79ec13 --- /dev/null +++ b/src/ot_scan.h @@ -0,0 +1,25 @@ +/* This software was written by Dirk Engling + It is considered beerware. Prost. Skol. Cheers or whatever. */ + +#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_uint(const char *src, uint64_t *dest, uint64_t max); + +/* As scan_uint, but following the bencode integer grammar, which permits a + leading zero on zero alone. */ +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