diff options
author | Kinsey Moore <kmoore@digium.com> | 2012-03-22 19:51:16 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2012-03-22 19:51:16 +0000 |
commit | c5b3db1956a3db2446b0310b3a7d59961fe3e089 (patch) | |
tree | 530b55034f5adfb0c7106ae1194679a031afc888 /main/asterisk.c | |
parent | 1d1c28ac4b09df2b663123e55239e411b8f5ad26 (diff) |
Kill off red blobs in most of main/*
Everything still compiled after making these changes, so I assume these
whitespace-only changes didn't break anything (and shouldn't have).
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360190 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 98d28ed3e..19982b6e2 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -23,18 +23,18 @@ * * \par Developer Documentation for Asterisk * - * This is the main developer documentation for Asterisk. It is - * generated by running "make progdocs" from the Asterisk source tree. + * This is the main developer documentation for Asterisk. It is + * generated by running "make progdocs" from the Asterisk source tree. * - * In addition to the information available on the Asterisk source code, - * please see the appendices for information on coding guidelines, + * In addition to the information available on the Asterisk source code, + * please see the appendices for information on coding guidelines, * release management, commit policies, and more. * * \arg \ref AsteriskArchitecture * * \par Additional documentation * \arg \ref Licensing - * \arg \ref DevDoc + * \arg \ref DevDoc * \arg \ref ConfigFiles * * \section copyright Copyright and Author @@ -56,7 +56,7 @@ /*! \file \brief Top level source file for Asterisk - the Open Source PBX. Implementation of PBX core functions and CLI interface. - + */ #include "asterisk.h" @@ -170,7 +170,7 @@ int daemon(int, int); /* defined in libresolv of all places */ /*! \defgroup main_options Main Configuration Options * \brief Main configuration options from asterisk.conf or OS command line on starting Asterisk. * \arg \ref Config_ast "asterisk.conf" - * \note Some of them can be changed in the CLI + * \note Some of them can be changed in the CLI */ /*! @{ */ @@ -323,7 +323,7 @@ void ast_register_file_version(const char *file, const char *version) work = ast_strdupa(version); work = ast_strip(ast_strip_quoted(work, "$", "$")); version_length = strlen(work) + 1; - + if (!(new = ast_calloc(1, sizeof(*new) + version_length))) return; @@ -385,8 +385,8 @@ const char *ast_file_version_find(const char *file) if (iterator) return iterator->version; return NULL; -} - +} + struct thread_list_t { @@ -399,7 +399,7 @@ struct thread_list_t { static AST_RWLIST_HEAD_STATIC(thread_list, thread_list_t); void ast_register_thread(char *name) -{ +{ struct thread_list_t *new = ast_calloc(1, sizeof(*new)); if (!new) @@ -459,7 +459,7 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c else ast_cli(a->fd, " Maximum calls: Not set\n"); if (option_maxfiles) - ast_cli(a->fd, " Maximum open file handles: %d\n", option_maxfiles); + ast_cli(a->fd, " Maximum open file handles: %d\n", option_maxfiles); else ast_cli(a->fd, " Maximum open file handles: Not set\n"); ast_cli(a->fd, " Verbosity: %d\n", option_verbose); @@ -522,7 +522,7 @@ static char *handle_show_threads(struct ast_cli_entry *e, int cmd, struct ast_cl switch (cmd) { case CLI_INIT: e->command = "core show threads"; - e->usage = + e->usage = "Usage: core show threads\n" " List threads currently active in the system.\n"; return NULL; @@ -535,7 +535,7 @@ static char *handle_show_threads(struct ast_cli_entry *e, int cmd, struct ast_cl ast_cli(a->fd, "%p %d %s\n", (void *)cur->id, cur->lwp, cur->name); count++; } - AST_RWLIST_UNLOCK(&thread_list); + AST_RWLIST_UNLOCK(&thread_list); ast_cli(a->fd, "%d threads listed.\n", count); return CLI_SUCCESS; } @@ -754,7 +754,7 @@ int64_t ast_profile(int i, int64_t delta) #elif defined(linux) static __inline uint64_t rdtsc(void) -{ +{ uint64_t rv; __asm __volatile(".byte 0x0f, 0x31" : "=A" (rv)); @@ -877,7 +877,7 @@ static char *handle_show_version_files(struct ast_cli_entry *e, int cmd, struct switch (cmd) { case CLI_INIT: e->command = "core show file version [like]"; - e->usage = + e->usage = "Usage: core show file version [like <pattern>]\n" " Lists the revision numbers of the files used to build this copy of Asterisk.\n" " Optional regular expression pattern is used to filter the file list.\n"; @@ -954,7 +954,7 @@ int ast_register_atexit(void (*func)(void)) ae->func = func; - ast_unregister_atexit(func); + ast_unregister_atexit(func); AST_RWLIST_WRLOCK(&atexits); AST_RWLIST_INSERT_HEAD(&atexits, ae, list); @@ -1056,7 +1056,7 @@ int ast_safe_system(const char *s) pid = fork(); #else pid = vfork(); -#endif +#endif if (pid == 0) { #ifdef HAVE_CAP @@ -1082,7 +1082,7 @@ int ast_safe_system(const char *s) if (res > -1) { res = WIFEXITED(status) ? WEXITSTATUS(status) : -1; break; - } else if (errno != EINTR) + } else if (errno != EINTR) break; } } else { @@ -1149,7 +1149,7 @@ static void ast_network_puts_mutable(const char *string, int level) if (consoles[x].mute) continue; if (consoles[x].fd > -1) { - if (!consoles[x].levels[level]) + if (!consoles[x].levels[level]) fdprint(consoles[x].p[1], string); } } @@ -1173,7 +1173,7 @@ static void ast_network_puts(const char *string) { int x; for (x = 0; x < AST_MAX_CONNECTS; x++) { - if (consoles[x].fd > -1) + if (consoles[x].fd > -1) fdprint(consoles[x].p[1], string); } } @@ -1262,7 +1262,7 @@ static void *netconsole(void *vconsole) char tmp[512]; int res; struct pollfd fds[2]; - + if (gethostname(hostname, sizeof(hostname)-1)) ast_copy_string(hostname, "<Unknown>", sizeof(hostname)); snprintf(tmp, sizeof(tmp), "%s/%ld/%s\n", hostname, (long)ast_mainpid, ast_get_version()); @@ -1311,7 +1311,7 @@ static void *netconsole(void *vconsole) close(con->p[0]); close(con->p[1]); con->fd = -1; - + return NULL; } @@ -1400,14 +1400,14 @@ static int ast_makesocket(void) uid_t uid = -1; gid_t gid = -1; - for (x = 0; x < AST_MAX_CONNECTS; x++) + for (x = 0; x < AST_MAX_CONNECTS; x++) consoles[x].fd = -1; unlink(ast_config_AST_SOCKET); ast_socket = socket(PF_LOCAL, SOCK_STREAM, 0); if (ast_socket < 0) { ast_log(LOG_WARNING, "Unable to create control socket: %s\n", strerror(errno)); return -1; - } + } memset(&sunaddr, 0, sizeof(sunaddr)); sunaddr.sun_family = AF_LOCAL; ast_copy_string(sunaddr.sun_path, ast_config_AST_SOCKET, sizeof(sunaddr.sun_path)); @@ -1438,7 +1438,7 @@ static int ast_makesocket(void) else uid = pw->pw_uid; } - + if (!ast_strlen_zero(ast_config_AST_CTL_GROUP)) { struct group *grp; if ((grp = getgrnam(ast_config_AST_CTL_GROUP)) == NULL) @@ -1486,8 +1486,8 @@ static int ast_tryconnect(void) /*! \brief Urgent handler Called by soft_hangup to interrupt the poll, read, or other - system call. We don't actually need to do anything though. - Remember: Cannot EVER ast_log from within a signal handler + system call. We don't actually need to do anything though. + Remember: Cannot EVER ast_log from within a signal handler */ static void _urg_handler(int num) { @@ -1529,7 +1529,7 @@ static void _child_handler(int sig) */ for (n = 0; wait4(-1, &status, WNOHANG, NULL) > 0; n++) ; - if (n == 0 && option_debug) + if (n == 0 && option_debug) printf("Huh? Child handler, but nobody there?\n"); errno = save_errno; } @@ -1543,22 +1543,22 @@ static struct sigaction child_handler = { static void set_ulimit(int value) { struct rlimit l = {0, 0}; - + if (value <= 0) { ast_log(LOG_WARNING, "Unable to change max files open to invalid value %i\n",value); return; } - + l.rlim_cur = value; l.rlim_max = value; - + if (setrlimit(RLIMIT_NOFILE, &l)) { ast_log(LOG_WARNING, "Unable to disable core size resource limit: %s\n",strerror(errno)); return; } - + ast_log(LOG_NOTICE, "Setting max files open to %d\n",value); - + return; } @@ -1582,7 +1582,7 @@ int ast_set_priority(int pri) struct sched_param sched; memset(&sched, 0, sizeof(sched)); #ifdef __linux__ - if (pri) { + if (pri) { sched.sched_priority = 10; if (sched_setscheduler(0, SCHED_RR, &sched)) { ast_log(LOG_WARNING, "Unable to set high priority\n"); @@ -1614,7 +1614,7 @@ static void ast_run_atexits(void) struct ast_atexit *ae; AST_RWLIST_RDLOCK(&atexits); AST_RWLIST_TRAVERSE(&atexits, ae, list) { - if (ae->func) + if (ae->func) ae->func(); } AST_RWLIST_UNLOCK(&atexits); @@ -1756,7 +1756,7 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart) /* close logger */ close_logger(); - /* If there is a consolethread running send it a SIGHUP + /* If there is a consolethread running send it a SIGHUP so it can execvp, otherwise we can do it ourselves */ if ((consolethread != AST_PTHREADT_NULL) && (consolethread != pthread_self())) { pthread_kill(consolethread, SIGHUP); @@ -1764,7 +1764,7 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart) sleep(2); } else execvp(_argv[0], _argv); - + } else { /* close logger */ close_logger(); @@ -1846,7 +1846,7 @@ static int ast_all_zeros(char *s) while (*s) { if (*s > 32) return 0; - s++; + s++; } return 1; } @@ -1865,7 +1865,7 @@ static void consolehandler(char *s) ast_safe_system(s+1); else ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh"); - } else + } else ast_cli_command(STDOUT_FILENO, s); } @@ -1925,7 +1925,7 @@ static char *handle_version(struct ast_cli_entry *e, int cmd, struct ast_cli_arg switch (cmd) { case CLI_INIT: e->command = "core show version"; - e->usage = + e->usage = "Usage: core show version\n" " Shows Asterisk version information.\n"; return NULL; @@ -1956,7 +1956,7 @@ static char *handle_stop_now(struct ast_cli_entry *e, int cmd, struct ast_cli_ar switch (cmd) { case CLI_INIT: e->command = "core stop now"; - e->usage = + e->usage = "Usage: core stop now\n" " Shuts down a running Asterisk immediately, hanging up all active calls .\n"; return NULL; @@ -1975,7 +1975,7 @@ static char *handle_stop_gracefully(struct ast_cli_entry *e, int cmd, struct ast switch (cmd) { case CLI_INIT: e->command = "core stop gracefully"; - e->usage = + e->usage = "Usage: core stop gracefully\n" " Causes Asterisk to not accept new calls, and exit when all\n" " active calls have terminated normally.\n"; @@ -1995,7 +1995,7 @@ static char *handle_stop_when_convenient(struct ast_cli_entry *e, int cmd, struc switch (cmd) { case CLI_INIT: e->command = "core stop when convenient"; - e->usage = + e->usage = "Usage: core stop when convenient\n" " Causes Asterisk to perform a shutdown when all active calls have ended.\n"; return NULL; @@ -2015,7 +2015,7 @@ static char *handle_restart_now(struct ast_cli_entry *e, int cmd, struct ast_cli switch (cmd) { case CLI_INIT: e->command = "core restart now"; - e->usage = + e->usage = "Usage: core restart now\n" " Causes Asterisk to hangup all calls and exec() itself performing a cold\n" " restart.\n"; @@ -2035,7 +2035,7 @@ static char *handle_restart_gracefully(struct ast_cli_entry *e, int cmd, struct switch (cmd) { case CLI_INIT: e->command = "core restart gracefully"; - e->usage = + e->usage = "Usage: core restart gracefully\n" " Causes Asterisk to stop accepting new calls and exec() itself performing a cold\n" " restart when all active calls have ended.\n"; @@ -2055,7 +2055,7 @@ static char *handle_restart_when_convenient(struct ast_cli_entry *e, int cmd, st switch (cmd) { case CLI_INIT: e->command = "core restart when convenient"; - e->usage = + e->usage = "Usage: core restart when convenient\n" " Causes Asterisk to perform a cold restart when all active calls have ended.\n"; return NULL; @@ -2077,7 +2077,7 @@ static char *handle_abort_shutdown(struct ast_cli_entry *e, int cmd, struct ast_ switch (cmd) { case CLI_INIT: e->command = "core abort shutdown"; - e->usage = + e->usage = "Usage: core abort shutdown\n" " Causes Asterisk to abort an executing shutdown or restart, and resume normal\n" " call operations.\n"; @@ -2107,7 +2107,7 @@ static char *handle_bang(struct ast_cli_entry *e, int cmd, struct ast_cli_args * switch (cmd) { case CLI_INIT: e->command = "!"; - e->usage = + e->usage = "Usage: !<command>\n" " Executes a given shell command\n"; return NULL; @@ -2147,7 +2147,7 @@ static char *show_warranty(struct ast_cli_entry *e, int cmd, struct ast_cli_args switch (cmd) { case CLI_INIT: e->command = "core show warranty"; - e->usage = + e->usage = "Usage: core show warranty\n" " Shows the warranty (if any) for this copy of Asterisk.\n"; return NULL; @@ -2184,7 +2184,7 @@ static char *show_license(struct ast_cli_entry *e, int cmd, struct ast_cli_args switch (cmd) { case CLI_INIT: e->command = "core show license"; - e->usage = + e->usage = "Usage: core show license\n" " Shows the license(s) for this copy of Asterisk.\n"; return NULL; @@ -2206,7 +2206,7 @@ static struct ast_cli_entry cli_asterisk[] = { AST_CLI_DEFINE(handle_stop_now, "Shut down Asterisk immediately"), AST_CLI_DEFINE(handle_stop_gracefully, "Gracefully shut down Asterisk"), AST_CLI_DEFINE(handle_stop_when_convenient, "Shut down Asterisk at empty call volume"), - AST_CLI_DEFINE(handle_restart_now, "Restart Asterisk immediately"), + AST_CLI_DEFINE(handle_restart_now, "Restart Asterisk immediately"), AST_CLI_DEFINE(handle_restart_gracefully, "Restart Asterisk gracefully"), AST_CLI_DEFINE(handle_restart_when_convenient, "Restart Asterisk at empty call volume"), AST_CLI_DEFINE(show_warranty, "Show the warranty (if any) for this copy of Asterisk"), @@ -2300,7 +2300,7 @@ static int ast_el_read_char(EditLine *editline, char *cp) WELCOME_MESSAGE; if (!ast_opt_mute) fdsend(ast_consock, "logger mute silent"); - else + else printf("log and verbose output currently muted ('logger mute' to unmute)\n"); break; } else @@ -2487,7 +2487,7 @@ static char *cli_prompt(EditLine *editline) ast_str_set(&prompt, 0, "%s", ASTERISK_PROMPT); } - return ast_str_buffer(prompt); + return ast_str_buffer(prompt); } static char **ast_el_strtoarr(char *buf) @@ -2619,7 +2619,7 @@ static char *cli_complete(EditLine *editline, int ch) len = lf->cursor - ptr; if (ast_opt_remote) { - snprintf(buf, sizeof(buf), "_COMMAND NUMMATCHES \"%s\" \"%s\"", lf->buffer, ptr); + snprintf(buf, sizeof(buf), "_COMMAND NUMMATCHES \"%s\" \"%s\"", lf->buffer, ptr); fdsend(ast_consock, buf); res = read(ast_consock, buf, sizeof(buf) - 1); buf[res] = '\0'; @@ -2628,19 +2628,19 @@ static char *cli_complete(EditLine *editline, int ch) if (nummatches > 0) { char *mbuf; int mlen = 0, maxmbuf = 2048; - /* Start with a 2048 byte buffer */ + /* Start with a 2048 byte buffer */ if (!(mbuf = ast_malloc(maxmbuf))) { lf->cursor[0] = savechr; return (char *)(CC_ERROR); } - snprintf(buf, sizeof(buf), "_COMMAND MATCHESARRAY \"%s\" \"%s\"", lf->buffer, ptr); + snprintf(buf, sizeof(buf), "_COMMAND MATCHESARRAY \"%s\" \"%s\"", lf->buffer, ptr); fdsend(ast_consock, buf); res = 0; mbuf[0] = '\0'; while (!strstr(mbuf, AST_CLI_COMPLETE_EOF) && res != -1) { if (mlen + 1024 > maxmbuf) { /* Every step increment buffer 1024 bytes */ - maxmbuf += 1024; + maxmbuf += 1024; if (!(mbuf = ast_realloc(mbuf, maxmbuf))) { lf->cursor[0] = savechr; return (char *)(CC_ERROR); @@ -2694,7 +2694,7 @@ static char *cli_complete(EditLine *editline, int ch) fprintf(stdout, "\n"); ast_cli_display_match_list(matches, nummatches, maxlen); retval = CC_REDISPLAY; - } else { + } else { el_insertstr(editline," "); retval = CC_REFRESH; } @@ -2728,7 +2728,7 @@ static int ast_el_initialize(void) el = el_init("asterisk", stdin, stdout, stderr); el_set(el, EL_PROMPT, cli_prompt); - el_set(el, EL_EDITMODE, 1); + el_set(el, EL_EDITMODE, 1); el_set(el, EL_EDITOR, editor); el_hist = history_init(); if (!el || !el_hist) @@ -2928,7 +2928,7 @@ static void ast_remotecontrol(char *data) ast_verbose("Connected to Asterisk %s currently running on %s (pid = %d)\n", version, hostname, pid); remotehostname = hostname; - if (getenv("HOME")) + if (getenv("HOME")) snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME")); if (el_hist == NULL || el == NULL) ast_el_initialize(); @@ -3009,7 +3009,7 @@ static int show_cli_help(void) return 0; } -static void ast_readconfig(void) +static void ast_readconfig(void) { struct ast_config *cfg; struct ast_variable *v; @@ -3025,14 +3025,14 @@ static void ast_readconfig(void) cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags); if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) ast_log(LOG_WARNING, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE); - } else + } else cfg = ast_config_load2(config, "" /* core, can't reload */, config_flags); /* init with buildtime config */ ast_copy_string(cfg_paths.config_dir, DEFAULT_CONFIG_DIR, sizeof(cfg_paths.config_dir)); ast_copy_string(cfg_paths.spool_dir, DEFAULT_SPOOL_DIR, sizeof(cfg_paths.spool_dir)); ast_copy_string(cfg_paths.module_dir, DEFAULT_MODULE_DIR, sizeof(cfg_paths.module_dir)); - snprintf(cfg_paths.monitor_dir, sizeof(cfg_paths.monitor_dir), "%s/monitor", cfg_paths.spool_dir); + snprintf(cfg_paths.monitor_dir, sizeof(cfg_paths.monitor_dir), "%s/monitor", cfg_paths.spool_dir); ast_copy_string(cfg_paths.var_dir, DEFAULT_VAR_DIR, sizeof(cfg_paths.var_dir)); ast_copy_string(cfg_paths.data_dir, DEFAULT_DATA_DIR, sizeof(cfg_paths.data_dir)); ast_copy_string(cfg_paths.log_dir, DEFAULT_LOG_DIR, sizeof(cfg_paths.log_dir)); @@ -3197,15 +3197,15 @@ static void ast_readconfig(void) ast_language_is_prefix = ast_true(v->value); } else if (!strcasecmp(v->name, "defaultlanguage")) { ast_copy_string(defaultlanguage, v->value, MAX_LANGUAGE); - } else if (!strcasecmp(v->name, "lockmode")) { - if (!strcasecmp(v->value, "lockfile")) { - ast_set_lock_type(AST_LOCK_TYPE_LOCKFILE); - } else if (!strcasecmp(v->value, "flock")) { - ast_set_lock_type(AST_LOCK_TYPE_FLOCK); - } else { + } else if (!strcasecmp(v->name, "lockmode")) { + if (!strcasecmp(v->value, "lockfile")) { + ast_set_lock_type(AST_LOCK_TYPE_LOCKFILE); + } else if (!strcasecmp(v->value, "flock")) { + ast_set_lock_type(AST_LOCK_TYPE_FLOCK); + } else { ast_log(LOG_WARNING, "'%s' is not a valid setting for the lockmode option, " "defaulting to 'lockfile'\n", v->value); - ast_set_lock_type(AST_LOCK_TYPE_LOCKFILE); + ast_set_lock_type(AST_LOCK_TYPE_LOCKFILE); } #if defined(HAVE_SYSINFO) } else if (!strcasecmp(v->name, "minmemfree")) { @@ -3398,7 +3398,7 @@ int main(int argc, char *argv[]) ast_fd_init(); ast_pbx_init(); - if (getenv("HOME")) + if (getenv("HOME")) snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME")); /* Check for options */ while ((c = getopt(argc, argv, "BC:cde:FfG:ghIiL:M:mnpqRrs:TtU:VvWXx:")) != -1) { @@ -3524,7 +3524,7 @@ int main(int argc, char *argv[]) WELCOME_MESSAGE; } - if (ast_opt_console && !option_verbose) + if (ast_opt_console && !option_verbose) ast_verbose("[ Booting...\n"); /* For remote connections, change the name of the remote connection. @@ -3750,7 +3750,7 @@ int main(int argc, char *argv[]) /* custom config setup */ register_config_cli(); read_config_maps(); - + if (ast_opt_console) { if (el_hist == NULL || el == NULL) ast_el_initialize(); |