122 static const char app[] =
"Directory";
127 #define VOICEMAIL_CONFIG "voicemail.conf"
178 digit = toupper(*text++);
242 if (*
template++ != digit)
257 "Not Exiting the Directory!\n", ext);
298 "Can't find extension '%s' in context '%s'. "
299 "Did you pass the wrong context to Directory?\n",
309 int res = 0, opt_pause = 0;
312 opt_pause = atoi(opts[OPT_ARG_PAUSE]);
313 if (opt_pause > 3000) {
330 for (ptr = items, i = 0; i < count; i++, ptr++) {
333 for (loop = 3 ; loop > 0; loop--) {
345 }
else if (res ==
'1') {
346 return select_entry(chan, dialcontext, item, flags) ? -1 : 1;
347 }
else if (res ==
'*') {
350 }
else if (res ==
'#') {
370 int i, limit, res = 0;
376 for (block = items; count; block += limit, count -= limit) {
381 for (i = 0; i < limit && !res; i++) {
384 snprintf(buf,
sizeof(buf),
"digits/%d", i + 1);
406 if (!res && count > limit) {
416 if (res && res >
'0' && res <
'1' + limit) {
417 return select_entry(chan, dialcontext, block[res -
'1'], flags) ? -1 : 1;
437 const char *fullname;
438 const char *hidefromdir, *searchcontexts = NULL;
483 snprintf(tmp,
sizeof(tmp),
"no-password,%s",
S_OR(fullname,
""));
509 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)
512 const char *
key = NULL;
521 key = strchr(item_fullname,
' ');
531 ast_debug(1,
"Found match %s@%s\n", item_ext, item_context);
542 if (key != item_fullname) {
544 namelen = key - item_fullname - 1;
545 if (namelen >
sizeof(item->
key) - strlen(item->
key) - 1)
546 namelen =
sizeof(item->
key) - strlen(item->
key) - 1;
547 strncat(item->
key, item_fullname, namelen);
576 pos =
strsep(&bufptr,
",");
601 const char *position;
602 if (!strcasecmp(cat,
"general"))
614 res =
check_match(&item, context, position, cat, ext, 0 );
617 res =
check_match(&item, context, position, cat, ext, 1 );
640 if (!strcmp(catg,
"general") || !strcmp(catg,
"zonemessages")) {
650 ast_debug(1,
"Searching by category default\n");
655 ast_debug(1,
"Searching by category %s\n", context);
671 for (ptr = sorted, i = 0; i < count - 1; i++, ptr++) {
672 if (strcasecmp(ptr[0]->
key, ptr[1]->
key) > 0) {
691 if (digit ==
'0' && !
goto_exten(chan, dialcontext,
"o")) {
695 if (digit ==
'*' && !
goto_exten(chan, dialcontext,
"a")) {
700 if (
ast_readstring(chan, ext + 1, digits - 1, 3000, 3000,
"#") < 0)
731 ast_debug(2,
"Listing matching entries:\n");
732 for (ptr = sorted, i = 0; i < count; i++, ptr++) {
761 int res = 0, digit = 3;
763 const char *dirintro;
767 enum { FIRST, LAST, BOTH } which = LAST;
768 char digits[9] =
"digits/3";
788 ast_log(
LOG_ERROR,
"Config file users.conf is in an invalid format. Aborting.\n");
800 digit = atoi(opts[OPT_ARG_EITHER]);
805 digit = atoi(opts[OPT_ARG_FIRSTNAME]);
810 digit = atoi(opts[OPT_ARG_LASTNAME]);
823 }
else if (digit < 1) {
826 digits[7] = digit +
'0';
848 which == FIRST ?
"dir-first" :
849 which == LAST ?
"dir-last" :
863 res =
do_directory(chan, cfg, ucfg,
args.vmcontext,
args.dialcontext, res, digit, &flags, opts);
878 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)
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
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.
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
char * strsep(char **str, const char *delims)
#define ast_test_flag(p, flag)
char context[AST_MAX_CONTEXT]
#define ast_set_flag(p, flag)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
struct directory_item::@13 entry
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_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
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[])
static struct ast_app_option directory_app_options[128]
const char * ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
Retrieve a configuration variable within the configuration set.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
char context[AST_MAX_CONTEXT+1]
int ast_unregister_application(const char *app)
Unregister an application.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
struct ast_category * ast_category_new(const char *name, const char *in_file, int lineno)
Create a category structure.
static int select_item_pause(struct ast_channel *chan, struct ast_flags *flags, char *opts[])
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name)
Retrieve a category if it exists.
static void sort_items(struct directory_item **sorted, int count)
static struct ast_config * realtime_directory(char *context)
#define ast_debug(level,...)
Log a DEBUG message.
char name[AST_MAX_EXTENSION+1]
static int unload_module(void)
static char dialcontext[AST_MAX_CONTEXT]
Asterisk file paths, configured in asterisk.conf.
#define ast_config_load(filename, flags)
Load a config file.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define AST_MAX_EXTENSION
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
int ast_app_sayname(struct ast_channel *chan, const char *mailbox, const char *context)
Given a mailbox and context, play that mailbox owner's name to the channel specified.
Core PBX routines and definitions.
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)
#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_strdupa(s)
duplicate a string in memory from the stack
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[])
#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".
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
enum ast_channel_state _state
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
#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]
char macrocontext[AST_MAX_CONTEXT]
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_say_character_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
static int load_module(void)
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[])
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
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.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
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)
#define AST_APP_ARG(name)
Define an application argument.
struct ast_variable * next
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
void ast_category_append(struct ast_config *config, struct ast_category *cat)
#define CONFIG_STATUS_FILEINVALID
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
Say numbers and dates (maybe words one day too)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
char * strcasestr(const char *, const char *)
const ast_string_field language
char exten[AST_MAX_EXTENSION]
int ast_stopstream(struct ast_channel *c)
Stops a stream.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
struct ast_variable * ast_variable_new(const char *name, const char *value, const char *filename)
static char mailbox[AST_MAX_EXTENSION]
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
struct ast_config * ast_load_realtime_multientry(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.