164{
  165    int res = 0;
  166    char tmp[256] = "";
  167    int maxdigits = 255;
  168    int tries = 1, to = 0, x = 0;
  169    double tosec;
  170    char *argcopy = 
NULL;
 
  174    const char *
status = 
"ERROR";
 
  175    char *terminator = "#"; 
  176 
  184    );
  185 
  189        return 0;
  190    }
  191 
  193 
  195 
  198    }
  199 
  201        tries = atoi(arglist.attempts);
  202        if (tries <= 0)
  203            tries = 1;
  204    }
  205 
  207        tosec = atof(arglist.timeout);
  208        if (tosec <= 0)
  209            to = 0;
  210        else
  211            to = tosec * 1000.0;
  212    }
  213 
  215        arglist.filename = 
NULL;
 
  216    }
  218        maxdigits = atoi(arglist.maxdigits);
  219        if ((maxdigits < 1) || (maxdigits > 255)) {
  220            maxdigits = 255;
  221        } else
  222            ast_verb(3, 
"Accepting a maximum of %d digits.\n", maxdigits);
 
  223    }
  225        ast_log(
LOG_WARNING, 
"Invalid! Usage: Read(variable[,filename][,maxdigits][,option][,attempts][,timeout])\n\n");
 
  226        return 0;
  227    }
  231        }
  232    }
  236        } else {
  237            terminator = ""; 
  238        }
  239    }
  242            
  243            if (ts) {
  245            }
  248            return 0;
  250            
  252        }
  253    }
  254    if (!res) {
  255        while (tries && !res) {
  257            if (ts && ts->
data[0]) {
 
  258                if (!to)
  261                for (x = 0; x < maxdigits; ) {
  264                    if (res < 1) {
  265                        if (res == 0)
  267                        tmp[x]='\0';
  268                        break;
  269                    }
  270                    tmp[x++] = res;
  271                    if (terminator && strchr(terminator, tmp[x-1])) {
  272                        tmp[x-1] = '\0';
  274                        break;
  275                    }
  276                    if (x >= maxdigits) {
  278                    }
  279                }
  280            } else {
  286                        
  287
  289                    }
  295                }
  296            }
  297            if (res > -1) {
  300                    ast_verb(3, 
"User entered '%s'\n", tmp);
 
  301                    tries = 0;
  302                } else {
  303                    tries--;
  304                    if (tries)
  305                        ast_verb(3, 
"User entered nothing, %d chance%s left\n", tries, (tries != 1) ? 
"s" : 
"");
 
  306                    else
  307                        ast_verb(3, 
"User entered nothing.\n");
 
  308                }
  309                res = 0;
  310            } else {
  313            }
  314        }
  315    }
  316 
  317    if (ts) {
  319    }
  320 
  324    return 0;
  325}
static const struct ast_app_option read_app_options[128]
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
ast_channel_state
ast_channel states
int ast_stopstream(struct ast_channel *c)
Stops a stream.
#define AST_APP_ARG(name)
Define an application argument.
@ AST_GETDATA_INTERRUPTED
@ AST_GETDATA_EMPTY_END_TERMINATED
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
enum ast_getdata_result ast_app_getdata_terminator(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, char *terminator)
Plays a stream and gets DTMF data from a channel.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
#define ast_verb(level,...)
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Structure used to handle boolean flags.
const char * data
Description of a tone.
#define ast_test_flag(p, flag)