diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-24 05:25:05 +0200 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-24 05:25:05 +0200 |
| commit | d95163270e022fe87ece0c151c2987fd62274ba8 (patch) | |
| tree | 3cd0a9803462829dd84430bbf8d56f4ef81723ed /ot_scan.h | |
| parent | a494c5a170bae9838df2f4ff511bc5f203221fb2 (diff) | |
Add a dedicated ranged unsigned int scanner and a bencoded variant
Diffstat (limited to 'ot_scan.h')
| -rw-r--r-- | ot_scan.h | 21 |
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. */ | ||
| 15 | size_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. */ | ||
| 19 | size_t scan_udec_bencode(const char *src, uint64_t *dest, uint64_t max); | ||
| 20 | |||
| 21 | #endif | ||
