139 static const char app[] =
"Directory";
144 #define VOICEMAIL_CONFIG "voicemail.conf" 197 digit = toupper(*text++);
261 if (*
template++ != digit)
276 "Not Exiting the Directory!\n", ext);
292 mailbox_id =
ast_alloca(strlen(ext) + strlen(context) + 2);
293 sprintf(mailbox_id,
"%s@%s", ext, context);
323 "Can't find extension '%s' in context '%s'. " 324 "Did you pass the wrong context to Directory?\n",
335 int res = 0, opt_pause = 0;
338 opt_pause = atoi(opts[OPT_ARG_PAUSE]);
339 if (opt_pause > 3000) {
356 for (ptr = items, i = 0; i < count; i++, ptr++) {
359 for (loop = 3 ; loop > 0; loop--) {
372 }
else if (res ==
'1') {
373 return select_entry(chan, dialcontext, item, flags) ? -1 : 1;
374 }
else if (res ==
'*') {
377 }
else if (res ==
'#') {
398 int i, limit, res = 0;
404 for (block = items; count; block += limit, count -= limit) {
409 for (i = 0; i < limit && !res; i++) {
412 snprintf(buf,
sizeof(buf),
"digits/%d", i + 1);
434 if (!res && count > limit) {
444 if (res && res >
'0' && res <
'1' + limit) {
446 return select_entry(chan, dialcontext, block[res -
'1'], flags) ? -1 : 1;
467 char *category =
NULL;
468 const char *fullname;
469 const char *hidefromdir, *searchcontexts =
NULL;
513 ast_debug(3,
"Skipping result with missing or empty mailbox\n");
529 if (!strcasecmp(alias->
name,
"alias")) {
559 static int check_match(
struct directory_item **
result,
const char *item_context,
const char *item_fullname,
const char *item_ext,
const char *pattern_ext,
int use_first_name)
571 key = strchr(item_fullname,
' ');
581 ast_debug(1,
"Found match %s@%s\n", item_ext, item_context);
592 if (key != item_fullname) {
594 namelen = key - item_fullname - 1;
595 if (namelen >
sizeof(item->
key) - strlen(item->
key) - 1)
596 namelen =
sizeof(item->
key) - strlen(item->
key) - 1;
597 strncat(item->
key, item_fullname, namelen);
629 name =
strsep(&options,
",");
634 if (options &&
strcasestr(options,
"hidefromdir=yes")) {
651 && options && (alias =
strcasestr(options,
"alias="))) {
654 ast_debug(1,
"Found alias: %s\n", alias);
655 while ((a =
strsep(&alias,
"|"))) {
656 if (!strncasecmp(a,
"alias=", 6)) {
666 }
else if (res < 0) {
675 const char *position;
677 if (!strcasecmp(cat,
"general")) {
691 res =
check_match(&item, context, position, cat, ext, 0 );
694 res =
check_match(&item, context, position, cat, ext, 1 );
698 if (!strcasecmp(v->
name,
"alias")
707 }
else if (res < 0) {
726 if (!strcmp(catg,
"general") || !strcmp(catg,
"zonemessages")) {
736 ast_debug(1,
"Searching by category default\n");
741 ast_debug(1,
"Searching by category %s\n", context);
757 for (ptr = sorted, i = 0; i < count - 1; i++, ptr++) {
758 if (strcasecmp(ptr[0]->
key, ptr[1]->
key) > 0) {
777 if (digit ==
'0' && !
goto_exten(chan, dialcontext,
"o")) {
782 if (digit ==
'*' && !
goto_exten(chan, dialcontext,
"a")) {
788 if (
ast_readstring(chan, ext + 1, digits - 1, 3000, 3000,
"#") < 0)
820 for (ptr = sorted, i = 0; i < count; i++, ptr++) {
849 int res = 0,
digit = 3;
851 const char *dirintro;
855 enum { FIRST, LAST, BOTH } which = LAST;
856 char digits[9] =
"digits/3";
876 ast_log(
LOG_ERROR,
"Config file users.conf is in an invalid format. Aborting.\n");
888 digit = atoi(opts[OPT_ARG_EITHER]);
893 digit = atoi(opts[OPT_ARG_FIRSTNAME]);
898 digit = atoi(opts[OPT_ARG_LASTNAME]);
911 }
else if (
digit < 1) {
914 digits[7] =
digit +
'0';
936 which == FIRST ?
"dir-first" :
937 which == LAST ?
"dir-last" :
972 }
else if (res < 0) {
977 return res < 0 ? -1 : 0;
static int select_entry(struct ast_channel *chan, const char *dialcontext, const struct directory_item *item, struct ast_flags *flags)
struct ast_variable * next
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Asterisk main include file. File version handling, generic pbx functions.
int ast_app_sayname(struct ast_channel *chan, const char *mailbox_id)
Play a recorded user name for the mailbox to the specified channel.
#define ast_test_flag(p, flag)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
#define ast_set_flag(p, flag)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define CONFIG_STATUS_FILEINVALID
Structure for variables, used for configurations and for channel variables.
static int goto_exten(struct ast_channel *chan, const char *dialcontext, char *ext)
static int select_item_seq(struct ast_channel *chan, struct directory_item **items, int count, const char *dialcontext, struct ast_flags *flags, char *opts[])
ast_channel_state
ast_channel states
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
static struct aco_type item
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
char context[AST_MAX_CONTEXT+1]
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_strlen_zero(foo)
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
static int select_item_pause(struct ast_channel *chan, struct ast_flags *flags, char *opts[])
static void sort_items(struct directory_item **sorted, int count)
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
static struct ast_config * realtime_directory(char *context)
#define ast_debug(level,...)
Log a DEBUG message.
char name[AST_MAX_EXTENSION+1]
#define ast_config_load(filename, flags)
Load a config file.
static int unload_module(void)
static char dialcontext[AST_MAX_CONTEXT]
Asterisk file paths, configured in asterisk.conf.
#define AST_MAX_EXTENSION
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_variable_new(name, value, filename)
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
int ast_say_character_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity)
function to pronounce character and phonetic strings
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.
Core PBX routines and definitions.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
static int check_match(struct directory_item **result, const char *item_context, const char *item_fullname, const char *item_ext, const char *pattern_ext, int use_first_name)
static int search_directory(const char *context, struct ast_config *vmcfg, struct ast_config *ucfg, const char *ext, struct ast_flags flags, itemlist *alist)
static int select_item_menu(struct ast_channel *chan, struct directory_item **items, int count, const char *dialcontext, struct ast_flags *flags, char *opts[])
struct ast_config * ast_load_realtime_multientry(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
static const struct ast_app_option directory_app_options[128]
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
char * strcasestr(const char *, const char *)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
static void parse(struct mgcp_request *req)
char exten[AST_MAX_EXTENSION+1]
#define ast_calloc(num, len)
A wrapper for calloc()
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
static int load_module(void)
#define ast_category_new_dynamic(name)
Create a category that is not backed by a file.
Structure used to handle boolean flags.
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.
static int do_directory(struct ast_channel *chan, struct ast_config *vmcfg, struct ast_config *ucfg, char *context, char *dialcontext, char digit, int digits, struct ast_flags *flags, char *opts[])
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
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...
void ast_category_append(struct ast_config *config, struct ast_category *cat)
Appends a category to a config.
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
char * strsep(char **str, const char *delims)
static int search_directory_sub(const char *context, struct ast_config *vmcfg, struct ast_config *ucfg, const char *ext, struct ast_flags flags, itemlist *alist)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int compare(const char *text, const char *template)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
int ast_answer(struct ast_channel *chan)
Answer a channel.
const char * ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
Retrieve a configuration variable within the configuration set.
const char * ast_channel_language(const struct ast_channel *chan)
static int directory_exec(struct ast_channel *chan, const char *data)
static int play_mailbox_owner(struct ast_channel *chan, const char *context, const char *ext, const char *name, struct ast_flags *flags)
const char * ast_channel_context(const struct ast_channel *chan)
struct directory_item::@21 entry
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
const char * ast_channel_macrocontext(const struct ast_channel *chan)
Say numbers and dates (maybe words one day too)
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define DEBUG_ATLEAST(level)
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
int ast_stopstream(struct ast_channel *c)
Stops a stream.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define AST_APP_ARG(name)
Define an application argument.