/* This software was written by Dirk Engling It is considered beerware. Prost. Skol. Cheers or whatever. $id$ */ #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