convert most of the option_*'s to a single ast_flags structure. Also, fix some
formatting, remove some unnecessary casts, and other little code cleanups. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7331 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
dc76ba74df
commit
cfb1ef4712
2
app.c
2
app.c
|
@ -636,7 +636,7 @@ int ast_play_and_record(struct ast_channel *chan, const char *playfile, const ch
|
|||
/* Request a video update */
|
||||
ast_indicate(chan, AST_CONTROL_VIDUPDATE);
|
||||
|
||||
if (option_transmit_silence_during_record)
|
||||
if (ast_opt_transmit_silence)
|
||||
silgen = ast_channel_start_silence_generator(chan);
|
||||
|
||||
if (x == fmtcnt) {
|
||||
|
|
|
@ -143,7 +143,7 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
|
|||
if (res < 1) {
|
||||
pbx_builtin_setvar_helper(chan, "AVAILCHAN", "");
|
||||
pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", "");
|
||||
if (priority_jump || option_priority_jumping) {
|
||||
if (priority_jump || ast_opt_priority_jumping) {
|
||||
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return -1;
|
||||
|
|
|
@ -139,7 +139,7 @@ static int controlplayback_exec(struct ast_channel *chan, void *data)
|
|||
pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "USERSTOPPED");
|
||||
} else {
|
||||
if (res < 0) {
|
||||
if (priority_jump || option_priority_jumping) {
|
||||
if (priority_jump || ast_opt_priority_jumping) {
|
||||
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
|
||||
ast_log(LOG_WARNING, "ControlPlayback tried to jump to priority n+101 as requested, but priority didn't exist\n");
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ static int get_exec(struct ast_channel *chan, void *data)
|
|||
} else {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "DBget: Value not found in database.\n");
|
||||
if (priority_jump || option_priority_jumping) {
|
||||
if (priority_jump || ast_opt_priority_jumping) {
|
||||
/* Send the call to n+101 priority, where n is the current priority */
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
}
|
||||
|
|
|
@ -418,7 +418,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
|||
strcpy(status, "CONGESTION");
|
||||
else if (numnochan)
|
||||
strcpy(status, "CHANUNAVAIL");
|
||||
if (option_priority_jumping || priority_jump)
|
||||
if (ast_opt_priority_jumping || priority_jump)
|
||||
ast_goto_if_exists(in, in->context, in->exten, in->priority + 101);
|
||||
} else {
|
||||
if (option_verbose > 2)
|
||||
|
@ -1453,7 +1453,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||
if ((macro_result = pbx_builtin_getvar_helper(peer, "MACRO_RESULT"))) {
|
||||
if (!strcasecmp(macro_result, "BUSY")) {
|
||||
ast_copy_string(status, macro_result, sizeof(status));
|
||||
if (option_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) {
|
||||
if (ast_opt_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) {
|
||||
if (!ast_goto_if_exists(chan, NULL, NULL, chan->priority + 101)) {
|
||||
ast_set_flag(peerflags, OPT_GO_ON);
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
|
|||
res = ast_get_enum(chan, args.d, dest, sizeof(dest), tech, sizeof(tech), NULL, NULL);
|
||||
|
||||
if (!res) { /* Failed to do a lookup */
|
||||
if (priority_jump || option_priority_jumping) {
|
||||
if (priority_jump || ast_opt_priority_jumping) {
|
||||
/* Look for a "busy" place */
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
|
|||
*t = 0;
|
||||
pbx_builtin_setvar_helper(chan, "ENUM", tmp);
|
||||
ast_log(LOG_NOTICE, "tel: ENUM set to \"%s\"\n", tmp);
|
||||
if (priority_jump || option_priority_jumping) {
|
||||
if (priority_jump || ast_opt_priority_jumping) {
|
||||
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 51))
|
||||
res = 0;
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ static int group_check_exec(struct ast_channel *chan, void *data)
|
|||
count = ast_app_group_get_count(pbx_builtin_getvar_helper(chan, category), category);
|
||||
if (count > max) {
|
||||
pbx_builtin_setvar_helper(chan, "CHECKGROUPSTATUS", "OVERMAX");
|
||||
if (priority_jump || option_priority_jumping) {
|
||||
if (priority_jump || ast_opt_priority_jumping) {
|
||||
if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
|
||||
res = -1;
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
|
|||
|
||||
if (vmcount > 0) {
|
||||
/* Branch to the next extension */
|
||||
if (priority_jump || option_priority_jumping) {
|
||||
if (priority_jump || ast_opt_priority_jumping) {
|
||||
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
|
||||
ast_log(LOG_WARNING, "VM box %s@%s has new voicemail, but extension %s, priority %d doesn't exist\n", vmbox, context, chan->exten, chan->priority + 101);
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ static int sendimage_exec(struct ast_channel *chan, void *data)
|
|||
|
||||
if (!ast_supports_images(chan)) {
|
||||
/* Does not support transport */
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "NOSUPPORT");
|
||||
LOCAL_USER_REMOVE(u);
|
||||
|
|
|
@ -96,7 +96,7 @@ lookupblacklist_exec (struct ast_channel *chan, void *data)
|
|||
}
|
||||
|
||||
if (bl) {
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "FOUND");
|
||||
} else
|
||||
|
|
|
@ -156,7 +156,7 @@ static int md5check_exec(struct ast_channel *chan, void *data)
|
|||
if (option_debug > 2)
|
||||
ast_log(LOG_DEBUG, "ERROR: MD5 not verified: %s -- %s\n", args.md5hash, args.string);
|
||||
pbx_builtin_setvar_helper(chan, "CHECKMD5STATUS", "NOMATCH");
|
||||
if (priority_jump || option_priority_jumping) {
|
||||
if (priority_jump || ast_opt_priority_jumping) {
|
||||
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
|
||||
if (option_debug > 2)
|
||||
ast_log(LOG_DEBUG, "ERROR: Can't jump to exten+101 (e%s,p%d), sorry\n", chan->exten,chan->priority+101);
|
||||
|
|
|
@ -171,7 +171,7 @@ static int osplookup_exec(struct ast_channel *chan, void *data)
|
|||
}
|
||||
if (!res) {
|
||||
/* Look for a "busy" place */
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
} else if (res > 0)
|
||||
res = 0;
|
||||
|
@ -244,7 +244,7 @@ static int ospnext_exec(struct ast_channel *chan, void *data)
|
|||
}
|
||||
if (!res) {
|
||||
/* Look for a "busy" place */
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
} else if (res > 0)
|
||||
res = 0;
|
||||
|
@ -317,7 +317,7 @@ static int ospfinished_exec(struct ast_channel *chan, void *data)
|
|||
}
|
||||
if (!res) {
|
||||
/* Look for a "busy" place */
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
} else if (res > 0)
|
||||
res = 0;
|
||||
|
|
|
@ -130,7 +130,7 @@ static int playback_exec(struct ast_channel *chan, void *data)
|
|||
ast_stopstream(chan);
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data);
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
res = 0;
|
||||
mres = 1;
|
||||
|
|
|
@ -202,7 +202,7 @@ static int privacy_exec (struct ast_channel *chan, void *data)
|
|||
ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID to %s\n",phone);
|
||||
pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "SUCCESS");
|
||||
} else {
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "FAILED");
|
||||
}
|
||||
|
|
|
@ -2617,7 +2617,7 @@ static int pqm_exec(struct ast_channel *chan, void *data)
|
|||
|
||||
if (set_member_paused(args.queuename, args.interface, 1)) {
|
||||
ast_log(LOG_WARNING, "Attempt to pause interface %s, not found\n", args.interface);
|
||||
if (priority_jump || option_priority_jumping) {
|
||||
if (priority_jump || ast_opt_priority_jumping) {
|
||||
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
|
||||
pbx_builtin_setvar_helper(chan, "PQMSTATUS", "NOTFOUND");
|
||||
LOCAL_USER_REMOVE(u);
|
||||
|
@ -2673,7 +2673,7 @@ static int upqm_exec(struct ast_channel *chan, void *data)
|
|||
|
||||
if (set_member_paused(args.queuename, args.interface, 0)) {
|
||||
ast_log(LOG_WARNING, "Attempt to unpause interface %s, not found\n", args.interface);
|
||||
if (priority_jump || option_priority_jumping) {
|
||||
if (priority_jump || ast_opt_priority_jumping) {
|
||||
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
|
||||
pbx_builtin_setvar_helper(chan, "UPQMSTATUS", "NOTFOUND");
|
||||
LOCAL_USER_REMOVE(u);
|
||||
|
@ -2738,7 +2738,7 @@ static int rqm_exec(struct ast_channel *chan, void *data)
|
|||
break;
|
||||
case RES_EXISTS:
|
||||
ast_log(LOG_WARNING, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename);
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTINQUEUE");
|
||||
res = 0;
|
||||
|
@ -2814,7 +2814,7 @@ static int aqm_exec(struct ast_channel *chan, void *data)
|
|||
break;
|
||||
case RES_EXISTS:
|
||||
ast_log(LOG_WARNING, "Unable to add interface '%s' to queue '%s': Already there\n", args.interface, args.queuename);
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
pbx_builtin_setvar_helper(chan, "AQMSTATUS", "MEMBERALREADY");
|
||||
res = 0;
|
||||
|
|
|
@ -249,7 +249,7 @@ static int record_exec(struct ast_channel *chan, void *data)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (option_transmit_silence_during_record)
|
||||
if (ast_opt_transmit_silence)
|
||||
silgen = ast_channel_start_silence_generator(chan);
|
||||
|
||||
/* Request a video update */
|
||||
|
|
|
@ -105,7 +105,7 @@ static int sendtext_exec(struct ast_channel *chan, void *data)
|
|||
if (!chan->tech->send_text) {
|
||||
ast_mutex_unlock(&chan->lock);
|
||||
/* Does not support transport */
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return 0;
|
||||
|
|
|
@ -111,7 +111,7 @@ static int system_exec_helper(struct ast_channel *chan, void *data, int failmode
|
|||
} else {
|
||||
if (res < 0)
|
||||
res = 0;
|
||||
if (option_priority_jumping && res)
|
||||
if (ast_opt_priority_jumping && res)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
|
||||
if (res != 0)
|
||||
|
|
|
@ -131,7 +131,7 @@ static int transfer_exec(struct ast_channel *chan, void *data)
|
|||
|
||||
if (res < 0) {
|
||||
status = "FAILURE";
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
res = 0;
|
||||
} else {
|
||||
|
|
|
@ -119,7 +119,7 @@ static int txtcidname_exec(struct ast_channel *chan, void *data)
|
|||
}
|
||||
if (!res) {
|
||||
/* Look for a "busy" place */
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
pbx_builtin_setvar_helper(chan, "TXTCIDNAMESTATUS", "FAILED");
|
||||
} else if (res > 0)
|
||||
|
|
|
@ -108,7 +108,7 @@ static int sendurl_exec(struct ast_channel *chan, void *data)
|
|||
|
||||
if (!ast_channel_supports_html(chan)) {
|
||||
/* Does not support transport */
|
||||
if (local_option_jump || option_priority_jumping)
|
||||
if (local_option_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED");
|
||||
LOCAL_USER_REMOVE(u);
|
||||
|
@ -144,7 +144,7 @@ static int sendurl_exec(struct ast_channel *chan, void *data)
|
|||
case AST_HTML_NOSUPPORT:
|
||||
/* Does not support transport */
|
||||
status ="UNSUPPORTED";
|
||||
if (local_option_jump || option_priority_jumping)
|
||||
if (local_option_jump || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
res = 0;
|
||||
goto out;
|
||||
|
|
|
@ -2382,7 +2382,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
|
|||
|
||||
if (!(vmu = find_user(&svm, context, ext))) {
|
||||
ast_log(LOG_WARNING, "No entry in voicemail config file for '%s'\n", ext);
|
||||
if (ast_test_flag(options, OPT_PRIORITY_JUMP) || option_priority_jumping)
|
||||
if (ast_test_flag(options, OPT_PRIORITY_JUMP) || ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
|
||||
return res;
|
||||
|
@ -5543,7 +5543,7 @@ static int vm_exec(struct ast_channel *chan, void *data)
|
|||
if (res == ERROR_LOCK_PATH) {
|
||||
ast_log(LOG_ERROR, "Could not leave voicemail. The path is already locked.\n");
|
||||
/*Send the call to n+101 priority, where n is the current priority*/
|
||||
if (ast_test_flag(&leave_options, OPT_PRIORITY_JUMP) || option_priority_jumping)
|
||||
if (ast_test_flag(&leave_options, OPT_PRIORITY_JUMP) || ast_opt_priority_jumping)
|
||||
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
|
||||
ast_log(LOG_WARNING, "Extension %s, priority %d doesn't exist.\n", chan->exten, chan->priority + 101);
|
||||
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
|
||||
|
@ -5633,7 +5633,7 @@ static int vm_box_exists(struct ast_channel *chan, void *data)
|
|||
|
||||
if (find_user(&svm, context, args.mbox)) {
|
||||
pbx_builtin_setvar_helper(chan, "VMBOXEXISTSSTATUS", "SUCCESS");
|
||||
if (priority_jump || option_priority_jumping)
|
||||
if (priority_jump || ast_opt_priority_jumping)
|
||||
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
|
||||
ast_log(LOG_WARNING, "VM box %s@%s exists, but extension %s, priority %d doesn't exist\n", box, context, chan->exten, chan->priority + 101);
|
||||
} else
|
||||
|
|
181
asterisk.c
181
asterisk.c
|
@ -136,32 +136,17 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||
Some of them can be changed in the CLI
|
||||
*/
|
||||
/*! @{ */
|
||||
int option_verbose=0; /*!< Verbosity level */
|
||||
int option_debug=0; /*!< Debug level */
|
||||
int option_exec_includes=0; /*!< Allow \#exec in config files? */
|
||||
int option_nofork=0; /*!< Do not fork */
|
||||
int option_quiet=0; /*!< Keep quiet */
|
||||
int option_console=0; /*!< Console mode, no background */
|
||||
int option_highpriority=0; /*!< Run in realtime Linux priority */
|
||||
int option_remote=0; /*!< Remote CLI */
|
||||
int option_exec=0; /*!< */
|
||||
int option_initcrypto=0; /*!< Initialize crypto keys for RSA auth */
|
||||
int option_nocolor; /*!< Don't use termcap colors */
|
||||
int option_dumpcore = 0; /*!< Dump core when failing */
|
||||
int option_cache_record_files = 0; /*!< Cache sound files */
|
||||
int option_timestamp = 0; /*!< Timestamp in logging */
|
||||
int option_overrideconfig = 0; /*!< */
|
||||
int option_reconnect = 0; /*!< */
|
||||
int option_transcode_slin = 1; /*!< */
|
||||
int option_maxcalls = 0; /*!< */
|
||||
|
||||
struct ast_flags ast_options = { AST_OPT_FLAG_TRANSCODE_VIA_SLIN | AST_OPT_FLAG_PRIORITY_JUMPING };
|
||||
|
||||
int option_verbose = 0; /*!< Verbosity level */
|
||||
int option_debug = 0; /*!< Debug level */
|
||||
|
||||
double option_maxload = 0.0; /*!< Max load avg on system */
|
||||
int option_dontwarn = 0; /*!< */
|
||||
int option_priority_jumping = 1; /*!< Enable priority jumping as result value for apps */
|
||||
int option_transmit_silence_during_record = 0; /*!< Transmit silence during record() app */
|
||||
int option_maxcalls = 0; /*!< Max number of active calls */
|
||||
|
||||
/*! @} */
|
||||
|
||||
int fully_booted = 0;
|
||||
char record_cache_dir[AST_CACHE_DIR_LEN] = AST_TMP_DIR;
|
||||
char debug_filename[AST_FILENAME_MAX] = "";
|
||||
|
||||
|
@ -831,7 +816,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
|
|||
if (!nice) {
|
||||
/* Begin shutdown routine, hanging up active channels */
|
||||
ast_begin_shutdown(1);
|
||||
if (option_verbose && option_console)
|
||||
if (option_verbose && ast_opt_console)
|
||||
ast_verbose("Beginning asterisk %s....\n", restart ? "restart" : "shutdown");
|
||||
time(&s);
|
||||
for(;;) {
|
||||
|
@ -849,7 +834,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
|
|||
} else {
|
||||
if (nice < 2)
|
||||
ast_begin_shutdown(0);
|
||||
if (option_verbose && option_console)
|
||||
if (option_verbose && ast_opt_console)
|
||||
ast_verbose("Waiting for inactivity to perform %s...\n", restart ? "restart" : "halt");
|
||||
for(;;) {
|
||||
if (!ast_active_channels())
|
||||
|
@ -861,12 +846,12 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
|
|||
}
|
||||
|
||||
if (!shuttingdown) {
|
||||
if (option_verbose && option_console)
|
||||
if (option_verbose && ast_opt_console)
|
||||
ast_verbose("Asterisk %s cancelled.\n", restart ? "restart" : "shutdown");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (option_console || option_remote) {
|
||||
if (ast_opt_console || ast_opt_remote) {
|
||||
if (getenv("HOME"))
|
||||
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
|
||||
if (!ast_strlen_zero(filename))
|
||||
|
@ -880,7 +865,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
|
|||
ast_verbose("Executing last minute cleanups\n");
|
||||
ast_run_atexits();
|
||||
/* Called on exit */
|
||||
if (option_verbose && option_console)
|
||||
if (option_verbose && ast_opt_console)
|
||||
ast_verbose("Asterisk %s ending (%d).\n", ast_active_channels() ? "uncleanly" : "cleanly", num);
|
||||
else if (option_debug)
|
||||
ast_log(LOG_DEBUG, "Asterisk ending (%d).\n", num);
|
||||
|
@ -892,17 +877,18 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
|
|||
if (ast_consock > -1)
|
||||
close(ast_consock);
|
||||
if (ast_socket > -1)
|
||||
unlink((char *)ast_config_AST_SOCKET);
|
||||
if (!option_remote) unlink((char *)ast_config_AST_PID);
|
||||
unlink(ast_config_AST_SOCKET);
|
||||
if (!ast_opt_remote)
|
||||
unlink(ast_config_AST_PID);
|
||||
printf(term_quit());
|
||||
if (restart) {
|
||||
if (option_verbose || option_console)
|
||||
if (option_verbose || ast_opt_console)
|
||||
ast_verbose("Preparing for Asterisk restart...\n");
|
||||
/* Mark all FD's for closing on exec */
|
||||
for (x=3;x<32768;x++) {
|
||||
fcntl(x, F_SETFD, FD_CLOEXEC);
|
||||
}
|
||||
if (option_verbose || option_console)
|
||||
if (option_verbose || ast_opt_console)
|
||||
ast_verbose("Restarting Asterisk NOW...\n");
|
||||
restartnow = 1;
|
||||
|
||||
|
@ -961,7 +947,7 @@ static void console_verboser(const char *s, int pos, int replace, int complete)
|
|||
fflush(stdout);
|
||||
if (complete) {
|
||||
/* Wake up a poll()ing console */
|
||||
if (option_console && consolethread != AST_PTHREADT_NULL)
|
||||
if (ast_opt_console && consolethread != AST_PTHREADT_NULL)
|
||||
pthread_kill(consolethread, SIGURG);
|
||||
}
|
||||
}
|
||||
|
@ -1172,7 +1158,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
|
|||
max = 1;
|
||||
fds[0].fd = ast_consock;
|
||||
fds[0].events = POLLIN;
|
||||
if (!option_exec) {
|
||||
if (!ast_opt_exec) {
|
||||
fds[1].fd = STDIN_FILENO;
|
||||
fds[1].events = POLLIN;
|
||||
max++;
|
||||
|
@ -1185,7 +1171,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!option_exec && fds[1].revents) {
|
||||
if (!ast_opt_exec && fds[1].revents) {
|
||||
num_read = read(STDIN_FILENO, cp, 1);
|
||||
if (num_read < 1) {
|
||||
break;
|
||||
|
@ -1197,7 +1183,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
|
|||
/* if the remote side disappears exit */
|
||||
if (res < 1) {
|
||||
fprintf(stderr, "\nDisconnected from Asterisk server\n");
|
||||
if (!option_reconnect) {
|
||||
if (!ast_opt_reconnect) {
|
||||
quit_handler(0, 0, 0, 0);
|
||||
} else {
|
||||
int tries;
|
||||
|
@ -1222,7 +1208,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
|
|||
|
||||
buf[res] = '\0';
|
||||
|
||||
if (!option_exec && !lastpos)
|
||||
if (!ast_opt_exec && !lastpos)
|
||||
write(STDOUT_FILENO, "\r", 1);
|
||||
write(STDOUT_FILENO, buf, res);
|
||||
if ((buf[res-1] == '\n') || (buf[res-2] == '\n')) {
|
||||
|
@ -1343,7 +1329,7 @@ static char *cli_prompt(EditLine *el)
|
|||
}
|
||||
break;
|
||||
case '#': /* process console or remote? */
|
||||
if (! option_remote) {
|
||||
if (!ast_opt_remote) {
|
||||
strncat(p, "#", sizeof(prompt) - strlen(prompt) - 1);
|
||||
} else {
|
||||
strncat(p, ">", sizeof(prompt) - strlen(prompt) - 1);
|
||||
|
@ -1497,7 +1483,7 @@ static char *cli_complete(EditLine *el, int ch)
|
|||
|
||||
len = lf->cursor - ptr;
|
||||
|
||||
if (option_remote) {
|
||||
if (ast_opt_remote) {
|
||||
snprintf(buf, sizeof(buf),"_COMMAND NUMMATCHES \"%s\" \"%s\"", lf->buffer, ptr);
|
||||
fdprint(ast_consock, buf);
|
||||
res = read(ast_consock, buf, sizeof(buf));
|
||||
|
@ -1707,7 +1693,7 @@ static void ast_remotecontrol(char * data)
|
|||
if (!ast_strlen_zero(filename))
|
||||
ast_el_read_history(filename);
|
||||
|
||||
if (option_exec && data) { /* hack to print output then exit if asterisk -rx is used */
|
||||
if (ast_opt_exec && data) { /* hack to print output then exit if asterisk -rx is used */
|
||||
char tempchar;
|
||||
struct pollfd fds[0];
|
||||
fds[0].fd = ast_consock;
|
||||
|
@ -1774,7 +1760,7 @@ static void ast_readconfig(void) {
|
|||
struct ast_variable *v;
|
||||
char *config = AST_CONFIG_FILE;
|
||||
|
||||
if (option_overrideconfig == 1) {
|
||||
if (ast_opt_override_config) {
|
||||
cfg = ast_config_load(ast_config_AST_CONFIG_FILE);
|
||||
if (!cfg)
|
||||
ast_log(LOG_WARNING, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE);
|
||||
|
@ -1843,10 +1829,10 @@ static void ast_readconfig(void) {
|
|||
option_verbose = atoi(v->value);
|
||||
/* whether or not to force timestamping. (-T at startup) */
|
||||
} else if (!strcasecmp(v->name, "timestamp")) {
|
||||
option_timestamp = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TIMESTAMP);
|
||||
/* whether or not to support #exec in config files */
|
||||
} else if (!strcasecmp(v->name, "execincludes")) {
|
||||
option_exec_includes = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_EXEC_INCLUDES);
|
||||
/* debug level (-d at startup) */
|
||||
} else if (!strcasecmp(v->name, "debug")) {
|
||||
option_debug = 0;
|
||||
|
@ -1855,40 +1841,40 @@ static void ast_readconfig(void) {
|
|||
}
|
||||
/* Disable forking (-f at startup) */
|
||||
} else if (!strcasecmp(v->name, "nofork")) {
|
||||
option_nofork = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK);
|
||||
/* Run quietly (-q at startup ) */
|
||||
} else if (!strcasecmp(v->name, "quiet")) {
|
||||
option_quiet = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);
|
||||
/* Run as console (-c at startup, implies nofork) */
|
||||
} else if (!strcasecmp(v->name, "console")) {
|
||||
option_console = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CONSOLE);
|
||||
/* Run with highg priority if the O/S permits (-p at startup) */
|
||||
} else if (!strcasecmp(v->name, "highpriority")) {
|
||||
option_highpriority = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIGH_PRIORITY);
|
||||
/* Initialize RSA auth keys (IAX2) (-i at startup) */
|
||||
} else if (!strcasecmp(v->name, "initcrypto")) {
|
||||
option_initcrypto = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_INIT_KEYS);
|
||||
/* Disable ANSI colors for console (-c at startup) */
|
||||
} else if (!strcasecmp(v->name, "nocolor")) {
|
||||
option_nocolor = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_COLOR);
|
||||
/* Disable some usage warnings for picky people :p */
|
||||
} else if (!strcasecmp(v->name, "dontwarn")) {
|
||||
option_dontwarn = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_DONT_WARN);
|
||||
/* Dump core in case of crash (-g) */
|
||||
} else if (!strcasecmp(v->name, "dumpcore")) {
|
||||
option_dumpcore = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_DUMP_CORE);
|
||||
/* Cache recorded sound files to another directory during recording */
|
||||
} else if (!strcasecmp(v->name, "cache_record_files")) {
|
||||
option_cache_record_files = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_RECORD_FILES);
|
||||
/* Specify cache directory */
|
||||
} else if (!strcasecmp(v->name, "record_cache_dir")) {
|
||||
ast_copy_string(record_cache_dir, v->value, AST_CACHE_DIR_LEN);
|
||||
/* Build transcode paths via SLINEAR, instead of directly */
|
||||
} else if (!strcasecmp(v->name, "transcode_via_sln")) {
|
||||
option_transcode_slin = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSCODE_VIA_SLIN);
|
||||
/* Transmit SLINEAR silence while a channel is being recorded */
|
||||
} else if (!strcasecmp(v->name, "transmit_silence_during_record")) {
|
||||
option_transmit_silence_during_record = ast_true(v->value);
|
||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSMIT_SILENCE);
|
||||
} else if (!strcasecmp(v->name, "maxcalls")) {
|
||||
if ((sscanf(v->value, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0)) {
|
||||
option_maxcalls = 0;
|
||||
|
@ -1940,8 +1926,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* if the progname is rasterisk consider it a remote console */
|
||||
if (argv[0] && (strstr(argv[0], "rasterisk")) != NULL) {
|
||||
option_remote++;
|
||||
option_nofork++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE);
|
||||
}
|
||||
if (gethostname(hostname, sizeof(hostname)-1))
|
||||
ast_copy_string(hostname, "<Unknown>", sizeof(hostname));
|
||||
|
@ -1970,33 +1955,29 @@ int main(int argc, char *argv[])
|
|||
switch(c) {
|
||||
case 'd':
|
||||
option_debug++;
|
||||
option_nofork++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
|
||||
break;
|
||||
case 'c':
|
||||
option_console++;
|
||||
option_nofork++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);
|
||||
break;
|
||||
case 'f':
|
||||
option_nofork++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
|
||||
break;
|
||||
case 'n':
|
||||
option_nocolor++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_COLOR);
|
||||
break;
|
||||
case 'r':
|
||||
option_remote++;
|
||||
option_nofork++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE);
|
||||
break;
|
||||
case 'R':
|
||||
option_remote++;
|
||||
option_nofork++;
|
||||
option_reconnect++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE | AST_OPT_FLAG_RECONNECT);
|
||||
break;
|
||||
case 'p':
|
||||
option_highpriority++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY);
|
||||
break;
|
||||
case 'v':
|
||||
option_verbose++;
|
||||
option_nofork++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
|
||||
break;
|
||||
case 'M':
|
||||
if ((sscanf(optarg, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0))
|
||||
|
@ -2007,27 +1988,27 @@ int main(int argc, char *argv[])
|
|||
option_maxload = 0.0;
|
||||
break;
|
||||
case 'q':
|
||||
option_quiet++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_QUIET);
|
||||
break;
|
||||
case 't':
|
||||
option_cache_record_files++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES);
|
||||
break;
|
||||
case 'T':
|
||||
option_timestamp++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP);
|
||||
break;
|
||||
case 'x':
|
||||
option_exec++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_EXEC);
|
||||
xarg = optarg;
|
||||
break;
|
||||
case 'C':
|
||||
ast_copy_string((char *)ast_config_AST_CONFIG_FILE,optarg,sizeof(ast_config_AST_CONFIG_FILE));
|
||||
option_overrideconfig++;
|
||||
ast_copy_string(ast_config_AST_CONFIG_FILE, optarg, sizeof(ast_config_AST_CONFIG_FILE));
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG);
|
||||
break;
|
||||
case 'i':
|
||||
option_initcrypto++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS);
|
||||
break;
|
||||
case'g':
|
||||
option_dumpcore++;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE);
|
||||
break;
|
||||
case 'h':
|
||||
show_cli_help();
|
||||
|
@ -2049,14 +2030,14 @@ int main(int argc, char *argv[])
|
|||
/* For remote connections, change the name of the remote connection.
|
||||
* We do this for the benefit of init scripts (which need to know if/when
|
||||
* the main asterisk process has died yet). */
|
||||
if (option_remote) {
|
||||
if (ast_opt_remote) {
|
||||
strcpy(argv[0], "rasterisk");
|
||||
for (x = 1; x < argc; x++) {
|
||||
argv[x] = argv[0] + 10;
|
||||
}
|
||||
}
|
||||
|
||||
if (option_dumpcore) {
|
||||
if (ast_opt_dump_core) {
|
||||
struct rlimit l;
|
||||
memset(&l, 0, sizeof(l));
|
||||
l.rlim_cur = RLIM_INFINITY;
|
||||
|
@ -2066,7 +2047,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (option_console && !option_verbose)
|
||||
if (ast_opt_console && !option_verbose)
|
||||
ast_verbose("[ Reading Master Configuration ]");
|
||||
ast_readconfig();
|
||||
|
||||
|
@ -2077,7 +2058,7 @@ int main(int argc, char *argv[])
|
|||
#ifndef __CYGWIN__
|
||||
|
||||
if (!is_child_of_nonroot)
|
||||
ast_set_priority(option_highpriority);
|
||||
ast_set_priority(ast_opt_high_priority);
|
||||
|
||||
if (!is_child_of_nonroot && rungroup) {
|
||||
struct group *gr;
|
||||
|
@ -2120,14 +2101,14 @@ int main(int argc, char *argv[])
|
|||
printf(term_end());
|
||||
fflush(stdout);
|
||||
|
||||
if (option_console && !option_verbose)
|
||||
if (ast_opt_console && !option_verbose)
|
||||
ast_verbose("[ Initializing Custom Configuration Options ]");
|
||||
/* custom config setup */
|
||||
register_config_cli();
|
||||
read_config_maps();
|
||||
|
||||
|
||||
if (option_console) {
|
||||
if (ast_opt_console) {
|
||||
if (el_hist == NULL || el == NULL)
|
||||
ast_el_initialize();
|
||||
|
||||
|
@ -2137,8 +2118,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (ast_tryconnect()) {
|
||||
/* One is already running */
|
||||
if (option_remote) {
|
||||
if (option_exec) {
|
||||
if (ast_opt_remote) {
|
||||
if (ast_opt_exec) {
|
||||
ast_remotecontrol(xarg);
|
||||
quit_handler(0, 0, 0, 0);
|
||||
exit(0);
|
||||
|
@ -2150,34 +2131,34 @@ int main(int argc, char *argv[])
|
|||
quit_handler(0, 0, 0, 0);
|
||||
exit(0);
|
||||
} else {
|
||||
ast_log(LOG_ERROR, "Asterisk already running on %s. Use 'asterisk -r' to connect.\n", (char *)ast_config_AST_SOCKET);
|
||||
ast_log(LOG_ERROR, "Asterisk already running on %s. Use 'asterisk -r' to connect.\n", ast_config_AST_SOCKET);
|
||||
printf(term_quit());
|
||||
exit(1);
|
||||
}
|
||||
} else if (option_remote || option_exec) {
|
||||
} else if (ast_opt_remote || ast_opt_exec) {
|
||||
ast_log(LOG_ERROR, "Unable to connect to remote asterisk (does %s exist?)\n",ast_config_AST_SOCKET);
|
||||
printf(term_quit());
|
||||
exit(1);
|
||||
}
|
||||
/* Blindly write pid file since we couldn't connect */
|
||||
unlink((char *)ast_config_AST_PID);
|
||||
f = fopen((char *)ast_config_AST_PID, "w");
|
||||
unlink(ast_config_AST_PID);
|
||||
f = fopen(ast_config_AST_PID, "w");
|
||||
if (f) {
|
||||
fprintf(f, "%d\n", getpid());
|
||||
fclose(f);
|
||||
} else
|
||||
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", (char *)ast_config_AST_PID, strerror(errno));
|
||||
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
|
||||
|
||||
if (!option_verbose && !option_debug && !option_nofork && !option_console) {
|
||||
if (!option_verbose && !option_debug && !ast_opt_no_fork && !ast_opt_console) {
|
||||
daemon(0,0);
|
||||
/* Blindly re-write pid file since we are forking */
|
||||
unlink((char *)ast_config_AST_PID);
|
||||
f = fopen((char *)ast_config_AST_PID, "w");
|
||||
unlink(ast_config_AST_PID);
|
||||
f = fopen(ast_config_AST_PID, "w");
|
||||
if (f) {
|
||||
fprintf(f, "%d\n", getpid());
|
||||
fclose(f);
|
||||
} else
|
||||
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", (char *)ast_config_AST_PID, strerror(errno));
|
||||
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
|
||||
}
|
||||
|
||||
/* Test recursive mutex locking. */
|
||||
|
@ -2192,13 +2173,13 @@ int main(int argc, char *argv[])
|
|||
sigaddset(&sigs, SIGPIPE);
|
||||
sigaddset(&sigs, SIGWINCH);
|
||||
pthread_sigmask(SIG_BLOCK, &sigs, NULL);
|
||||
if (option_console || option_verbose || option_remote)
|
||||
if (ast_opt_console || option_verbose || ast_opt_remote)
|
||||
ast_register_verbose(console_verboser);
|
||||
/* Print a welcome message if desired */
|
||||
if (option_verbose || option_console) {
|
||||
if (option_verbose || ast_opt_console) {
|
||||
WELCOME_MESSAGE;
|
||||
}
|
||||
if (option_console && !option_verbose)
|
||||
if (ast_opt_console && !option_verbose)
|
||||
ast_verbose("[ Booting...");
|
||||
|
||||
signal(SIGURG, urg_handler);
|
||||
|
@ -2285,20 +2266,20 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* We might have the option of showing a console, but for now just
|
||||
do nothing... */
|
||||
if (option_console && !option_verbose)
|
||||
if (ast_opt_console && !option_verbose)
|
||||
ast_verbose(" ]\n");
|
||||
if (option_verbose || option_console)
|
||||
if (option_verbose || ast_opt_console)
|
||||
ast_verbose(term_color(tmp, "Asterisk Ready.\n", COLOR_BRWHITE, COLOR_BLACK, sizeof(tmp)));
|
||||
if (option_nofork)
|
||||
if (ast_opt_no_fork)
|
||||
consolethread = pthread_self();
|
||||
fully_booted = 1;
|
||||
ast_set_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED);
|
||||
pthread_sigmask(SIG_UNBLOCK, &sigs, NULL);
|
||||
#ifdef __AST_DEBUG_MALLOC
|
||||
__ast_mm_init();
|
||||
#endif
|
||||
time(&ast_startuptime);
|
||||
ast_cli_register_multiple(core_cli, sizeof(core_cli) / sizeof(core_cli[0]));
|
||||
if (option_console) {
|
||||
if (ast_opt_console) {
|
||||
/* Console stuff now... */
|
||||
/* Register our quit function */
|
||||
char title[256];
|
||||
|
|
|
@ -2689,7 +2689,7 @@ int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *pe
|
|||
/* if the best path is not 'pass through', then
|
||||
transcoding is needed; if desired, force transcode path
|
||||
to use SLINEAR between channels */
|
||||
if ((src != dst) && option_transcode_slin)
|
||||
if ((src != dst) && ast_opt_transcode_via_slin)
|
||||
dst = AST_FORMAT_SLINEAR;
|
||||
if (ast_set_read_format(chan, dst) < 0) {
|
||||
ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", chan->name, dst);
|
||||
|
@ -2710,7 +2710,7 @@ int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *pe
|
|||
/* if the best path is not 'pass through', then
|
||||
transcoding is needed; if desired, force transcode path
|
||||
to use SLINEAR between channels */
|
||||
if ((src != dst) && option_transcode_slin)
|
||||
if ((src != dst) && ast_opt_transcode_via_slin)
|
||||
dst = AST_FORMAT_SLINEAR;
|
||||
if (ast_set_read_format(peer, dst) < 0) {
|
||||
ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", peer->name, dst);
|
||||
|
|
2
config.c
2
config.c
|
@ -450,7 +450,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
|
|||
do_exec = !strcasecmp(cur, "exec");
|
||||
else
|
||||
do_exec = 0;
|
||||
if (do_exec && !option_exec_includes) {
|
||||
if (do_exec && !ast_opt_exec_includes) {
|
||||
ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n");
|
||||
do_exec = 0;
|
||||
}
|
||||
|
|
2
file.c
2
file.c
|
@ -909,7 +909,7 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
|
|||
}
|
||||
}
|
||||
|
||||
if (option_cache_record_files && (fd > -1)) {
|
||||
if (ast_opt_cache_record_files && (fd > -1)) {
|
||||
char *c;
|
||||
|
||||
fclose(bfile);
|
||||
|
|
2
frame.c
2
frame.c
|
@ -587,7 +587,7 @@ static int show_codecs(int fd, int argc, char *argv[])
|
|||
if ((argc < 2) || (argc > 3))
|
||||
return RESULT_SHOWUSAGE;
|
||||
|
||||
if (!option_dontwarn)
|
||||
if (!ast_opt_dont_warn)
|
||||
ast_cli(fd, "Disclaimer: this command is for informational purposes only.\n"
|
||||
"\tIt does not indicate anything about your configuration.\n");
|
||||
|
||||
|
|
|
@ -39,6 +39,11 @@ extern "C" {
|
|||
a; \
|
||||
}
|
||||
|
||||
#define VERBOSE_PREFIX_1 " "
|
||||
#define VERBOSE_PREFIX_2 " == "
|
||||
#define VERBOSE_PREFIX_3 " -- "
|
||||
#define VERBOSE_PREFIX_4 " > "
|
||||
|
||||
/*! Used for sending a log message */
|
||||
/*!
|
||||
\brief This is the standard logger function. Probably the only way you will invoke it would be something like this:
|
||||
|
|
|
@ -27,38 +27,86 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AST_CACHE_DIR_LEN 512
|
||||
#define AST_CACHE_DIR_LEN 512
|
||||
#define AST_FILENAME_MAX 80
|
||||
|
||||
enum ast_option_flags {
|
||||
/*! Allow \#exec in config files */
|
||||
AST_OPT_FLAG_EXEC_INCLUDES = (1 << 0),
|
||||
/*! Do not fork() */
|
||||
AST_OPT_FLAG_NO_FORK = (1 << 1),
|
||||
/*! Keep quiet */
|
||||
AST_OPT_FLAG_QUIET = (1 << 2),
|
||||
/*! Console mode */
|
||||
AST_OPT_FLAG_CONSOLE = (1 << 3),
|
||||
/*! Run in realtime Linux priority */
|
||||
AST_OPT_FLAG_HIGH_PRIORITY = (1 << 4),
|
||||
/*! Initialize keys for RSA authentication */
|
||||
AST_OPT_FLAG_INIT_KEYS = (1 << 5),
|
||||
/*! Remote console */
|
||||
AST_OPT_FLAG_REMOTE = (1 << 6),
|
||||
/*! Execute an asterisk CLI command upon startup */
|
||||
AST_OPT_FLAG_EXEC = (1 << 7),
|
||||
/*! Don't use termcap colors */
|
||||
AST_OPT_FLAG_NO_COLOR = (1 << 8),
|
||||
/*! Are we fully started yet? */
|
||||
AST_OPT_FLAG_FULLY_BOOTED = (1 << 9),
|
||||
/*! Trascode via signed linear */
|
||||
AST_OPT_FLAG_TRANSCODE_VIA_SLIN = (1 << 10),
|
||||
/*! Enable priority jumping in applications */
|
||||
AST_OPT_FLAG_PRIORITY_JUMPING = (1 << 11),
|
||||
/*! Dump core on a seg fault */
|
||||
AST_OPT_FLAG_DUMP_CORE = (1 << 12),
|
||||
/*! Cache sound files */
|
||||
AST_OPT_FLAG_CACHE_RECORD_FILES = (1 << 13),
|
||||
/*! Display timestamp in log messages */
|
||||
AST_OPT_FLAG_TIMESTAMP = (1 << 14),
|
||||
/*! Override config */
|
||||
AST_OPT_FLAG_OVERRIDE_CONFIG = (1 << 15),
|
||||
/*! Reconnect */
|
||||
AST_OPT_FLAG_RECONNECT = (1 << 16),
|
||||
/*! Transmit Silence during Record() */
|
||||
AST_OPT_FLAG_TRANSMIT_SILENCE = (1 << 17),
|
||||
/*! Suppress some warnings */
|
||||
AST_OPT_FLAG_DONT_WARN = (1 << 18)
|
||||
};
|
||||
|
||||
#define ast_opt_exec_includes ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
|
||||
#define ast_opt_no_fork ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK)
|
||||
#define ast_opt_quiet ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET)
|
||||
#define ast_opt_console ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE)
|
||||
#define ast_opt_high_priority ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)
|
||||
#define ast_opt_init_keys ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS)
|
||||
#define ast_opt_remote ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)
|
||||
#define ast_opt_exec ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC)
|
||||
#define ast_opt_no_color ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR)
|
||||
#define ast_fully_booted ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)
|
||||
#define ast_opt_transcode_via_slin ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)
|
||||
#define ast_opt_priority_jumping ast_test_flag(&ast_options, AST_OPT_FLAG_PRIORITY_JUMPING)
|
||||
#define ast_opt_dump_core ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE)
|
||||
#define ast_opt_cache_record_files ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
|
||||
#define ast_opt_timestamp ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP)
|
||||
#define ast_opt_override_config ast_test_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)
|
||||
#define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)
|
||||
#define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
|
||||
#define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)
|
||||
|
||||
extern struct ast_flags ast_options;
|
||||
|
||||
extern int option_verbose;
|
||||
extern int option_debug;
|
||||
extern int option_nofork;
|
||||
extern int option_quiet;
|
||||
extern int option_console;
|
||||
extern int option_initcrypto;
|
||||
extern int option_nocolor;
|
||||
extern int fully_booted;
|
||||
extern int option_exec_includes;
|
||||
extern int option_cache_record_files;
|
||||
extern int option_timestamp;
|
||||
extern int option_transcode_slin;
|
||||
extern int option_transmit_silence_during_record;
|
||||
extern int option_maxcalls;
|
||||
extern double option_maxload;
|
||||
extern int option_dontwarn;
|
||||
extern int option_priority_jumping;
|
||||
|
||||
extern char defaultlanguage[];
|
||||
|
||||
extern time_t ast_startuptime;
|
||||
extern time_t ast_lastreloadtime;
|
||||
extern int ast_mainpid;
|
||||
|
||||
extern char record_cache_dir[AST_CACHE_DIR_LEN];
|
||||
extern char debug_filename[AST_FILENAME_MAX];
|
||||
|
||||
#define VERBOSE_PREFIX_1 " "
|
||||
#define VERBOSE_PREFIX_2 " == "
|
||||
#define VERBOSE_PREFIX_3 " -- "
|
||||
#define VERBOSE_PREFIX_4 " > "
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
6
loader.c
6
loader.c
|
@ -383,10 +383,10 @@ static int __load_resource(const char *resource_name, const struct ast_config *c
|
|||
ast_mutex_unlock(&modlock);
|
||||
return -1;
|
||||
}
|
||||
if (!fully_booted) {
|
||||
if (!ast_fully_booted) {
|
||||
if (option_verbose)
|
||||
ast_verbose( " => (%s)\n", term_color(tmp, m->description(), COLOR_BROWN, COLOR_BLACK, sizeof(tmp)));
|
||||
if (option_console && !option_verbose)
|
||||
if (ast_opt_console && !option_verbose)
|
||||
ast_verbose( ".");
|
||||
} else {
|
||||
if (option_verbose)
|
||||
|
@ -560,7 +560,7 @@ int load_modules(const int preload_only)
|
|||
}
|
||||
closedir(mods);
|
||||
} else {
|
||||
if (!option_quiet)
|
||||
if (!ast_opt_quiet)
|
||||
ast_log(LOG_WARNING, "Unable to open modules directory %s.\n", (char *)ast_config_AST_MODULE_DIR);
|
||||
}
|
||||
}
|
||||
|
|
6
logger.c
6
logger.c
|
@ -753,7 +753,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
|||
|
||||
if (level != __LOG_VERBOSE) {
|
||||
sprintf(linestr, "%d", line);
|
||||
snprintf(buf, sizeof(buf), option_timestamp ? "[%s] %s[%ld]: %s:%s %s: " : "%s %s[%ld]: %s:%s %s: ",
|
||||
snprintf(buf, sizeof(buf), ast_opt_timestamp ? "[%s] %s[%ld]: %s:%s %s: " : "%s %s[%ld]: %s:%s %s: ",
|
||||
date,
|
||||
term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)),
|
||||
(long)GETTID(),
|
||||
|
@ -770,7 +770,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
|||
/* File channels */
|
||||
} else if ((chan->logmask & (1 << level)) && (chan->fileptr)) {
|
||||
int res;
|
||||
snprintf(buf, sizeof(buf), option_timestamp ? "[%s] %s[%ld]: " : "%s %s[%ld] %s: ", date,
|
||||
snprintf(buf, sizeof(buf), ast_opt_timestamp ? "[%s] %s[%ld]: " : "%s %s[%ld] %s: ", date,
|
||||
levels[level], (long)GETTID(), file);
|
||||
res = fprintf(chan->fileptr, buf);
|
||||
if (res <= 0 && buf[0] != '\0') { /* Error, no characters printed */
|
||||
|
@ -830,7 +830,7 @@ void ast_verbose(const char *fmt, ...)
|
|||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
|
||||
if (option_timestamp) {
|
||||
if (ast_opt_timestamp) {
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
char date[40];
|
||||
|
|
|
@ -1618,23 +1618,17 @@ static int pbx_load_module(void)
|
|||
cfg = ast_config_load(config);
|
||||
if (cfg) {
|
||||
/* Use existing config to populate the PBX table */
|
||||
static_config = ast_true(ast_variable_retrieve(cfg, "general",
|
||||
"static"));
|
||||
write_protect_config = ast_true(ast_variable_retrieve(cfg, "general",
|
||||
"writeprotect"));
|
||||
autofallthrough_config = ast_true(ast_variable_retrieve(cfg, "general",
|
||||
"autofallthrough"));
|
||||
clearglobalvars_config = ast_true(ast_variable_retrieve(cfg, "general",
|
||||
"clearglobalvars"));
|
||||
option_priority_jumping = !ast_false(ast_variable_retrieve(cfg, "general",
|
||||
"priorityjumping"));
|
||||
|
||||
static_config = ast_true(ast_variable_retrieve(cfg, "general", "static"));
|
||||
write_protect_config = ast_true(ast_variable_retrieve(cfg, "general", "writeprotect"));
|
||||
autofallthrough_config = ast_true(ast_variable_retrieve(cfg, "general", "autofallthrough"));
|
||||
clearglobalvars_config = ast_true(ast_variable_retrieve(cfg, "general", "clearglobalvars"));
|
||||
ast_set2_flag(&ast_options, !ast_false(ast_variable_retrieve(cfg, "general", "priorityjumping")), AST_OPT_FLAG_PRIORITY_JUMPING);
|
||||
|
||||
v = ast_variable_browse(cfg, "globals");
|
||||
while(v) {
|
||||
for (; v; v = v->next) {
|
||||
memset(realvalue, 0, sizeof(realvalue));
|
||||
pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
|
||||
pbx_builtin_setvar_helper(NULL, v->name, realvalue);
|
||||
v = v->next;
|
||||
}
|
||||
cxt = ast_category_browse(cfg, NULL);
|
||||
while(cxt) {
|
||||
|
@ -1736,7 +1730,7 @@ static int pbx_load_module(void)
|
|||
if (plus)
|
||||
ipri += atoi(plus);
|
||||
lastpri = ipri;
|
||||
if(!option_dontwarn) {
|
||||
if (!ast_opt_dont_warn) {
|
||||
if (!strcmp(realext, "_."))
|
||||
ast_log(LOG_WARNING, "The use of '_.' for an extension is strongly discouraged and can have unexpected behavior. Please use '_X.' instead at line %d\n", v->lineno);
|
||||
}
|
||||
|
|
|
@ -3912,7 +3912,7 @@ static int dundi_lookup_exec(struct ast_channel *chan, void *data)
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (option_priority_jumping)
|
||||
} else if (ast_opt_priority_jumping)
|
||||
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
|
||||
|
||||
LOCAL_USER_REMOVE(u);
|
||||
|
|
|
@ -268,7 +268,7 @@ static struct ast_key *try_load_key (char *dir, char *fname, int ifd, int ofd, i
|
|||
ast_log(LOG_NOTICE, "Key '%s' needs passcode.\n", key->name);
|
||||
key->ktype |= KEY_NEEDS_PASSCODE;
|
||||
if (!notice) {
|
||||
if (!option_initcrypto)
|
||||
if (!ast_opt_init_keys)
|
||||
ast_log(LOG_NOTICE, "Add the '-i' flag to the asterisk command line if you want to automatically initialize passcodes at launch.\n");
|
||||
notice++;
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ int reload(void)
|
|||
int load_module(void)
|
||||
{
|
||||
crypto_init();
|
||||
if (option_initcrypto)
|
||||
if (ast_opt_init_keys)
|
||||
crypto_load(STDIN_FILENO, STDOUT_FILENO);
|
||||
else
|
||||
crypto_load(-1, -1);
|
||||
|
|
Reference in New Issue