diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-12-02 09:23:45 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-12-02 16:34:26 -0500 |
commit | 9606eabd82e6523ffb8ab8b3eeb405f24e3e2346 (patch) | |
tree | fc7e21688361bc15f8492b30cd7b381a07ba0fec /src/bfstd.h | |
parent | 46e0c0bccbee21903efc9c924874970e251dde48 (diff) | |
download | bfs-9606eabd82e6523ffb8ab8b3eeb405f24e3e2346.tar.xz |
bfstd: Add more strto*() wrappers
Diffstat (limited to 'src/bfstd.h')
-rw-r--r-- | src/bfstd.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/bfstd.h b/src/bfstd.h index 97867fd..84f92ec 100644 --- a/src/bfstd.h +++ b/src/bfstd.h @@ -179,23 +179,26 @@ int open_cterm(int flags); const char *xgetprogname(void); /** + * Wrapper for strtol() that forbids leading spaces. + */ +int xstrtol(const char *str, char **end, int base, long *value); + +/** * Wrapper for strtoll() that forbids leading spaces. - * - * @str - * The string to parse. - * @end - * If non-NULL, will hold a pointer to the first invalid character. - * If NULL, the entire string must be valid. - * @base - * The base for the conversion, or 0 to auto-detect. - * @value - * Will hold the parsed integer value, on success. - * @return - * 0 on success, -1 on failure. */ int xstrtoll(const char *str, char **end, int base, long long *value); /** + * Wrapper for strtof() that forbids leading spaces. + */ +int xstrtof(const char *str, char **end, float *value); + +/** + * Wrapper for strtod() that forbids leading spaces. + */ +int xstrtod(const char *str, char **end, double *value); + +/** * Process a yes/no prompt. * * @return 1 for yes, 0 for no, and -1 for unknown. |