path: root/m_option.h
diff options
authorUoti Urpala <>2011-07-28 11:07:47 +0300
committerUoti Urpala <>2011-07-29 05:50:38 +0300
commite873d703e956d3e2e68b9e18562983b029b5c7a8 (patch)
tree44a2c48ae4e94bd580ffd5833cd71a037af36043 /m_option.h
parentd8374376c0d46ffab88b96eb32b52621c34f562c (diff)
options: change option parsing to use bstr
Using bstr allows simpler parsing code, especially because it avoids the need to modify or copy strings just to terminate extracted substrings.
Diffstat (limited to 'm_option.h')
1 files changed, 4 insertions, 14 deletions
diff --git a/m_option.h b/m_option.h
index 76d3366d18..123e51005c 100644
--- a/m_option.h
+++ b/m_option.h
@@ -24,6 +24,7 @@
#include <stdbool.h>
#include "config.h"
+#include "bstr.h"
// m_option allows to parse, print and copy data of various types.
@@ -217,7 +218,7 @@ struct m_option_type {
* \return On error a negative value is returned, on success the number
* of arguments consumed. For details see \ref OptionParserReturn.
- int (*parse)(const m_option_t *opt, const char *name, const char *param,
+ int (*parse)(const m_option_t *opt, struct bstr name, struct bstr param,
bool ambiguous_param, void *dst);
// Print back a value in string form.
@@ -440,8 +441,8 @@ static inline void *m_option_get_ptr(const struct m_option *opt,
// Helper to parse options, see \ref m_option_type::parse.
-static inline int m_option_parse(const m_option_t *opt, const char *name,
- const char *param, bool ambiguous_param,
+static inline int m_option_parse(const m_option_t *opt, struct bstr name,
+ struct bstr param, bool ambiguous_param,
void *dst)
return opt->type->parse(opt, name, param, ambiguous_param, dst);
@@ -475,17 +476,6 @@ static inline void m_option_free(const m_option_t *opt, void *dst)
- * Parse a string as a timestamp.
- *
- * @param[in] str the string to parse.
- * @param[out] time parsed time.
- * @param[in] endchar return an error of the next character after the
- * timestamp is neither nul nor endchar.
- * @return Number of chars in the timestamp.
- */
-int parse_timestring(const char *str, double *time, char endchar);