* \param prompt The file to stream to the channel
* \param s The string to read in to. Must be at least the size of your length
* \param maxlen How many digits to read (maximum)
- * \param timeout set timeout to 0 for "standard" timeouts. Set timeout to -1 for
+ * \param timeout set timeout to 0 for "standard" timeouts. Set timeout to -1 for
* "ludicrous time" (essentially never times out) */
enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
{
return r;
}
-int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path)
+int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path)
{
int silencethreshold;
int maxsilence = 0;
*
* \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
/*! \file
\brief Top level source file for Asterisk - the Open Source PBX. Implementation
of PBX core functions and CLI interface.
-
+
*/
#include "asterisk.h"
/*! \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
*/
/*! @{ */
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;
if (iterator)
return iterator->version;
return NULL;
-}
-
+}
+
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)
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);
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;
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;
}
#elif defined(linux)
static __inline uint64_t
rdtsc(void)
-{
+{
uint64_t rv;
__asm __volatile(".byte 0x0f, 0x31" : "=A" (rv));
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";
ae->func = func;
- ast_unregister_atexit(func);
+ ast_unregister_atexit(func);
AST_RWLIST_WRLOCK(&atexits);
AST_RWLIST_INSERT_HEAD(&atexits, ae, list);
pid = fork();
#else
pid = vfork();
-#endif
+#endif
if (pid == 0) {
#ifdef HAVE_CAP
if (res > -1) {
res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
break;
- } else if (errno != EINTR)
+ } else if (errno != EINTR)
break;
}
} else {
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);
}
}
{
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);
}
}
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());
close(con->p[0]);
close(con->p[1]);
con->fd = -1;
-
+
return NULL;
}
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));
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)
/*! \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)
{
*/
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;
}
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;
}
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");
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);
/* 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);
sleep(2);
} else
execvp(_argv[0], _argv);
-
+
} else {
/* close logger */
close_logger();
while (*s) {
if (*s > 32)
return 0;
- s++;
+ s++;
}
return 1;
}
ast_safe_system(s+1);
else
ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
- } else
+ } else
ast_cli_command(STDOUT_FILENO, s);
}
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;
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;
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";
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;
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";
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";
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;
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";
switch (cmd) {
case CLI_INIT:
e->command = "!";
- e->usage =
+ e->usage =
"Usage: !<command>\n"
" Executes a given shell command\n";
return NULL;
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;
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;
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"),
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
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)
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';
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);
fprintf(stdout, "\n");
ast_cli_display_match_list(matches, nummatches, maxlen);
retval = CC_REDISPLAY;
- } else {
+ } else {
el_insertstr(editline," ");
retval = CC_REFRESH;
}
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)
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();
return 0;
}
-static void ast_readconfig(void)
+static void ast_readconfig(void)
{
struct ast_config *cfg;
struct ast_variable *v;
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));
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")) {
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) {
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.
/* custom config setup */
register_config_cli();
read_config_maps();
-
+
if (ast_opt_console) {
if (el_hist == NULL || el == NULL)
ast_el_initialize();
int hash = HASH(ptr);
struct ast_region *reg;
size_t len = 0;
-
+
ast_mutex_lock(®lock);
for (reg = regions[hash]; reg; reg = reg->next) {
if (reg->data == ptr) {
}
free(reg);
} else {
- astmm_log("WARNING: Freeing unused memory at %p, in %s of %s, line %d\n",
+ astmm_log("WARNING: Freeing unused memory at %p, in %s of %s, line %d\n",
ptr, func, file, lineno);
}
}
-void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
+void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
{
void *ptr;
- if ((ptr = __ast_alloc_region(size * nmemb, FUNC_CALLOC, file, lineno, func, 0)))
+ if ((ptr = __ast_alloc_region(size * nmemb, FUNC_CALLOC, file, lineno, func, 0)))
memset(ptr, 0, size * nmemb);
return ptr;
}
-void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
+void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
{
void *ptr;
- if ((ptr = __ast_alloc_region(size * nmemb, FUNC_CALLOC, file, lineno, func, 1)))
+ if ((ptr = __ast_alloc_region(size * nmemb, FUNC_CALLOC, file, lineno, func, 1)))
memset(ptr, 0, size * nmemb);
return ptr;
}
-void *__ast_malloc(size_t size, const char *file, int lineno, const char *func)
+void *__ast_malloc(size_t size, const char *file, int lineno, const char *func)
{
return __ast_alloc_region(size, FUNC_MALLOC, file, lineno, func, 0);
}
-void __ast_free(void *ptr, const char *file, int lineno, const char *func)
+void __ast_free(void *ptr, const char *file, int lineno, const char *func)
{
__ast_free_region(ptr, file, lineno, func);
}
-void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func)
+void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func)
{
void *tmp;
size_t len = 0;
memcpy(tmp, ptr, len);
__ast_free_region(ptr, file, lineno, func);
}
-
+
return tmp;
}
-char *__ast_strdup(const char *s, const char *file, int lineno, const char *func)
+char *__ast_strdup(const char *s, const char *file, int lineno, const char *func)
{
size_t len;
void *ptr;
return ptr;
}
-char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func)
+char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func)
{
size_t len;
void *ptr;
return size;
}
-int __ast_vasprintf(char **strp, const char *fmt, va_list ap, const char *file, int lineno, const char *func)
+int __ast_vasprintf(char **strp, const char *fmt, va_list ap, const char *file, int lineno, const char *func)
{
int size;
va_list ap2;
fence = (unsigned int *)(reg->data + reg->len);
if (reg->fence != FENCE_MAGIC) {
astmm_log("WARNING: Low fence violation at %p, "
- "in %s of %s, line %d\n", reg->data,
+ "in %s of %s, line %d\n", reg->data,
reg->func, reg->file, reg->lineno);
}
if (get_unaligned_uint32(fence) != FENCE_MAGIC) {
}
}
if (!fn || !strcasecmp(fn, reg->file)) {
- ast_cli(a->fd, "%10d bytes allocated%s in %20s at line %5d of %s\n",
- (int) reg->len, reg->cache ? " (cache)" : "",
+ ast_cli(a->fd, "%10d bytes allocated%s in %20s at line %5d of %s\n",
+ (int) reg->len, reg->cache ? " (cache)" : "",
reg->func, reg->lineno, reg->file);
len += reg->len;
if (reg->cache)
}
}
ast_mutex_unlock(®lock);
-
+
if (cache_len)
ast_cli(a->fd, "%d bytes allocated (%d in caches) in %d allocations\n", len, cache_len, count);
else
ast_cli(a->fd, "%d bytes allocated in %d allocations\n", len, count);
-
+
return CLI_SUCCESS;
}
int count;
struct file_summary *next;
} *list = NULL, *cur;
-
+
switch (cmd) {
case CLI_INIT:
e->command = "memory show summary";
return NULL;
}
- if (a->argc > 3)
+ if (a->argc > 3)
fn = a->argv[3];
ast_mutex_lock(®lock);
}
}
ast_mutex_unlock(®lock);
-
+
/* Dump the whole list */
for (cur = list; cur; cur = cur->next) {
len += cur->len;
count += cur->count;
if (cur->cache_len) {
if (fn) {
- ast_cli(a->fd, "%10d bytes (%10d cache) in %d allocations in function '%s' of '%s'\n",
+ ast_cli(a->fd, "%10d bytes (%10d cache) in %d allocations in function '%s' of '%s'\n",
cur->len, cur->cache_len, cur->count, cur->fn, fn);
} else {
- ast_cli(a->fd, "%10d bytes (%10d cache) in %d allocations in file '%s'\n",
+ ast_cli(a->fd, "%10d bytes (%10d cache) in %d allocations in file '%s'\n",
cur->len, cur->cache_len, cur->count, cur->fn);
}
} else {
if (fn) {
- ast_cli(a->fd, "%10d bytes in %d allocations in function '%s' of '%s'\n",
+ ast_cli(a->fd, "%10d bytes in %d allocations in function '%s' of '%s'\n",
cur->len, cur->count, cur->fn, fn);
} else {
- ast_cli(a->fd, "%10d bytes in %d allocations in file '%s'\n",
+ ast_cli(a->fd, "%10d bytes in %d allocations in file '%s'\n",
cur->len, cur->count, cur->fn);
}
}
}
ast_cli_register_multiple(cli_memory, ARRAY_LEN(cli_memory));
-
+
snprintf(filename, sizeof(filename), "%s/mmlog", ast_config_AST_LOG_DIR);
-
+
ast_verb(1, "Asterisk Malloc Debugger Started (see %s))\n", filename);
-
+
if ((mmlog = fopen(filename, "a+"))) {
fprintf(mmlog, "%ld - New session\n", (long)time(NULL));
fflush(mmlog);
/* Ensure the factory is able to give us the samples we want */
if (samples > ast_slinfactory_available(factory))
return NULL;
-
+
/* Read data in from factory */
if (!ast_slinfactory_read(factory, buf, samples))
return NULL;
samples_converted = samples * (ast_format_rate(format) / (float) audiohook->hook_internal_samp_rate);
}
- if (!(read_frame = (direction == AST_AUDIOHOOK_DIRECTION_BOTH ?
- audiohook_read_frame_both(audiohook, samples_converted, read_reference, write_reference) :
- audiohook_read_frame_single(audiohook, samples_converted, direction)))) {
- return NULL;
+ if (!(read_frame = (direction == AST_AUDIOHOOK_DIRECTION_BOTH ?
+ audiohook_read_frame_both(audiohook, samples_converted, read_reference, write_reference) :
+ audiohook_read_frame_single(audiohook, samples_converted, direction)))) {
+ return NULL;
}
/* If they don't want signed linear back out, we'll have to send it through the translation path */
if (audiohook_list->out_translate[i].trans_pvt)
ast_translator_free_path(audiohook_list->out_translate[i].trans_pvt);
}
-
+
/* Free ourselves */
ast_free(audiohook_list);
* because no translation to SLINEAR audio was required.
* Part_3: Translate end_frame's audio back into the format of start frame if necessary. This
* is only necessary if manipulation of middle_frame occurred.
- *
+ *
* \param chan Channel that the list is coming off of
* \param audiohook_list List of audiohooks
* \param direction Direction frame is coming in from
wait = ast_tvadd(ast_tvnow(), ast_samp2tv(50000, 1000));
ts.tv_sec = wait.tv_sec;
ts.tv_nsec = wait.tv_usec * 1000;
-
+
ast_cond_timedwait(&audiohook->trigger, &audiohook->lock, &ts);
-
+
return;
}
*
* \brief Automatic channel service routines
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
* \author Russell Bryant <russell@digium.com>
*/
struct asent {
struct ast_channel *chan;
/*! This gets incremented each time autoservice gets started on the same
- * channel. It will ensure that it doesn't actually get stopped until
+ * channel. It will ensure that it doesn't actually get stopped until
* it gets stopped for the last time. */
unsigned int use_count;
unsigned int orig_end_dtmf_flag:1;
if (defer_frame) {
for (i = 0; i < x; i++) {
struct ast_frame *dup_f;
-
+
if (mons[i] != chan) {
continue;
}
-
+
if (defer_frame != f) {
if ((dup_f = ast_frdup(defer_frame))) {
AST_LIST_INSERT_HEAD(&ents[i]->deferred_frames, dup_f, frame_list);
AST_LIST_INSERT_HEAD(&ents[i]->deferred_frames, dup_f, frame_list);
}
}
-
+
break;
}
} else if (f) {
if (!(as = ast_calloc(1, sizeof(*as))))
return -1;
-
+
/* New entry created */
as->chan = chan;
as->use_count = 1;
/* Find the entry, but do not free it because it still can be in the
autoservice thread array */
- AST_LIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) {
if (as->chan == chan) {
as->use_count--;
if (as->use_count < 1) {
/*! \file
*
- * \brief CallerID Generation support
+ * \brief CallerID Generation support
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
*/
#include "asterisk.h"
int sawflag;
int len;
- int skipflag;
+ int skipflag;
unsigned short crc;
};
*cr1 = t;
t = 2.0 - (*cr1 * *cr1 + *ci1 * *ci1);
*cr1 *= t;
- *ci1 *= t;
+ *ci1 *= t;
t = *cr2 * ddr2 - *ci2 * ddi2;
*ci2 = *cr2 * ddi2 + *ci2 * ddr2;
*cr2 = t;
t = 2.0 - (*cr2 * *cr2 + *ci2 * *ci2);
*cr2 *= t;
- *ci2 *= t;
+ *ci2 *= t;
buf[x] = AST_LIN2X((*cr1 + *cr2) * 2048.0);
}
}
*cr1 = t;
t = 2.0 - (*cr1 * *cr1 + *ci1 * *ci1);
*cr1 *= t;
- *ci1 *= t;
+ *ci1 *= t;
buf[x] = AST_LIN2X(*cr1 * 8192.0);
}
}
if ((cid = ast_calloc(1, sizeof(*cid)))) {
#ifdef INTEGER_CALLERID
- cid->fskd.ispb = 7; /* 1200 baud */
+ cid->fskd.ispb = 7; /* 1200 baud */
/* Set up for 1200 / 8000 freq *32 to allow ints */
cid->fskd.pllispb = (int)(8000 * 32 / 1200);
cid->fskd.pllids = cid->fskd.pllispb/32;
cid->fskd.pllispb2 = cid->fskd.pllispb/2;
-
+
cid->fskd.icont = 0; /* PLL REset */
/* cid->fskd.hdlc = 0; */ /* Async */
cid->fskd.nbit = 8; /* 8 bits */
*flags = CID_UNKNOWN_NUMBER;
return;
}
-
+
/* Detect protocol and special types */
if (cidstring[0] == 'B') {
/* Handle special codes */
code = atoi(&cidstring[1]);
if (code == 0)
*flags = CID_UNKNOWN_NUMBER;
- else if (code == 10)
+ else if (code == 10)
*flags = CID_PRIVATE_NUMBER;
else
ast_debug(1, "Unknown DTMF code %d\n", code);
for (i = 0; i < CHAR_BIT; i++) {
org <<= 1;
dst >>= 1;
- if (org & 0x100)
+ if (org & 0x100)
dst |= 0x80;
}
data = (unsigned char) dst;
else
crc <<= 1 ;
}
- return crc;
+ return crc;
}
int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, struct ast_format *codec)
memcpy(buf, cid->oldstuff, cid->oldlen);
mylen += cid->oldlen / 2;
- for (x = 0; x < len; x++)
+ for (x = 0; x < len; x++)
buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]);
while (mylen >= 160) {
}
break;
case 1: /* SOH */
- if (b == 0x01)
+ if (b == 0x01)
cid->sawflag = 2;
break ;
case 2: /* HEADER */
- if (b == 0x07)
+ if (b == 0x07)
cid->sawflag = 3;
break;
case 3: /* STX */
- if (b == 0x02)
+ if (b == 0x02)
cid->sawflag = 4;
break;
case 4: /* SERVICE TYPE */
- if (b == 0x40)
+ if (b == 0x40)
cid->sawflag = 5;
break;
case 5: /* Frame Length */
cid->sawflag = 6;
- break;
+ break;
case 6: /* NUMBER TYPE */
cid->sawflag = 7;
cid->pos = 0;
if (cid->crc != 0) {
ast_log(LOG_WARNING, "crc checksum error\n") ;
return -1;
- }
+ }
/* extract caller id data */
for (x = 0; x < cid->pos;) {
switch (cid->rawdata[x++]) {
break;
case 0x21: /* additional information */
/* length */
- x++;
+ x++;
/* number type */
- switch (cid->rawdata[x]) {
+ switch (cid->rawdata[x]) {
case 0x00: /* unknown */
case 0x01: /* international number */
case 0x02: /* domestic number */
ast_debug(2, "cid info:#1=%X\n", cid->rawdata[x]);
break ;
}
- x++;
+ x++;
/* numbering plan octed 4 */
- x++;
+ x++;
/* numbering plan octed 5 */
- switch (cid->rawdata[x]) {
+ switch (cid->rawdata[x]) {
case 0x00: /* unknown */
case 0x01: /* recommendation E.164 ISDN */
case 0x03: /* recommendation X.121 */
ast_debug(2, "cid info:#2=%X\n", cid->rawdata[x]);
break ;
}
- x++;
+ x++;
break ;
case 0x04: /* no callerid reason */
/* length */
- x++;
+ x++;
/* no callerid reason code */
switch (cid->rawdata[x]) {
case 'P': /* caller id denied by user */
ast_debug(2, "no cid reason:%c\n", cid->rawdata[x]);
break ;
}
- x++;
+ x++;
break ;
case 0x09: /* dialed number */
/* length */
cid->oldlen = mylen * 2;
} else
cid->oldlen = 0;
-
+
return 0;
}
memcpy(buf, cid->oldstuff, cid->oldlen);
mylen += cid->oldlen/2;
- for (x = 0; x < len; x++)
+ for (x = 0; x < len; x++)
buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]);
while (mylen >= 160) {
olen = mylen;
cid->sawflag = 0;
break;
}
-
+
cid->number[0] = '\0';
cid->name[0] = '\0';
/* Update flags */
res = cid->rawdata[x];
if (res > 32) {
ast_log(LOG_NOTICE, "Truncating long caller ID number from %d bytes to 32\n", cid->rawdata[x]);
- res = 32;
+ res = 32;
}
if (ast_strlen_zero(cid->number)) {
memcpy(cid->number, cid->rawdata + x + 1, res);
res = cid->rawdata[x];
if (res > 32) {
ast_log(LOG_NOTICE, "Truncating long caller ID name from %d bytes to 32\n", cid->rawdata[x]);
- res = 32;
+ res = 32;
}
memcpy(cid->name, cid->rawdata + x + 1, res);
cid->name[res] = '\0';
ast_log(LOG_NOTICE, "IE %d has bad field length of %d at offset %d\n", cid->rawdata[x-1], cid->rawdata[x], x);
/* Try again */
cid->sawflag = 0;
- break; /* Exit the loop */
+ break; /* Exit the loop */
}
x += cid->rawdata[x];
x++;
/* Get the time */
ast_localtime(&now, &tm, NULL);
-
+
ptr = msg;
-
+
/* Format time and message header */
res = snprintf(ptr, size, "\001\010%02d%02d%02d%02d", tm.tm_mon + 1,
tm.tm_mday, tm.tm_hour, tm.tm_min);
size -= i;
}
return (ptr - msg);
-
+
}
int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, struct ast_format *codec,
float cr = 1.0;
float ci = 0.0;
float scont = 0.0;
-
+
if (type == CID_MWI_TYPE_MDMF_FULL) {
/* MDMF Message waiting with date, number, name and MWI parameter */
msg[0] = 0x82;
/* put date, number info at the right place */
- len = callerid_genmsg(msg+2, sizeof(msg)-2, number, name, flags);
-
+ len = callerid_genmsg(msg+2, sizeof(msg)-2, number, name, flags);
+
/* length of MDMF CLI plus Message Waiting Structure */
msg[1] = len+3;
-
+
/* Go to the position to write to */
len = len+2;
-
+
/* "Message Waiting Parameter" */
msg[len++] = 0x0b;
/* Length of IE is one */
msg[len++] = 0xff;
else
msg[len++] = 0x00;
-
+
} else if (type == CID_MWI_TYPE_MDMF) {
/* MDMF Message waiting only */
/* same as above except that the we only put MWI parameter */
/* Send 50 more ms of marks */
for (x = 0; x < 50; x++)
PUT_CLID_MARKMS;
-
+
return bytes;
}
unknown = "<unknown>";
if (name && num)
snprintf(buf, bufsiz, "\"%s\" <%s>", name, num);
- else if (name)
+ else if (name)
ast_copy_string(buf, name, bufsiz);
else if (num)
ast_copy_string(buf, num, bufsiz);
/*! \brief CEL is off by default */
#define CEL_ENABLED_DEFAULT 0
-/*!
- * \brief which events we want to track
+/*!
+ * \brief which events we want to track
*
* \note bit field, up to 64 events
*/
*/
#define CEL_MAX_EVENT_IDS 64
-/*!
+/*!
* \brief Track no events by default.
*/
#define CEL_DEFAULT_EVENTS 0
AST_THREADSTORAGE(state2str_threadbuf);
#define STATE2STR_BUFSIZE 32
-/*! Default amount of time to use when emulating a digit as a begin and end
+/*! Default amount of time to use when emulating a digit as a begin and end
* 100ms */
#define AST_DEFAULT_EMULATE_DTMF_DURATION 100
/*! Minimum allowed digit length - 80ms */
#define AST_MIN_DTMF_DURATION 80
-/*! Minimum amount of time between the end of the last digit and the beginning
+/*! Minimum amount of time between the end of the last digit and the beginning
* of a new one - 45ms */
#define AST_MIN_DTMF_GAP 45
/*! \brief All active channels on the system */
static struct ao2_container *channels;
-/*! \brief map AST_CAUSE's to readable string representations
+/*! \brief map AST_CAUSE's to readable string representations
*
* \ref causes.h
*/
}
}
AST_RWLIST_UNLOCK(&backends);
-
+
return ret;
}
if (a->argc != 4)
return CLI_SHOWUSAGE;
-
+
AST_RWLIST_RDLOCK(&backends);
AST_RWLIST_TRAVERSE(&backends, cl, list) {
(cl->tech->send_html) ? "yes" : "no",
(cl->tech->send_image) ? "yes" : "no",
(cl->tech->send_text) ? "yes" : "no"
-
+
);
AST_RWLIST_UNLOCK(&backends);
struct ast_chan_trace_data *traced;
if (!store) {
store = ast_datastore_alloc(&ast_chan_trace_datastore_info, "ChanTrace");
- if (!store)
+ if (!store)
return -1;
traced = ast_calloc(1, sizeof(*traced));
if (!traced) {
ast_datastore_free(store);
return -1;
- }
+ }
store->data = traced;
AST_LIST_HEAD_INIT_NOLOCK(&traced->trace);
ast_channel_datastore_add(chan, store);
- }
+ }
((struct ast_chan_trace_data *)store->data)->enabled = 1;
ast_channel_trace_data_update(chan, store->data);
return 0;
AST_LIST_REMOVE_CURRENT(list);
ast_free(chan);
ast_verb(2, "Unregistered channel type '%s'\n", tech->type);
- break;
+ break;
}
}
AST_LIST_TRAVERSE_SAFE_END;
}
AST_RWLIST_UNLOCK(&backends);
-
+
return ret;
}
return ast_channel_unref(tmp);
}
ast_channel_sched_set(tmp, schedctx);
-
+
ast_party_dialed_init(ast_channel_dialed(tmp));
ast_party_caller_init(ast_channel_caller(tmp));
ast_party_connected_line_init(ast_channel_connected(tmp));
ast_channel_state_set(tmp, state);
ast_channel_streamid_set(tmp, -1);
-
+
ast_channel_fin_set(tmp, global_fin);
ast_channel_fout_set(tmp, global_fout);
if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) {
- ast_channel_uniqueid_build(tmp, "%li.%d", (long) time(NULL),
+ ast_channel_uniqueid_build(tmp, "%li.%d", (long) time(NULL),
ast_atomic_fetchadd_int(&uniqueint, 1));
} else {
- ast_channel_uniqueid_build(tmp, "%s-%li.%d", ast_config_AST_SYSTEM_NAME,
+ ast_channel_uniqueid_build(tmp, "%s-%li.%d", ast_config_AST_SYSTEM_NAME,
(long) time(NULL), ast_atomic_fetchadd_int(&uniqueint, 1));
}
/* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call.
* And they all use slightly different formats for their name string.
* This means, to set the name here, we have to accept variable args, and call the string_field_build from here.
- * This means, that the stringfields must have a routine that takes the va_lists directly, and
+ * This means, that the stringfields must have a routine that takes the va_lists directly, and
* uses them to build the string, instead of forming the va_lists internally from the vararg ... list.
* This new function was written so this can be accomplished.
*/
} else {
ast_channel_amaflags_set(tmp, ast_default_amaflags);
}
-
+
if (!ast_strlen_zero(acctcode))
ast_channel_accountcode_set(tmp, acctcode);
else
ast_channel_accountcode_set(tmp, ast_default_accountcode);
-
+
ast_channel_context_set(tmp, S_OR(context, "default"));
ast_channel_exten_set(tmp, S_OR(exten, "s"));
ast_channel_priority_set(tmp, 1);
headp = ast_channel_varshead(tmp);
AST_LIST_HEAD_INIT_NOLOCK(headp);
-
+
AST_LIST_HEAD_INIT_NOLOCK(ast_channel_datastores(tmp));
AST_LIST_HEAD_INIT_NOLOCK(ast_channel_autochans(tmp));
-
+
ast_channel_language_set(tmp, defaultlanguage);
ast_channel_tech_set(tmp, &null_tech);
"Exten: %s\r\n"
"Context: %s\r\n"
"Uniqueid: %s\r\n",
- ast_channel_name(tmp),
- state,
+ ast_channel_name(tmp),
+ state,
ast_state2str(state),
S_OR(cid_num, ""),
S_OR(cid_name, ""),
ast_frfree(f);
continue;
}
-
+
if ((dup_f = ast_frisolate(f))) {
if (dup_f != f) {
ast_frfree(f);
#endif
while ((f = AST_LIST_REMOVE_HEAD(ast_channel_readq(chan), frame_list)))
ast_frfree(f);
-
+
/* loop over the variables list, freeing all data and deleting list items */
/* no need to lock the list, as the channel is already locked */
headp = ast_channel_varshead(chan);
struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
{
struct ast_datastore *datastore = NULL;
-
+
if (info == NULL)
return NULL;
if (fd > -1) {
if (!aed && (!(aed = ast_calloc(1, sizeof(*aed)))))
return;
-
+
ast_channel_internal_epfd_data_set(chan, which, aed);
aed->chan = chan;
aed->which = which;
-
+
ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
ev.data.ptr = aed;
epoll_ctl(ast_channel_epfd(chan), EPOLL_CTL_ADD, fd, &ev);
*outfd = -99999;
if (exception)
*exception = 0;
-
+
/* Perform any pending masquerades */
for (x = 0; x < n; x++) {
if (ast_channel_masq(c[x]) && ast_do_masquerade(c[x])) {
if (*ms > 0)
start = ast_tvnow();
-
+
if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */
do {
int kbrms = rms;
ast_set_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
/* Wait for a digit, no more than ms milliseconds total. */
-
+
while (ms) {
struct ast_channel *rchan;
int outfd=-1;
errno = 0;
rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
-
+
if (!rchan && outfd < 0 && ms) {
if (errno == 0 || errno == EINTR)
continue;
* code. 1) this function is only called from within __ast_read() and 2) all generators
* call ast_write() in their generate callback.
*
- * The reason this is added is so that when ast_write is called, the lock that occurs
- * there will not recursively lock the channel. Doing this will cause intended deadlock
+ * The reason this is added is so that when ast_write is called, the lock that occurs
+ * there will not recursively lock the channel. Doing this will cause intended deadlock
* avoidance not to work in deeper functions
*/
ast_channel_unlock(chan);
* explicitly deferred. Skip this digit, then. */
return 1;
}
-
- if (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
+
+ if (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
ast_tvdiff_ms(ast_tvnow(), *ast_channel_dtmf_tv(chan)) < AST_MIN_DTMF_GAP) {
/* We're not in the middle of a digit, but it hasn't been long enough
* since the last digit, so we'll have to skip DTMF for now. */
/*!
* \brief calculates the number of samples to jump forward with in a monitor stream.
-
+
* \note When using ast_seekstream() with the read and write streams of a monitor,
* the number of samples to seek forward must be of the same sample rate as the stream
* or else the jump will not be calculated correctly.
return &ast_null_frame;
case AST_TIMING_EVENT_CONTINUOUS:
- if (AST_LIST_EMPTY(ast_channel_readq(chan)) ||
+ if (AST_LIST_EMPTY(ast_channel_readq(chan)) ||
!AST_LIST_NEXT(AST_LIST_FIRST(ast_channel_readq(chan)), frame_list)) {
ast_timer_disable_continuous(ast_channel_timer(chan));
}
break;
}
AST_LIST_TRAVERSE_SAFE_END;
-
+
if (!f) {
/* There were no acceptable frames on the readq. */
f = &ast_null_frame;
ast_frfree(f);
f = &ast_null_frame;
} else if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF | AST_FLAG_END_DTMF_ONLY)) {
- if (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
+ if (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
ast_tvdiff_ms(ast_tvnow(), *ast_channel_dtmf_tv(chan)) < AST_MIN_DTMF_GAP) {
/* If it hasn't been long enough, defer this digit */
queue_dtmf_readq(chan, f);
if (f->len) {
if (f->len > AST_MIN_DTMF_DURATION)
ast_channel_emulate_dtmf_duration_set(chan, f->len);
- else
+ else
ast_channel_emulate_dtmf_duration_set(chan, AST_MIN_DTMF_DURATION);
} else
ast_channel_emulate_dtmf_duration_set(chan, AST_DEFAULT_EMULATE_DTMF_DURATION);
case AST_FRAME_DTMF_BEGIN:
send_dtmf_event(chan, "Received", f->subclass.integer, "Yes", "No");
ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, ast_channel_name(chan));
- if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY | AST_FLAG_EMULATE_DTMF) ||
- (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
+ if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY | AST_FLAG_EMULATE_DTMF) ||
+ (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
ast_tvdiff_ms(ast_tvnow(), *ast_channel_dtmf_tv(chan)) < AST_MIN_DTMF_GAP) ) {
ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
ast_frfree(f);
int ast_indicate_data(struct ast_channel *chan, int _condition,
const void *data, size_t datalen)
{
- /* By using an enum, we'll get compiler warnings for values not handled
+ /* By using an enum, we'll get compiler warnings for values not handled
* in switch statements. */
enum ast_control_frame_type condition = _condition;
struct ast_tone_zone_sound *ts = NULL;
ast_party_redirecting_free(&redirecting);
}
break;
-
+
default:
break;
}
{
int res, done = 0;
char *buf = NULL;
-
+
while (!done) {
struct ast_frame *f;
if (ast_check_hangup(chan))
* offset field indicates the number of bytes that the audio is offset. The plc->samples_buf
* is not an array of bytes, but rather an array of 16-bit integers since it holds SLIN
* samples. So I had two choices to make here with the offset.
- *
+ *
* 1. Make the offset AST_FRIENDLY_OFFSET bytes. The main downside for this is that
* I can't just add AST_FRIENDLY_OFFSET to the plc->samples_buf and have the pointer
* arithmetic come out right. I would have to do some odd casting or division for this to
* 2. Make the offset AST_FRIENDLY_OFFSET * 2 bytes. This allows the pointer arithmetic
* to work out better with the plc->samples_buf. The downside here is that the buffer's
* allocation contains an extra 64 bytes of unused space.
- *
+ *
* I decided to go with option 2. This is why in the calloc statement and the statement that
* sets the frame's offset, AST_FRIENDLY_OFFSET is multiplied by 2.
*/
prev = cur;
}
}
-
+
/* If Monitor is running on this channel, then we have to write frames out there too */
/* the translator on chan->writetrans may have returned multiple frames
from the single frame we passed in; if so, feed each one of them to the
ast_channel_name(chan),
direction ? "write" : "read",
ast_getformatname(&best_set_fmt));
-
+
/* If there is a generator on the channel, it needs to know about this
* change if it is the write format. */
if (direction && ast_channel_generatordata(chan)) {
int res = 0;
int last_subclass = 0;
struct ast_party_connected_line connected;
-
+
if (outstate)
*outstate = 0;
else
ast_channel_context_set(chan, oh->context);
if (!ast_strlen_zero(oh->exten))
ast_channel_exten_set(chan, oh->exten);
- if (oh->priority)
+ if (oh->priority)
ast_channel_priority_set(chan, oh->priority);
}
if (ast_channel_state(chan) == AST_STATE_UP)
ast_format_clear(&best_audio_fmt);
/* find the best audio format to use */
if ((tmp_cap = ast_format_cap_get_type(request_cap, AST_FORMAT_TYPE_AUDIO))) {
- /* We have audio - is it possible to connect the various calls to each other?
+ /* We have audio - is it possible to connect the various calls to each other?
(Avoid this check for calls without audio, like text+video calls)
*/
res = ast_translator_best_choice(tmp_cap, chan->tech->capabilities, &tmp_fmt, &best_audio_fmt);
AST_LIST_APPEND_LIST(ast_channel_varshead(original), ast_channel_varshead(clonechan), entries);
/* then, dup the varshead list into the clone */
-
+
AST_LIST_TRAVERSE(ast_channel_varshead(original), current, entries) {
newvar = ast_var_assign(current->name, current->value);
if (newvar)
* reason we're keeping it, it's still awesomely weird. XXX */
/* The reasoning for the channels ao2_container lock here is complex.
- *
+ *
* In order to check for a race condition, the original channel must
* be locked. If it is determined that the masquerade should proceed
* the original channel can absolutely not be unlocked until the end
/* Swap the alertpipes */
ast_channel_internal_alertpipe_swap(original, clonechan);
- /*
+ /*
* Swap the readq's. The end result should be this:
*
* 1) All frames should be on the new (original) channel.
ast_log(LOG_WARNING, "Channel type '%s' does not have a fixup routine (for %s)! Bad things may happen.\n",
ast_channel_tech(original)->type, ast_channel_name(original));
- /*
- * If an indication is currently playing, maintain it on the channel
- * that is taking the place of original
+ /*
+ * If an indication is currently playing, maintain it on the channel
+ * that is taking the place of original
*
* This is needed because the masquerade is swapping out in the internals
* of this channel, and the new channel private data needs to be made
sec = remain;
}
}
-
+
if (!strcmp(sound,"timeleft")) { /* Queue support */
ast_stream_and_wait(chan, "vm-youhave", "");
if (min) {
if (config->feature_timer > 0 && ast_tvzero(config->nexteventts)) {
/* nexteventts is not set when the bridge is not scheduled to
- * break, so calculate when the bridge should possibly break
- * if a partial feature match timed out */
+ * break, so calculate when the bridge should possibly break
+ * if a partial feature match timed out */
config->nexteventts = ast_tvadd(ast_tvnow(), ast_samp2tv(config->feature_timer, 1000));
}
break;
}
} else {
- /* If a feature has been started and the bridge is configured to
- * to not break, leave the channel bridge when the feature timer
- * time has elapsed so the DTMF will be sent to the other side.
- */
+ /* If a feature has been started and the bridge is configured to
+ * to not break, leave the channel bridge when the feature timer
+ * time has elapsed so the DTMF will be sent to the other side.
+ */
if (!ast_tvzero(config->nexteventts)) {
int diff = ast_tvdiff_ms(config->nexteventts, ast_tvnow());
if (diff <= 0) {
/* Write immediately frames, not passed through jb */
if (!frame_put_in_jb)
ast_write(other, f);
-
+
/* Check if we have to deliver now */
if (jb_in_use)
ast_jb_get_and_deliver(c0, c1);
}
/*! \brief Send manager event for bridge link and unlink events.
- * \param onoff Link/Unlinked
+ * \param onoff Link/Unlinked
* \param type 1 for core, 2 for native
* \param c0 first channel in bridge
* \param c1 second channel in bridge
ast_channel_name(c1), ast_channel_name(ast_channel_internal_bridged_channel(c1)));
return -1;
}
-
+
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(ast_channel_flags(c0), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
ast_test_flag(ast_channel_flags(c1), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1))
return -1;
}
memset(&ts->f, 0, sizeof(ts->f));
- for (x=0;x<len/2;x++) {
- ts->v1_1 = ts->v2_1;
- ts->v2_1 = ts->v3_1;
- ts->v3_1 = (ts->fac1 * ts->v2_1 >> 15) - ts->v1_1;
-
- ts->v1_2 = ts->v2_2;
- ts->v2_2 = ts->v3_2;
- ts->v3_2 = (ts->fac2 * ts->v2_2 >> 15) - ts->v1_2;
- if (ts->modulate) {
- int p;
- p = ts->v3_2 - 32768;
- if (p < 0) p = -p;
- p = ((p * 9) / 10) + 1;
- ts->data[x] = (ts->v3_1 * p) >> 15;
- } else
- ts->data[x] = ts->v3_1 + ts->v3_2;
- }
+ for (x=0;x<len/2;x++) {
+ ts->v1_1 = ts->v2_1;
+ ts->v2_1 = ts->v3_1;
+ ts->v3_1 = (ts->fac1 * ts->v2_1 >> 15) - ts->v1_1;
+
+ ts->v1_2 = ts->v2_2;
+ ts->v2_2 = ts->v3_2;
+ ts->v3_2 = (ts->fac2 * ts->v2_2 >> 15) - ts->v1_2;
+ if (ts->modulate) {
+ int p;
+ p = ts->v3_2 - 32768;
+ if (p < 0) p = -p;
+ p = ((p * 9) / 10) + 1;
+ ts->data[x] = (ts->v3_1 * p) >> 15;
+ } else
+ ts->data[x] = ts->v3_1 + ts->v3_2;
+ }
ts->f.frametype = AST_FRAME_VOICE;
ast_format_set(&ts->f.subclass.format, AST_FORMAT_SLINEAR, 0);
ts->f.datalen = len;
return 0;
c = ast_strdupa(s);
-
+
while ((piece = strsep(&c, ","))) {
if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) {
/* Range */
char num[3];
buf[0] = '\0';
-
+
if (!group) /* Return empty string if no group */
return buf;
for (i = 0; i <= 63; i++) { /* Max group is 63 */
if (group & ((ast_group_t) 1 << i)) {
- if (!first) {
+ if (!first) {
strncat(buf, ", ", buflen - strlen(buf) - 1);
} else {
first = 0;
- }
+ }
snprintf(num, sizeof(num), "%u", i);
strncat(buf, num, buflen - strlen(buf) - 1);
}
struct ast_variable *cur;
for (cur = vars; cur; cur = cur->next)
- pbx_builtin_setvar_helper(chan, cur->name, cur->value);
+ pbx_builtin_setvar_helper(chan, cur->name, cur->value);
}
static void *silence_generator_alloc(struct ast_channel *chan, void *data)
*
* \brief Channel Variables
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
*/
#include "asterisk.h"
#else
struct ast_var_t *ast_var_assign(const char *name, const char *value)
#endif
-{
+{
struct ast_var_t *var;
int name_len = strlen(name) + 1;
int value_len = strlen(value) + 1;
ast_copy_string(var->name, name, name_len);
var->value = var->name + name_len;
ast_copy_string(var->value, value, value_len);
-
+
return var;
-}
-
+}
+
void ast_var_delete(struct ast_var_t *var)
{
if (var)
*
* \brief Standard Command Line Interface
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
*/
#include "asterisk.h"
}
}
-unsigned int ast_debug_get_by_module(const char *module)
+unsigned int ast_debug_get_by_module(const char *module)
{
struct module_level *ml;
unsigned int res = 0;
return res;
}
-unsigned int ast_verbose_get_by_module(const char *module)
+unsigned int ast_verbose_get_by_module(const char *module)
{
struct module_level *ml;
unsigned int res = 0;
snprintf(filename, sizeof(filename), "%s/%s", ast_config_AST_MODULE_DIR, word);
c = d = filename_completion_function(filename, state);
-
+
if (c && word[0] != '/')
c += (strlen(ast_config_AST_MODULE_DIR) + 1);
if (c)
c = ast_strdup(c);
free(d);
-
+
return c;
}
return CLI_SUCCESS;
}
-/*!
- * \brief Find the debug or verbose file setting
+/*!
+ * \brief Find the debug or verbose file setting
* \arg debug 1 for debug, 0 for verbose
*/
static struct module_level *find_module_level(const char *module, unsigned int debug)
switch (cmd) {
case CLI_INIT:
e->command = "logger mute";
- e->usage =
+ e->usage =
"Usage: logger mute\n"
" Disables logging output to the current console, making it possible to\n"
" gather information without being disturbed by scrolling lines.\n";
if (strcasestr(module, like) ) {
ast_cli(climodentryfd, MODLIST_FORMAT, module, description, usecnt);
return 1;
- }
+ }
return 0;
}
like = a->argv[e->args];
else
return CLI_SHOWUSAGE;
-
+
ast_mutex_lock(&climodentrylock);
climodentryfd = a->fd; /* global, protected by climodentrylock */
ast_cli(a->fd, MODLIST_FORMAT2, "Module", "Description", "Use Count");
} else {
ast_cli(a->fd, "%d active call%s\n", ast_active_calls(), ESS(ast_active_calls()));
}
-
+
ast_cli(a->fd, "%d call%s processed\n", ast_processed_calls(), ESS(ast_processed_calls()));
if (ast_startuptime.tv_sec && showuptime) {
if (!concise && !verbose)
ast_cli(a->fd, FORMAT_STRING2, "Channel", "Location", "State", "Application(Data)");
else if (verbose)
- ast_cli(a->fd, VERBOSE_FORMAT_STRING2, "Channel", "Context", "Extension", "Priority", "State", "Application", "Data",
+ ast_cli(a->fd, VERBOSE_FORMAT_STRING2, "Channel", "Context", "Extension", "Priority", "State", "Application", "Data",
"CallerID", "Duration", "Accountcode", "PeerAccount", "BridgedTo");
}
snprintf(durbuf, sizeof(durbuf), "%02d:%02d:%02d", durh, durm, durs);
} else {
snprintf(durbuf, sizeof(durbuf), "%d", duration);
- }
+ }
}
if (concise) {
ast_cli(a->fd, CONCISE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_state2str(ast_channel_state(c)),
S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, ""),
S_OR(ast_channel_accountcode(c), ""),
S_OR(ast_channel_peeraccount(c), ""),
- ast_channel_amaflags(c),
+ ast_channel_amaflags(c),
durbuf,
bc ? ast_channel_name(bc) : "(None)",
ast_channel_uniqueid(c));
} else {
char locbuf[40] = "(None)";
char appdata[40] = "(None)";
-
- if (!ast_strlen_zero(ast_channel_context(c)) && !ast_strlen_zero(ast_channel_exten(c)))
+
+ if (!ast_strlen_zero(ast_channel_context(c)) && !ast_strlen_zero(ast_channel_exten(c)))
snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", ast_channel_exten(c), ast_channel_context(c), ast_channel_priority(c));
if (ast_channel_appl(c))
snprintf(appdata, sizeof(appdata), "%s(%s)", ast_channel_appl(c), S_OR(ast_channel_data(c), ""));
}
return CLI_SUCCESS;
-
+
#undef FORMAT_STRING
#undef FORMAT_STRING2
#undef CONCISE_FORMAT_STRING
int len = 0;
char **matches;
int x, matchlen;
-
+
switch (cmd) {
case CLI_INIT:
e->command = "_command matchesarray";
- e->usage =
+ e->usage =
"Usage: _command matchesarray \"<line>\" text \n"
" This function is used internally to help with command completion and should.\n"
" never be called by the user directly.\n";
if (len + matchlen >= buflen) {
buflen += matchlen * 3;
obuf = buf;
- if (!(buf = ast_realloc(obuf, buflen)))
+ if (!(buf = ast_realloc(obuf, buflen)))
/* Memory allocation failure... Just free old buffer and be done */
ast_free(obuf);
}
switch (cmd) {
case CLI_INIT:
e->command = "_command nummatches";
- e->usage =
+ e->usage =
"Usage: _command nummatches \"<line>\" text \n"
" This function is used internally to help with command completion and should.\n"
" never be called by the user directly.\n";
switch (cmd) {
case CLI_INIT:
e->command = "_command complete";
- e->usage =
+ e->usage =
"Usage: _command complete \"<line>\" text state\n"
" This function is used internally to help with command completion and should.\n"
" never be called by the user directly.\n";
return res;
}
-
+
static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ast_channel *c=NULL;
switch (cmd) {
case CLI_INIT:
e->command = "core show channel";
- e->usage =
+ e->usage =
"Usage: core show channel <channel>\n"
" Shows lots of information about the specified channel.\n";
return NULL;
case CLI_GENERATE:
return ast_complete_channels(a->line, a->word, a->pos, a->n, 3);
}
-
+
if (a->argc != 4) {
return CLI_SHOWUSAGE;
}
S_COR(ast_channel_connected(c)->id.number.valid, ast_channel_connected(c)->id.number.str, "(N/A)"),
S_COR(ast_channel_connected(c)->id.name.valid, ast_channel_connected(c)->id.name.str, "(N/A)"),
S_OR(ast_channel_dialed(c)->number.str, "(N/A)"),
- ast_channel_language(c),
- ast_state2str(ast_channel_state(c)), ast_channel_state(c), ast_channel_rings(c),
+ ast_channel_language(c),
+ ast_state2str(ast_channel_state(c)), ast_channel_state(c), ast_channel_rings(c),
ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(c)),
ast_getformatname(ast_channel_writeformat(c)),
ast_getformatname(ast_channel_readformat(c)),
ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
(long)ast_channel_whentohangup(c)->tv_sec,
- cdrtime, ast_channel_internal_bridged_channel(c) ? ast_channel_name(ast_channel_internal_bridged_channel(c)) : "<none>", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>",
+ cdrtime, ast_channel_internal_bridged_channel(c) ? ast_channel_name(ast_channel_internal_bridged_channel(c)) : "<none>", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>",
ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_callgroup(c), ast_channel_pickupgroup(c), (ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ),
(ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)"),
(ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)"));
-
+
if (pbx_builtin_serialize_variables(c, &obuf)) {
ast_str_append(&output, 0, " Variables:\n%s\n", ast_str_buffer(obuf));
}
switch (cmd) {
case CLI_INIT:
e->command = "group show channels";
- e->usage =
+ e->usage =
"Usage: group show channels [pattern]\n"
" Lists all currently active channels with channel group(s) specified.\n"
" Optional regular expression pattern is matched to group names for each\n"
if (a->argc < 3 || a->argc > 4)
return CLI_SHOWUSAGE;
-
+
if (a->argc == 4) {
if (regcomp(®exbuf, a->argv[3], REG_EXTENDED | REG_NOSUB))
return CLI_SHOWUSAGE;
ast_cli(a->fd, FORMAT_STRING, "Channel", "Group", "Category");
ast_app_group_list_rdlock();
-
+
gi = ast_app_group_list_head();
while (gi) {
if (!havepattern || !regexec(®exbuf, gi->group, 0, NULL, 0)) {
}
gi = AST_LIST_NEXT(gi, group_list);
}
-
+
ast_app_group_list_unlock();
-
+
if (havepattern)
regfree(®exbuf);
AST_RWLIST_WRLOCK(&cli_perms);
AST_LIST_TRAVERSE(&cli_perms, cp_entry, list) {
if ((pw && cp_entry->uid == pw->pw_uid) || (gr && cp_entry->gid == gr->gr_gid)) {
- /* if it is duplicated, just added this new settings, to
+ /* if it is duplicated, just added this new settings, to
the current list. */
user_group = cp_entry;
break;
s = ast_skip_blanks(s);
}
*dst++ = NULL;
-
+
AST_RWLIST_WRLOCK(&helpers);
-
+
if (find_cli(e->cmda, 1)) {
ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", S_OR(e->_full_cmd, e->command));
goto done;
if (lf < len)
len = lf;
if (strncasecmp(e->_full_cmd, cur->_full_cmd, len) < 0) {
- AST_RWLIST_INSERT_BEFORE_CURRENT(e, list);
+ AST_RWLIST_INSERT_BEFORE_CURRENT(e, list);
break;
}
}
AST_RWLIST_TRAVERSE_SAFE_END;
if (!cur)
- AST_RWLIST_INSERT_TAIL(&helpers, e, list);
+ AST_RWLIST_INSERT_TAIL(&helpers, e, list);
ret = 0; /* success */
done:
if (!(retstr = ast_malloc(max_equal + 1)))
return NULL;
-
+
ast_copy_string(retstr, match_list[1], max_equal + 1);
match_list[0] = retstr;
}
return 0;
}
-
+
/*
* generate the entry at position 'state'
*/
ast_str_append(cb, 0, "%s", str);
}
-static void CB_RESET(struct ast_str *cb, struct ast_str *llb)
-{
+static void CB_RESET(struct ast_str *cb, struct ast_str *llb)
+{
if (cb) {
ast_str_reset(cb);
}
}
static struct ast_comment *ALLOC_COMMENT(struct ast_str *buffer)
-{
+{
struct ast_comment *x = NULL;
if (!buffer || !ast_str_strlen(buffer)) {
return NULL;
struct ast_config_include *ast_include_new(struct ast_config *conf, const char *from_file, const char *included_file, int is_exec, const char *exec_file, int from_lineno, char *real_included_file_name, int real_included_file_name_size)
{
/* a file should be included ONCE. Otherwise, if one of the instances is changed,
- * then all be changed. -- how do we know to include it? -- Handling modified
+ * then all be changed. -- how do we know to include it? -- Handling modified
* instances is possible, I'd have
* to create a new master for each instance. */
struct ast_config_include *inc;
struct stat statbuf;
-
+
inc = ast_include_find(conf, included_file);
if (inc) {
do {
ast_log(LOG_WARNING,"'%s', line %d: Same File included more than once! This data will be saved in %s if saved back to disk.\n", from_file, from_lineno, real_included_file_name);
} else
*real_included_file_name = 0;
-
+
inc = ast_calloc(1,sizeof(struct ast_config_include));
if (!inc) {
return NULL;
inc->included_file = ast_strdup(real_included_file_name);
else
inc->included_file = ast_strdup(included_file);
-
+
inc->exec = is_exec;
if (is_exec)
inc->exec_file = ast_strdup(exec_file);
/* attach this new struct to the conf struct */
inc->next = conf->includes;
conf->includes = inc;
-
+
return inc;
}
int from_len = strlen(from_file);
int to_len = strlen(to_file);
-
+
if (strcmp(from_file, to_file) == 0) /* no use wasting time if the name is the same */
return;
-
+
/* the manager code allows you to read in one config file, then
* write it back out under a different name. But, the new arrangement
* ties output lines to the file name. So, before you try to write
return new;
}
-
+
static void move_variables(struct ast_category *old, struct ast_category *new)
{
struct ast_variable *var = old->root;
ast_variable_append(new, var);
}
-struct ast_category *ast_category_new(const char *name, const char *in_file, int lineno)
+struct ast_category *ast_category_new(const char *name, const char *in_file, int lineno)
{
struct ast_category *category;
cat->next = config->root;
config->root = cat;
return;
- }
+ }
for (cur_category = config->root; cur_category; cur_category = cur_category->next) {
if (!strcasecmp(cur_category->next->name, match)) {
cat->next = cur_category->next;
static void ast_includes_destroy(struct ast_config_include *incls)
{
struct ast_config_include *incl,*inclnext;
-
+
for (incl=incls; incl; incl = inclnext) {
inclnext = incl->next;
ast_free(incl->include_location_file);
}
char *ast_category_browse(struct ast_config *config, const char *prev)
-{
+{
struct ast_category *cat;
if (!prev) {
}
}
}
-
+
if (cat)
cat = next_available_category(cat);
ast_variable_append(new, variable_clone(var));
}
-struct ast_config *ast_config_new(void)
+struct ast_config *ast_config_new(void)
{
struct ast_config *config;
return res;
}
-int ast_variable_update(struct ast_category *category, const char *variable,
+int ast_variable_update(struct ast_category *category, const char *variable,
const char *value, const char *match, unsigned int object)
{
struct ast_variable *cur, *prev=NULL, *newer=NULL;
}
*c++ = '\0';
cur++;
- if (*c++ != '(')
- c = NULL;
+ if (*c++ != '(')
+ c = NULL;
catname = cur;
if (!(*cat = newcat = ast_category_new(catname,
S_OR(suggested_include_file, cfg->include_level == 1 ? "" : configfile),
(*cat)->lineno = lineno;
*last_var = 0;
*last_cat = newcat;
-
+
/* add comments */
if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS))
newcat->precomments = ALLOC_COMMENT(comment_buffer);
newcat->sameline = ALLOC_COMMENT(lline_buffer);
if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS))
CB_RESET(comment_buffer, lline_buffer);
-
- /* If there are options or categories to inherit from, process them now */
- if (c) {
- if (!(cur = strchr(c, ')'))) {
- ast_log(LOG_WARNING, "parse error: no closing ')', line %d of %s\n", lineno, configfile);
- return -1;
- }
- *cur = '\0';
- while ((cur = strsep(&c, ","))) {
+
+ /* If there are options or categories to inherit from, process them now */
+ if (c) {
+ if (!(cur = strchr(c, ')'))) {
+ ast_log(LOG_WARNING, "parse error: no closing ')', line %d of %s\n", lineno, configfile);
+ return -1;
+ }
+ *cur = '\0';
+ while ((cur = strsep(&c, ","))) {
if (!strcasecmp(cur, "!")) {
(*cat)->ignored = 1;
} else if (!strcasecmp(cur, "+")) {
}
} else {
struct ast_category *base;
-
+
base = category_get(cfg, cur, 1);
if (!base) {
ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile);
}
inherit_category(*cat, base);
}
- }
- }
+ }
+ }
if (newcat)
ast_category_append(cfg, *cat);
} else if (cur[0] == '#') { /* A directive - #include or #exec */
v->sameline = ALLOC_COMMENT(lline_buffer);
if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS))
CB_RESET(comment_buffer, lline_buffer);
-
+
} else {
return -1;
}
CB_ADD(&comment_buffer, ast_str_buffer(lline_buffer)); /* add the current lline buffer to the comment buffer */
ast_str_reset(lline_buffer); /* erase the lline buffer */
}
-
+
new_buf = buf;
- if (comment)
+ if (comment)
process_buf = NULL;
else
process_buf = buf;
-
+
if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && comment_buffer && ast_str_strlen(comment_buffer) && (ast_strlen_zero(buf) || strlen(buf) == strspn(buf," \t\n\r"))) {
/* blank line? really? Can we add it to an existing comment and maybe preserve inter- and post- comment spacing? */
CB_ADD(&comment_buffer, "\n"); /* add a newline to the comment buffer */
continue; /* go get a new line, then */
}
-
+
while ((comment_p = strchr(new_buf, COMMENT_META))) {
if ((comment_p > new_buf) && (*(comment_p - 1) == '\\')) {
/* Escaped semicolons aren't comments. */
CB_ADD(&comment_buffer, ";");
CB_ADD_LEN(&comment_buffer, oldptr+1, new_buf-oldptr-1);
}
-
+
memmove(oldptr, new_buf, strlen(new_buf) + 1);
new_buf = oldptr;
} else
}
} else {
if (!comment) {
- /* If ; is found, and we are not nested in a comment,
+ /* If ; is found, and we are not nested in a comment,
we immediately stop all comment processing */
if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) {
CB_ADD(&lline_buffer, comment_p);
}
- *comment_p = '\0';
+ *comment_p = '\0';
new_buf = comment_p;
} else
new_buf = comment_p + 1;
if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && comment && !process_buf ) {
CB_ADD(&comment_buffer, buf); /* the whole line is a comment, store it */
}
-
+
if (process_buf) {
char *buffer = ast_strip(process_buf);
if (!ast_strlen_zero(buffer)) {
comment_buffer = NULL;
lline_buffer = NULL;
}
-
+
if (count == 0)
return NULL;
/* NOTE: categories and variables each have a file and lineno attribute. On a save operation, these are used to determine
which file and line number to write out to. Thus, an entire hierarchy of config files (via #include statements) can be
recreated. BUT, care must be taken to make sure that every cat and var has the proper file name stored, or you may
- be shocked and mystified as to why things are not showing up in the files!
+ be shocked and mystified as to why things are not showing up in the files!
Also, All #include/#exec statements are recorded in the "includes" LL in the ast_config structure. The file name
and line number are stored for each include, plus the name of the file included, so that these statements may be
- included in the output files on a file_save operation.
+ included in the output files on a file_save operation.
The lineno's are really just for relative placement in the file. There is no attempt to make sure that blank lines
are included to keep the lineno's the same between input and output. The lineno fields are used mainly to determine
} else if (lineno == 0) {
/* Line replacements also mess things up */
return;
- } else if (lineno - precomment_lines - fi->lineno < 5) {
- /* Only insert less than 5 blank lines; if anything more occurs,
- * it's probably due to context deletion. */
- for (i = fi->lineno; i < lineno - precomment_lines; i++) {
- fprintf(fp, "\n");
- }
- } else {
- /* Deletion occurred - insert a single blank line, for separation of
- * contexts. */
- fprintf(fp, "\n");
- }
-
- fi->lineno = lineno + 1; /* Advance the file lineno */
+ } else if (lineno - precomment_lines - fi->lineno < 5) {
+ /* Only insert less than 5 blank lines; if anything more occurs,
+ * it's probably due to context deletion. */
+ for (i = fi->lineno; i < lineno - precomment_lines; i++) {
+ fprintf(fp, "\n");
+ }
+ } else {
+ /* Deletion occurred - insert a single blank line, for separation of
+ * contexts. */
+ fprintf(fp, "\n");
+ }
+
+ fi->lineno = lineno + 1; /* Advance the file lineno */
}
int config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator)
return 0;
}
-static void clear_config_maps(void)
+static void clear_config_maps(void)
{
struct ast_config_map *map;
config_maps = config_maps->next;
ast_free(map);
}
-
+
ast_mutex_unlock(&config_lock);
}
return 0;
}
-int read_config_maps(void)
+int read_config_maps(void)
{
struct ast_config *config, *configtmp;
struct ast_variable *v;
ast_log(LOG_WARNING, "The 'iaxfriends' table is obsolete, update your config to use iaxusers and iaxpeers, though they can point to the same table.\n");
append_mapping("iaxusers", driver, database, table ? table : "iaxfriends", pri);
append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends", pri);
- } else
+ } else
append_mapping(v->name, driver, database, table, pri);
}
-
+
ast_config_destroy(config);
return 0;
}
-int ast_config_engine_register(struct ast_config_engine *new)
+int ast_config_engine_register(struct ast_config_engine *new)
{
struct ast_config_engine *ptr;
return 1;
}
-int ast_config_engine_deregister(struct ast_config_engine *del)
+int ast_config_engine_deregister(struct ast_config_engine *del)
{
struct ast_config_engine *ptr, *last=NULL;
}
/*! \brief Find realtime engine for realtime family */
-static struct ast_config_engine *find_engine(const char *family, int priority, char *database, int dbsiz, char *table, int tabsiz)
+static struct ast_config_engine *find_engine(const char *family, int priority, char *database, int dbsiz, char *table, int tabsiz)
{
struct ast_config_engine *eng, *ret = NULL;
struct ast_config_map *map;
}
ast_mutex_unlock(&config_lock);
-
+
/* if we found a mapping, but the engine is not available, then issue a warning */
if (map && !ret)
ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver);
char db[256];
char table[256];
struct ast_config_engine *loader = &text_file_engine;
- struct ast_config *result;
+ struct ast_config *result;
/* The config file itself bumps include_level by 1 */
if (cfg->max_include_level > 0 && cfg->include_level == cfg->max_include_level + 1) {
"extract inaddr from [%s] gives [%s:%d](%d)\n",
arg, ast_inet_ntoa(sa->sin_addr),
ntohs(sa->sin_port), error);
- break;
+ break;
}
}
va_end(ap);
case CLI_GENERATE:
return NULL;
}
-
+
ast_mutex_lock(&config_lock);
if (!config_engine_list) {
}
}
}
-
+
ast_mutex_unlock(&config_lock);
return CLI_SUCCESS;
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
- * channels for your use.
+ * channels for your use.
*
- * This program is free software, distributed under the terms of
+ * This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
- * \brief
+ * \brief
* Loader for Asterisk under Cygwin/windows.
* Open the dll, locate main, run.
*/
*
* \brief Device state management
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
* \author Russell Bryant <russell@digium.com>
*
* \arg \ref AstExtState
* The device state is basically based on the current calls.
* If the devicestate engine can find a call from or to the
* device, it's in use.
- *
- * Some channel drivers implement a callback function for
+ *
+ * Some channel drivers implement a callback function for
* a better level of reporting device states. The SIP channel
- * has a complicated system for this, which is improved
+ * has a complicated system for this, which is improved
* by adding call limits to the configuration.
- *
+ *
* Functions that want to check the status of an extension
* register themself as a \b watcher.
* Watchers in this system can subscribe either to all extensions
* for app_meetme.c - the conference bridge - and call
* parking (metermaids).
*
- * There are manly three subscribers to extension states
+ * There are manly three subscribers to extension states
* within Asterisk:
* - AMI, the manager interface
* - app_queue.c - the Queue dialplan application
- * - SIP subscriptions, a.k.a. "blinking lamps" or
+ * - SIP subscriptions, a.k.a. "blinking lamps" or
* "buddy lists"
*
* The CLI command "show hints" show last known state
*
* \section AstDevStateArch Architecture for devicestates
*
- * When a channel driver or asterisk app changes state for
+ * When a channel driver or asterisk app changes state for
* a watched object, it alerts the core. The core queues
* a change. When the change is processed, there's a query
* sent to the channel driver/provider if there's a function
* to handle that, otherwise a channel walk is issued to find
* a channel that involves the object.
- *
+ *
* The changes are queued and processed by a separate thread.
- * This thread calls the watchers subscribing to status
- * changes for the object. For manager, this results
+ * This thread calls the watchers subscribing to status
+ * changes for the object. For manager, this results
* in events. For SIP, NOTIFY requests.
*
* - Device states
- * \arg \ref devicestate.c
- * \arg \ref devicestate.h
+ * \arg \ref devicestate.c
+ * \arg \ref devicestate.h
*
* \section AstExtStateArch Architecture for extension states
- *
+ *
* Hints are connected to extension. If an extension changes state
* it checks the hint devices. If there is a hint, the callbacks into
* device states are checked. The aggregated state is set for the hint
*
* - Extension states
* \arg \ref AstENUM ast_extension_states
- * \arg \ref pbx.c
- * \arg \ref pbx.h
+ * \arg \ref pbx.c
+ * \arg \ref pbx.h
* - Structures
* - \ref ast_state_cb struct. Callbacks for watchers
* - Callback ast_state_cb_type
* - \ref ast_hint struct.
- * - Functions
+ * - Functions
* - ast_extension_state_add()
* - ast_extension_state_del()
* - ast_get_hint()
- *
+ *
*/
#include "asterisk.h"
static int getproviderstate(const char *provider, const char *address);
/*! \brief Find devicestate as text message for output */
-const char *ast_devstate2str(enum ast_device_state devstate)
+const char *ast_devstate2str(enum ast_device_state devstate)
{
return devstatestring[devstate][0];
}
/* Deprecated interface (not prefixed with ast_) */
-const char *devstate2str(enum ast_device_state devstate)
+const char *devstate2str(enum ast_device_state devstate)
{
return devstatestring[devstate][0];
}
return AST_DEVICE_UNKNOWN;
}
-/*! \brief Find out if device is active in a call or not
+/*! \brief Find out if device is active in a call or not
\note find channels with the device's name in it
- This function is only used for channels that does not implement
+ This function is only used for channels that does not implement
devicestate natively
*/
enum ast_device_state ast_parse_device_state(const char *device)
}
res = (ast_channel_state(chan) == AST_STATE_RINGING) ? AST_DEVICE_RINGING : AST_DEVICE_INUSE;
-
+
chan = ast_channel_unref(chan);
return res;
{
struct state_change *change;
- /*
+ /*
* If we know the state change (how nice of the caller of this function!)
- * then we can just generate a device state event.
+ * then we can just generate a device state event.
*
* Otherwise, we do the following:
* - Queue an event up to another thread that the state has changed
return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, dev);
}
-int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...)
+int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...)
{
char buf[AST_MAX_EXTENSION];
va_list ap;
return ast_devstate_changed_literal(state, buf);
}
-int ast_device_state_changed(const char *fmt, ...)
+int ast_device_state_changed(const char *fmt, ...)
{
char buf[AST_MAX_EXTENSION];
va_list ap;
ast_devstate_aggregate_init(&agg);
for (i = 0; i < collection->num_states; i++) {
- ast_debug(1, "Adding per-server state of '%s' for '%s'\n",
+ ast_debug(1, "Adding per-server state of '%s' for '%s'\n",
ast_devstate2str(collection->states[i].state), device);
ast_devstate_aggregate_add(&agg, collection->states[i].state);
}
event = ast_event_get_cached(AST_EVENT_DEVICE_STATE,
AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, device,
AST_EVENT_IE_END);
-
+
if (event) {
enum ast_device_state old_state;
old_state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
-
+
ast_event_destroy(event);
if (state == old_state) {
/* Create new data structure */
if (!(answer_exec = ast_calloc(1, sizeof(*answer_exec))))
return NULL;
-
+
/* Parse out application and arguments */
if ((args = strchr(app, ','))) {
*args++ = '\0';
set_state(dial, AST_DIAL_RESULT_RINGING);
if (chan)
ast_indicate(chan, AST_CONTROL_RINGING);
- } else if (chan && dial->options[AST_DIAL_OPTION_MUSIC] &&
+ } else if (chan && dial->options[AST_DIAL_OPTION_MUSIC] &&
!ast_strlen_zero(dial->options[AST_DIAL_OPTION_MUSIC])) {
char *original_moh = ast_strdupa(ast_channel_musicclass(chan));
ast_indicate(chan, -1);
channel->is_running_app = 0;
}
- if (chan && dial->options[AST_DIAL_OPTION_MUSIC] &&
+ if (chan && dial->options[AST_DIAL_OPTION_MUSIC] &&
!ast_strlen_zero(dial->options[AST_DIAL_OPTION_MUSIC])) {
ast_moh_stop(chan);
}
if (!dial)
return;
-
+
AST_LIST_LOCK(&dial->channels);
AST_LIST_TRAVERSE(&dial->channels, channel, list) {
if (channel->owner) {
if (!dial)
return -1;
-
+
/* Hangup and deallocate all the dialed channels */
AST_LIST_LOCK(&dial->channels);
AST_LIST_TRAVERSE_SAFE_BEGIN(&dial->channels, channel, list) {
}
AST_LIST_TRAVERSE_SAFE_END;
AST_LIST_UNLOCK(&dial->channels);
-
+
/* Disable any enabled options globally */
for (i = 0; i < AST_DIAL_OPTION_MAX; i++) {
if (!dial->options[i])
break;
}
AST_LIST_UNLOCK(&dial->channels);
-
+
return channel;
}
* -
* Copyright (c) 1983, 1989, 1993
* The Regents of the University of California. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* SUCH DAMAGE.
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
+ *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
AST_MUTEX_DEFINE_STATIC(res_lock);
#endif
-/*! \brief Lookup record in DNS
+/*! \brief Lookup record in DNS
\note Asterisk DNS is synchronus at this time. This means that if your DNS does
not work properly, Asterisk might not start properly or a channel may lock.
*/
*
* \brief Background DNS update manager
*
- * \author Kevin P. Fleming <kpfleming@digium.com>
+ * \author Kevin P. Fleming <kpfleming@digium.com>
*
* \bug There is a minor race condition. In the event that an IP address
* of a dnsmgr managed host changes, there is the potential for the consumer
} else {
limit = samples;
}
- /* The following unrolled loop takes only 35% (rough estimate) of the
+ /* The following unrolled loop takes only 35% (rough estimate) of the
time of a rolled loop on the machine on which it was developed */
for (j = sample; j < limit; j++) {
famp = amp[j];
}
static int mf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[],
- int samples, int squelch, int relax)
+ int samples, int squelch, int relax)
{
float energy[6];
int best;
} else {
limit = samples;
}
- /* The following unrolled loop takes only 35% (rough estimate) of the
+ /* The following unrolled loop takes only 35% (rough estimate) of the
time of a rolled loop on the machine on which it was developed */
for (j = sample; j < limit; j++) {
/* With GCC 2.95, the following unrolled code seems to take about 35%
for (v = ast_variable_browse(cfg, "default"); v; v = v->next) {
if (!strcasecmp(v->name, "silencethreshold")) {
if (sscanf(v->value, "%30d", &cfg_threshold) < 1) {
- ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value);
+ ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value);
} else if (cfg_threshold < 0) {
ast_log(LOG_WARNING, "Invalid silence threshold '%d' specified, using default\n", cfg_threshold);
} else {
/* ecdisa.h: Generated from frequency 2100
by gentone. 80 samples */
static unsigned char ecdisa[80] = {
- 255, 143, 58, 16, 171, 146, 34, 20,
- 156, 151, 25, 26, 149, 159, 19, 38,
- 145, 177, 16, 73, 143, 73, 16, 177,
- 145, 38, 19, 159, 149, 26, 25, 151,
- 156, 20, 34, 146, 171, 16, 58, 143,
- 255, 15, 186, 144, 43, 18, 162, 148,
- 28, 23, 153, 154, 21, 31, 147, 166,
- 17, 49, 144, 201, 15, 201, 144, 49,
- 17, 166, 147, 31, 21, 154, 153, 23,
- 28, 148, 162, 18, 43, 144, 186, 15,
-
+ 255, 143, 58, 16, 171, 146, 34, 20,
+ 156, 151, 25, 26, 149, 159, 19, 38,
+ 145, 177, 16, 73, 143, 73, 16, 177,
+ 145, 38, 19, 159, 149, 26, 25, 151,
+ 156, 20, 34, 146, 171, 16, 58, 143,
+ 255, 15, 186, 144, 43, 18, 162, 148,
+ 28, 23, 153, 154, 21, 31, 147, 166,
+ 17, 49, 144, 201, 15, 201, 144, 49,
+ 17, 166, 147, 31, 21, 154, 153, 23,
+ 28, 148, 162, 18, 43, 144, 186, 15,
+
};
* - ENUM SIP: http://www.ietf.org/rfc/rfc3764.txt
* - IANA ENUM Services: http://www.iana.org/assignments/enum-services
*
- * - I-ENUM:
+ * - I-ENUM:
* http://tools.ietf.org/wg/enum/draft-ietf-enum-combined/
* http://tools.ietf.org/wg/enum/draft-ietf-enum-branch-location-record/
*
#define ENUMLOOKUP_BLR_TXT 1
#define ENUMLOOKUP_BLR_EBL 2
static int ebl_alg = ENUMLOOKUP_BLR_CC;
-
+
/* EBL record provisional type code */
#define T_EBL 65300
* Input: E.164 number w/o leading +
*
* Output: number of digits in the country code
- * 0 on invalid number
+ * 0 on invalid number
*
* Algorithm:
* 3 digits is the default length of a country code.
}
strncpy(digits, number, 2);
-
+
if (!sscanf(digits, "%30d", &cc)) {
return 0;
}
if (cc / 10 == 1 || cc / 10 == 7)
- return 1;
+ return 1;
if (cc == 20 || cc == 27 || (cc >= 30 && cc <= 34) || cc == 36 ||
cc == 39 || cc == 40 || cc == 41 || (cc >= 40 && cc <= 41) ||
return 0;
}
- /* RFC1035:
+ /* RFC1035:
*
* <character-string> is a single length octet followed by that number of characters.
* TXT-DATA One or more <character-string>s.
/*
* Input: CC code
*
- * Output: number of digits in the number before the i-enum branch
+ * Output: number of digits in the number before the i-enum branch
*
* Algorithm: Build <ienum_branchlabel>.c.c.<suffix> and look for a TXT lookup.
- * Return atoi(TXT-record).
- * Return -1 on not found.
+ * Return atoi(TXT-record).
+ * Return -1 on not found.
*
*/
static int blr_txt(const char *cc, const char *suffix)
return ret;
}
}
-
+
ast_verb(3, "blr_txt() BLR TXT record for %s not found (apex: %s)\n", cc, suffix);
return -1;
c->pos = 0; /* default to empty */
c->separator[0] = 0;
c->sep_len = 0;
- c->apex[0] = 0;
+ c->apex[0] = 0;
c->apex_len = 0;
if (answer == NULL) {
* +--+--+--+--+--+--+--+--+
*
* where POSITION is a single byte, SEPARATOR is a <character-string>
- * and APEX is a <domain-name>.
- *
+ * and APEX is a <domain-name>.
+ *
*/
c->pos = *answer++;
answer += i;
len -= i;
- if ((i = dn_expand((unsigned char *)fullanswer, (unsigned char *)answer + len,
+ if ((i = dn_expand((unsigned char *)fullanswer, (unsigned char *)answer + len,
(unsigned char *)answer, c->apex, sizeof(c->apex) - 1)) < 0) {
ast_log(LOG_WARNING, "Failed to expand hostname\n");
return 0;
/*
* Input: CC code
*
- * Output: number of digits in the number before the i-enum branch
+ * Output: number of digits in the number before the i-enum branch
*
- * Algorithm: Build <ienum_branchlabel>.c.c.<suffix> and look for an EBL record
- * Return pos and fill in separator and apex.
- * Return -1 on not found.
+ * Algorithm: Build <ienum_branchlabel>.c.c.<suffix> and look for an EBL record
+ * Return pos and fill in separator and apex.
+ * Return -1 on not found.
*
*/
static int blr_ebl(const char *cc, const char *suffix, char *separator, int sep_len, char* apex, int apex_len)
return -1;
}
- /* this takes the first character of the regexp (which is a delimiter)
+ /* this takes the first character of the regexp (which is a delimiter)
* and uses that character to find the index of the second delimiter */
delim = regexp[0];
delim2 = strchr(regexp + 1, delim);
/*
* Process options:
*
- * c Return count, not URI
- * i Use infrastructure ENUM
- * s Do ISN transformation
- * d Direct DNS query: no reversing.
+ * c Return count, not URI
+ * i Use infrastructure ENUM
+ * s Do ISN transformation
+ * d Direct DNS query: no reversing.
*
*/
if (options != NULL) {
number, tech, suffix, context->options, context->position);
/*
- * This code does more than simple RFC3261 ENUM. All these rewriting
+ * This code does more than simple RFC3261 ENUM. All these rewriting
* schemes have in common that they build the FQDN for the NAPTR lookup
* by concatenating
* - a number which needs be flipped and "."-seperated (left)
ast_copy_string(left, number, sizeof(left));
middle[0] = '\0';
/*
- * I-ENUM can change the apex, thus we copy it
+ * I-ENUM can change the apex, thus we copy it
*/
ast_copy_string(apex, suffix, sizeof(apex));
/* ISN rewrite */
if (chan && ast_autoservice_start(chan) < 0) {
return -1;
}
-
+
if (pos > 128) {
pos = 128;
}
ebl_alg = ENUMLOOKUP_BLR_CC; /* default */
if (!strcasecmp(string, "txt"))
- ebl_alg = ENUMLOOKUP_BLR_TXT;
+ ebl_alg = ENUMLOOKUP_BLR_TXT;
else if (!strcasecmp(string, "ebl"))
- ebl_alg = ENUMLOOKUP_BLR_EBL;
+ ebl_alg = ENUMLOOKUP_BLR_EBL;
else if (!strcasecmp(string, "cc"))
- ebl_alg = ENUMLOOKUP_BLR_CC;
+ ebl_alg = ENUMLOOKUP_BLR_CC;
else
ast_log(LOG_WARNING, "No valid parameter for ienum/ebl_alg.\n");
}
* \brief Event types that are kept in the cache.
*/
static struct {
- /*!
+ /*!
* \brief Container of cached events
*
* \details This gets allocated in ast_event_init() when Asterisk starts
*
* \brief Routines implementing call features as call pickup, parking and transfer
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
*/
/*** MODULEINFO
<variable name="LIMIT_PLAYAUDIO_CALLER">
<para>Play sounds to the caller. yes|no (default yes)</para>
</variable>
- <variable name="LIMIT_PLAYAUDIO_CALLEE">
+ <variable name="LIMIT_PLAYAUDIO_CALLEE">
<para>Play sounds to the callee. yes|no</para>
</variable>
<variable name="LIMIT_TIMEOUT_FILE">
static void *dial_features_duplicate(void *data)
{
struct ast_dial_features *df = data, *df_copy;
-
- if (!(df_copy = ast_calloc(1, sizeof(*df)))) {
- return NULL;
- }
-
- memcpy(df_copy, df, sizeof(*df));
-
- return df_copy;
+
+ if (!(df_copy = ast_calloc(1, sizeof(*df)))) {
+ return NULL;
+ }
+
+ memcpy(df_copy, df, sizeof(*df));
+
+ return df_copy;
}
static void dial_features_destroy(void *data)
{
- struct ast_dial_features *df = data;
- if (df) {
- ast_free(df);
- }
+ struct ast_dial_features *df = data;
+ if (df) {
+ ast_free(df);
+ }
}
static const struct ast_datastore_info dial_features_info = {
- .type = "dial-features",
- .destroy = dial_features_destroy,
- .duplicate = dial_features_duplicate,
+ .type = "dial-features",
+ .destroy = dial_features_destroy,
+ .duplicate = dial_features_duplicate,
};
-
+
/* Forward declarations */
static struct ast_parkinglot *parkinglot_addref(struct ast_parkinglot *parkinglot);
static void parkinglot_unref(struct ast_parkinglot *parkinglot);
return pickup_ext;
}
-struct ast_bridge_thread_obj
+struct ast_bridge_thread_obj
{
struct ast_bridge_config bconfig;
struct ast_channel *chan;
}
/*!
- * \brief store context, extension and priority
+ * \brief store context, extension and priority
* \param chan, context, ext, pri
*/
static void set_c_e_p(struct ast_channel *chan, const char *context, const char *ext, int pri)
*
* Check if channel has 'GOTO_ON_BLINDXFR' set, if not exit.
* When found make sure the types are compatible. Check if channel is valid
- * if so start the new channel else hangup the call.
+ * if so start the new channel else hangup the call.
*/
-static void check_goto_on_transfer(struct ast_channel *chan)
+static void check_goto_on_transfer(struct ast_channel *chan)
{
struct ast_channel *xferchan;
const char *val;
}
ast_parseable_goto(xferchan, goto_on_transfer);
ast_channel_state_set(xferchan, AST_STATE_UP);
- ast_clear_flag(ast_channel_flags(xferchan), AST_FLAGS_ALL);
+ ast_clear_flag(ast_channel_flags(xferchan), AST_FLAGS_ALL);
ast_channel_clear_softhangup(xferchan, AST_SOFTHANGUP_ALL);
if (ast_do_masquerade(xferchan) || ast_pbx_start(xferchan)) {
int timeout, int *outstate, const char *language);
/*!
- * \brief bridge the call
+ * \brief bridge the call
* \param data thread bridge.
*
* Set Last Data for respective channels, reset cdr for channels
*
* Create thread and attributes, call bridge_call_thread
*/
-static void bridge_call_thread_launch(void *data)
+static void bridge_call_thread_launch(void *data)
{
pthread_t thread;
pthread_attr_t attr;
!ast_strlen_zero(pu->parkinglot->cfg.mohclass) ? strlen(pu->parkinglot->cfg.mohclass) + 1 : 0);
}
}
-
+
pu->start = ast_tvnow();
pu->parkingtime = (args->timeout > 0) ? args->timeout : pu->parkinglot->cfg.parkingtime;
if (args->extout)
* context. Information on extension options is lost here, so
* we set a flag
*/
- ast_copy_string(pu->context,
- S_OR(args->return_con, S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan))),
+ ast_copy_string(pu->context,
+ S_OR(args->return_con, S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan))),
sizeof(pu->context));
- ast_copy_string(pu->exten,
- S_OR(args->return_ext, S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan))),
+ ast_copy_string(pu->exten,
+ S_OR(args->return_ext, S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan))),
sizeof(pu->exten));
- pu->priority = args->return_pri ? args->return_pri :
+ pu->priority = args->return_pri ? args->return_pri :
(ast_channel_macropriority(chan) ? ast_channel_macropriority(chan) : ast_channel_priority(chan));
/*
}
parse = ast_strdupa(app_data);
AST_STANDARD_APP_ARGS(app_args, parse);
-
+
if (!ast_strlen_zero(app_args.pl_name)) {
/* Find the specified exclusive parking lot */
args.parkinglot = find_parkinglot(app_args.pl_name);
}
parse = ast_strdupa(app_data);
AST_STANDARD_APP_ARGS(app_args, parse);
-
+
if (!ast_strlen_zero(app_args.pl_name)) {
/* Find the specified exclusive parking lot */
args.parkinglot = find_parkinglot(app_args.pl_name);
return -1;
}
}
-
+
if (ast_channel_monitor(callee_chan)) {
ast_verb(4, "User hit '%s' to stop recording call.\n", code);
if (!ast_strlen_zero(automon_message_stop)) {
if (!touch_monitor)
touch_monitor = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR");
-
+
if (!touch_monitor_prefix)
touch_monitor_prefix = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_PREFIX");
-
+
if (touch_monitor) {
len = strlen(touch_monitor) + 50;
args = alloca(len);
if (args[x] == '/')
args[x] = '-';
}
-
+
ast_verb(4, "User hit '%s' to record call. filename: %s\n", code, args);
pbx_exec(callee_chan, monitor_app, args);
if (!ast_strlen_zero(automon_message_start)) { /* Play start message for both channels */
play_message_in_bridged_call(caller_chan, callee_chan, automon_message_start);
}
-
+
return AST_FEATURE_RETURN_SUCCESS;
}
-
- ast_log(LOG_NOTICE,"Cannot record the call. One or both channels have gone away.\n");
+
+ ast_log(LOG_NOTICE,"Cannot record the call. One or both channels have gone away.\n");
return -1;
}
/* This means a mixmonitor is attached to the channel, running or not is unknown. */
if (count > 0) {
-
+
ast_verb(3, "User hit '%s' to stop recording call.\n", code);
/* Make sure they are running */
return AST_FEATURE_RETURN_SUCCESS;
}
}
-
- ast_log(LOG_WARNING,"Stopped MixMonitors are attached to the channel.\n");
- }
+
+ ast_log(LOG_WARNING,"Stopped MixMonitors are attached to the channel.\n");
+ }
if (caller_chan && callee_chan) {
const char *touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MIXMONITOR_FORMAT");
pbx_builtin_setvar_helper(callee_chan, "TOUCH_MIXMONITOR_OUTPUT", touch_filename);
pbx_builtin_setvar_helper(caller_chan, "TOUCH_MIXMONITOR_OUTPUT", touch_filename);
return AST_FEATURE_RETURN_SUCCESS;
-
+
}
ast_log(LOG_NOTICE,"Cannot record the call. One or both channels have gone away.\n");
* \brief Find the context for the transfer
* \param transferer
* \param transferee
- *
+ *
* Grab the TRANSFER_CONTEXT, if fails try grabbing macrocontext.
* \return a context string
*/
if (ast_strlen_zero(s)) {
s = ast_channel_context(transferer);
}
- return s;
+ return s;
}
/*!
* \param code
* \param data
* \param sense feature options
- *
+ *
* Place chan on hold, check if transferred to parkinglot extension,
* otherwise check extension exists and transfer caller.
* \retval AST_FEATURE_RETURN_SUCCESS.
ast_log(LOG_NOTICE,"You didn't pass a feature!\n");
return;
}
-
+
AST_RWLIST_WRLOCK(&feature_list);
AST_RWLIST_INSERT_HEAD(&feature_list,feature,feature_entry);
AST_RWLIST_UNLOCK(&feature_list);
ast_verb(2, "Registered Feature '%s'\n",feature->sname);
}
-/*!
+/*!
* \brief Add new feature group
* \param fgname feature group name.
*
return fg;
}
-/*!
+/*!
* \brief Add feature to group
* \param fg feature group
* \param exten
* \param feature feature to add.
*
* Check fg and feature specified, add feature to list
- * \note This function MUST be called while feature_groups is locked.
+ * \note This function MUST be called while feature_groups is locked.
*/
static void register_group_feature(struct feature_group *fg, const char *exten, struct ast_call_feature *feature)
{
AST_RWLIST_UNLOCK(&feature_groups);
}
-/*!
- * \brief Find a group by name
+/*!
+ * \brief Find a group by name
* \param name feature name
* \retval feature group on success.
* \retval NULL on failure.
}
/*!
- * \brief exec an app by feature
+ * \brief exec an app by feature
* \param chan,peer,config,code,sense,data
*
* Find a feature, determine which channel activated
if (!feature) { /* shouldn't ever happen! */
ast_log(LOG_NOTICE, "Found feature before, but at execing we've lost it??\n");
- return -1;
+ return -1;
}
if (sense == FEATURE_SENSE_CHAN) {
ast_autoservice_start(idle);
ast_autoservice_ignore(idle, AST_FRAME_DTMF_END);
-
+
if(work && idle) {
pbx_builtin_setvar_helper(work, "DYNAMIC_PEERNAME", ast_channel_name(idle));
pbx_builtin_setvar_helper(idle, "DYNAMIC_PEERNAME", ast_channel_name(work));
if (!(monitor_app = pbx_findapp("Monitor")))
monitor_ok=0;
}
- if ((monitor_exec = pbx_builtin_getvar_helper(chan, "AUTO_MONITOR")))
+ if ((monitor_exec = pbx_builtin_getvar_helper(chan, "AUTO_MONITOR")))
src = chan;
else if ((monitor_exec = pbx_builtin_getvar_helper(peer, "AUTO_MONITOR")))
src = peer;
/* Another case where the peer cdr's time will be set, is when
A self-parks by pickup up phone and dialing 700, then B
- picks up A by dialing its parking slot; there may be more
+ picks up A by dialing its parking slot; there may be more
practical paths that get the same result, tho... in which
case you get the previous answer time from the Park... which
- is before the bridge's start time, so I added in the
+ is before the bridge's start time, so I added in the
tvcmp check to the if below */
if (peer_cdr && !ast_tvzero(peer_cdr->answer) && ast_tvcmp(peer_cdr->answer, bridge_cdr->start) >= 0) {
for (;;) {
struct ast_channel *other; /* used later */
-
+
res = ast_channel_bridge(chan, peer, config, &f, &who);
if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)
/* When frame is not set, we are probably involved in a situation
where we've timed out.
When frame is set, we'll come this code twice; once for DTMF_BEGIN
- and also for DTMF_END. If we flow into the following 'if' for both, then
+ and also for DTMF_END. If we flow into the following 'if' for both, then
our wait times are cut in half, as both will subtract from the
feature_timer. Not good!
*/
* However, we don't think the feature has quite yet timed out, so just
* go back into the bridge. */
continue;
- }
+ }
} else {
if (config->feature_timer <=0) {
/* We ran out of time */
}
goto before_you_go;
}
-
+
if (!f || (f->frametype == AST_FRAME_CONTROL &&
(f->subclass.integer == AST_CONTROL_HANGUP || f->subclass.integer == AST_CONTROL_BUSY ||
f->subclass.integer == AST_CONTROL_CONGESTION))) {
* they are useful. I haven't deleted them entirely because I
* just am not sure of the ramifications of removing them. */
if (aoh && aoh->flag == AST_OPTION_FLAG_REQUEST) {
- switch (ntohs(aoh->option)) {
+ switch (ntohs(aoh->option)) {
case AST_OPTION_TONE_VERIFY:
case AST_OPTION_TDD:
case AST_OPTION_RELAXDTMF:
case AST_OPTION_AUDIO_MODE:
case AST_OPTION_DIGIT_DETECT:
case AST_OPTION_FAX_DETECT:
- ast_channel_setoption(other, ntohs(aoh->option), aoh->data,
+ ast_channel_setoption(other, ntohs(aoh->option), aoh->data,
f->datalen - sizeof(struct ast_option_header), 0);
}
}
sendingdtmfdigit = 0;
} else {
/*! append the event to featurecode. we rely on the string being zero-filled, and
- * not overflowing it.
+ * not overflowing it.
* \todo XXX how do we guarantee the latter ?
*/
featurecode[strlen(featurecode)] = f->subclass.integer;
config->end_bridge_callback(config->end_bridge_callback_data);
}
- /* run the hangup exten on the chan object IFF it was NOT involved in a parking situation
+ /* run the hangup exten on the chan object IFF it was NOT involved in a parking situation
* if it were, then chan belongs to a different thread now, and might have been hung up long
* ago.
*/
}
ast_set2_flag(ast_channel_flags(chan), autoloopflag, AST_FLAG_IN_AUTOLOOP);
}
-
+
/* obey the NoCDR() wishes. -- move the DISABLED flag to the bridge CDR if it was set on the channel during the bridge... */
new_chan_cdr = pick_unlocked_cdr(ast_channel_cdr(chan)); /* the proper chan cdr, if there are forked cdrs */
/* If the channel CDR has been modified during the call, record the changes in the bridge cdr,
ast_cdr_end(bridge_cdr);
ast_cdr_detach(bridge_cdr);
}
-
+
/* do a specialized reset on the beginning channel
CDR's, if they still exist, so as not to mess up
issues in future bridges;
-
+
Here are the rules of the game:
1. The chan and peer channel pointers will not change
during the life of the bridge.
2. But, in transfers, the channel names will change.
between the time the bridge is started, and the
- time the channel ends.
+ time the channel ends.
Usually, when a channel changes names, it will
also change CDR pointers.
3. Usually, only one of the two channels (chan or peer)
if (new_chan_cdr) {
struct ast_channel *chan_ptr = NULL;
- if (strcasecmp(orig_channame, ast_channel_name(chan)) != 0) {
+ if (strcasecmp(orig_channame, ast_channel_name(chan)) != 0) {
/* old channel */
if ((chan_ptr = ast_channel_get_by_name(orig_channame))) {
ast_channel_lock(chan_ptr);
new_peer_cdr = pick_unlocked_cdr(ast_channel_cdr(peer)); /* the proper chan cdr, if there are forked cdrs */
if (new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED) && new_peer_cdr && !ast_test_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED))
ast_set_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED); /* DISABLED is viral-- it will propagate across a bridge */
- if (strcasecmp(orig_peername, ast_channel_name(peer)) != 0) {
+ if (strcasecmp(orig_peername, ast_channel_name(peer)) != 0) {
/* old channel */
if ((chan_ptr = ast_channel_get_by_name(orig_peername))) {
ast_channel_lock(chan_ptr);
ast_cdr_specialized_reset(ast_channel_cdr(peer), 0); /* nothing changed, reset the peer cdr */
}
}
-
+
return res;
}
"ConnectedLineNum: %s\r\n"
"ConnectedLineName: %s\r\n"
"UniqueID: %s\r\n",
- pu->parkingexten,
+ pu->parkingexten,
ast_channel_name(pu->chan),
pu->parkinglot->name,
S_COR(ast_channel_caller(pu->chan)->id.number.valid, ast_channel_caller(pu->chan)->id.number.str, "<unknown>"),
AST_LIST_UNLOCK(&curlot->parkings);
}
-/*!
- * \brief Take care of parked calls and unpark them if needed
+/*!
+ * \brief Take care of parked calls and unpark them if needed
* \param ignore unused var.
- *
+ *
* Start inf loop, lock parking lot, check if any parked channels have gone above timeout
* if so, remove channel from parking lot and return it to the extension that parked it.
* Check if parked channel decided to hangup, wait until next FD via select().
/*!
* \brief Unreference parkinglot object.
*/
-static void parkinglot_unref(struct ast_parkinglot *parkinglot)
+static void parkinglot_unref(struct ast_parkinglot *parkinglot)
{
ast_debug(3, "Multiparking: %s refcount now %d\n", parkinglot->name,
ao2_ref(parkinglot, 0) - 1);
newlot = ao2_alloc(sizeof(*newlot), parkinglot_destroy);
if (!newlot)
return NULL;
-
+
ast_copy_string(newlot->name, name, sizeof(newlot->name));
newlot->cfg.is_invalid = 1;/* No config is set yet. */
AST_LIST_HEAD_INIT(&newlot->parkings);
return newlot;
}
-/*!
+/*!
* \brief Add parking hints for all defined parking spaces.
* \param context Dialplan context to add the hints.
* \param start Starting space in parkinglot.
int i;
struct ast_variable *var = NULL;
struct feature_group *fg = NULL;
- char *ctg;
- static const char * const categories[] = {
+ char *ctg;
+ static const char * const categories[] = {
/* Categories in features.conf that are not
* to be parsed as group categories
*/
struct ast_call_feature *feature;
AST_RWLIST_RDLOCK(&feature_list);
- if (!(feature = find_dynamic_feature(var->name)) &&
+ if (!(feature = find_dynamic_feature(var->name)) &&
!(feature = ast_find_call_feature(var->name))) {
AST_RWLIST_UNLOCK(&feature_list);
ast_log(LOG_WARNING, "Feature '%s' was not found.\n", var->name);
#define HFS_FORMAT "%-25s %-7s %-7s\n"
switch (cmd) {
-
+
case CLI_INIT:
e->command = "features show";
e->usage =
static char *handle_features_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- switch (cmd) {
+ switch (cmd) {
case CLI_INIT:
e->command = "features reload";
e->usage =
* \brief Actual bridge
* \param chan
* \param tmpchan
- *
+ *
* Stop hold music, lock both channels, masq channels,
* after bridge return channel to next priority.
*/
* \brief Bridge channels together
* \param s
* \param m
- *
- * Make sure valid channels were specified,
+ *
+ * Make sure valid channels were specified,
* send errors if any of the channels could not be found/locked, answer channels if needed,
- * create the placeholder channels and grab the other channels
- * make the channels compatible, send error if we fail doing so
+ * create the placeholder channels and grab the other channels
+ * make the channels compatible, send error if we fail doing so
* setup the bridge thread object and start the bridge.
- *
+ *
* \retval 0 on success or on incorrect use.
* \retval 1 on failure to bridge channels.
*/
ast_answer(chana);
/* create the placeholder channels and grab the other channels */
- if (!(tmpchana = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
+ if (!(tmpchana = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
NULL, NULL, ast_channel_linkedid(chana), 0, "Bridge/%s", ast_channel_name(chana)))) {
astman_send_error(s, m, "Unable to create temporary channel!");
chana = ast_channel_unref(chana);
ast_answer(chanb);
/* create the placeholder channels and grab the other channels */
- if (!(tmpchanb = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
+ if (!(tmpchanb = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
NULL, NULL, ast_channel_linkedid(chanb), 0, "Bridge/%s", ast_channel_name(chanb)))) {
astman_send_error(s, m, "Unable to create temporary channels!");
ast_hangup(tmpchana);
/*!
* \brief CLI command to list parked calls
- * \param e
+ * \param e
* \param cmd
* \param a
- *
+ *
* Check right usage, lock parking lot, display parked calls, unlock parking lot list.
* \retval CLI_SUCCESS on success.
* \retval CLI_SHOWUSAGE on incorrect number of arguments.
AST_CLI_DEFINE(handle_parkedcalls, "List currently parked calls"),
};
-/*!
+/*!
* \brief Dump parking lot status
* \param s
* \param m
- *
+ *
* Lock parking lot, iterate list and append parked calls status, unlock parking lot.
- * \return Always RESULT_SUCCESS
+ * \return Always RESULT_SUCCESS
*/
static int manager_parking_status(struct mansession *s, const struct message *m)
{
* attempting to pickup the same channel.
*/
static const struct ast_datastore_info pickup_active = {
- .type = "pickup-active",
+ .type = "pickup-active",
};
int ast_can_pickup(struct ast_channel *chan)
ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n", chan_name);
goto pickup_failed;
}
-
+
/* setting this flag to generate a reason header in the cancel message to the ringing channel */
ast_set_flag(ast_channel_flags(chan), AST_FLAG_ANSWERED_ELSEWHERE);
OPT_CALLER_PARK = (1 << 10),
OPT_CALLEE_KILL = (1 << 11),
};
-
+
enum {
OPT_ARG_DURATION_LIMIT = 0,
OPT_ARG_DURATION_STOP,
config->play_warning = config->warning_freq = 0;
}
}
-
+
ast_channel_lock(chan);
var = pbx_builtin_getvar_helper(chan, "LIMIT_PLAYAUDIO_CALLER");
* \brief Bridge channels
* \param chan
* \param data channel to bridge with.
- *
+ *
* Split data, check we aren't bridging with ourself, check valid channel,
* answer call if not already, check compatible channels, setup bridge config
* now bridge call, if transfered party hangs up return to PBX extension.
AST_APP_ARG(dest_chan);
AST_APP_ARG(options);
);
-
+
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Bridge require at least 1 argument specifying the other end of the bridge\n");
return -1;
}
/* try to allocate a place holder where current_dest_chan will be placed */
- if (!(final_dest_chan = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
+ if (!(final_dest_chan = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
NULL, NULL, ast_channel_linkedid(current_dest_chan), 0, "Bridge/%s", ast_channel_name(current_dest_chan)))) {
ast_log(LOG_WARNING, "Cannot create placeholder channel for chan %s\n", args.dest_chan);
ast_manager_event(chan, EVENT_FLAG_CALL, "BridgeExec",
"Channel1: %s\r\n"
"Channel2: %s\r\n", ast_channel_name(chan), ast_channel_name(final_dest_chan));
- /* we have 2 valid channels to bridge, now it is just a matter of setting up the bridge config and starting the bridge */
+ /* we have 2 valid channels to bridge, now it is just a matter of setting up the bridge config and starting the bridge */
if (ast_test_flag(&opts, BRIDGE_OPT_PLAYTONE) && !ast_strlen_zero(xfersound)) {
if (!ast_streamfile(final_dest_chan, xfersound, ast_channel_language(final_dest_chan))) {
if (ast_waitstream(final_dest_chan, "") < 0)
ast_log(LOG_WARNING, "Failed to play courtesy tone on %s\n", ast_channel_name(final_dest_chan));
}
}
-
+
current_dest_chan = ast_channel_unref(current_dest_chan);
-
+
if (ast_test_flag(&opts, OPT_DURATION_LIMIT) && !ast_strlen_zero(opt_args[OPT_ARG_DURATION_LIMIT])) {
if (ast_bridge_timelimit(chan, &bconfig, opt_args[OPT_ARG_DURATION_LIMIT], &calldurationlimit))
goto done;
*
* \brief Generic File Format Support.
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
*/
#include "asterisk.h"
int align = (char *)&p.b - (char *)&p.a;
tmp->buf_size = ((f->buf_size + align - 1) / align) * align;
}
-
+
memset(&tmp->list, 0, sizeof(tmp->list));
AST_RWLIST_INSERT_HEAD(&formats, tmp, list);
if (fs->vfs)
return ast_writestream(fs->vfs, f);
/* else ignore */
- return 0;
+ return 0;
}
} else if (f->frametype != AST_FRAME_VOICE) {
ast_log(LOG_WARNING, "Tried to write non-voice frame\n");
}
if (ast_format_cmp(&f->subclass.format, &fs->fmt->format) != AST_FORMAT_CMP_NOT_EQUAL) {
res = fs->fmt->write(fs, f);
- if (res < 0)
+ if (res < 0)
ast_log(LOG_WARNING, "Natural write failed\n");
else if (res > 0)
ast_log(LOG_WARNING, "Huh??\n");
ast_translator_free_path(fs->trans);
fs->trans = NULL;
}
- if (!fs->trans)
+ if (!fs->trans)
fs->trans = ast_translator_build_path(&fs->fmt->format, &f->subclass.format);
if (!fs->trans)
ast_log(LOG_WARNING, "Unable to translate to format %s, source format %s\n",
* unused for DELETE
* optional ast_format_cap holding all the formats found for a file, for EXISTS.
* destination file name (const char *) for COPY and RENAME
- * struct ast_channel * for OPEN
+ * struct ast_channel * for OPEN
* if fmt is NULL, OPEN will return the first matching entry,
* whereas other functions will run on all matching entries.
*/
/*!
* \brief helper routine to locate a file with a given format
* and language preference.
- *
+ *
* \note Try preflang, preflang with stripped '_' suffices, or NULL.
*
* \note The last parameter(s) point to a buffer of sufficient size,
struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char *filename, const char *preflang, int asis)
{
- /*
+ /*
* Use fileexists_core() to find a file in a compatible
* language and format, set up a suitable translator,
* and open the stream.
ast_frfree(fr);
}
goto return_failure;
- }
+ }
if (fr) {
ast_frfree(fr);
if (res == FSREAD_SUCCESS_SCHED)
return 1;
-
+
return 0;
}
if (res == FSREAD_SUCCESS_SCHED)
return 1;
-
+
return 0;
}
struct ast_format_def *f;
struct ast_filestream *fs = NULL;
char *fn;
- int format_found = 0;
+ int format_found = 0;
AST_RWLIST_RDLOCK(&formats);
fs = NULL;
if (!exts_compare(f->exts, type))
continue;
- else
+ else
format_found = 1;
fn = build_filename(filename, type);
fs = NULL;
bfile = NULL;
ast_free(fn);
- break;
+ break;
}
/* found it */
fs->trans = NULL;
/* set the O_TRUNC flag if and only if there is no O_APPEND specified */
/* We really can't use O_APPEND as it will break WAV header updates */
- if (flags & O_APPEND) {
+ if (flags & O_APPEND) {
flags &= ~O_APPEND;
} else {
myflags = O_TRUNC;
}
-
+
myflags |= O_WRONLY | O_CREAT;
/* XXX need to fix this - we should just do the fopen,
fd = -1;
}
}
-
+
if (ast_opt_cache_record_files && (fd > -1)) {
char *c;
ast_frfree(fr);
ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
return res;
- }
+ }
}
break;
case AST_FRAME_CONTROL:
}
}
return res;
-}
+}
char *ast_format_str_reduce(char *fmts)
{
* this code.
*/
-/*! \file
- *
+/*! \file
+ *
* \brief Jitterbuffering algorithm.
- *
+ *
* \author Slav Klenov <slav@securax.org>
*/
static void get_jb_head(struct fixed_jb *jb, struct fixed_jb_frame *frame)
{
struct fixed_jb_frame *fr;
-
+
/* unlink the frame */
fr = jb->frames;
jb->frames = fr->next;
/* the jb is empty - update tail */
jb->tail = NULL;
}
-
+
/* update next */
jb->next_delivery = fr->delivery + fr->ms;
-
+
/* copy the destination */
memcpy(frame, fr, sizeof(struct fixed_jb_frame));
-
+
/* and release the frame */
release_jb_frame(jb, fr);
}
struct fixed_jb *fixed_jb_new(struct fixed_jb_conf *conf)
{
struct fixed_jb *jb;
-
+
if (!(jb = ast_calloc(1, sizeof(*jb))))
return NULL;
-
+
/* First copy our config */
memcpy(&jb->conf, conf, sizeof(struct fixed_jb_conf));
/* we don't need the passed config anymore - continue working with the saved one */
conf = &jb->conf;
-
+
/* validate the configuration */
if (conf->jbsize < 1)
conf->jbsize = FIXED_JB_SIZE_DEFAULT;
if (conf->resync_threshold < 1)
conf->resync_threshold = FIXED_JB_RESYNCH_THRESHOLD_DEFAULT;
-
+
/* Set the constant delay to the jitterbuf */
jb->delay = conf->jbsize;
-
+
return jb;
}
{
/* jitterbuf MUST be empty before it can be destroyed */
ASSERT(jb->frames == NULL);
-
+
ast_free(jb);
}
{
long diff, offset;
struct fixed_jb_frame *frame;
-
+
/* If jb is empty, just reinitialize the jb */
if (!jb->frames) {
/* debug check: tail should also be NULL */
ASSERT(jb->tail == NULL);
-
+
return fixed_jb_put_first(jb, data, ms, ts, now);
}
-
+
/* Adjust all jb state just as the new frame is with delivery = the delivery of the last
frame (e.g. this one with max delivery) + the length of the last frame. */
-
+
/* Get the diff in timestamps */
diff = ts - jb->tail->ts;
-
+
/* Ideally this should be just the length of the last frame. The deviation is the desired
offset */
offset = diff - jb->tail->ms;
-
+
/* Do we really need to resynch, or this is just a frame for dropping? */
if (!jb->force_resynch && (offset < jb->conf.resync_threshold && offset > -jb->conf.resync_threshold))
return FIXED_JB_DROP;
-
+
/* Reset the force resynch flag */
jb->force_resynch = 0;
-
+
/* apply the offset to the jb state */
jb->rxcore -= offset;
frame = jb->frames;
frame->ts += offset;
frame = frame->next;
}
-
+
/* now jb_put() should add the frame at a last position */
return fixed_jb_put(jb, data, ms, ts, now);
}
{
/* this is our first frame - set the base of the receivers time */
jb->rxcore = now - ts;
-
+
/* init next for a first time - it should be the time the first frame should be played */
jb->next_delivery = now + jb->delay;
-
+
/* put the frame */
return fixed_jb_put(jb, data, ms, ts, now);
}
{
struct fixed_jb_frame *frame, *next, *newframe;
long delivery;
-
+
/* debug check the validity of the input params */
ASSERT(data != NULL);
/* do not allow frames shorter than 2 ms */
ASSERT(ms >= 2);
ASSERT(ts >= 0);
ASSERT(now >= 0);
-
+
delivery = jb->rxcore + jb->delay + ts;
-
+
/* check if the new frame is not too late */
if (delivery < jb->next_delivery) {
/* should drop the frame, but let first resynch_jb() check if this is not a jump in ts, or
the force resynch flag was not set. */
return resynch_jb(jb, data, ms, ts, now);
}
-
+
/* what if the delivery time is bigger than next + delay? Seems like a frame for the future.
However, allow more resync_threshold ms in advance */
if (delivery > jb->next_delivery + jb->delay + jb->conf.resync_threshold) {
while (frame && frame->delivery > delivery) {
frame = frame->prev;
}
-
+
/* Check if the new delivery time is not covered already by the chosen frame */
if (frame && (frame->delivery == delivery ||
delivery < frame->delivery + frame->ms ||
{
/* TODO: Should we check for resynch here? Be careful to do not allow threshold smaller than
the size of the jb */
-
+
/* should drop the frame, but let first resynch_jb() check if this is not a jump in ts, or
the force resynch flag was not set. */
return resynch_jb(jb, data, ms, ts, now);
}
-
+
/* Reset the force resynch flag */
jb->force_resynch = 0;
-
+
/* Get a new frame */
newframe = alloc_jb_frame(jb);
newframe->data = data;
newframe->ts = ts;
newframe->ms = ms;
newframe->delivery = delivery;
-
+
/* and insert it right on place */
if (frame) {
next = frame->next;
newframe->next = NULL;
}
newframe->prev = frame;
-
+
return FIXED_JB_OK;
} else if (!jb->frames) {
/* the frame list is empty or thats just the first frame ever */
jb->frames = jb->tail = newframe;
newframe->next = NULL;
newframe->prev = NULL;
-
+
return FIXED_JB_OK;
} else {
/* insert on a first position - should update frames head */
newframe->prev = NULL;
jb->frames->prev = newframe;
jb->frames = newframe;
-
+
return FIXED_JB_OK;
}
}
{
ASSERT(now >= 0);
ASSERT(interpl >= 2);
-
+
if (now < jb->next_delivery) {
/* too early for the next frame */
return FIXED_JB_NOFRAME;
}
-
+
/* Is the jb empty? */
if (!jb->frames) {
/* should interpolate a frame */
/* update next */
jb->next_delivery += interpl;
-
+
return FIXED_JB_INTERP;
}
-
+
/* Isn't it too late for the first frame available in the jb? */
if (now > jb->frames->delivery + jb->frames->ms) {
/* yes - should drop this frame and update next to point the next frame (get_jb_head() does it) */
get_jb_head(jb, frame);
-
+
return FIXED_JB_DROP;
}
-
+
/* isn't it too early to play the first frame available? */
if (now < jb->frames->delivery) {
/* yes - should interpolate one frame */
/* update next */
jb->next_delivery += interpl;
-
+
return FIXED_JB_INTERP;
}
-
+
/* we have a frame for playing now (get_jb_head() updates next) */
get_jb_head(jb, frame);
-
+
return FIXED_JB_OK;
}
{
if (!jb->frames)
return FIXED_JB_NOFRAME;
-
+
get_jb_head(jb, frameout);
-
+
return FIXED_JB_OK;
}
* at the top of the source tree.
*/
-/*! \file
- *
+/*! \file
+ *
* \brief Jitterbuffering algorithm.
- *
+ *
*/
#ifndef _FIXEDJITTERBUF_H_
struct fixed_jb_conf
{
long jbsize;
- long resync_threshold;
+ long resync_threshold;
};
*
* \brief Frame and codec manipulation routines
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
*/
#include "asterisk.h"
/*! \brief A per-thread cache of frame headers */
AST_THREADSTORAGE_CUSTOM(frame_cache, NULL, frame_cache_cleanup);
-/*!
+/*!
* \brief Maximum ast_frame cache size
*
* In most cases where the frame header cache will be useful, the size
* of the cache will stay very small. However, it is not always the case that
* the same thread that allocates the frame will be the one freeing them, so
* sometimes a thread will never have any frames in its cache, or the cache
- * will never be pulled from. For the latter case, we limit the maximum size.
- */
+ * will never be pulled from. For the latter case, we limit the maximum size.
+ */
#define FRAME_CACHE_MAX_SIZE 10
/*! \brief This is just so ast_frames, a list head struct for holding a list of
#endif
f->mallocd_hdr_len = sizeof(*f);
-
+
return f;
}
while ((f = AST_LIST_REMOVE_HEAD(&frames->list, frame_list)))
ast_free(f);
-
+
ast_free(frames);
}
#endif
#if !defined(LOW_MEMORY)
if (cache && fr->mallocd == AST_MALLOCD_HDR) {
- /* Cool, only the header is malloc'd, let's just cache those for now
+ /* Cool, only the header is malloc'd, let's just cache those for now
* to keep things simple... */
struct ast_frame_cache *frames;
}
}
#endif
-
+
if (fr->mallocd & AST_MALLOCD_DATA) {
- if (fr->data.ptr)
+ if (fr->data.ptr)
ast_free(fr->data.ptr - fr->offset);
}
if (fr->mallocd & AST_MALLOCD_SRC) {
} else {
out = fr;
}
-
+
if (!(fr->mallocd & AST_MALLOCD_SRC) && fr->src) {
if (!(out->src = ast_strdup(fr->src))) {
if (out != fr) {
fr->src = NULL;
fr->mallocd &= ~AST_MALLOCD_SRC;
}
-
+
if (!(fr->mallocd & AST_MALLOCD_DATA)) {
if (!fr->datalen) {
out->data.uint32 = fr->data.uint32;
}
out->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_SRC | AST_MALLOCD_DATA;
-
+
return out;
}
srclen = strlen(f->src);
if (srclen > 0)
len += srclen + 1;
-
+
#if !defined(LOW_MEMORY)
if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
AST_LIST_TRAVERSE_SAFE_BEGIN(&frames->list, out, frame_list) {
out->offset = AST_FRIENDLY_OFFSET;
if (out->datalen) {
out->data.ptr = buf + sizeof(*out) + AST_FRIENDLY_OFFSET;
- memcpy(out->data.ptr, f->data.ptr, out->datalen);
+ memcpy(out->data.ptr, f->data.ptr, out->datalen);
} else {
out->data.uint32 = f->data.uint32;
}
if (!f) {
- ast_verbose("%s [ %s (NULL) ] [%s]\n",
+ ast_verbose("%s [ %s (NULL) ] [%s]\n",
term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
- term_color(cft, "HANGUP", COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
+ term_color(cft, "HANGUP", COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
return;
}
snprintf(ftype, sizeof(ftype), "Unknown Frametype '%d'", f->frametype);
}
if (!ast_strlen_zero(moreinfo))
- ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) '%s' ] [%s]\n",
+ ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) '%s' ] [%s]\n",
term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
- f->frametype,
+ f->frametype,
term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
- f->subclass.integer,
+ f->subclass.integer,
term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)),
term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
else
- ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) ] [%s]\n",
+ ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) ] [%s]\n",
term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
- f->frametype,
+ f->frametype,
term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
- f->subclass.integer,
+ f->subclass.integer,
term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
}
-int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_format_cap *cap, const char *list, int allowing)
+int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_format_cap *cap, const char *list, int allowing)
{
int errors = 0, framems = 0, all = 0, iter_allowing;
char *parse = NULL, *this = NULL, *psize = NULL;
int byte = bit / 8; /* byte containing first bit */
int rem = 8 - (bit % 8); /* remaining bits in first byte */
unsigned char ret = 0;
-
+
if (n <= 0 || n > 8)
return 0;
unsigned char c;
/* skip up to two wideband frames */
- if (((len * 8 - off) >= 5) &&
+ if (((len * 8 - off) >= 5) &&
get_n_bits_at(data, 1, off)) {
c = get_n_bits_at(data, 3, off + 1);
off += SpeexWBSubModeSz[c];
- if (((len * 8 - off) >= 5) &&
+ if (((len * 8 - off) >= 5) &&
get_n_bits_at(data, 1, off)) {
c = get_n_bits_at(data, 3, off + 1);
off += SpeexWBSubModeSz[c];
- if (((len * 8 - off) >= 5) &&
+ if (((len * 8 - off) >= 5) &&
get_n_bits_at(data, 1, off)) {
ast_log(LOG_WARNING, "Encountered corrupt speex frame; too many wideband frames in a row.\n");
return -1;
{
static const int SpeexSubModeSz[] = {
5, 43, 119, 160,
- 220, 300, 364, 492,
+ 220, 300, 364, 492,
79, 0, 0, 0,
0, 0, 0, 0 };
- static const int SpeexInBandSz[] = {
+ static const int SpeexInBandSz[] = {
1, 1, 4, 4,
4, 4, 4, 4,
8, 8, 16, 16,
c = get_n_bits_at(data, 5, bit);
bit += 5;
- if (c == 15) {
+ if (c == 15) {
/* terminator */
- break;
+ break;
} else if (c == 14) {
/* in-band signal; next 4 bits contain signal id */
c = get_n_bits_at(data, 4, bit);
{
int len = 0;
- /* XXX Still need speex, and lpc10 XXX */
+ /* XXX Still need speex, and lpc10 XXX */
switch(format->id) {
case AST_FORMAT_G723_1:
len = (samples / 240) * 20;
* Copyright (C) 1999 - 2005, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
- *
+ *
* Includes code and algorithms from the Zapata library.
*
* See http://www.asterisk.org for more information about
/*! \file
*
- * \brief FSK Modulator/Demodulator
+ * \brief FSK Modulator/Demodulator
*
* \author Mark Spencer <markster@digium.com>
*
#define GET_SAMPLE get_sample(&buffer, len)
/*! \brief Coefficients for input filters
- * Coefficients table, generated by program "mkfilter"
+ * Coefficients table, generated by program "mkfilter"
* mkfilter is part of the zapatatelephony.org distribution
* Format: coef[IDX_FREC][IDX_BW][IDX_COEF]
- * IDX_COEF = 0 => 1/GAIN
- * IDX_COEF = 1-6 => Coefficientes y[n]
+ * IDX_COEF = 0 => 1/GAIN
+ * IDX_COEF = 1-6 => Coefficientes y[n]
*/
static double coef_in[NF][NBW][8] = {
{
- { 1.8229206611e-04,-7.8997325866e-01,2.2401819940e+00,-4.6751353581e+00,5.5080745712e+00,-5.0571565772e+00,2.6215820004e+00,0.0000000000e+00, },
- { 9.8532175289e-02,-5.6297236492e-02,3.3146713415e-01,-9.2239200436e-01,1.4844365184e+00,-2.0183258642e+00,2.0074154497e+00,0.0000000000e+00, },
- },
- {
- { 1.8229206610e-04,-7.8997325866e-01,7.7191410839e-01,-2.8075643964e+00,1.6948618347e+00,-3.0367273700e+00,9.0333559408e-01,0.0000000000e+00, } ,
- { 9.8531161839e-02,-5.6297236492e-02,1.1421579050e-01,-4.8122536483e-01,4.0121072432e-01,-7.4834487567e-01,6.9170822332e-01,0.0000000000e+00, },
+ { 1.8229206611e-04,-7.8997325866e-01,2.2401819940e+00,-4.6751353581e+00,5.5080745712e+00,-5.0571565772e+00,2.6215820004e+00,0.0000000000e+00, },
+ { 9.8532175289e-02,-5.6297236492e-02,3.3146713415e-01,-9.2239200436e-01,1.4844365184e+00,-2.0183258642e+00,2.0074154497e+00,0.0000000000e+00, },
+ },
+ {
+ { 1.8229206610e-04,-7.8997325866e-01,7.7191410839e-01,-2.8075643964e+00,1.6948618347e+00,-3.0367273700e+00,9.0333559408e-01,0.0000000000e+00, },
+ { 9.8531161839e-02,-5.6297236492e-02,1.1421579050e-01,-4.8122536483e-01,4.0121072432e-01,-7.4834487567e-01,6.9170822332e-01,0.0000000000e+00, },
},
{
- { 1.8229206611e-04,-7.8997325866e-01,2.9003821430e+00,-6.1082779024e+00,7.7169345751e+00,-6.6075999680e+00,3.3941838836e+00,0.0000000000e+00, },
+ { 1.8229206611e-04,-7.8997325866e-01,2.9003821430e+00,-6.1082779024e+00,7.7169345751e+00,-6.6075999680e+00,3.3941838836e+00,0.0000000000e+00, },
{ 9.8539686961e-02,-5.6297236492e-02,4.2915323820e-01,-1.2609358633e+00,2.2399213250e+00,-2.9928879142e+00,2.5990173742e+00,0.0000000000e+00, },
},
{
{ 9.8531161839e-02,-5.6297236492e-02,-1.1421579050e-01,-4.8122536483e-01,-4.0121072432e-01,-7.4834487567e-01,-6.9170822332e-01,0.0000000000e+00, },
},
{
- { 1.8229206611e-04,-7.8997325866e-01,2.5782298908e+00,-5.3629717478e+00,6.5890882172e+00,-5.8012914776e+00,3.0171839130e+00,0.0000000000e+00, },
- { 9.8534230718e-02,-5.6297236492e-02,3.8148618075e-01,-1.0848760410e+00,1.8441165168e+00,-2.4860666655e+00,2.3103384142e+00,0.0000000000e+00, },
+ { 1.8229206611e-04,-7.8997325866e-01,2.5782298908e+00,-5.3629717478e+00,6.5890882172e+00,-5.8012914776e+00,3.0171839130e+00,0.0000000000e+00, },
+ { 9.8534230718e-02,-5.6297236492e-02,3.8148618075e-01,-1.0848760410e+00,1.8441165168e+00,-2.4860666655e+00,2.3103384142e+00,0.0000000000e+00, },
},
{
{ 1.8229206610e-04,-7.8997325866e-01,-3.8715051001e-01,-2.6192408538e+00,-8.3977994034e-01,-2.8329897913e+00,-4.5306444352e-01,0.0000000000e+00, },
{ 9.8531160936e-02,-5.6297236492e-02,-5.7284484199e-02,-4.3673866734e-01,-1.9564766257e-01,-6.2028156584e-01,-3.4692356122e-01,0.0000000000e+00, },
- },
+ },
};
/*! \brief Coefficients for output filter
* Coefficients table, generated by program "mkfilter"
- * Format: coef[IDX_BW][IDX_COEF]
- * IDX_COEF = 0 => 1/GAIN
+ * Format: coef[IDX_BW][IDX_COEF]
+ * IDX_COEF = 0 => 1/GAIN
* IDX_COEF = 1-6 => Coefficientes y[n]
*/
static double coef_out[NBW][8] = {
{ 1.3868644653e-08,-6.3283665042e-01,4.0895057217e+00,-1.1020074592e+01,1.5850766191e+01,-1.2835109292e+01,5.5477477340e+00,0.0000000000e+00, },
- { 3.1262119724e-03,-7.8390522307e-03,8.5209627801e-02,-4.0804129163e-01,1.1157139955e+00,-1.8767603680e+00,1.8916395224e+00,0.0000000000e+00, },
+ { 3.1262119724e-03,-7.8390522307e-03,8.5209627801e-02,-4.0804129163e-01,1.1157139955e+00,-1.8767603680e+00,1.8916395224e+00,0.0000000000e+00, },
};
int i, j;
double s;
double *pc;
-
+
pc = &coef_in[fskd->f_mark_idx][fskd->bw][0];
fskd->fmxv[(fskd->fmp+6)&7] = in*(*pc++);
-
+
s = (fskd->fmxv[(fskd->fmp + 6) & 7] - fskd->fmxv[fskd->fmp]) + 3 * (fskd->fmxv[(fskd->fmp + 2) & 7] - fskd->fmxv[(fskd->fmp + 4) & 7]);
- for (i = 0, j = fskd->fmp; i < 6; i++, j++)
+ for (i = 0, j = fskd->fmp; i < 6; i++, j++)
s += fskd->fmyv[j&7]*(*pc++);
fskd->fmyv[j&7] = s;
fskd->fmp++;
int i, j;
double s;
double *pc;
-
+
pc = &coef_in[fskd->f_space_idx][fskd->bw][0];
fskd->fsxv[(fskd->fsp+6)&7] = in*(*pc++);
-
+
s = (fskd->fsxv[(fskd->fsp + 6) & 7] - fskd->fsxv[fskd->fsp]) + 3 * (fskd->fsxv[(fskd->fsp + 2) & 7] - fskd->fsxv[(fskd->fsp + 4) & 7]);
- for (i = 0, j = fskd->fsp; i < 6; i++, j++)
+ for (i = 0, j = fskd->fsp; i < 6; i++, j++)
s += fskd->fsyv[j&7]*(*pc++);
fskd->fsyv[j&7] = s;
fskd->fsp++;
int i, j;
double s;
double *pc;
-
+
pc = &coef_out[fskd->bw][0];
- fskd->flxv[(fskd->flp + 6) & 7] = in * (*pc++);
-
+ fskd->flxv[(fskd->flp + 6) & 7] = in * (*pc++);
+
s = (fskd->flxv[fskd->flp] + fskd->flxv[(fskd->flp+6)&7]) +
6 * (fskd->flxv[(fskd->flp+1)&7] + fskd->flxv[(fskd->flp+5)&7]) +
15 * (fskd->flxv[(fskd->flp+2)&7] + fskd->flxv[(fskd->flp+4)&7]) +
- 20 * fskd->flxv[(fskd->flp+3)&7];
-
+ 20 * fskd->flxv[(fskd->flp+3)&7];
+
for (i = 0,j = fskd->flp;i<6;i++,j++)
s += fskd->flyv[j&7]*(*pc++);
fskd->flyv[j&7] = s;
float xS,xM;
fskd->cola_in[fskd->pcola] = x;
-
+
xS = filterS(fskd,x);
xM = filterM(fskd,x);
fskd->cola_filter[fskd->pcola] = xM-xS;
x = filterL(fskd,xM*xM - xS*xS);
-
+
fskd->cola_demod[fskd->pcola++] = x;
fskd->pcola &= (NCOLA-1);
float x,spb,spb2,ds;
int f;
- spb = fskd->spb;
+ spb = fskd->spb;
if (fskd->spb == 7)
spb = 8000.0 / 1200.0;
ds = spb/32.;
return -1;
samples++;
for (;;) {
-search_startbit2:
+search_startbit2:
if (*len <= 0) {
fskd->state = STATE_SEARCH_STARTBIT2;
return 0;
return(-1);
#if 0
printf("x2 = %5.5f ", fskd->x2);
-#endif
+#endif
if (fskd->x2 < -0.5)
- break;
+ break;
}
-search_startbit3:
+search_startbit3:
/* We await for 0.5 bits before using DPLL */
i = fskd->spb/2;
if (*len < i) {
}
for (; i>0; i--) {
if (demodulator(fskd, &fskd->x1, GET_SAMPLE))
- return(-1);
+ return(-1);
#if 0
printf("x1 = %5.5f ", fskd->x1);
-#endif
+#endif
samples++;
}
- /* x1 must be negative (start bit confirmation) */
+ /* x1 must be negative (start bit confirmation) */
} while (fskd->x1 > 0);
fskd->state = STATE_GET_BYTE;
/* We read parity bit (if exists) and check parity */
if (fskd->parity) {
olen = *len;
- i = get_bit_raw(fskd, buffer, len);
+ i = get_bit_raw(fskd, buffer, len);
buffer += (olen - *len);
if (i == -1)
return(-1);
a |= 0x100; /* error */
}
}
-
+
/* We read STOP bits. All of them must be 1 */
-
+
for (j = fskd->nstop;j;j--) {
r = get_bit_raw(fskd, buffer, len);
if (r == -1)
* Copyright (C) 1999 - 2005, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
- *
+ *
* Includes code and algorithms from the Zapata library.
*
* See http://www.asterisk.org for more information about
/*! \file
*
- * \brief FSK Modulator/Demodulator
+ * \brief FSK Modulator/Demodulator
*
* \author Mark Spencer <markster@digium.com>
*
#define IGET_SAMPLE iget_sample(&buffer, len)
/*! \brief Coefficients for input filters
- * Coefficients table, generated by program "mkfilter"
+ * Coefficients table, generated by program "mkfilter"
* mkfilter is part of the zapatatelephony.org distribution
* Format: coef[IDX_FREC][IDX_BW][IDX_COEF]
- * IDX_COEF = 0 => 1/GAIN
- * IDX_COEF = 1-6 => Coefficientes y[n]
+ * IDX_COEF = 0 => 1/GAIN
+ * IDX_COEF = 1-6 => Coefficientes y[n]
*/
static double coef_in[NF][NBW][8]={
{ { 1.8229206611e-04,-7.8997325866e-01,2.2401819940e+00,-4.6751353581e+00,5.5080745712e+00,-5.0571565772e+00,2.6215820004e+00,0.0000000000e+00,
}, { 9.8534230718e-02,-5.6297236492e-02,3.8148618075e-01,-1.0848760410e+00,1.8441165168e+00,-2.4860666655e+00,2.3103384142e+00,0.0000000000e+00,
}, }, { { 1.8229206610e-04,-7.8997325866e-01,-3.8715051001e-01,-2.6192408538e+00,-8.3977994034e-01,-2.8329897913e+00,-4.5306444352e-01,0.0000000000e+00,
}, { 9.8531160936e-02,-5.6297236492e-02,-5.7284484199e-02,-4.3673866734e-01,-1.9564766257e-01,-6.2028156584e-01,-3.4692356122e-01,0.0000000000e+00,
- }, },
+ }, },
};
/*! \brief Coefficients for output filter
* Coefficients table, generated by program "mkfilter"
- * Format: coef[IDX_BW][IDX_COEF]
- * IDX_COEF = 0 => 1/GAIN
+ * Format: coef[IDX_BW][IDX_COEF]
+ * IDX_COEF = 0 => 1/GAIN
* IDX_COEF = 1-6 => Coefficientes y[n]
*/
static double coef_out[NBW][8]={
{ 1.3868644653e-08,-6.3283665042e-01,4.0895057217e+00,-1.1020074592e+01,1.5850766191e+01,-1.2835109292e+01,5.5477477340e+00,0.0000000000e+00,
- }, { 3.1262119724e-03,-7.8390522307e-03,8.5209627801e-02,-4.0804129163e-01,1.1157139955e+00,-1.8767603680e+00,1.8916395224e+00,0.0000000000e+00
- },
+ }, { 3.1262119724e-03,-7.8390522307e-03,8.5209627801e-02,-4.0804129163e-01,1.1157139955e+00,-1.8767603680e+00,1.8916395224e+00,0.0000000000e+00
+ },
};
/*! Integer Pass Band demodulator filter */
int i,j;
int s;
int64_t s_interim;
-
+
/* integer filter */
s = in * fs->icoefs[0];
fs->ixv[(fs->ip + 6) & 7] = s;
-
+
s = (fs->ixv[fs->ip] + fs->ixv[(fs->ip + 6) & 7]) +
6 * (fs->ixv[(fs->ip + 1) & 7] + fs->ixv[(fs->ip + 5) & 7]) +
15 * (fs->ixv[(fs->ip + 2) & 7] + fs->ixv[(fs->ip + 4) & 7]) +
20 * fs->ixv[(fs->ip + 3) & 7];
-
+
for (i = 1, j = fs->ip; i < 7; i++, j++) {
/* Promote operation to 64 bit to prevent overflow that occurred in 32 bit) */
- s_interim = (int64_t)(fs->iyv[j & 7]) *
+ s_interim = (int64_t)(fs->iyv[j & 7]) *
(int64_t)(fs->icoefs[i]) /
(int64_t)(1024);
s += (int) s_interim;
int i, j;
int s;
int64_t s_interim;
-
+
/* integer filter */
s = in * fs->icoefs[0] / 256;
fs->ixv[(fs->ip + 6) & 7] = s;
-
+
s = (fs->ixv[(fs->ip + 6) & 7] - fs->ixv[fs->ip])
+ 3 * (fs->ixv[(fs->ip + 2) & 7] - fs->ixv[(fs->ip + 4) & 7]);
-
- for (i = 1, j = fs->ip; i < 7; i++, j++) {
- s_interim = (int64_t)(fs->iyv[j & 7]) *
- (int64_t)(fs->icoefs[i]) /
+
+ for (i = 1, j = fs->ip; i < 7; i++, j++) {
+ s_interim = (int64_t)(fs->iyv[j & 7]) *
+ (int64_t)(fs->icoefs[i]) /
(int64_t)(256);
s += (int) s_interim;
}
{
int is, im, id;
int ilin2;
-
+
is = ibpfilter(&fskd->space_filter, x);
im = ibpfilter(&fskd->mark_filter, x);
-
+
ilin2 = ((im * im) - (is * is)) / (256 * 256);
-
+
id = ibpdfilter(&fskd->demod_filter, ilin2);
-
+
*retval = id;
return 0;
}
if ((ix * fskd->xi0) < 0) { /* Transicion */
if (!f) {
if (fskd->icont < (fskd->pllispb2)) {
- fskd->icont += fskd->pllids;
+ fskd->icont += fskd->pllids;
} else {
fskd->icont -= fskd->pllids;
}
fskd->demod_filter.ip = 0;
for ( i = 0 ; i < 7 ; i++ ) {
- fskd->space_filter.icoefs[i] =
+ fskd->space_filter.icoefs[i] =
coef_in[fskd->f_space_idx][fskd->bw][i] * 256;
fskd->space_filter.ixv[i] = 0;;
fskd->space_filter.iyv[i] = 0;;
- fskd->mark_filter.icoefs[i] =
+ fskd->mark_filter.icoefs[i] =
coef_in[fskd->f_mark_idx][fskd->bw][i] * 256;
fskd->mark_filter.ixv[i] = 0;;
fskd->mark_filter.iyv[i] = 0;;
- fskd->demod_filter.icoefs[i] =
+ fskd->demod_filter.icoefs[i] =
coef_out[fskd->bw][i] * 1024;
fskd->demod_filter.ixv[i] = 0;;
fskd->demod_filter.iyv[i] = 0;;
int olen;
int beginlen = *len;
int beginlenx;
-
+
switch (fskd->state) {
/* Pick up where we left off */
case STATE_SEARCH_STARTBIT2:
just start sending a start bit with nothing preceding it at the beginning
of a transmission (what a LOSING design), we cant do it this elegantly */
/* NOT USED
- if (demodulator(zap,&x1))
+ if (demodulator(zap,&x1))
return -1;
for(;;) {
- if (demodulator(zap,&x2))
+ if (demodulator(zap,&x2))
return -1;
if (x1>0 && x2<0) break;
x1=x2;
return -1;
samples++;
for(;;) {
-search_startbit2:
+search_startbit2:
if (*len <= 0) {
fskd->state = STATE_SEARCH_STARTBIT2;
return 0;
}
samples++;
- if (idemodulator(fskd, &fskd->xi2, IGET_SAMPLE))
+ if (idemodulator(fskd, &fskd->xi2, IGET_SAMPLE))
return -1;
#if 0
printf("xi2 = %d ", fskd->xi2);
-#endif
+#endif
if (fskd->xi2 < 512) {
break;
}
}
-search_startbit3:
+search_startbit3:
/* We await for 0.5 bits before using DPLL */
i = fskd->ispb / 2;
if (*len < i) {
}
for (; i > 0; i--) {
if (idemodulator(fskd, &fskd->xi1, IGET_SAMPLE))
- return(-1);
+ return(-1);
#if 0
printf("xi1 = %d ", fskd->xi1);
#endif
- samples++;
+ samples++;
}
/* x1 must be negative (start bit confirmation) */
olen = *len;
i = get_bit_raw(fskd, buffer, len);
buffer += (olen - *len);
- if (i == -1)
+ if (i == -1)
return -1;
- if (i)
+ if (i)
n1++;
- a >>= 1;
+ a >>= 1;
a |= i;
}
j = 8 - fskd->nbit;
/* We read parity bit (if exists) and check parity */
if (fskd->parity) {
olen = *len;
- i = get_bit_raw(fskd, buffer, len);
+ i = get_bit_raw(fskd, buffer, len);
buffer += (olen - *len);
- if (i == -1)
+ if (i == -1)
return -1;
- if (i)
+ if (i)
n1++;
if (fskd->parity == 1) { /* parity=1 (even) */
- if (n1 & 1)
+ if (n1 & 1)
a |= 0x100; /* error */
} else { /* parity=2 (odd) */
- if (!(n1 & 1))
+ if (!(n1 & 1))
a |= 0x100; /* error */
}
}
-
+
/* We read STOP bits. All of them must be 1 */
-
+
for (j = fskd->instop; j; j--) {
r = get_bit_raw(fskd, buffer, len);
- if (r == -1)
+ if (r == -1)
return -1;
- if (!r)
+ if (!r)
a |= 0x200;
}
- /* And finally we return
- * Bit 8 : Parity error
+ /* And finally we return
+ * Bit 8 : Parity error
* Bit 9 : Framming error
*/
-
+
*outbyte = a;
fskd->state = STATE_SEARCH_STARTBIT;
return 1;
*
* \brief Image Management
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
*/
#include "asterisk.h"
int fd;
int len=0;
struct ast_frame *f = NULL;
-
+
AST_RWLIST_RDLOCK(&imagers);
AST_RWLIST_TRAVERSE(&imagers, i, list) {
/* if NULL image format, just pick the first one, otherwise match it. */
}
}
if (found)
- break;
+ break;
}
if (found) {
if (!found->identify || found->identify(fd)) {
/* Reset file pointer */
lseek(fd, 0, SEEK_SET);
- f = found->read_image(fd, len);
+ f = found->read_image(fd, len);
} else
ast_log(LOG_WARNING, "%s does not appear to be a %s file\n", buf, found->name);
close(fd);
ast_log(LOG_WARNING, "Unable to open '%s': %s\n", buf, strerror(errno));
} else
ast_log(LOG_WARNING, "Image file '%s' not found\n", filename);
-
+
AST_RWLIST_UNLOCK(&imagers);
-
+
return f;
}
int ast_tone_zone_part_parse(const char *s, struct ast_tone_zone_part *tone_data)
{
- if (sscanf(s, "%30u+%30u/%30u", &tone_data->freq1, &tone_data->freq2,
+ if (sscanf(s, "%30u+%30u/%30u", &tone_data->freq1, &tone_data->freq2,
&tone_data->time) == 3) {
/* f1+f2/time format */
} else if (sscanf(s, "%30u+%30u", &tone_data->freq1, &tone_data->freq2) == 2) {
/* f1+f2 format */
tone_data->time = 0;
- } else if (sscanf(s, "%30u*%30u/%30u", &tone_data->freq1, &tone_data->freq2,
+ } else if (sscanf(s, "%30u*%30u/%30u", &tone_data->freq1, &tone_data->freq2,
&tone_data->time) == 3) {
/* f1*f2/time format */
tone_data->modulate = 1;
/* f1 format */
tone_data->freq2 = 0;
tone_data->time = 0;
- } else if (sscanf(s, "M%30u+M%30u/%30u", &tone_data->freq1, &tone_data->freq2,
+ } else if (sscanf(s, "M%30u+M%30u/%30u", &tone_data->freq1, &tone_data->freq2,
&tone_data->time) == 3) {
/* Mf1+Mf2/time format */
tone_data->midinote = 1;
/* Mf1+Mf2 format */
tone_data->time = 0;
tone_data->midinote = 1;
- } else if (sscanf(s, "M%30u*M%30u/%30u", &tone_data->freq1, &tone_data->freq2,
+ } else if (sscanf(s, "M%30u*M%30u/%30u", &tone_data->freq1, &tone_data->freq2,
&tone_data->time) == 3) {
/* Mf1*Mf2/time format */
tone_data->modulate = 1;
return ao2_iterator_init(ast_tone_zones, 0);
}
-/*! \brief Set global indication country
+/*! \brief Set global indication country
If no country is specified or we are unable to find the zone, then return not found */
static int ast_set_indication_country(const char *country)
{
#ifdef DEBUG_IO
#define DEBUG DEBUG_M
#else
-#define DEBUG(a)
+#define DEBUG(a)
#endif
/*! \brief
*/
struct io_rec {
ast_io_cb callback; /*!< What is to be called */
- void *data; /*!< Data to be passed */
- int *id; /*!< ID number */
+ void *data; /*!< Data to be passed */
+ int *id; /*!< ID number */
};
/* These two arrays are keyed with
if (!(tmp = ast_malloc(sizeof(*tmp))))
return NULL;
-
+
tmp->needshrink = 0;
tmp->fdcnt = 0;
tmp->maxfdcnt = GROW_SHRINK_SIZE/2;
tmp->current_ioc = -1;
-
+
if (!(tmp->fds = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->fds)))) {
ast_free(tmp);
tmp = NULL;
}
/*! \brief
- * Grow the size of our arrays.
+ * Grow the size of our arrays.
* \return 0 on success or -1 on failure
*/
static int io_grow(struct io_context *ioc)
}
} else {
/*
- * Memory allocation failure. We return to the old size, and
+ * Memory allocation failure. We return to the old size, and
* return a failure
*/
ioc->maxfdcnt -= GROW_SHRINK_SIZE;
/*! \brief
* Add a new I/O entry for this file descriptor
* with the given event mask, to call callback with
- * data as an argument.
+ * data as an argument.
* \return Returns NULL on failure.
*/
int *ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
DEBUG(ast_debug(1, "ast_io_add()\n"));
if (ioc->fdcnt >= ioc->maxfdcnt) {
- /*
+ /*
* We don't have enough space for this entry. We need to
* reallocate maxfdcnt poll fd's and io_rec's, or back out now.
*/
{
int getfrom, putto = 0;
- /*
+ /*
* Bring the fields from the very last entry to cover over
- * the entry we are removing, then decrease the size of the
+ * the entry we are removing, then decrease the size of the
* arrays by one.
*/
for (getfrom = 0; getfrom < ioc->fdcnt; getfrom++) {
return 0;
}
}
-
+
ast_log(LOG_NOTICE, "Unable to remove unknown id %p\n", _id);
return -1;
ast_debug(1, "| ID FD Callback Data Events |\n");
ast_debug(1, "+------+------+-----------+-----------+--------+\n");
for (x = 0; x < ioc->fdcnt; x++) {
- ast_debug(1, "| %.4d | %.4d | %p | %p | %.6x |\n",
+ ast_debug(1, "| %.4d | %.4d | %p | %p | %.6x |\n",
*ioc->ior[x].id,
ioc->fds[x].fd,
ioc->ior[x].callback,
static jb_output_function_t warnf, errf, dbgf;
-void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg)
+void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg)
{
errf = err;
warnf = warn;
dbgf = dbg;
}
-static void increment_losspct(jitterbuf *jb)
+static void increment_losspct(jitterbuf *jb)
{
- jb->info.losspct = (100000 + 499 * jb->info.losspct)/500;
+ jb->info.losspct = (100000 + 499 * jb->info.losspct)/500;
}
-static void decrement_losspct(jitterbuf *jb)
+static void decrement_losspct(jitterbuf *jb)
{
- jb->info.losspct = (499 * jb->info.losspct)/500;
+ jb->info.losspct = (499 * jb->info.losspct)/500;
}
-void jb_reset(jitterbuf *jb)
+void jb_reset(jitterbuf *jb)
{
/* only save settings */
jb_conf s = jb->info.conf;
/* initialize length, using the default value */
jb->info.current = jb->info.target = jb->info.conf.target_extra = JB_TARGET_EXTRA;
- jb->info.silence_begin_ts = -1;
+ jb->info.silence_begin_ts = -1;
}
-jitterbuf * jb_new()
+jitterbuf * jb_new()
{
jitterbuf *jb;
- if (!(jb = ast_malloc(sizeof(*jb))))
+ if (!(jb = ast_malloc(sizeof(*jb))))
return NULL;
jb_reset(jb);
return jb;
}
-void jb_destroy(jitterbuf *jb)
+void jb_destroy(jitterbuf *jb)
{
- jb_frame *frame;
+ jb_frame *frame;
jb_dbg2("jb_destroy(%x)\n", jb);
/* free all the frames on the "free list" */
frame = next;
}
- /* free ourselves! */
+ /* free ourselves! */
ast_free(jb);
}
/* optimization; the max/min buffers don't need to be recalculated, if this packet's
* entry doesn't change them. This happens if this packet is not involved, _and_ any packet
- * that got kicked out of the history is also not involved
+ * that got kicked out of the history is also not involved
* We do a number of comparisons, but it's probably still worthwhile, because it will usually
* succeed, and should be a lot faster than going through all 500 packets in history */
if (!jb->hist_maxbuf_valid)
return 0;
- /* don't do this until we've filled history
+ /* don't do this until we've filled history
* (reduces some edge cases below) */
if (jb->hist_ptr < JB_HISTORY_SZ)
goto invalidate;
goto invalidate;
/* or the kicked delay would be in min */
- if (kicked <= jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ-1])
+ if (kicked <= jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ-1])
goto invalidate;
- if (kicked >= jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ-1])
+ if (kicked >= jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ-1])
goto invalidate;
- /* if we got here, we don't need to invalidate, 'cause this delay didn't
+ /* if we got here, we don't need to invalidate, 'cause this delay didn't
* affect things */
return 0;
/* end optimization */
return 0;
}
-static void history_calc_maxbuf(jitterbuf *jb)
+static void history_calc_maxbuf(jitterbuf *jb)
{
int i,j;
- if (jb->hist_ptr == 0)
+ if (jb->hist_ptr == 0)
return;
/* we want it to be the top "n" values, in order */
/* start at the beginning, or JB_HISTORY_SZ frames ago */
- i = (jb->hist_ptr > JB_HISTORY_SZ) ? (jb->hist_ptr - JB_HISTORY_SZ) : 0;
+ i = (jb->hist_ptr > JB_HISTORY_SZ) ? (jb->hist_ptr - JB_HISTORY_SZ) : 0;
for (;i<jb->hist_ptr;i++) {
long toins = jb->history[i % JB_HISTORY_SZ];
}
}
- if (0) {
+ if (0) {
int k;
fprintf(stderr, "toins = %ld\n", toins);
fprintf(stderr, "maxbuf =");
- for (k=0;k<JB_HISTORY_MAXBUF_SZ;k++)
+ for (k=0;k<JB_HISTORY_MAXBUF_SZ;k++)
fprintf(stderr, "%ld ", jb->hist_maxbuf[k]);
fprintf(stderr, "\nminbuf =");
- for (k=0;k<JB_HISTORY_MAXBUF_SZ;k++)
+ for (k=0;k<JB_HISTORY_MAXBUF_SZ;k++)
fprintf(stderr, "%ld ", jb->hist_minbuf[k]);
fprintf(stderr, "\n");
}
jb->hist_maxbuf_valid = 1;
}
-static void history_get(jitterbuf *jb)
+static void history_get(jitterbuf *jb)
{
long max, min, jitter;
int idx;
int count;
- if (!jb->hist_maxbuf_valid)
+ if (!jb->hist_maxbuf_valid)
history_calc_maxbuf(jb);
/* count is how many items in history we're examining */
idx = count * JB_HISTORY_DROPPCT / 100;
/* sanity checks for idx */
- if (idx > (JB_HISTORY_MAXBUF_SZ - 1))
+ if (idx > (JB_HISTORY_MAXBUF_SZ - 1))
idx = JB_HISTORY_MAXBUF_SZ - 1;
if (idx < 0) {
}
/* returns 1 if frame was inserted into head of queue, 0 otherwise */
-static int queue_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts)
+static int queue_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts)
{
jb_frame *frame;
jb_frame *p;