==> include/mesh/parse.h <==1/* @ajax/mesh-parse: numbers parsed exactly as Rust's `str::parse` accepts them.
2 *
3 * C's strtoul skips whitespace, accepts "-1" for an unsigned (wrapping it), "0x10" with base 0 and
4 * stops at the first bad byte; Rust accepts none of that. The fleet's text formats are parsed by
5 * these so a C member accepts and refuses exactly what a Rust member does. All return false on
6 * anything Rust's parse would refuse (empty, junk, overflow), leaving *out unchanged. */
7#ifndef MESH_PARSE_H
8#define MESH_PARSE_H
9
10#include <stdbool.h>
11#include <stdint.h>
12
13/* An optional '+', then decimal digits only. */
14bool mp_u64(const char *s, uint64_t *out);
15bool mp_u32(const char *s, uint32_t *out);
16bool mp_u16(const char *s, uint16_t *out);
17/* An optional '+' or '-', then decimal digits. */
18bool mp_i32(const char *s, int32_t *out);
19/* `u64::from_str_radix(s, 16)`: an optional '+', then hex digits of either case. */
20bool mp_hex_u64(const char *s, uint64_t *out);
21bool mp_hex_u32(const char *s, uint32_t *out);
22/* Rust's float grammar: [+-] (digits [. digits] | . digits) [(e|E) [+-] digits], or inf,
23 * infinity, nan (any case); no whitespace, no hex floats. */
24bool mp_f64(const char *s, double *out);
25bool mp_f32(const char *s, float *out);
26
27#endif