summaryrefslogtreecommitdiffstats
path: root/gatchat/gatchat.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2011-07-24 16:15:42 -0500
committerMarcel Holtmann <marcel@holtmann.org>2011-07-25 03:44:56 +0200
commit0471e3ec8de0e2e1dd77d003fe8d184128b6a109 (patch)
tree0c4412e23996bb647560931257ba9c4991dc3bf4 /gatchat/gatchat.c
parenta1baf7aa824c3e44f0880c110c1cdf7637368afe (diff)
downloadofono-0471e3ec8de0e2e1dd77d003fe8d184128b6a109.tar.bz2
gatchat: Add terminator blacklisting
Diffstat (limited to 'gatchat/gatchat.c')
-rw-r--r--gatchat/gatchat.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index 1f1204db..f37606db 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -102,6 +102,7 @@ struct at_chat {
gboolean in_read_handler; /* Re-entrancy guard */
gboolean in_notify;
GSList *terminator_list; /* Non-standard terminator */
+ guint16 terminator_blacklist; /* Blacklisted terinators */
};
struct _GAtChat {
@@ -490,6 +491,12 @@ static void at_chat_add_terminator(struct at_chat *chat, char *terminator,
chat->terminator_list = g_slist_prepend(chat->terminator_list, info);
}
+static void at_chat_blacklist_terminator(struct at_chat *chat,
+ GAtChatTerminator terminator)
+{
+ chat->terminator_blacklist |= 1 << terminator;
+}
+
static gboolean check_terminator(struct terminator_info *info, char *line)
{
if (info->len == -1 && !strcmp(line, info->terminator))
@@ -512,7 +519,8 @@ static gboolean at_chat_handle_command_response(struct at_chat *p,
for (i = 0; i < size; i++) {
struct terminator_info *info = &terminator_table[i];
- if (check_terminator(info, line)) {
+ if (check_terminator(info, line) &&
+ (p->terminator_blacklist & 1 << i) == 0) {
at_chat_finish_command(p, info->success, line);
return TRUE;
}
@@ -1439,6 +1447,15 @@ void g_at_chat_add_terminator(GAtChat *chat, char *terminator,
at_chat_add_terminator(chat->parent, terminator, len, success);
}
+void g_at_chat_blacklist_terminator(GAtChat *chat,
+ GAtChatTerminator terminator)
+{
+ if (chat == NULL || chat->group != 0)
+ return;
+
+ at_chat_blacklist_terminator(chat->parent, terminator);
+}
+
gboolean g_at_chat_set_wakeup_command(GAtChat *chat, const char *cmd,
unsigned int timeout, unsigned int msec)
{