User can call this function with hfp_gw_result, which will be passed to prefix handler. --- src/shared/hfp.c | 33 +++++++++++++++++++++++++++++++++ src/shared/hfp.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/src/shared/hfp.c b/src/shared/hfp.c index 8feaf16..d168ac4 100644 --- a/src/shared/hfp.c +++ b/src/shared/hfp.c @@ -218,6 +218,39 @@ done: return true; } +static void next_field(struct hfp_gw_result *result) +{ + if (result->data[result->offset] == ',') + result->offset++; +} + +bool hfp_gw_result_get_number(struct hfp_gw_result *result, int *val) +{ + int temp = 0; + int i; + + skip_whitespace(result); + + i = result->offset; + + while (result->data[i] >= '0' && result->data[i] <= '9') { + temp *= 10; + temp += result->data[i++] - '0'; + } + + if (i == result->offset) + return false; + + if (val) + *val = temp; + result->offset = i; + + skip_whitespace(result); + next_field(result); + + return true; +} + static void process_input(struct hfp_gw *hfp) { char *str, *ptr; diff --git a/src/shared/hfp.h b/src/shared/hfp.h index dee80d9..37d5c9b 100644 --- a/src/shared/hfp.h +++ b/src/shared/hfp.h @@ -113,3 +113,5 @@ bool hfp_gw_register_prefix_handler(struct hfp_gw *hfp, void *user_data, hfp_destroy_func_t destroy); bool hfp_gw_unregister_prefix_handler(struct hfp_gw *hfp, const char *prefix); + +bool hfp_gw_result_get_number(struct hfp_gw_result *result, int *val); -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html