Diff between 30eb808daaddfea2ca955535db3a023e9c131311 and d8c57b505f7ef0347fee56148e890e7fd5c188df

Changed Files

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

Full Patch

diff --git a/src/shared/hfp.c b/src/shared/hfp.c
index d7cca32..10734fc 100644
--- a/src/shared/hfp.c
+++ b/src/shared/hfp.c
@@ -275,6 +275,39 @@ bool hfp_gw_result_close_container(struct hfp_gw_result *result)
 	return true;
 }
 
+bool hfp_gw_result_get_string(struct hfp_gw_result *result, char *buf,
+								uint8_t len)
+{
+	int i = 0;
+	const char *data = result->data;
+
+	skip_whitespace(result);
+
+	if (data[result->offset] != '"')
+		return false;
+
+	result->offset++;
+
+	while (data[result->offset] != '\0' && data[result->offset] != '"') {
+		if (i < len)
+			buf[i++] = data[result->offset];
+		result->offset++;
+	}
+
+	if (i < len)
+		buf[i++] = '\0';
+
+	if (data[result->offset] == '"')
+		result->offset++;
+	else
+		return false;
+
+	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 00905de..3313d91 100644
--- a/src/shared/hfp.h
+++ b/src/shared/hfp.h
@@ -116,3 +116,5 @@ bool hfp_gw_unregister(struct hfp_gw *hfp, const char *prefix);
 bool hfp_gw_result_get_number(struct hfp_gw_result *result, unsigned int *val);
 bool hfp_gw_result_open_container(struct hfp_gw_result *result);
 bool hfp_gw_result_close_container(struct hfp_gw_result *result);
+bool hfp_gw_result_get_string(struct hfp_gw_result *result, char *buf,
+								uint8_t len);