diff options
author | Denis Kenzior <denis.kenzior@intel.com> | 2009-09-03 23:03:42 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-09-03 23:20:22 -0500 |
commit | 1a1f7d34d2301ebac972e11bb08834be57660dd8 (patch) | |
tree | b700edb1358d32a1e13e2869a108e3d922c84215 /gatchat/gatresult.c | |
parent | 05d62d82a564cc99abb7e1a236a0c1c7d495aded (diff) | |
download | ofono-1a1f7d34d2301ebac972e11bb08834be57660dd8.tar.bz2 |
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/gatresult.c')
-rw-r--r-- | gatchat/gatresult.c | 45 |
1 files changed, 45 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; |