enum { OPT_PREDIAL_CALLEE = (1 << 0), OPT_PREDIAL_CALLER = (1 << 1), }; enum { OPT_ARG_PREDIAL_CALLEE, OPT_ARG_PREDIAL_CALLER, /* note: this entry _MUST_ be the last one in the enum */ OPT_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(originate_exec_options, BEGIN_OPTIONS AST_APP_OPTION_ARG('b', OPT_PREDIAL_CALLEE, OPT_ARG_PREDIAL_CALLEE), AST_APP_OPTION_ARG('B', OPT_PREDIAL_CALLER, OPT_ARG_PREDIAL_CALLER), END_OPTIONS ); static int originate_exec(struct ast_channel *chan, const char *data) { AST_DECLARE_APP_ARGS(args, AST_APP_ARG(tech_data); AST_APP_ARG(type); AST_APP_ARG(arg1); AST_APP_ARG(arg2); AST_APP_ARG(arg3); AST_APP_ARG(timeout); AST_APP_ARG(options); );
OPT_ARG_PAUSE = 3, /* This *must* be the last value in this enum! */ OPT_ARG_ARRAY_SIZE = 4, }; struct directory_item { char exten[AST_MAX_EXTENSION + 1]; char name[AST_MAX_EXTENSION + 1]; char context[AST_MAX_CONTEXT + 1]; char key[50]; /* Text to order items. Either lastname+firstname or firstname+lastname */ AST_LIST_ENTRY(directory_item) entry; }; AST_APP_OPTIONS(directory_app_options, { AST_APP_OPTION_ARG('f', OPT_LISTBYFIRSTNAME, OPT_ARG_FIRSTNAME), AST_APP_OPTION_ARG('l', OPT_LISTBYLASTNAME, OPT_ARG_LASTNAME), AST_APP_OPTION_ARG('b', OPT_LISTBYEITHER, OPT_ARG_EITHER), AST_APP_OPTION_ARG('p', OPT_PAUSE, OPT_ARG_PAUSE), AST_APP_OPTION('e', OPT_SAYEXTENSION), AST_APP_OPTION('v', OPT_FROMVOICEMAIL), AST_APP_OPTION('m', OPT_SELECTFROMMENU), AST_APP_OPTION('n', OPT_NOANSWER), AST_APP_OPTION('a', OPT_ALIAS), }); static int compare(const char *text, const char *template) { char digit; if (ast_strlen_zero(text)) {
OPT_ARG_ARRAY_SIZE /* Always the last element of the enum */ }; enum park_flags { MUXFLAG_RINGING = (1 << 0), MUXFLAG_RANDOMIZE = (1 << 1), MUXFLAG_NOANNOUNCE = (1 << 2), MUXFLAG_COMEBACK_OVERRIDE = (1 << 3), MUXFLAG_TIMEOUT_OVERRIDE = (1 << 4), }; AST_APP_OPTIONS(park_opts, { AST_APP_OPTION('r', MUXFLAG_RINGING), AST_APP_OPTION('R', MUXFLAG_RANDOMIZE), AST_APP_OPTION('s', MUXFLAG_NOANNOUNCE), AST_APP_OPTION_ARG('c', MUXFLAG_COMEBACK_OVERRIDE, OPT_ARG_COMEBACK), AST_APP_OPTION_ARG('t', MUXFLAG_TIMEOUT_OVERRIDE, OPT_ARG_TIMEOUT), }); static int apply_option_timeout (int *var, char *timeout_arg) { if (ast_strlen_zero(timeout_arg)) { ast_log(LOG_ERROR, "No duration value provided for the timeout ('t') option.\n"); return -1; } if (sscanf(timeout_arg, "%d", var) != 1 || *var < 0) { ast_log(LOG_ERROR, "Duration value provided for timeout ('t') option must be 0 or greater.\n"); return -1; }
MON_FLAG_DROP_IN = (1 << 2), MON_FLAG_DROP_OUT = (1 << 3), MON_FLAG_BEEP = (1 << 4), }; enum { OPT_ARG_BEEP_INTERVAL, OPT_ARG_ARRAY_SIZE, /* Always last element of the enum */ }; AST_APP_OPTIONS(monitor_opts, { AST_APP_OPTION('b', MON_FLAG_BRIDGED), AST_APP_OPTION('m', MON_FLAG_MIX), AST_APP_OPTION('i', MON_FLAG_DROP_IN), AST_APP_OPTION('o', MON_FLAG_DROP_OUT), AST_APP_OPTION_ARG('B', MON_FLAG_BEEP, OPT_ARG_BEEP_INTERVAL), }); /*! * \brief Start monitor * \param chan * \param data arguments passed fname|options * \retval 0 on success. * \retval -1 on failure. */ static int start_monitor_exec(struct ast_channel *chan, const char *data) { char *arg; char *options; char *delay; char *urlprefix = NULL;
enum bridgewait_flags { MUXFLAG_MOHCLASS = (1 << 0), MUXFLAG_ENTERTAINMENT = (1 << 1), MUXFLAG_TIMEOUT = (1 << 2), }; enum bridgewait_args { OPT_ARG_ENTERTAINMENT, OPT_ARG_MOHCLASS, OPT_ARG_TIMEOUT, OPT_ARG_ARRAY_SIZE, /* Always the last element of the enum */ }; AST_APP_OPTIONS(bridgewait_opts, { AST_APP_OPTION_ARG('e', MUXFLAG_ENTERTAINMENT, OPT_ARG_ENTERTAINMENT), AST_APP_OPTION_ARG('m', MUXFLAG_MOHCLASS, OPT_ARG_MOHCLASS), AST_APP_OPTION_ARG('S', MUXFLAG_TIMEOUT, OPT_ARG_TIMEOUT), }); static int bridgewait_timeout_callback(struct ast_bridge_channel *bridge_channel, void *hook_pvt) { ast_verb(3, "Channel %s timed out.\n", ast_channel_name(bridge_channel->chan)); ast_bridge_channel_leave_bridge(bridge_channel, BRIDGE_CHANNEL_STATE_END, AST_CAUSE_NORMAL_CLEARING); return -1; } static int apply_option_timeout(struct ast_bridge_features *features, char *duration_arg) { unsigned int duration;
static char *app = "SkelGuessNumber"; enum option_flags { OPTION_CHEAT = (1 << 0), OPTION_NUMGAMES = (1 << 1), }; enum option_args { OPTION_ARG_NUMGAMES, /* This *must* be the last value in this enum! */ OPTION_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(app_opts, { AST_APP_OPTION('c', OPTION_CHEAT), AST_APP_OPTION_ARG('n', OPTION_NUMGAMES, OPTION_ARG_NUMGAMES), }); /*! \brief A structure to hold global configuration-related options */ struct skel_global_config { AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(prompt); /*!< The comma-separated list of sounds to prompt to enter a number */ AST_STRING_FIELD(wrong); /*!< The comma-separated list of sounds to indicate a wrong guess */ AST_STRING_FIELD(right); /*!< The comma-separated list of sounds to indicate a right guess */ AST_STRING_FIELD(high); /*!< The comma-separated list of sounds to indicate a high guess */ AST_STRING_FIELD(low); /*!< The comma-separated list of sounds to indicate a low guess */ AST_STRING_FIELD(lose); /*!< The comma-separated list of sounds to indicate a lost game */ ); uint32_t num_games; /*!< The number of games to play before hanging up */ unsigned char cheat:1; /*!< Whether the computer can cheat or not */ };
MUXFLAG_VOLUME = (1 << 3), MUXFLAG_READVOLUME = (1 << 4), MUXFLAG_WRITEVOLUME = (1 << 5), } mixmonitor_flags; enum { OPT_ARG_READVOLUME = 0, OPT_ARG_WRITEVOLUME, OPT_ARG_VOLUME, OPT_ARG_ARRAY_SIZE, } mixmonitor_args; AST_APP_OPTIONS(mixmonitor_opts, { AST_APP_OPTION('a', MUXFLAG_APPEND), AST_APP_OPTION('b', MUXFLAG_BRIDGED), AST_APP_OPTION_ARG('v', MUXFLAG_READVOLUME, OPT_ARG_READVOLUME), AST_APP_OPTION_ARG('V', MUXFLAG_WRITEVOLUME, OPT_ARG_WRITEVOLUME), AST_APP_OPTION_ARG('W', MUXFLAG_VOLUME, OPT_ARG_VOLUME), }); /* This structure is used as a means of making sure that our pointer to * the channel we are monitoring remains valid. This is very similar to * what is used in app_chanspy.c. */ struct mixmonitor_ds { struct ast_channel *chan; /* These condition variables are used to be sure that the channel * hangup code completes before the mixmonitor thread attempts to * free this structure. The combination of a bookean flag and a * ast_cond_t ensure that no matter what order the threads run in, * we are guaranteed to never have the waiting thread block forever
#define BACKGROUND_NOANSWER (1 << 1) #define BACKGROUND_MATCHEXTEN (1 << 2) #define BACKGROUND_PLAYBACK (1 << 3) AST_APP_OPTIONS(background_opts, { AST_APP_OPTION('s', BACKGROUND_SKIP), AST_APP_OPTION('n', BACKGROUND_NOANSWER), AST_APP_OPTION('m', BACKGROUND_MATCHEXTEN), AST_APP_OPTION('p', BACKGROUND_PLAYBACK), }); #define WAITEXTEN_MOH (1 << 0) #define WAITEXTEN_DIALTONE (1 << 1) AST_APP_OPTIONS(waitexten_opts, { AST_APP_OPTION_ARG('m', WAITEXTEN_MOH, 0), AST_APP_OPTION_ARG('d', WAITEXTEN_DIALTONE, 0), }); int pbx_builtin_raise_exception(struct ast_channel *chan, const char *reason) { /* Priority will become 1, next time through the AUTOLOOP */ return raise_exception(chan, reason, 0); } /*! * \ingroup applications */ static int pbx_builtin_proceeding(struct ast_channel *chan, const char *data) { ast_indicate(chan, AST_CONTROL_PROCEEDING);
OPT_CALLER_PARK = (1 << 10), OPT_CALLEE_KILL = (1 << 11), OPT_CALLEE_GO_ON = (1 << 12), }; enum { OPT_ARG_DURATION_LIMIT = 0, OPT_ARG_DURATION_STOP, OPT_ARG_CALLEE_GO_ON, /* note: this entry _MUST_ be the last one in the enum */ OPT_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(bridge_exec_options, BEGIN_OPTIONS AST_APP_OPTION('p', BRIDGE_OPT_PLAYTONE), AST_APP_OPTION_ARG('F', OPT_CALLEE_GO_ON, OPT_ARG_CALLEE_GO_ON), AST_APP_OPTION('h', OPT_CALLEE_HANGUP), AST_APP_OPTION('H', OPT_CALLER_HANGUP), AST_APP_OPTION('k', OPT_CALLEE_PARK), AST_APP_OPTION('K', OPT_CALLER_PARK), AST_APP_OPTION_ARG('L', OPT_DURATION_LIMIT, OPT_ARG_DURATION_LIMIT), AST_APP_OPTION_ARG('S', OPT_DURATION_STOP, OPT_ARG_DURATION_STOP), AST_APP_OPTION('t', OPT_CALLEE_TRANSFER), AST_APP_OPTION('T', OPT_CALLER_TRANSFER), AST_APP_OPTION('w', OPT_CALLEE_MONITOR), AST_APP_OPTION('W', OPT_CALLER_MONITOR), AST_APP_OPTION('x', OPT_CALLEE_KILL), END_OPTIONS ); int ast_bridge_timelimit(struct ast_channel *chan, struct ast_bridge_config *config, char *parse, struct timeval *calldurationlimit)
PAGE_ANNOUNCE = (1 << 5), PAGE_NOCALLERANNOUNCE = (1 << 6), }; enum { OPT_ARG_ANNOUNCE = 0, OPT_ARG_ARRAY_SIZE = 1, }; AST_APP_OPTIONS(page_opts, { AST_APP_OPTION('d', PAGE_DUPLEX), AST_APP_OPTION('q', PAGE_QUIET), AST_APP_OPTION('r', PAGE_RECORD), AST_APP_OPTION('s', PAGE_SKIP), AST_APP_OPTION('i', PAGE_IGNORE_FORWARDS), AST_APP_OPTION_ARG('A', PAGE_ANNOUNCE, OPT_ARG_ANNOUNCE), AST_APP_OPTION('n', PAGE_NOCALLERANNOUNCE), }); /* We use this structure as a way to pass this to all dialed channels */ struct page_options { char *opts[OPT_ARG_ARRAY_SIZE]; struct ast_flags flags; }; static void page_state_callback(struct ast_dial *dial) { struct ast_channel *chan; struct page_options *options; if (ast_dial_state(dial) != AST_DIAL_RESULT_ANSWERED ||
enum { OPTION_A = (1 << 0), OPTION_B = (1 << 1), OPTION_C = (1 << 2), } option_flags; enum { OPTION_ARG_B = 0, OPTION_ARG_C = 1, /* This *must* be the last value in this enum! */ OPTION_ARG_ARRAY_SIZE = 2, } option_args; AST_APP_OPTIONS(app_opts,{ AST_APP_OPTION('a', OPTION_A), AST_APP_OPTION_ARG('b', OPTION_B, OPTION_ARG_B), AST_APP_OPTION_ARG('c', OPTION_C, OPTION_ARG_C), }); LOCAL_USER_DECL; static int app_exec(struct ast_channel *chan, void *data) { int res = 0; struct ast_flags flags; struct localuser *u; char *parse, *opts[OPTION_ARG_ARRAY_SIZE]; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(dummy); AST_APP_ARG(options); );
</application> ***/ enum { OPT_JUMP = (1 << 0), }; enum { OPT_ARG_JUMP = 0, /* note: this entry _MUST_ be the last one in the enum */ OPT_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(sayunixtime_exec_options, BEGIN_OPTIONS AST_APP_OPTION_ARG('j', OPT_JUMP, OPT_ARG_JUMP), END_OPTIONS ); static char *app_sayunixtime = "SayUnixTime"; static char *app_datetime = "DateTime"; static int sayunixtime_exec(struct ast_channel *chan, const char *data) { AST_DECLARE_APP_ARGS(args, AST_APP_ARG(timeval); AST_APP_ARG(timezone); AST_APP_ARG(format); AST_APP_ARG(options); ); char *parse; int res = 0;
} chanspy_opt_flags; enum { OPT_ARG_VOLUME = 0, OPT_ARG_GROUP, OPT_ARG_RECORD, OPT_ARG_ENFORCED, OPT_ARG_ARRAY_SIZE, } chanspy_opt_args; AST_APP_OPTIONS(spy_opts, { AST_APP_OPTION('q', OPTION_QUIET), AST_APP_OPTION('b', OPTION_BRIDGED), AST_APP_OPTION('w', OPTION_WHISPER), AST_APP_OPTION('W', OPTION_PRIVATE), AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME), AST_APP_OPTION_ARG('g', OPTION_GROUP, OPT_ARG_GROUP), AST_APP_OPTION_ARG('r', OPTION_RECORD, OPT_ARG_RECORD), AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED), AST_APP_OPTION('o', OPTION_READONLY), AST_APP_OPTION('X', OPTION_EXIT), }); static int next_unique_id_to_use = 0; struct chanspy_translation_helper { /* spy data */ struct ast_audiohook spy_audiohook; struct ast_audiohook whisper_audiohook; int fd; int volfactor;
}; enum { OPT_ARG_VARSET = 0, /* note: this entry _MUST_ be the last one in the enum */ OPT_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(forkcdr_exec_options, { AST_APP_OPTION('a', OPT_SETANS), AST_APP_OPTION('A', OPT_ANSLOCK), AST_APP_OPTION('d', OPT_SETDISP), AST_APP_OPTION('D', OPT_RESETDEST), AST_APP_OPTION('e', OPT_ENDCDR), AST_APP_OPTION('R', OPT_NORESET), AST_APP_OPTION_ARG('s', OPT_VARSET, OPT_ARG_VARSET), AST_APP_OPTION('T', OPT_DONTOUCH), AST_APP_OPTION('v', OPT_KEEPVARS), }); static void ast_cdr_fork(struct ast_channel *chan, struct ast_flags optflags, char *set) { struct ast_cdr *cdr; struct ast_cdr *newcdr; struct ast_flags flags = { AST_CDR_FLAG_KEEP_VARS }; cdr = ast_channel_cdr(chan); while (cdr->next) cdr = cdr->next;
}; enum mixmonitor_args { OPT_ARG_READVOLUME = 0, OPT_ARG_WRITEVOLUME, OPT_ARG_VOLUME, OPT_ARG_WRITENAME, OPT_ARG_READNAME, OPT_ARG_UID, OPT_ARG_ARRAY_SIZE, /* Always last element of the enum */ }; AST_APP_OPTIONS(mixmonitor_opts, { AST_APP_OPTION('a', MUXFLAG_APPEND), AST_APP_OPTION('b', MUXFLAG_BRIDGED), AST_APP_OPTION_ARG('v', MUXFLAG_READVOLUME, OPT_ARG_READVOLUME), AST_APP_OPTION_ARG('V', MUXFLAG_WRITEVOLUME, OPT_ARG_WRITEVOLUME), AST_APP_OPTION_ARG('W', MUXFLAG_VOLUME, OPT_ARG_VOLUME), AST_APP_OPTION_ARG('r', MUXFLAG_READ, OPT_ARG_READNAME), AST_APP_OPTION_ARG('t', MUXFLAG_WRITE, OPT_ARG_WRITENAME), AST_APP_OPTION_ARG('i', MUXFLAG_UID, OPT_ARG_UID), }); struct mixmonitor_ds { unsigned int destruction_ok; ast_cond_t destruction_condition; ast_mutex_t lock; /* The filestream is held in the datastore so it can be stopped * immediately during stop_mixmonitor or channel destruction. */ int fs_quit;
enum { OPT_ARG_VOLUME = 0, OPT_ARG_GROUP, OPT_ARG_RECORD, OPT_ARG_ENFORCED, OPT_ARG_NAME, OPT_ARG_EXIT, OPT_ARG_CYCLE, OPT_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(spy_opts, { AST_APP_OPTION('b', OPTION_BRIDGED), AST_APP_OPTION('B', OPTION_BARGE), AST_APP_OPTION_ARG('c', OPTION_DTMF_CYCLE, OPT_ARG_CYCLE), AST_APP_OPTION('d', OPTION_DTMF_SWITCH_MODES), AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED), AST_APP_OPTION('E', OPTION_EXITONHANGUP), AST_APP_OPTION_ARG('g', OPTION_GROUP, OPT_ARG_GROUP), AST_APP_OPTION_ARG('n', OPTION_NAME, OPT_ARG_NAME), AST_APP_OPTION('o', OPTION_READONLY), AST_APP_OPTION('q', OPTION_QUIET), AST_APP_OPTION_ARG('r', OPTION_RECORD, OPT_ARG_RECORD), AST_APP_OPTION('s', OPTION_NOTECH), AST_APP_OPTION('S', OPTION_STOP), AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME), AST_APP_OPTION('w', OPTION_WHISPER), AST_APP_OPTION('W', OPTION_PRIVATE), AST_APP_OPTION_ARG('x', OPTION_DTMF_EXIT, OPT_ARG_EXIT), AST_APP_OPTION('X', OPTION_EXIT),
</application> ***/ static const char app[] = "ControlPlayback"; enum { OPT_OFFSET = (1 << 1), }; enum { OPT_ARG_OFFSET = 0, /* must stay as the last entry ... */ OPT_ARG_ARRAY_LEN, }; AST_APP_OPTIONS(cpb_opts, BEGIN_OPTIONS AST_APP_OPTION_ARG('o', OPT_OFFSET, OPT_ARG_OFFSET), END_OPTIONS ); static int is_on_phonepad(char key) { return key == 35 || key == 42 || (key >= 48 && key <= 57); } static int is_argument(const char *haystack, int needle) { if (ast_strlen_zero(haystack)) return 0; if (strchr(haystack, needle)) return -1;