Add unquoted string capability

This is completely broken according to the standard, but some vendors
use this in their "special" commands.
This commit is contained in:
Denis Kenzior 2009-09-03 23:03:42 -05:00 committed by Denis Kenzior
parent 05d62d82a5
commit 1a1f7d34d2
2 changed files with 47 additions and 0 deletions

View File

@ -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;

View File

@ -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);