[PATCH 6/8] shared/hfp: Add hfp_gw_result_get_number_default function

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

 



---
 src/shared/hfp.c | 15 +++++++++++++++
 src/shared/hfp.h |  3 +++
 2 files changed, 18 insertions(+)

diff --git a/src/shared/hfp.c b/src/shared/hfp.c
index 44b5b55..e548672 100644
--- a/src/shared/hfp.c
+++ b/src/shared/hfp.c
@@ -224,6 +224,21 @@ static void next_field(struct hfp_gw_result *result)
 		result->offset++;
 }
 
+bool hfp_gw_result_get_number_default(struct hfp_gw_result *result,
+						unsigned int *val,
+						unsigned int default_val)
+{
+	skip_whitespace(result);
+
+	if (result->data[result->offset] == ',') {
+		if (val)
+			*val = default_val;
+		return true;
+	}
+
+	return hfp_gw_result_get_number(result, val);
+}
+
 bool hfp_gw_result_get_number(struct hfp_gw_result *result, unsigned int *val)
 {
 	int tmp = 0;
diff --git a/src/shared/hfp.h b/src/shared/hfp.h
index 4da5c97..743db65 100644
--- a/src/shared/hfp.h
+++ b/src/shared/hfp.h
@@ -114,6 +114,9 @@ bool hfp_gw_register(struct hfp_gw *hfp, hfp_result_func_t callback,
 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_get_number_default(struct hfp_gw_result *result,
+						unsigned int *val,
+						unsigned int default_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,
-- 
1.8.3.2

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