summaryrefslogtreecommitdiff
path: root/gatchat
diff options
context:
space:
mode:
authorDenis Kenzior <denis.kenzior@intel.com>2009-09-03 23:03:42 -0500
committerMarcel Holtmann <marcel@holtmann.org>2009-09-05 04:57:05 +0200
commita7b632bd9e26fb0f580b7683700343e300da1680 (patch)
tree99eacf7cccb0b98c1006c1ed99b9496ef8c37070 /gatchat
parent4af2c01a6f364a4f881fbbae6a4201fc51a3192f (diff)
downloadconnman-a7b632bd9e26fb0f580b7683700343e300da1680.tar.gz
connman-a7b632bd9e26fb0f580b7683700343e300da1680.tar.bz2
connman-a7b632bd9e26fb0f580b7683700343e300da1680.zip
Add unquoted string capability
This is completely broken according to the standard, but some vendors use this in their "special" commands.
Diffstat (limited to 'gatchat')
-rw-r--r--gatchat/gatresult.c45
-rw-r--r--gatchat/gatresult.h2
2 files changed, 47 insertions, 0 deletions
diff --git a/gatchat/gatresult.c b/gatchat/gatresult.c
index 389f7e82..ee02c0ca 100644
--- a/gatchat/gatresult.c
+++ b/gatchat/gatresult.c
@@ -105,6 +105,51 @@ static inline int skip_to_next_field(const char *line, int pos, int len)
return pos;
}
+gboolean g_at_result_iter_next_unquoted_string(GAtResultIter *iter,
+ const char **str)
+{
+ unsigned int pos;
+ unsigned int end;
+ unsigned int len;
+ char *line;
+
+ if (!iter)
+ return FALSE;
+
+ if (!iter->l)
+ return FALSE;
+
+ line = iter->l->data;
+ len = strlen(line);
+
+ pos = iter->line_pos;
+
+ /* Omitted string */
+ if (line[pos] == ',') {
+ end = pos;
+ iter->buf[pos] = '\0';
+ goto out;
+ }
+
+ if (line[pos] == '"')
+ return FALSE;
+
+ end = pos;
+
+ while (end < len && line[end] != ',')
+ end += 1;
+
+ iter->buf[end] = '\0';
+
+out:
+ iter->line_pos = skip_to_next_field(line, end, len);
+
+ if (str)
+ *str = iter->buf + pos;
+
+ return TRUE;
+}
+
gboolean g_at_result_iter_next_string(GAtResultIter *iter, const char **str)
{
unsigned int pos;
diff --git a/gatchat/gatresult.h b/gatchat/gatresult.h
index fc4c123c..392e56cf 100644
--- a/gatchat/gatresult.h
+++ b/gatchat/gatresult.h
@@ -55,6 +55,8 @@ gboolean g_at_result_iter_skip_next(GAtResultIter *iter);
gboolean g_at_result_iter_next_range(GAtResultIter *iter, gint *min, gint *max);
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_hexstring(GAtResultIter *iter,
const guint8 **str, gint *length);