diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-06-21 01:16:18 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-06-21 01:16:18 +0000 |
commit | 2d0f688cafaebbbc21901710ab13edcf292c4d61 (patch) | |
tree | b444aa3127e9807ba76c0a7ba3ef2791adb97a81 /channel.c | |
parent | b10a02101a8f084691e8fb8b7a104afe78c55eb1 (diff) |
add AGI 'RECEIVE TEXT' command (bug #4525)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5950 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rwxr-xr-x | channel.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -1652,6 +1652,40 @@ int ast_recvchar(struct ast_channel *chan, int timeout) } } +char *ast_recvtext(struct ast_channel *chan, int timeout) +{ + int res,ourto; + struct ast_frame *f; + char *buf; + + ourto = timeout; + for(;;) { + if (ast_check_hangup(chan)) return NULL; + res = ast_waitfor(chan,ourto); + if (res <= 0) { + /* if timeout */ + return NULL; + } + ourto = res; + f = ast_read(chan); + if (f == NULL) return NULL; /* no frame */ + if ((f->frametype == AST_FRAME_CONTROL) && + (f->subclass == AST_CONTROL_HANGUP)) return NULL; /* if hangup */ + if (f->frametype == AST_FRAME_TEXT) { + /* if a text frame */ + buf = (char *)malloc(strlen((char *)f->data)); + if (buf) { + strcpy(buf, (char *)f->data); + ast_frfree(f); + return(buf); + } else { + return NULL; + } + } + ast_frfree(f); + } +} + int ast_sendtext(struct ast_channel *chan, char *text) { int res = 0; |