Asterisk source code analysis (main function)

Source: Internet
Author: User

File: The asterisk. c file under the main directory

1,CodeFragment:

 
/* If the progname is rasterisk consider it a remote console */If (argv [0] & (strstr (argv [0], "rasterisk "))! = NULL) {ast_set_flag (& ast_options, outputs | ast_opt_flag_remote);}... case 'r': ast_set_flag (& ast_options, outputs | ast_opt_flag_remote); break;

Note:

 
Running the rasterisk command on the terminal is equivalent to running asterisk-R, that is, the remote connection of Asterisk.

2. code snippet:

 
If (getenv ("home") snprintf (filename, sizeof (filename), "% S/. asterisk_history", getenv ("home "));

Note: commands run in rasterisk (or Asterisk-R) are recorded in. asterisk in the user's home directory.In the history file (for example,/root/. AsteriskHistory)

Asterisk startup parameters

Code snippet:

Case 'B':/* force black background */ast_set_flag (& ast_options, ast_opt_flag_force_black_background); ast_clear_flag (& ast_options, ast_opt_flag_light_background); break;

Note:-B is forced to run with a black background, which is equivalent to setting forceblackbackground in the file/etc/asterisk/Asterisk. conf to yes.

Code snippet:

 
Case 'X': ast_set_flag (& ast_options, ast_opt_flag_exec_shortdes); break;

Note:-X can be used to configure commands such as "# EXEC" in the configuration file (for example, # exec/tmp/shelltest. SH), equivalent to the file/etc/asterisk. execincludes = yes in Conf

Code snippet:

 
Case 'C': ast_copy_string (pai_paths.config_file, optarg, sizeof (pai_paths.config_file); ast_set_flag (& ast_options, ast_opt_flag_override_config); break;

-:-C file uses file to replace/etc/asterisk/Asterisk. conf file InitializationProgram, The file here should be an absolute path.

Code snippet:

Case 'C': ast_set_flag (& ast_options, ast_opt_flag_no_fork | ast_opt_flag_console); break;

Note:-C runs in Console mode, which is equivalent to configuring console = yes in the file/etc/asterisk/Asterisk. conf.

Code snippet:

 
Case 'D': option_debug ++; ast_set_flag (& ast_options, ast_opt_flag_no_fork); break;

Note:

 
In-D or-DDD debugging mode, the number of D is the debugging level. For example, "-DDD" is equivalent to configuring DEBUG = 3 in the file/etc/asterisk/Asterisk. conf.

Code snippet:

 
Case 'E': If (sscanf (& optarg [1], "% 30ld", & option_minmemfree )! = 1) | (option_minmemfree <0) {option_minmemfree = 0;} break;

Note:

 
-E memory is equivalent to configuring minmemfree = memory in the file/etc/asterisk/Asterisk. conf. When the available memory in the system is lower than the preset memory value, asterisk stops receiving new calls.

Code snippet:

Case 'F': ast_set_flag (& ast_options, ast_opt_flag_always_fork); break;

Note:

 
-F is equivalent to configuring alwaysfork = yes in the file/etc/asterisk/Asterisk. conf

Code snippet:

 
Case 'F': ast_set_flag (& ast_options, ast_opt_flag_no_fork); break;

Note:

 
-F is equivalent to configuring nofork = yes in the file/etc/asterisk/Asterisk. conf

Code snippet:

 
Case 'G': rungroup = ast_strdupa (optarg); break;

Note:

 
-G group

Code snippet:

 
Case 'G': ast_set_flag (& ast_options, ast_opt_flag_dump_core); break;

Note:

 
-G fault dump Problems

Code snippet:

Case 'H': show_cli_help (); exit (0 );

Note:

 
-H: Display help information

Code snippet:

 
Case 'I': ast_set_flag (& ast_options, ast_opt_flag_internal_timing); break;

Note:-I enables internal Timing If the dahdi timer is available

Code snippet:

 
Case 'I': ast_set_flag (& ast_options, ast_opt_flag_init_keys); break;

Note:

 
-I initialize the encryption key at startup

Code snippet:

 
Case 'l': If (sscanf (optarg, "% 30lf", & option_maxload )! = 1) | (option_maxload <0.0) {option_maxload = 0.0;} break;

Note:

 
-L <load> limit the maximum average load before rejecting a new call

Code snippet:

Case 'M': If (sscanf (optarg, "% 30d", & option_maxcils )! = 1) | (option_maxcils <0) {option_maxcils = 0;} break;

Note:

 
-M <value> specifies the maximum number of phone numbers.

Code snippet:

 
Case 'M': ast_set_flag (& ast_options, ast_opt_flag_mute); break;

Note:

 
-M shield output in the console

Code snippet:

 
Case 'N': ast_set_flag (& ast_options, ast_opt_flag_no_color); break;

Note:-N disables the color output function, for example, asterisk-n.

Code snippet:

 
Case 'p': ast_set_flag (& ast_options, ast_opt_flag_high_priority); break;

Note:

 
-P runs as a Pseudo Real-Time Thread

Code snippet:

Case 'q': ast_set_flag (& ast_options, ast_opt_flag_quiet); break;

Note:

 
-Q quiet mode (Suppress output)

Code snippet:

 
Case 'r': ast_set_flag (& ast_options, ast_opt_flag_no_fork | ast_opt_flag_remote | ast_opt_flag_reconnect); break;

Note:

 
-R connects to the asterisk server of the Local Machine. After being disconnected, it will reconnect.

Code snippet:

 
Case 'r': ast_set_flag (& ast_options, ast_opt_flag_no_fork | ast_opt_flag_remote); break;

Note:

 
-R: connect to the local asterisk Server

Code snippet:

 
Case's ': remotesock = ast_strdupa (optarg); break;

Note:

 
-S <socket-File> connects to Asterisk through socket, which is valid when used together with the R parameter

Code snippet:

Case 'T': ast_set_flag (& ast_options, ast_opt_flag_timestamp); break;

Note:

 
-T display time in CLI output

Code snippet:

 
Case 'T': ast_set_flag (& ast_options, ast_opt_flag_cache_record_files); break;

-:-T record soundfiles in/var/tmp and move them where they belong after they are done

Code snippet:

 
Case 'U': runuser = ast_strdupa (optarg); break;

Note:

 
-U <user> Run as user <user>

Code snippet:

 
Case 'V': show_version (); exit (0 );

Note:

 
-V: display version information

Code snippet:

Case 'V': option_verbose ++; ast_set_flag (& ast_options, ast_opt_flag_no_fork); break;

Note:

 
-V: multiple values. More information is displayed.

Code snippet:

 
Case 'W':/* white background */ast_set_flag (& ast_options, ast_opt_flag_light_background); ast_clear_flag (& ast_options, ast_opt_flag_force_black_background); break;

Note:

 
-W: Adjust terminal color

Code snippet:

 
Case 'X': ast_set_flag (& ast_options, ast_opt_flag_exec | ast_opt_flag_no_color); xarg = ast_strdupa (optarg); break;

Note:

 
-X <cmd> run cli commands and use them with R parameters, for example, asterisk-Rx 'core show channels'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.