Hi Fred,
gatchat/gatresult.c | 25 +++++++++++++++++++++++++
gatchat/gatresult.h | 2 ++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/gatchat/gatresult.c b/gatchat/gatresult.c
index 8a6dfae..0003f0b 100644
--- a/gatchat/gatresult.c
+++ b/gatchat/gatresult.c
@@ -292,6 +292,31 @@ gboolean g_at_result_iter_next_number(GAtResultIter *iter, gint
*number)
return TRUE;
}
+gboolean g_at_result_iter_next_number_or_void(GAtResultIter *iter, gint *number)
+{
+ unsigned int pos;
+ int len;
+ char *line;
+
+ if (iter == NULL)
+ return FALSE;
+
+ if (iter->l == NULL)
+ return FALSE;
+
+ line = iter->l->data;
+ len = strlen(line);
+
+ pos = skip_to_next_field(line, iter->line_pos, len);
+
+ if (pos != iter->line_pos) {
+ iter->line_pos = pos;
+ return TRUE;
+ }
a general assumption is that if you return TRUE, you can assume that the
*number value is filled in properly. This is not the case anymore. So
you might need to give a default value in case it is void.
And that might mean we better do g_at_result_iter_next_number_default()
or something alike.
Or just having a peek function to check for an empty entry ahead before
calling g_at_result_iter_next_number() might be sufficient.
Regards
Marcel