diff options
author | Frédéric Danis <frederic.danis@linux.intel.com> | 2011-02-24 18:16:05 +0100 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-02-24 14:01:23 -0600 |
commit | 8f8559edf68e4d10670e82d5368844db68e25d31 (patch) | |
tree | 8ab63a7b3d3c587c263dbde0349b380d060bc5a5 | |
parent | 82b75c0bb69e8fb929066e2ca2cd0c0b9a785798 (diff) | |
download | ofono-8f8559edf68e4d10670e82d5368844db68e25d31.tar.bz2 |
gatchat: add g_at_result_iter_next_number_default API
-rw-r--r-- | gatchat/gatresult.c | 30 | ||||
-rw-r--r-- | gatchat/gatresult.h | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/gatchat/gatresult.c b/gatchat/gatresult.c index 8a6dfae4..f9924869 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 a74741fb..f498c861 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); |