[PATCH 9/9] shared/hfp_at: Add function to get unquoted string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/shared/hfp_at.c | 27 +++++++++++++++++++++++++++
 src/shared/hfp_at.h |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/src/shared/hfp_at.c b/src/shared/hfp_at.c
index 750133f..50e8614 100644
--- a/src/shared/hfp_at.c
+++ b/src/shared/hfp_at.c
@@ -278,6 +278,33 @@ bool hfp_at_get_string(struct hfp_at *hfp_at, const char *data, char *buf,
 	return true;
 }
 
+bool hfp_at_get_unquoted_string(struct hfp_at *hfp_at, const char *data,
+							char *buf, uint8_t len)
+{
+	int i = 0;
+	char c;
+
+	hfp_at_skip_whitespace(hfp_at, data);
+
+	c = data[hfp_at->offset];
+	if (c == '"' || c == ')' || c == '(')
+		return false;
+
+	while (data[hfp_at->offset] != '\0' && data[hfp_at->offset] != ','
+					&& data[hfp_at->offset] != ')') {
+		if (i < len)
+			buf[i++] = data[hfp_at->offset];
+		hfp_at->offset++;
+	}
+
+	if (i < len)
+		buf[i++] = '\0';
+
+	hfp_at_next_field(hfp_at, data);
+
+	return true;
+}
+
 bool hfp_at_open_container(struct hfp_at *hfp_at, const char *data)
 {
 	hfp_at_skip_whitespace(hfp_at, data);
diff --git a/src/shared/hfp_at.h b/src/shared/hfp_at.h
index 4da381b..76bdb03 100644
--- a/src/shared/hfp_at.h
+++ b/src/shared/hfp_at.h
@@ -47,6 +47,8 @@ bool hfp_at_open_container(struct hfp_at *hfp_at, const char *data);
 bool hfp_at_close_container(struct hfp_at *hfp_at, const char *data);
 bool hfp_at_get_string(struct hfp_at *hfp_at, const char *data, char *buf,
 								uint8_t len);
+bool hfp_at_get_unquoted_string(struct hfp_at *hfp_at, const char *data,
+							char *buf, uint8_t len);
 
 struct hfp_at *hfp_at_new(const struct hfp_at_handler *handlers);
 void hfp_at_free(struct hfp_at *hfp_at);
-- 
1.8.5.3

--
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




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux