summaryrefslogtreecommitdiffstats
path: root/src/bfstd.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-12-02 09:23:45 -0500
committerTavian Barnes <tavianator@tavianator.com>2024-12-02 16:34:26 -0500
commit9606eabd82e6523ffb8ab8b3eeb405f24e3e2346 (patch)
treefc7e21688361bc15f8492b30cd7b381a07ba0fec /src/bfstd.h
parent46e0c0bccbee21903efc9c924874970e251dde48 (diff)
downloadbfs-9606eabd82e6523ffb8ab8b3eeb405f24e3e2346.tar.xz
bfstd: Add more strto*() wrappers
Diffstat (limited to 'src/bfstd.h')
-rw-r--r--src/bfstd.h27
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.