diff options
-rw-r--r-- | gatchat/gatchat.c | 19 | ||||
-rw-r--r-- | gatchat/gatchat.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c index 31ec81e5..8f060eeb 100644 --- a/gatchat/gatchat.c +++ b/gatchat/gatchat.c @@ -1231,6 +1231,25 @@ GAtChat *g_at_chat_new_blocking(GIOChannel *channel, GAtSyntax *syntax) return g_at_chat_new_common(channel, 0, syntax); } +GAtChat *g_at_chat_clone(GAtChat *clone) +{ + GAtChat *chat; + + if (clone == NULL) + return NULL; + + chat = g_try_new0(GAtChat, 1); + if (chat == NULL) + return NULL; + + chat->parent = clone->parent; + chat->group = chat->parent->next_gid++; + chat->ref_count = 1; + g_atomic_int_inc(&chat->parent->ref_count); + + return chat; +} + GIOChannel *g_at_chat_get_channel(GAtChat *chat) { if (chat == NULL || chat->parent->io == NULL) diff --git a/gatchat/gatchat.h b/gatchat/gatchat.h index 9fd7cede..f61fe538 100644 --- a/gatchat/gatchat.h +++ b/gatchat/gatchat.h @@ -48,6 +48,8 @@ GAtIO *g_at_chat_get_io(GAtChat *chat); GAtChat *g_at_chat_ref(GAtChat *chat); void g_at_chat_unref(GAtChat *chat); +GAtChat *g_at_chat_clone(GAtChat *chat); + void g_at_chat_suspend(GAtChat *chat); void g_at_chat_resume(GAtChat *chat); |