Diff between bb6a7ebe15d8ccb82a6de6726cd72950f085a178 and 38bd99683d46ca9f5701f117af80a1cd79fa0c08

Changed Files

File Additions Deletions Status
src/shared/hfp.c +31 -0 modified
src/shared/hfp.h +2 -0 modified

Full Patch

diff --git a/src/shared/hfp.c b/src/shared/hfp.c
index e375d27..6c804f5 100644
--- a/src/shared/hfp.c
+++ b/src/shared/hfp.c
@@ -415,6 +415,37 @@ bool hfp_context_has_next(struct hfp_context *context)
 	return context->data[context->offset] != '\0';
 }
 
+bool hfp_context_get_range(struct hfp_context *context, uint32_t *min,
+								uint32_t *max)
+{
+	uint32_t l, h;
+	uint32_t start;
+
+	start = context->offset;
+
+	if (!hfp_context_get_number(context, &l))
+		goto failed;
+
+	if (context->data[context->offset] != '-')
+		goto failed;
+
+	context->offset++;
+
+	if (!hfp_context_get_number(context, &h))
+		goto failed;
+
+	*min = l;
+	*max = h;
+
+	next_field(context);
+
+	return true;
+
+failed:
+	context->offset = start;
+	return false;
+}
+
 static void process_input(struct hfp_gw *hfp)
 {
 	char *str, *ptr;
diff --git a/src/shared/hfp.h b/src/shared/hfp.h
index be7cbb8..5ba020d 100644
--- a/src/shared/hfp.h
+++ b/src/shared/hfp.h
@@ -127,6 +127,8 @@ bool hfp_context_get_string(struct hfp_context *context, char *buf,
 								uint8_t len);
 bool hfp_context_get_unquoted_string(struct hfp_context *context,
 						char *buf, uint8_t len);
+bool hfp_context_get_range(struct hfp_context *context, unsigned int *min,
+							unsigned int *max);
 bool hfp_context_has_next(struct hfp_context *context);
 
 typedef void (*hfp_hf_result_func_t)(struct hfp_context *context,