aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_zap.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-28 23:20:13 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-28 23:20:13 +0000
commit5004f1cb9d2ff2b7874867150eae2c4f04772505 (patch)
tree613c42124f71ecf84d48db76e931936f9652d7f0 /channels/chan_zap.c
parent8a81f683ed2be99d131499aea9a8d8d04d19ccff (diff)
normalize/simplify a bit of the command completion code.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@15856 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_zap.c')
-rw-r--r--channels/chan_zap.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index adc6217c9..3f933df3f 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -9394,20 +9394,19 @@ static int start_pri(struct zt_pri *pri)
static char *complete_span_helper(const char *line, const char *word, int pos, int state, int rpos)
{
- int span=1;
- char tmp[50];
+ int which, span;
+ char *ret = NULL;
+
if (pos != rpos)
- return 0;
- while(span <= NUM_SPANS) {
- if (span > state && pris[span-1].pri)
+ return ret;
+
+ for (which = span = 0; span < NUM_SPANS; span++) {
+ if (pris[span].pri && ++which > state) {
+ asprintf(&ret, "%d", span + 1); /* user indexes start from 1 */
break;
- span++;
+ }
}
- if (span <= NUM_SPANS) {
- snprintf(tmp, sizeof(tmp), "%d", span);
- return ast_strdup(tmp);
- } else
- return NULL;
+ return ret;
}
static char *complete_span_4(const char *line, const char *word, int pos, int state)