From 1a1d120edb6e18db01c174482a7c6037e3db2a57 Mon Sep 17 00:00:00 2001 From: Lukasz Rymanowski Date: Mon, 3 Nov 2014 10:36:00 +0100 Subject: [PATCH] shared/hfp: Add function to skip field in hfp_context Some fields in AT commands are not used by HFP spec. When parsing such commands it is convinient to just skip it without looking what is inside there --- src/shared/hfp.c | 12 ++++++++++++ src/shared/hfp.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/shared/hfp.c b/src/shared/hfp.c index 6c804f576..a35cb7bce 100644 --- a/src/shared/hfp.c +++ b/src/shared/hfp.c @@ -415,6 +415,18 @@ bool hfp_context_has_next(struct hfp_context *context) return context->data[context->offset] != '\0'; } +void hfp_context_skip_field(struct hfp_context *context) +{ + const char *data = context->data; + unsigned int offset = context->offset; + + while (data[offset] != '\0' && data[offset] != ',') + offset++; + + context->offset = offset; + next_field(context); +} + bool hfp_context_get_range(struct hfp_context *context, uint32_t *min, uint32_t *max) { diff --git a/src/shared/hfp.h b/src/shared/hfp.h index 5ba020d75..2eb783849 100644 --- a/src/shared/hfp.h +++ b/src/shared/hfp.h @@ -130,6 +130,7 @@ bool hfp_context_get_unquoted_string(struct hfp_context *context, bool hfp_context_get_range(struct hfp_context *context, unsigned int *min, unsigned int *max); bool hfp_context_has_next(struct hfp_context *context); +void hfp_context_skip_field(struct hfp_context *context); typedef void (*hfp_hf_result_func_t)(struct hfp_context *context, void *user_data); -- 2.47.3