From 1ab52a857a5a9f7ebb3cd7bd2918394fdf17ffd0 Mon Sep 17 00:00:00 2001 From: rizzo Date: Sun, 16 Apr 2006 07:53:25 +0000 Subject: implement ast_waitfordigit() and ast_readstring() in terms of their '_full()' version, so we can remove the replicated implementation and, especially, the risk that they get out of sync. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@20389 f38db490-d61c-443f-a65b-d21fe96a405b --- channel.c | 63 ++------------------------------------------------------------- 1 file changed, 2 insertions(+), 61 deletions(-) (limited to 'channel.c') diff --git a/channel.c b/channel.c index b6236d4f5..0add8638e 100644 --- a/channel.c +++ b/channel.c @@ -1746,31 +1746,7 @@ int ast_waitfor(struct ast_channel *c, int ms) /* XXX never to be called with ms = -1 */ int ast_waitfordigit(struct ast_channel *c, int ms) { - /* XXX Should I be merged with waitfordigit_full XXX */ - struct ast_frame *f; - int result = 0; - - /* Stop if we're a zombie or need a soft hangup */ - if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) - return -1; - - /* Wait for a digit, no more than ms milliseconds total. */ - while(ms && !result) { - ms = ast_waitfor(c, ms); - if (ms < 0) /* Error */ - result = -1; - else if (ms > 0) { - /* Read something */ - f = ast_read(c); - if (f) { - if (f->frametype == AST_FRAME_DTMF) - result = f->subclass; - ast_frfree(f); - } else - result = -1; - } - } - return result; + return ast_waitfordigit_full(c, ms, -1, -1); } int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data), void *data) @@ -2718,42 +2694,7 @@ int ast_transfer(struct ast_channel *chan, char *dest) int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders) { - int pos=0; - int to = ftimeout; - int d; - - /* XXX Merge with full version? XXX */ - /* Stop if we're a zombie or need a soft hangup */ - if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) - return -1; - if (!len) - return -1; - for (;;) { - if (c->stream) { - d = ast_waitstream(c, AST_DIGIT_ANY); - ast_stopstream(c); - usleep(1000); - if (!d) - d = ast_waitfordigit(c, to); - } else { - d = ast_waitfordigit(c, to); - } - if (d < 0) - return -1; - if (d == 0) { - s[pos]='\0'; - return 1; - } - if (!strchr(enders, d)) - s[pos++] = d; - if (strchr(enders, d) || (pos >= len)) { - s[pos]='\0'; - return 0; - } - to = timeout; - } - /* Never reached */ - return 0; + return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1); } int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders, int audiofd, int ctrlfd) -- cgit v1.2.3