120{
121 int res = 0;
122 char exten[256] = "";
123 int maxdigits = sizeof(exten) - 1;
124 int timeout = 0, digit_timeout = 0, x = 0;
128
135 );
136
140 return 0;
141 }
142
145
147 ast_log(
LOG_WARNING,
"Usage: ReadExten(variable[,filename[,context[,options[,timeout]]]])\n");
149 return 0;
150 }
151
153 arglist.filename =
NULL;
154 }
155
158 }
159
162 }
163
165 timeout = atoi(arglist.timeout);
166 if (timeout > 0)
167 timeout *= 1000;
168 }
169
170 if (timeout <= 0)
172
174
177 }
178
179 do {
182
185 break;
187
189 }
190 }
191
192 if (res < 0) {
194 break;
195 }
196
199
200 if (ts && ts->
data[0]) {
202 } else if (arglist.filename) {
204
205
206
207
208
209
211 } else {
213 }
214 }
215
216 for (x = 0; x < maxdigits; x++) {
217 ast_debug(3,
"extension so far: '%s', timeout: %d\n", exten, timeout);
219
222 timeout = digit_timeout;
223
224 if (res < 1) {
227 } else if (x == 0) {
230 }
231 break;
232 }
233
235 exten[x] = 0;
236 break;
237 }
238
239 exten[x] = res;
244 && res == '#') {
245 exten[x] = '\0';
246 }
247 break;
248 }
249 }
250
252 break;
253
256 ast_debug(3,
"User entered valid extension '%s'\n", exten);
259 } else {
260 ast_debug(3,
"User dialed invalid extension '%s' in context '%s' on %s\n", exten, arglist.context,
ast_channel_name(chan));
264 }
265 } while (0);
266
267 if (ts) {
269 }
270
272
273 return status[0] ==
'H' ? -1 : 0;
274}
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)