157static const char app[] =
"Directory";
162#define VOICEMAIL_CONFIG "voicemail.conf"
215 unsigned char buf[256];
217 unsigned char keys[6];
237 unsigned char buf[4096];
241 unsigned char keys[8];
244 snprintf(matchbuf,
sizeof(matchbuf),
"%d of %d",
seq + 1,
total);
248 lines[2] = (
char*)
name;
252 lines[3] = (
char*) exten;
256 for (x = 0; lines[x]; x++) {
271 ast_debug(3,
"Sending ADSI confirmation menu for %s\n",
name);
349 if (*
template++ !=
digit)
362 "Not Exiting the Directory!\n",
ext);
412 "Can't find extension '%s' in context '%s'. "
413 "Did you pass the wrong context to Directory?\n",
424 int res = 0, opt_pause = 0;
428 if (opt_pause > 3000) {
445 for (ptr = items, i = 0; i < count; i++, ptr++) {
452 for (loop = 3 ; loop > 0; loop--) {
465 }
else if (res ==
'1') {
467 }
else if (res ==
'*') {
470 }
else if (res ==
'#') {
491 int i, limit, res = 0;
497 for (block = items; count; block += limit, count -= limit) {
502 for (i = 0; i < limit && !res; i++) {
505 snprintf(
buf,
sizeof(
buf),
"digits/%d", i + 1);
527 if (!res && count > limit) {
537 if (res && res >
'0' && res <
'1' + limit) {
560 char *category =
NULL;
561 const char *fullname;
562 const char *hidefromdir, *searchcontexts =
NULL;
578 ast_log(
LOG_ERROR,
"Config file %s is in an invalid format. Aborting.\n", filename);
606 ast_debug(3,
"Skipping result with missing or empty mailbox\n");
622 if (!strcasecmp(alias->
name,
"alias")) {
652static 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)
664 key = strchr(item_fullname,
' ');
674 ast_debug(1,
"Found match %s@%s\n", item_ext, item_context);
685 if (
key != item_fullname) {
687 namelen =
key - item_fullname - 1;
688 if (namelen >
sizeof(
item->key) - strlen(
item->key) - 1)
689 namelen =
sizeof(
item->key) - strlen(
item->key) - 1;
690 strncat(
item->key, item_fullname, namelen);
747 ast_debug(1,
"Found alias: %s\n", alias);
748 while ((
a =
strsep(&alias,
"|"))) {
749 if (!strncasecmp(
a,
"alias=", 6)) {
759 }
else if (res < 0) {
768 const char *position;
770 if (!strcasecmp(cat,
"general")) {
791 if (!strcasecmp(v->
name,
"alias")
800 }
else if (res < 0) {
819 if (!strcmp(catg,
"general") || !strcmp(catg,
"zonemessages")) {
829 ast_debug(1,
"Searching by category default\n");
850 for (ptr = sorted, i = 0; i < count - 1; i++, ptr++) {
851 if (strcasecmp(ptr[0]->
key, ptr[1]->
key) > 0) {
913 for (ptr = sorted, i = 0; i < count; i++, ptr++) {
942 int res = 0,
digit = 3;
944 const char *dirintro;
948 enum { FIRST, LAST, BOTH } which = LAST;
949 char digits[9] =
"digits/3";
971 ast_log(
LOG_ERROR,
"Config file users.conf is in an invalid format. Aborting.\n");
1006 }
else if (
digit < 1) {
1009 digits[7] =
digit +
'0';
1046 which == FIRST ?
"dir-first" :
1047 which == LAST ?
"dir-last" :
1082 }
else if (res < 0) {
1087 return res < 0 ? -1 : 0;
ADSI Support (built upon Caller*ID)
int ast_adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2)
Loads a line of info into the display.
int ast_adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
Creates "load soft key" parameters.
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
int ast_adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
Set input information.
int ast_adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
Set input format.
int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
Check if scripts for a given app are already loaded. Version may be -1, if any version is okay,...
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
#define ADSI_DIR_FROM_LEFT
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
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[])
static int select_item_pause(struct ast_channel *chan, struct ast_flags *flags, char *opts[])
static const struct ast_app_option directory_app_options[128]
static int directory_exec(struct ast_channel *chan, const char *data)
static struct ast_config * realtime_directory(char *context, const char *filename)
static int goto_exten(struct ast_channel *chan, const char *dialcontext, char *ext)
static void sort_items(struct directory_item **sorted, int count)
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_sub(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[])
static int adsi_confirm_match(struct ast_channel *chan, int seq, int total, const char *exten, const char *name, int showexten)
static int select_entry(struct ast_channel *chan, const char *dialcontext, const struct directory_item *item, struct ast_flags *flags)
static int play_mailbox_owner(struct ast_channel *chan, const char *context, const char *ext, const char *name, struct ast_flags *flags)
static int adsi_search_input(struct ast_channel *chan)
static int load_module(void)
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 unload_module(void)
static int compare(const char *text, const char *template)
static int select_item_seq(struct ast_channel *chan, struct directory_item **items, int count, const char *dialcontext, struct ast_flags *flags, char *opts[])
static volatile unsigned int seq
static char dialcontext[AST_MAX_CONTEXT]
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
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.
const char * ast_channel_language(const struct ast_channel *chan)
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
int ast_answer(struct ast_channel *chan)
Answer a channel.
#define AST_MAX_EXTENSION
ast_channel_state
ast_channel states
Generic File Format Support. Should be included by clients of the file handling routines....
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_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.
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an 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_sayname(struct ast_channel *chan, const char *mailbox_id)
Play a recorded user name for the mailbox to the specified channel.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
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.
char * strsep(char **str, const char *delims)
char * strcasestr(const char *, const char *)
#define ast_config_load(filename, flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
struct ast_config * ast_load_realtime_multientry(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
void ast_category_append(struct ast_config *config, struct ast_category *category)
Appends a category to a config.
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
#define ast_variable_new(name, value, filename)
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
const char * ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
Retrieve a configuration variable within the configuration set.
#define ast_category_new_dynamic(name)
Create a category that is not backed by a file.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
#define DEBUG_ATLEAST(level)
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Asterisk file paths, configured in asterisk.conf.
Core PBX routines and definitions.
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_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
Say numbers and dates (maybe words one day too)
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_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
Main Channel structure associated with a channel.
Structure used to handle boolean flags.
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
struct directory_item::@19 entry
char name[AST_MAX_EXTENSION+1]
char context[AST_MAX_CONTEXT+1]
char exten[AST_MAX_EXTENSION+1]
static struct aco_type item
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
#define ast_test_flag(p, flag)
#define ast_clear_flag(p, flag)
#define ast_set_flag(p, flag)