---
 gatchat/gatresult.c |   30 ++++++++++++++++++++++++++++++
 gatchat/gatresult.h |    2 ++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/gatchat/gatresult.c b/gatchat/gatresult.c
index 8a6dfae..f992486 100644
--- a/gatchat/gatresult.c
+++ b/gatchat/gatresult.c
@@ -292,6 +292,36 @@ gboolean g_at_result_iter_next_number(GAtResultIter *iter, 
gint *number)
        return TRUE;
 }
 
+gboolean g_at_result_iter_next_number_default(GAtResultIter *iter, gint dflt,
+                                               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;
+
+               if (number)
+                       *number = dflt;
+
+               return TRUE;
+       }
+
+       return g_at_result_iter_next_number(iter, number);
+}
+
 gboolean g_at_result_iter_next_range(GAtResultIter *iter, gint *min, gint *max)
 {
        int pos;
diff --git a/gatchat/gatresult.h b/gatchat/gatresult.h
index a74741f..f498c86 100644
--- a/gatchat/gatresult.h
+++ b/gatchat/gatresult.h
@@ -58,6 +58,8 @@ gboolean g_at_result_iter_next_string(GAtResultIter *iter, 
const char **str);
 gboolean g_at_result_iter_next_unquoted_string(GAtResultIter *iter,
                                                const char **str);
 gboolean g_at_result_iter_next_number(GAtResultIter *iter, gint *number);
+gboolean g_at_result_iter_next_number_default(GAtResultIter *iter, gint dflt,
+                                               gint *number);
 gboolean g_at_result_iter_next_hexstring(GAtResultIter *iter,
                const guint8 **str, gint *length);
 
-- 
1.7.1

_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to