diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-02 20:50:24 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-02 21:14:02 +0100 |
| commit | ad541c67761b8aa6da1566802c347cac4018d0c2 (patch) | |
| tree | a9166fa9d349911d69a6948e53b05344dcc348a0 /src/ot_scan.h | |
| parent | c679ff8a3b1418a5960cc49ba6458a0007df54fa (diff) | |
Move the build sources into src/
Diffstat (limited to 'src/ot_scan.h')
| -rw-r--r-- | src/ot_scan.h | 25 |
1 files changed, 25 insertions, 0 deletions
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 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | ||
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ | ||
| 3 | |||
| 4 | #ifndef OT_SCAN_H__ | ||
| 5 | #define OT_SCAN_H__ | ||
| 6 | |||
| 7 | #include <stddef.h> | ||
| 8 | #include <stddef.h> | ||
| 9 | #include <stdint.h> | ||
| 10 | |||
| 11 | /* Read an unsigned decimal number from src into dest and return how many | ||
| 12 | characters were consumed. Returns zero and leaves dest untouched when src | ||
| 13 | does not begin with a digit, or when the value would exceed max. */ | ||
| 14 | size_t scan_uint(const char *src, uint64_t *dest, uint64_t max); | ||
| 15 | |||
| 16 | /* As scan_uint, but following the bencode integer grammar, which permits a | ||
| 17 | leading zero on zero alone. */ | ||
| 18 | size_t scan_uint_bencode(const char *src, uint64_t *dest, uint64_t max); | ||
| 19 | |||
| 20 | /* Read a signed decimal number that has to take up exactly len characters, | ||
| 21 | which is how a value lifted out of a query string arrives. Returns 0, or | ||
| 22 | -1 leaving dest untouched. */ | ||
| 23 | int scan_int(const char *src, size_t len, int64_t *dest); | ||
| 24 | |||
| 25 | #endif | ||
