123{
124 int res = 0;
125 char exten[256] = "";
126 int maxdigits = sizeof(exten) - 1;
127 int timeout = 0, digit_timeout = 0, x = 0;
131
138 );
139
143 return 0;
144 }
145
148
150 ast_log(
LOG_WARNING,
"Usage: ReadExten(variable[,filename[,context[,options[,timeout]]]])\n");
152 return 0;
153 }
154
156 arglist.filename =
NULL;
157 }
158
161 }
162
165 }
166
168 timeout = atoi(arglist.timeout);
169 if (timeout > 0)
170 timeout *= 1000;
171 }
172
173 if (timeout <= 0)
175
177
180 }
181
182 do {
185
188 break;
190
192 }
193 }
194
195 if (res < 0) {
197 break;
198 }
199
202
203 if (ts && ts->
data[0]) {
205 } else if (arglist.filename) {
207
208
209
210
211
212
214 } else {
216 }
217 }
218
219 for (x = 0; x < maxdigits; x++) {
220 ast_debug(3,
"extension so far: '%s', timeout: %d\n", exten, timeout);
222
225 timeout = digit_timeout;
226
227 if (res < 1) {
230 } else if (x == 0) {
233 }
234 break;
235 }
236
238 exten[x] = 0;
239 break;
240 }
241
242 exten[x] = res;
247 && res == '#') {
248 exten[x] = '\0';
249 }
250 break;
251 }
252 }
253
255 break;
256
259 ast_debug(3,
"User entered valid extension '%s'\n", exten);
262 } else {
263 ast_debug(3,
"User dialed invalid extension '%s' in context '%s' on %s\n", exten, arglist.context,
ast_channel_name(chan));
267 }
268 } while (0);
269
270 if (ts) {
272 }
273
275
276 return status[0] ==
'H' ? -1 : 0;
277}
static const struct ast_app_option readexten_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.
const char * ast_channel_name(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
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)
const char * ast_channel_language(const struct ast_channel *chan)
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(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.
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
Checks for the existence of a given file.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#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_debug(level,...)
Log a DEBUG message.
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 ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
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.
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Structure used to handle boolean flags.
const char * data
Description of a tone.
#define ast_test_flag(p, flag)