* \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;
frame->ms = ms;
frame->type = type;
- /*
- * frames are a circular list, jb-frames points to to the lowest ts,
+ /*
+ * frames are a circular list, jb-frames points to to the lowest ts,
* jb->frames->prev points to the highest ts
*/
jb->frames = frame;
head = 1;
- } else {
+ } else {
p = jb->frames;
/* frame is out of order */
if (resync_ts < p->prev->ts) jb->info.frames_ooo++;
- while (resync_ts < p->prev->ts && p->prev != jb->frames)
+ while (resync_ts < p->prev->ts && p->prev != jb->frames)
p = p->prev;
frame->next = p;
return head;
}
-static long queue_next(jitterbuf *jb)
+static long queue_next(jitterbuf *jb)
{
- if (jb->frames)
+ if (jb->frames)
return jb->frames->ts;
- else
+ else
return -1;
}
-static long queue_last(jitterbuf *jb)
+static long queue_last(jitterbuf *jb)
{
- if (jb->frames)
+ if (jb->frames)
return jb->frames->prev->ts;
- else
+ else
return -1;
}
-static jb_frame *_queue_get(jitterbuf *jb, long ts, int all)
+static jb_frame *_queue_get(jitterbuf *jb, long ts, int all)
{
jb_frame *frame;
frame = jb->frames;
jb->info.frames_cur--;
- /* we return the frame pointer, even though it's on free list,
+ /* we return the frame pointer, even though it's on free list,
* but caller must copy data */
return frame;
- }
+ }
return NULL;
}
-static jb_frame *queue_get(jitterbuf *jb, long ts)
+static jb_frame *queue_get(jitterbuf *jb, long ts)
{
return _queue_get(jb,ts,0);
}
-static jb_frame *queue_getall(jitterbuf *jb)
+static jb_frame *queue_getall(jitterbuf *jb)
{
return _queue_get(jb,0,1);
}
#if 0
/* some diagnostics */
-static void jb_dbginfo(jitterbuf *jb)
+static void jb_dbginfo(jitterbuf *jb)
{
- if (dbgf == NULL)
+ if (dbgf == NULL)
return;
jb_dbg("\njb info: fin=%ld fout=%ld flate=%ld flost=%ld fdrop=%ld fcur=%ld\n",
jb->info.frames_in, jb->info.frames_out, jb->info.frames_late, jb->info.frames_lost, jb->info.frames_dropped, jb->info.frames_cur);
-
+
jb_dbg("jitter=%ld current=%ld target=%ld min=%ld sil=%d len=%d len/fcur=%ld\n",
- jb->info.jitter, jb->info.current, jb->info.target, jb->info.min, jb->info.silence_begin_ts, jb->info.current - jb->info.min,
+ jb->info.jitter, jb->info.current, jb->info.target, jb->info.min, jb->info.silence_begin_ts, jb->info.current - jb->info.min,
jb->info.frames_cur ? (jb->info.current - jb->info.min)/jb->info.frames_cur : -8);
- if (jb->info.frames_in > 0)
+ if (jb->info.frames_in > 0)
jb_dbg("jb info: Loss PCT = %ld%%, Late PCT = %ld%%\n",
- jb->info.frames_lost * 100/(jb->info.frames_in + jb->info.frames_lost),
+ jb->info.frames_lost * 100/(jb->info.frames_in + jb->info.frames_lost),
jb->info.frames_late * 100/jb->info.frames_in);
jb_dbg("jb info: queue %d -> %d. last_ts %d (queue len: %d) last_ms %d\n",
- queue_next(jb),
+ queue_next(jb),
queue_last(jb),
- jb->info.next_voice_ts,
+ jb->info.next_voice_ts,
queue_last(jb) - queue_next(jb),
jb->info.last_voice_ms);
}
#endif
#ifdef DEEP_DEBUG
-static void jb_chkqueue(jitterbuf *jb)
+static void jb_chkqueue(jitterbuf *jb)
{
int i=0;
jb_frame *p = jb->frames;
do {
if (p->next == NULL) {
- jb_err("Queue is BROKEN at item [%d]", i);
+ jb_err("Queue is BROKEN at item [%d]", i);
}
i++;
p=p->next;
} while (p->next != jb->frames);
}
-static void jb_dbgqueue(jitterbuf *jb)
+static void jb_dbgqueue(jitterbuf *jb)
{
int i=0;
jb_frame *p = jb->frames;
}
#endif
-enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now)
+enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now)
{
long delay = now - (ts - jb->info.resync_offset);
jb_dbg2("jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now);
}
-static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
+static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
{
jb_frame *frame;
long diff;
dbg_cnt++;
/* target */
- jb->info.target = jb->info.jitter + jb->info.min + jb->info.conf.target_extra;
+ jb->info.target = jb->info.jitter + jb->info.min + jb->info.conf.target_extra;
/* if a hard clamp was requested, use it */
if ((jb->info.conf.max_jitterbuf) && ((jb->info.target - jb->info.min) > jb->info.conf.max_jitterbuf)) {
/* jb->info.last_voice_ms, jb->info.last_adjustment, now); */
/* let's work on non-silent case first */
- if (!jb->info.silence_begin_ts) {
+ if (!jb->info.silence_begin_ts) {
/* we want to grow */
- if ((diff > 0) &&
+ if ((diff > 0) &&
/* we haven't grown in the delay length */
- (((jb->info.last_adjustment + JB_ADJUST_DELAY) < now) ||
+ (((jb->info.last_adjustment + JB_ADJUST_DELAY) < now) ||
/* we need to grow more than the "length" we have left */
(diff > queue_last(jb) - queue_next(jb)) ) ) {
/* grow by interp frame length */
if (frame && frame->ts + jb->info.current < jb->info.next_voice_ts) {
if (frame->ts + jb->info.current > jb->info.next_voice_ts - jb->info.last_voice_ms) {
/* either we interpolated past this frame in the last jb_get */
- /* or the frame is still in order, but came a little too quick */
+ /* or the frame is still in order, but came a little too quick */
*frameout = *frame;
/* reset expectation for next frame */
jb->info.next_voice_ts = frame->ts + jb->info.current + frame->ms;
/* unless we don't have a frame, then shrink 1 frame */
/* every 80ms (though perhaps we can shrink even faster */
/* in this case) */
- if (diff < -jb->info.conf.target_extra &&
- ((!frame && jb->info.last_adjustment + 80 < now) ||
+ if (diff < -jb->info.conf.target_extra &&
+ ((!frame && jb->info.last_adjustment + 80 < now) ||
(jb->info.last_adjustment + 500 < now))) {
jb->info.last_adjustment = now;
* otherwise, we presently get into a pattern where we return
* INTERP for the lost frame, then it shows up next, and we
* throw it away because it's late */
- /* I've recently only been able to replicate this using
+ /* I've recently only been able to replicate this using
* iaxclient talking to app_echo on asterisk. In this case,
* my outgoing packets go through asterisk's (old)
- * jitterbuffer, and then might get an unusual increasing delay
+ * jitterbuffer, and then might get an unusual increasing delay
* there if it decides to grow?? */
/* Update: that might have been a different bug, that has been fixed..
* But, this still seemed like a good idea, except that it ended up making a single actual
* lost frame get interpolated two or more times, when there was "room" to grow, so it might
* be a bit of a bad idea overall */
- /*if (diff > -1 * jb->info.last_voice_ms) {
+ /*if (diff > -1 * jb->info.last_voice_ms) {
jb->info.current += jb->info.last_voice_ms;
jb->info.last_adjustment = now;
jb_warn("g");
decrement_losspct(jb);
jb_dbg("v");
return JB_OK;
- } else {
+ } else {
/* TODO: after we get the non-silent case down, we'll make the
* silent case -- basically, we'll just grow and shrink faster
* here, plus handle next_voice_ts a bit differently */
/* to disable silent special case altogether, just uncomment this: */
/* jb->info.silence_begin_ts = 0; */
- /* shrink interpl len every 10ms during silence */
- if (diff < -jb->info.conf.target_extra &&
- jb->info.last_adjustment + 10 <= now) {
- jb->info.current -= interpl;
- jb->info.last_adjustment = now;
- }
+ /* shrink interpl len every 10ms during silence */
+ if (diff < -jb->info.conf.target_extra &&
+ jb->info.last_adjustment + 10 <= now) {
+ jb->info.current -= interpl;
+ jb->info.last_adjustment = now;
+ }
frame = queue_get(jb, now - jb->info.current);
if (!frame) {
}
}
-long jb_next(jitterbuf *jb)
+long jb_next(jitterbuf *jb)
{
if (jb->info.silence_begin_ts) {
if (jb->frames) {
return jb->info.last_adjustment + 10;
return next + jb->info.target;
}
- else
+ else
return JB_LONGMAX;
} else {
return jb->info.next_voice_ts;
}
}
-enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
+enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
{
enum jb_return_code ret = _jb_get(jb, frameout, now, interpl);
#if 0
if (thists && thists < lastts) jb_warn("XXXX timestamp roll-back!!!\n");
lastts = thists;
#endif
- if (ret == JB_INTERP)
+ if (ret == JB_INTERP)
frameout->ms = jb->info.last_voice_ms;
-
+
return ret;
}
-enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
+enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
{
jb_frame *frame;
frame = queue_getall(jb);
}
-enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
+enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
{
history_get(jb);
return JB_OK;
}
-enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
+enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
{
/* take selected settings from the struct */
jb->info.conf.max_jitterbuf = conf->max_jitterbuf;
- jb->info.conf.resync_threshold = conf->resync_threshold;
+ jb->info.conf.resync_threshold = conf->resync_threshold;
jb->info.conf.max_contig_interp = conf->max_contig_interp;
/* -1 indicates use of the default JB_TARGET_EXTRA value */
? JB_TARGET_EXTRA
: conf->target_extra
;
-
+
/* update these to match new target_extra setting */
jb->info.current = jb->info.conf.target_extra;
jb->info.target = jb->info.conf.target_extra;
*
* If the ast_heap is provided (not NULL) the module is found and added to the
* heap without running the module's load() function. By doing this, modules
- * added to the resource_heap can be initialized later in order by priority.
+ * added to the resource_heap can be initialized later in order by priority.
*
* If the ast_heap is not provided, the module's load function will be executed
* immediately */
AST_LIST_TRAVERSE(load_order, order, entry) {
if (!resource_name_match(order->resource, resource)) {
- /* Make sure we have the proper setting for the required field
+ /* Make sure we have the proper setting for the required field
(we might have both load= and required= lines in modules.conf) */
order->required |= required;
return NULL;
return res;
}
-/*! loads modules in order by load_pri, updates mod_count
+/*! loads modules in order by load_pri, updates mod_count
\return -1 on failure to load module, -2 on failure to load required module, otherwise 0
*/
static int load_resource_list(struct load_order *load_order, unsigned int global_symbols, int *mod_count)
}
AST_LIST_UNLOCK(&module_list);
-
+
/* Tell manager clients that are aggressive at logging in that we're done
loading modules. If there's a DNS problem in chan_sip, we might not
even reach this */
manager_event(EVENT_FLAG_SYSTEM, "ModuleLoadReport", "ModuleLoadStatus: Done\r\nModuleSelection: %s\r\nModuleCount: %d\r\n", preload_only ? "Preload" : "All", modulecount);
-
+
return res;
}
if (AST_LIST_TRYLOCK(&module_list))
unlock = 0;
-
+
AST_LIST_TRAVERSE(&module_list, cur, entry) {
total_mod_loaded += modentry(cur->resource, cur->info->description, cur->usecount, like);
}
}
int __ast_pthread_mutex_lock(const char *filename, int lineno, const char *func,
- const char* mutex_name, ast_mutex_t *t)
+ const char* mutex_name, ast_mutex_t *t)
{
int res;
}
int __ast_pthread_mutex_trylock(const char *filename, int lineno, const char *func,
- const char* mutex_name, ast_mutex_t *t)
+ const char* mutex_name, ast_mutex_t *t)
{
int res;
switch (cmd) {
case CLI_INIT:
e->command = "logger rotate";
- e->usage =
+ e->usage =
"Usage: logger rotate\n"
" Rotates and Reopens the log files.\n";
return NULL;
case CLI_GENERATE:
- return NULL;
+ return NULL;
}
if (reload_logger(1, NULL)) {
ast_cli(a->fd, "Failed to reload the logger and rotate log files\n");
return CLI_FAILURE;
- }
+ }
return CLI_SUCCESS;
}
switch (cmd) {
case CLI_INIT:
e->command = "logger set level {DEBUG|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}";
- e->usage =
+ e->usage =
"Usage: logger set level {DEBUG|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}\n"
" Set a specific log level to enabled/disabled for this console.\n";
return NULL;
switch (cmd) {
case CLI_INIT:
e->command = "logger show channels";
- e->usage =
+ e->usage =
"Usage: logger show channels\n"
" List configured logger channels.\n";
return NULL;
case CLI_GENERATE:
- return NULL;
+ return NULL;
}
ast_cli(a->fd, FORMATL, "Channel", "Type", "Status");
ast_cli(a->fd, "Configuration\n");
#ifdef HAVE_BKTR
-struct ast_bt *ast_bt_create(void)
+struct ast_bt *ast_bt_create(void)
{
struct ast_bt *bt = ast_calloc(1, sizeof(*bt));
if (!bt) {
va_end(ap);
}
-int ast_register_verbose(void (*v)(const char *string))
+int ast_register_verbose(void (*v)(const char *string))
{
struct verb *verb;
AST_RWLIST_WRLOCK(&verbosers);
AST_RWLIST_INSERT_HEAD(&verbosers, verb, list);
AST_RWLIST_UNLOCK(&verbosers);
-
+
return 0;
}
}
AST_RWLIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&verbosers);
-
+
return cur ? 0 : -1;
}
static struct mansession_session *unref_mansession(struct mansession_session *s)
{
int refcount = ao2_ref(s, -1);
- if (manager_debug) {
+ if (manager_debug) {
ast_debug(1, "Mansession: %p refcount now %d\n", s, refcount - 1);
}
return s;
s->hook->helper(EVENT_FLAG_HOOKRESPONSE, "HookResponse", string);
return 0;
}
-
+
if ((res = ast_careful_fwrite(f, fd, string, strlen(string), s->session->writetimeout))) {
s->write_error = 1;
}
const char *varname = astman_get_header(m, "Variable");
const char *varval = astman_get_header(m, "Value");
int res = 0;
-
+
if (ast_strlen_zero(varname)) {
astman_send_error(s, m, "No variable specified");
return 0;
c = ast_channel_unref(c);
}
if (res == 0) {
- astman_send_ack(s, m, "Variable Set");
+ astman_send_ack(s, m, "Variable Set");
} else {
astman_send_error(s, m, "Variable not set");
}
static int action_filter(struct mansession *s, const struct message *m)
{
const char *filter = astman_get_header(m, "Filter");
- const char *operation = astman_get_header(m, "Operation");
- int res;
+ const char *operation = astman_get_header(m, "Operation");
+ int res;
- if (!strcasecmp(operation, "Add")) {
+ if (!strcasecmp(operation, "Add")) {
res = manager_add_filter(filter, s->session->whitefilters, s->session->blackfilters);
if (res != FILTER_SUCCESS) {
}
astman_send_ack(s, m, "Success");
- return 0;
- }
+ return 0;
+ }
astman_send_error(s, m, "Unknown operation");
return 0;
ao2_t_link(whitefilters, new_filter, "link new filter into white user container");
}
- return FILTER_SUCCESS;
+ return FILTER_SUCCESS;
}
static int match_filter(struct mansession *s, char *eventdata)
return 1; /* no filtering means match all */
} else if (ao2_container_count(s->session->whitefilters) && !ao2_container_count(s->session->blackfilters)) {
/* white filters only: implied black all filter processed first, then white filters */
- ao2_t_callback_data(s->session->whitefilters, OBJ_NODATA, whitefilter_cmp_fn, eventdata, &result, "find filter in session filter container");
+ ao2_t_callback_data(s->session->whitefilters, OBJ_NODATA, whitefilter_cmp_fn, eventdata, &result, "find filter in session filter container");
} else if (!ao2_container_count(s->session->whitefilters) && ao2_container_count(s->session->blackfilters)) {
/* black filters only: implied white all filter processed first, then black filters */
- ao2_t_callback_data(s->session->blackfilters, OBJ_NODATA, blackfilter_cmp_fn, eventdata, &result, "find filter in session filter container");
+ ao2_t_callback_data(s->session->blackfilters, OBJ_NODATA, blackfilter_cmp_fn, eventdata, &result, "find filter in session filter container");
} else {
/* white and black filters: implied black all filter processed first, then white filters, and lastly black filters */
- ao2_t_callback_data(s->session->whitefilters, OBJ_NODATA, whitefilter_cmp_fn, eventdata, &result, "find filter in session filter container");
+ ao2_t_callback_data(s->session->whitefilters, OBJ_NODATA, whitefilter_cmp_fn, eventdata, &result, "find filter in session filter container");
if (result) {
result = 0;
- ao2_t_callback_data(s->session->blackfilters, OBJ_NODATA, blackfilter_cmp_fn, eventdata, &result, "find filter in session filter container");
+ ao2_t_callback_data(s->session->blackfilters, OBJ_NODATA, blackfilter_cmp_fn, eventdata, &result, "find filter in session filter container");
}
}
}
}
- astman_send_ack(s, m, "Event Sent");
+ astman_send_ack(s, m, "Event Sent");
manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", event, ast_str_buffer(body));
return 0;
}
if (!(sessions && ao2_container_count(sessions)) && AST_RWLIST_EMPTY(&manager_hooks)) {
return 0;
}
-
+
if (!(buf = ast_str_thread_get(&manager_event_buf, MANAGER_EVENT_BUF_INITSIZE))) {
return -1;
}
}
} else if (!strcasecmp(var->name, "eventfilter")) {
const char *value = var->value;
- manager_add_filter(value, user->whitefilters, user->blackfilters);
+ manager_add_filter(value, user->whitefilters, user->blackfilters);
} else {
ast_debug(1, "%s is an unknown option.\n", var->name);
}
}
/*
- * Final wrapup - pad to 64-byte boundary with the bit pattern
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
struct ast_msg_tech_holder {
const struct ast_msg_tech *tech;
- /*!
+ /*!
* \brief A rwlock for this object
*
* a read/write lock must be used to protect the wrapper instead
/*!
* \internal
* \brief Find or create a message datastore on a channel
- *
+ *
* \pre chan is locked
*
* \param chan the relevant channel
if (sscanf(s, "%2x:%2x:%2x:%2x:%2x:%2x", &eid_int[0], &eid_int[1], &eid_int[2],
&eid_int[3], &eid_int[4], &eid_int[5]) != 6)
- return -1;
+ return -1;
for (x = 0; x < 6; x++)
eid->eid[x] = eid_int[x];
ast_unlock_contexts();
}
- /* loop thru all contexts, and verify the exten structure compares to the
+ /* loop thru all contexts, and verify the exten structure compares to the
hashtab structure */
for(c2=contexts;c2;c2=c2->next) {
c1 = find_context_locked(c2->name);
}
}
- /* is every entry in the root_table also in the root list? */
+ /* is every entry in the root_table also in the root list? */
if (!c2->root_table) {
if (c2->root) {
ast_log(LOG_NOTICE,"Called from: %s:%d: No c2->root_table for context %s!\n", file, line, c2->name);
node->alt_char = (*parent_ptr);
*parent_ptr = node;
return;
- }
+ }
lcurr = *parent_ptr;
for (curr = (*parent_ptr)->alt_char; curr; curr = curr->alt_char) {
/*!
* \brief Increase call count for channel
* \retval 0 on success
- * \retval non-zero if a configured limit (maxcalls, maxload, minmemfree) was reached
+ * \retval non-zero if a configured limit (maxcalls, maxload, minmemfree) was reached
*/
static int increase_call_count(const struct ast_channel *c)
{
dupdstr = ast_strdup(prio_item->data);
- res1 = ast_add_extension2(new, 0, prio_item->exten, prio_item->priority, prio_item->label,
+ res1 = ast_add_extension2(new, 0, prio_item->exten, prio_item->priority, prio_item->label,
prio_item->matchcid ? prio_item->cidmatch : NULL, prio_item->app, dupdstr, prio_item->datad, prio_item->registrar);
if (!res1 && new_exten_item && new_prio_item){
ast_verb(3,"Dropping old dialplan item %s/%s/%d [%s(%s)] (registrar=%s) due to conflict with new dialplan\n",
ast_app_parse_options(waitexten_opts, &flags, opts, args.options);
if (ast_test_flag(&flags, WAITEXTEN_MOH) && !opts[0] ) {
- ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n");
+ ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n");
} else if (ast_test_flag(&flags, WAITEXTEN_MOH)) {
ast_indicate_data(chan, AST_CONTROL_HOLD, S_OR(opts[0], NULL), strlen(opts[0]));
} else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE)) {
orig_len = len;
if (s->missing_samples == 0) {
/* As the gap in real speech starts we need to assess the last known pitch,
- and prepare the synthetic data we will use for fill-in */
+ and prepare the synthetic data we will use for fill-in */
normalise_history(s);
s->pitch = amdf_pitch(PLC_PITCH_MIN, PLC_PITCH_MAX, s->history + PLC_HISTORY_LEN - CORRELATION_SPAN - PLC_PITCH_MIN, CORRELATION_SPAN);
/* We overlap a 1/4 wavelength */
pitch_overlap = s->pitch >> 2;
/* Cook up a single cycle of pitch, using a single of the real signal with 1/4
- cycle OLA'ed to make the ends join up nicely */
+ cycle OLA'ed to make the ends join up nicely */
/* The first 3/4 of the cycle is a simple copy */
for (i = 0; i < s->pitch - pitch_overlap; i++)
s->pitchbuf[i] = s->history[PLC_HISTORY_LEN - s->pitch + i];
new_weight += new_step;
}
/* We should now be ready to fill in the gap with repeated, decaying cycles
- of what is in pitchbuf */
+ of what is in pitchbuf */
/* We need to OLA the first 1/4 wavelength of the synthetic data, to smooth
- it into the previous real data. To avoid the need to introduce a delay
- in the stream, reverse the last 1/4 wavelength, and OLA with that. */
+ it into the previous real data. To avoid the need to introduce a delay
+ in the stream, reverse the last 1/4 wavelength, and OLA with that. */
gain = 1.0;
new_step = 1.0 / pitch_overlap;
old_step = new_step;
*
* \brief Privacy Routines
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
*/
#include "asterisk.h"
return 0;
}
snprintf(key, sizeof(key), "%s/%s", dest, trimcid);
- if (status == AST_PRIVACY_UNKNOWN)
+ if (status == AST_PRIVACY_UNKNOWN)
res = ast_db_del("privacy", key);
else if (status == AST_PRIVACY_ALLOW)
res = ast_db_put("privacy", key, "allow");
ast_rtp_codecs_payloads_copy(&tinstance0->codecs, &tinstance1->codecs, tinstance1);
}
- if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0)) {
- ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
- }
+ if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0)) {
+ ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
+ }
res = 0;
* \brief Say numbers and dates (maybe words one day too)
*
* \author Mark Spencer <markster@digium.com>
- *
+ *
* \note 12-16-2004 : Support for Greek added by InAccess Networks (work funded by HOL, www.hol.gr) George Konstantoulakis <gkon@inaccessnetworks.com>
- *
+ *
* \note 2007-02-08 : Support for Georgian added by Alexander Shaduri <ashaduri@gmail.com>,
- * Next Generation Networks (NGN).
+ * Next Generation Networks (NGN).
* \note 2007-03-20 : Support for Thai added by Dome C. <dome@tel.co.th>,
- * IP Crossing Co., Ltd.
+ * IP Crossing Co., Ltd.
*/
#include "asterisk.h"
\arg \b it - Italian
\arg \b nl - Dutch
\arg \b no - Norwegian
- \arg \b pl - Polish
+ \arg \b pl - Polish
\arg \b pt - Portuguese
\arg \b pt_BR - Portuguese (Brazil)
\arg \b se - Swedish
\arg Use the option argument 'f' for female, 'm' for male and 'n' for neuter in languages like Portuguese, French, Spanish and German.
\arg use the option argument 'c' is for commune and 'n' for neuter gender in nordic languages like Danish, Swedish and Norwegian.
use the option argument 'p' for plural enumerations like in German
-
+
Date/Time functions currently have less languages supported than saynumber().
\todo Note that in future, we need to move to a model where we can differentiate further - e.g. between en_US & en_UK
static int ast_say_datetime_from_now_ka(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
static int ast_say_datetime_from_now_he(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
-static int wait_file(struct ast_channel *chan, const char *ints, const char *file, const char *lang)
+static int wait_file(struct ast_channel *chan, const char *ints, const char *file, const char *lang)
{
int res;
if ((res = ast_streamfile(chan, file, lang)))
return res;
}
-/*! \brief ast_say_number_full: call language-specific functions
+/*! \brief ast_say_number_full: call language-specific functions
\note Called from AGI */
static int say_number_full(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
return ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd);
}
-/*! \brief ast_say_number_full_en: English syntax
+/*! \brief ast_say_number_full_en: English syntax
\note This is the default syntax, if no other syntax defined in this file is used */
static int ast_say_number_full_en(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
{
int res = 0;
int playh = 0;
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
while (!res && (num || playh)) {
num = -num;
} else {
num = 0;
- }
+ }
} else if (playh) {
ast_copy_string(fn, "digits/hundred", sizeof(fn));
playh = 0;
return res;
}
-/*! \brief ast_say_number_full_cs: Czech syntax
+/*! \brief ast_say_number_full_cs: Czech syntax
*
* files needed:
* - 1m,2m - gender male
* - 1w,2w - gender female
* - 3,4,...,20
* - 30,40,...,90
- *
- * - hundereds - 100 - sto, 200 - 2ste, 300,400 3,4sta, 500,600,...,900 5,6,...9set
- *
+ *
+ * - hundereds - 100 - sto, 200 - 2ste, 300,400 3,4sta, 500,600,...,900 5,6,...9set
+ *
* for each number 10^(3n + 3) exist 3 files represented as:
- * 1 tousand = jeden tisic = 1_E3
- * 2,3,4 tousands = dva,tri,ctyri tisice = 2-3_E3
- * 5,6,... tousands = pet,sest,... tisic = 5_E3
+ * 1 tousand = jeden tisic = 1_E3
+ * 2,3,4 tousands = dva,tri,ctyri tisice = 2-3_E3
+ * 5,6,... tousands = pet,sest,... tisic = 5_E3
*
- * million = _E6
- * miliard = _E9
- * etc...
+ * million = _E6
+ * miliard = _E9
+ * etc...
*
* tousand, milion are gender male, so 1 and 2 is 1m 2m
* miliard is gender female, so 1 and 2 is 1w 2w
int res = 0;
int playh = 0;
char fn[256] = "";
-
+
int hundered = 0;
int left = 0;
int length = 0;
-
+
/* options - w = woman, m = man, n = neutral. Defaultl is woman */
if (!options)
options = "w";
-
- if (!num)
+
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
-
+
while (!res && (num || playh)) {
if (num < 0) {
ast_copy_string(fn, "digits/minus", sizeof(fn));
num = -num;
} else {
num = 0;
- }
+ }
} else if (num < 3 ) {
snprintf(fn, sizeof(fn), "digits/%d%c", num, options[0]);
playh = 0;
res = ast_say_number_full_cs(chan, hundered, ints, language, options, audiofd, ctrlfd);
if (res)
return res;
- if (hundered == 3 || hundered == 4) {
+ if (hundered == 3 || hundered == 4) {
ast_copy_string(fn, "digits/sta", sizeof(fn));
} else if ( hundered > 4 ) {
ast_copy_string(fn, "digits/set", sizeof(fn));
}
num -= (hundered * 100);
} else { /* num > 1000 */
- length = (int)log10(num)+1;
+ length = (int)log10(num)+1;
while ( (length % 3 ) != 1 ) {
- length--;
+ length--;
}
left = num / (exp10_int(length-1));
- if ( left == 2 ) {
+ if ( left == 2 ) {
switch (length-1) {
case 9: options = "w"; /* 1,000,000,000 gender female */
break;
}
if ( left > 1 ) { /* we don't say "one thousand" but only thousand */
res = ast_say_number_full_cs(chan, left, ints, language, options, audiofd, ctrlfd);
- if (res)
+ if (res)
return res;
}
if ( left >= 5 ) { /* >= 5 have the same declesion */
- snprintf(fn, sizeof(fn), "digits/5_E%d", length - 1);
+ snprintf(fn, sizeof(fn), "digits/5_E%d", length - 1);
} else if ( left >= 2 && left <= 4 ) {
snprintf(fn, sizeof(fn), "digits/2-4_E%d", length - 1);
} else { /* left == 1 */
ast_stopstream(chan);
}
}
- return res;
+ return res;
}
/*! \brief ast_say_number_full_da: Danish syntax
New files:
- - In addition to English, the following sounds are required: "1N", "millions", "and" and "1-and" through "9-and"
+ - In addition to English, the following sounds are required: "1N", "millions", "and" and "1-and" through "9-and"
*/
static int ast_say_number_full_da(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
int playa = 0;
int cn = 1; /* +1 = commune; -1 = neuter */
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
if (options && !strncasecmp(options, "n", 1)) cn = -1;
num = -num;
} else {
num = 0;
- }
+ }
} else if (playh) {
ast_copy_string(fn, "digits/hundred", sizeof(fn));
playh = 0;
return res;
}
-/*! \brief ast_say_number_full_de: German syntax
-
+/*! \brief ast_say_number_full_de: German syntax
+
New files:
In addition to English, the following sounds are required:
- "millions"
- - "1-and" through "9-and"
+ - "1-and" through "9-and"
- "1F" (eine)
- "1N" (ein)
- NB "1" is recorded as 'eins'
int mf = 1; /* +1 = male and neuter; -1 = female */
char fn[256] = "";
char fna[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
if (options && (!strncasecmp(options, "f", 1)))
} else if (num == 1000 && t == 0) {
ast_copy_string(fn, "digits/thousand", sizeof(fn));
num = 0;
- } else if (num < 1000000) {
+ } else if (num < 1000000) {
int thousands = num / 1000;
num = num % 1000;
t = 1;
return res;
}
-/*! \brief ast_say_number_full_en_GB: British syntax
+/*! \brief ast_say_number_full_en_GB: British syntax
New files:
- In addition to American English, the following sounds are required: "and"
*/
int playh = 0;
int playa = 0;
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
while (!res && (num || playh || playa )) {
num = -num;
} else {
num = 0;
- }
+ }
} else if (playh) {
ast_copy_string(fn, "digits/hundred", sizeof(fn));
playh = 0;
return res;
}
-/*! \brief ast_say_number_full_es: Spanish syntax
+/*! \brief ast_say_number_full_es: Spanish syntax
New files:
Requires a few new audios:
1F.gsm: feminine 'una'
- 21.gsm thru 29.gsm, cien.gsm, mil.gsm, millon.gsm, millones.gsm, 100.gsm, 200.gsm, 300.gsm, 400.gsm, 500.gsm, 600.gsm, 700.gsm, 800.gsm, 900.gsm, y.gsm
+ 21.gsm thru 29.gsm, cien.gsm, mil.gsm, millon.gsm, millones.gsm, 100.gsm, 200.gsm, 300.gsm, 400.gsm, 500.gsm, 600.gsm, 700.gsm, 800.gsm, 900.gsm, y.gsm
*/
static int ast_say_number_full_es(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
int playa = 0;
int mf = 0; /* +1 = male; -1 = female */
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
if (options) {
num = -num;
} else {
num = 0;
- }
+ }
} else if (playa) {
ast_copy_string(fn, "digits/and", sizeof(fn));
playa = 0;
snprintf(fn, sizeof(fn), "digits/%dF", num);
else if (mf > 0)
snprintf(fn, sizeof(fn), "digits/%dM", num);
- else
+ else
snprintf(fn, sizeof(fn), "digits/%d", num);
num = 0;
} else if (num < 31) {
}
/*! \brief ast_say_number_full_fr: French syntax
- Extra sounds needed:
- 1F: feminin 'une'
- et: 'and' */
+ Extra sounds needed:
+ 1F: feminin 'une'
+ et: 'and' */
static int ast_say_number_full_fr(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
int res = 0;
int playa = 0;
int mf = 1; /* +1 = male; -1 = female */
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
-
+
if (options && !strncasecmp(options, "f", 1))
mf = -1;
num = -num;
} else {
num = 0;
- }
+ }
} else if (playh) {
ast_copy_string(fn, "digits/hundred", sizeof(fn));
playh = 0;
return res;
}
-/*! \brief ast_say_number_full_hu: Hungarian syntax
+/*! \brief ast_say_number_full_hu: Hungarian syntax
Extra sounds needed:
10en: "tizen"
int res = 0;
int playh = 0;
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
/*
num = -num;
} else {
num = 0;
- }
+ }
} else if (playh) {
ast_copy_string(fn, "digits/hundred", sizeof(fn));
playh = 0;
Italian support
Like english, numbers up to 20 are a single 'word', and others
- compound, but with exceptions.
+ compound, but with exceptions.
For example 21 is not twenty-one, but there is a single word in 'it'.
Idem for 28 (ie when a the 2nd part of a compund number
starts with a vowel)
In english 100 = one hundred, 200 is two hundred.
In italian 100 = cento , like to say hundred (without one),
200 and more are like english.
-
+
Same applies for thousand:
1000 is one thousand in en, 2000 is two thousand.
- In it we have 1000 = mille , 2000 = 2 mila
+ In it we have 1000 = mille , 2000 = 2 mila
For million(s) we use the plural, if more than one
Also, one million is abbreviated in it, like on-million,
num = -num;
} else {
num = 0;
- }
+ }
} else if (playh) {
ast_copy_string(fn, "digits/hundred", sizeof(fn));
playh = 0;
return res;
}
-/*! \brief ast_say_number_full_nl: dutch syntax
+/*! \brief ast_say_number_full_nl: dutch syntax
* New files: digits/nl-en
*/
static int ast_say_number_full_nl(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
int playh = 0;
int units = 0;
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
while (!res && (num || playh )) {
if (num < 0) {
num = -num;
} else {
num = 0;
- }
+ }
} else if (playh) {
ast_copy_string(fn, "digits/hundred", sizeof(fn));
playh = 0;
return res;
}
-/*! \brief ast_say_number_full_no: Norwegian syntax
+/*! \brief ast_say_number_full_no: Norwegian syntax
* New files:
* In addition to American English, the following sounds are required: "and", "1N"
*
int playa = 0;
int cn = 1; /* +1 = commune; -1 = neuter */
char fn[256] = "";
-
- if (!num)
+
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
-
+
if (options && !strncasecmp(options, "n", 1)) cn = -1;
while (!res && (num || playh || playa )) {
num = -num;
} else {
num = 0;
- }
+ }
} else if (playh) {
ast_copy_string(fn, "digits/hundred", sizeof(fn));
playh = 0;
return res;
}
-typedef struct {
+typedef struct {
char *separator_dziesiatek;
char *cyfry[10];
char *cyfry2[10];
char *setki[10];
char *dziesiatki[10];
- char *nastki[10];
+ char *nastki[10];
char *rzedy[3][3];
} odmiana;
{
if (rzad==0)
return "";
-
+
if (i==1)
return odm->rzedy[rzad - 1][0];
if ((i > 21 || i < 11) && i%10 > 1 && i%10 < 5)
int i1000 = 0;
int m100 = 0;
int i100 = 0;
-
- if (i == 0 && rzad > 0) {
+
+ if (i == 0 && rzad > 0) {
return;
}
if (i == 0) {
m100 = m1000 % 100;
i100 = m1000 / 100;
-
+
if (i100>0)
pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->setki[i100]);
} else {
char buf[10];
char *b = buf;
- b = pl_append(b, odm->dziesiatki[m100 / 10]);
- b = pl_append(b, odm->separator_dziesiatek);
- b = pl_append(b, odm->cyfry2[m100 % 10]);
+ b = pl_append(b, odm->dziesiatki[m100 / 10]);
+ b = pl_append(b, odm->separator_dziesiatek);
+ b = pl_append(b, odm->cyfry2[m100 % 10]);
pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, buf);
}
- }
+ }
if (rzad > 0) {
pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, pl_rzad_na_tekst(odm, i, rzad));
}
}
-/* ast_say_number_full_pl: Polish syntax
+/* ast_say_number_full_pl: Polish syntax
Sounds needed:
0 zero
char *nijaki_nastki[] = {"", "11", "12", "13", "14", "15", "16", "17", "18", "19"};
- char *rzedy[][3] = { {"1000", "1000.2", "1000.5"}, {"1000000", "1000000.2", "1000000.5"}, {"1000000000", "1000000000.2", "1000000000.5"}};
+ char *rzedy[][3] = { {"1000", "1000.2", "1000.5"}, {"1000000", "1000000.2", "1000000.5"}, {"1000000000", "1000000000.2", "1000000000.5"}};
/* Initialise variables to allow compilation on Debian-stable, etc */
odmiana *o;
- static odmiana *odmiana_nieosobowa = NULL;
- static odmiana *odmiana_meska = NULL;
- static odmiana *odmiana_zenska = NULL;
+ static odmiana *odmiana_nieosobowa = NULL;
+ static odmiana *odmiana_meska = NULL;
+ static odmiana *odmiana_zenska = NULL;
if (odmiana_nieosobowa == NULL) {
odmiana_nieosobowa = ast_malloc(sizeof(*odmiana_nieosobowa));
return 0;
}
-/* ast_say_number_full_pt: Portuguese syntax
+/* ast_say_number_full_pt: Portuguese syntax
- * Extra sounds needed:
- * For feminin all sound files ends with F
+ * Extra sounds needed:
+ * For feminin all sound files ends with F
* 100E for 100+ something
* 1000000S for plural
- * pt-e for 'and'
+ * pt-e for 'and'
*/
static int ast_say_number_full_pt(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
int mf = 1; /* +1 = male; -1 = female */
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
if (options && !strncasecmp(options, "f", 1))
num = -num;
} else {
num = 0;
- }
+ }
} else if (num < 20) {
if ((num == 1 || num == 2) && (mf < 0))
snprintf(fn, sizeof(fn), "digits/%dF", num);
ast_copy_string(fn, "digits/1000000", sizeof(fn));
else
ast_copy_string(fn, "digits/1000000S", sizeof(fn));
-
+
if ((num % 1000000) &&
/* no thousands */
((!((num / 1000) % 1000) && ((num % 1000) < 100 || !(num % 100))) ||
if (!res) {
if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
- res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
+ res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
res = ast_waitstream(chan, ints);
}
return res;
}
-/*! \brief ast_say_number_full_se: Swedish syntax
+/*! \brief ast_say_number_full_se: Swedish syntax
Sound files needed
- 1N
snprintf(fn, sizeof(fn), "digits/hundred");
num -= 100;
} else if (num == 1 && cn == -1) { /* En eller ett? */
- ast_copy_string(fn, "digits/1N", sizeof(fn));
+ ast_copy_string(fn, "digits/1N", sizeof(fn));
num = 0;
} else if (num < 20) {
snprintf(fn, sizeof(fn), "digits/%d", num);
num = -num;
} else {
num = 0;
- }
+ }
} else if (playz) {
snprintf(fn, sizeof(fn), "digits/0");
last_length = 0;
}
-/*! \brief ast_say_number_full_ru: Russian syntax
+/*! \brief ast_say_number_full_ru: Russian syntax
additional files:
n00.gsm (one hundred, two hundred, ...)
int res = 0;
int lastdigits = 0;
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
while (!res && (num)) {
num = -num;
} else {
num = 0;
- }
+ }
} else if (num < 20) {
if (options && strlen(options) == 1 && num < 3) {
snprintf(fn, sizeof(fn), "digits/%d%s", num, options);
int res = 0;
int playh = 0;
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
while(!res && (num || playh)) {
num = -num;
} else {
num = 0;
- }
+ }
} else if (playh) {
ast_copy_string(fn, "digits/roi", sizeof(fn));
playh = 0;
int playz = 0;
int playl = 0;
char fn[256] = "";
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
while (!res && (num || playh)) {
if (num < 0) {
num = -num;
} else {
num = 0;
- }
+ }
} else if (playl) {
snprintf(fn, sizeof(fn), "digits/%da", num);
playl = 0;
playh = 0;
} else if (playz) {
ast_copy_string(fn, "digits/odd", sizeof(fn));
- playz = 0;
+ playz = 0;
} else if (playoh) {
ast_copy_string(fn, "digits/0-hundred", sizeof(fn));
playoh = 0;
if ((num == 5) || (num == 4) || (num == 1)) playl++;
} else {
if (num < 1000) {
- snprintf(fn, sizeof(fn), "digits/%d", (num/100));
+ snprintf(fn, sizeof(fn), "digits/%d", (num/100));
num %= 100;
if (num && (num < 10)) {
playz++;
return res;
}
-/*! \brief ast_say_enumeration_full: call language-specific functions
+/*! \brief ast_say_enumeration_full: call language-specific functions
* \note Called from AGI */
static int say_enumeration_full(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
return ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd);
}
-/*! \brief ast_say_enumeration_full_en: English syntax
+/*! \brief ast_say_enumeration_full_en: English syntax
\note This is the default syntax, if no other syntax defined in this file is used */
static int ast_say_enumeration_full_en(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
{
int res = 0, t = 0;
char fn[256] = "";
-
+
while (!res && num) {
if (num < 0) {
ast_copy_string(fn, "digits/minus", sizeof(fn)); /* kind of senseless for enumerations, but our best effort for error checking */
num = -num;
} else {
num = 0;
- }
+ }
} else if (num < 20) {
snprintf(fn, sizeof(fn), "digits/h-%d", num);
num = 0;
- } else if (num < 100) {
+ } else if (num < 100) {
int tens = num / 10;
num = num % 10;
if (num == 0) {
num = num % 100;
if (hundreds > 1 || t == 1) {
res = ast_say_number_full_en(chan, hundreds, ints, language, audiofd, ctrlfd);
- }
+ }
if (res)
return res;
if (num) {
}
if (res)
return res;
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/thousand", sizeof(fn));
} else {
ast_copy_string(fn, "digits/h-thousand", sizeof(fn));
res = ast_say_number_full_en(chan, millions, ints, language, audiofd, ctrlfd);
if (res)
return res;
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/million", sizeof(fn));
} else {
ast_copy_string(fn, "digits/h-million", sizeof(fn));
gender = "";
}
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
while (!res && num) {
num = -num;
} else {
num = 0;
- }
+ }
} else if (num < 100 && t) {
ast_copy_string(fn, "digits/and", sizeof(fn));
t = 0;
} else {
snprintf(fn, sizeof(fn), "digits/%d", hundreds);
}
- if (num) {
+ if (num) {
ast_copy_string(fna, "digits/hundred", sizeof(fna));
} else {
snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender);
}
t = 1;
- } else if (num < 1000000) {
+ } else if (num < 1000000) {
int thousands = num / 1000;
num = num % 1000;
if (thousands == 1) {
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/1N", sizeof(fn));
ast_copy_string(fna, "digits/thousand", sizeof(fna));
} else {
if (res) {
return res;
}
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/thousand", sizeof(fn));
} else {
snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
int millions = num / 1000000;
num = num % 1000000;
if (millions == 1) {
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/1F", sizeof(fn));
ast_copy_string(fna, "digits/million", sizeof(fna));
} else {
if (res) {
return res;
}
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/millions", sizeof(fn));
} else {
snprintf(fn, sizeof(fn), "digits/h-million%s", gender);
int billions = num / 1000000000;
num = num % 1000000000;
if (billions == 1) {
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/1F", sizeof(fn));
ast_copy_string(fna, "digits/milliard", sizeof(fna));
} else {
gender = "";
}
- if (!num)
+ if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
while (!res && num) {
num = -num;
} else {
num = 0;
- }
+ }
} else if (num < 100 && t) {
ast_copy_string(fn, "digits/and", sizeof(fn));
t = 0;
} else {
snprintf(fn, sizeof(fn), "digits/%d", hundreds);
}
- if (num) {
+ if (num) {
ast_copy_string(fna, "digits/hundred", sizeof(fna));
} else {
snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender);
}
t = 1;
- } else if (num < 1000000) {
+ } else if (num < 1000000) {
int thousands = num / 1000;
num = num % 1000;
if (thousands == 1) {
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/1N", sizeof(fn));
ast_copy_string(fna, "digits/thousand", sizeof(fna));
} else {
if (res) {
return res;
}
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/thousand", sizeof(fn));
} else {
snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
int millions = num / 1000000;
num = num % 1000000;
if (millions == 1) {
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/1F", sizeof(fn));
ast_copy_string(fna, "digits/million", sizeof(fna));
} else {
if (res) {
return res;
}
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/millions", sizeof(fn));
} else {
snprintf(fn, sizeof(fn), "digits/h-million%s", gender);
int billions = num / 1000000000;
num = num % 1000000000;
if (billions == 1) {
- if (num) {
+ if (num) {
ast_copy_string(fn, "digits/1F", sizeof(fn));
ast_copy_string(fna, "digits/milliard", sizeof(fna));
} else {
/* Year */
int year = tm.tm_year + 1900;
if (year > 1999) { /* year 2000 and later */
- res = ast_say_number(chan, year, ints, lang, (char *) NULL);
+ res = ast_say_number(chan, year, ints, lang, (char *) NULL);
} else {
if (year < 1100) {
/* I'm not going to handle 1100 and prior */
if (!res) {
res = wait_file(chan, ints, "digits/hundred", lang);
if (!res && year % 100 != 0) {
- res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL);
+ res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL);
}
}
}
/* Year */
int year = tm.tm_year + 1900;
if (year > 1999) { /* year 2000 and later */
- res = ast_say_number(chan, year, ints, lang, (char *) NULL);
+ res = ast_say_number(chan, year, ints, lang, (char *) NULL);
} else {
if (year < 1100) {
/* I'm not going to handle 1100 and prior */
if (!res) {
res = wait_file(chan, ints, "digits/hundred", lang);
if (!res && year % 100 != 0) {
- res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL);
+ res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL);
}
}
}
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
- }
+ }
if (!res)
ast_say_number(chan, tm.tm_mday , ints, lang, (char *) NULL);
if (!res)
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
- res = ast_waitstream(chan, ints);
+ res = ast_waitstream(chan, ints);
}
return res;
}
ast_copy_string(fn, "digits/posor", sizeof(fn));
res = ast_streamfile(chan, fn, lang);
res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
- }
+ }
return res;
}
break;
case 'm':
/* Month enumerated */
- res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL);
+ res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL);
break;
case 'd':
case 'e':
/* First - Thirtyfirst */
- res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char *) NULL);
+ res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char *) NULL);
break;
case 'Y':
/* Year */
break;
case 'm':
/* Month enumerated */
- res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m");
+ res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m");
break;
case 'd':
case 'e':
/* First - Thirtyfirst */
- res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m");
+ res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m");
break;
case 'Y':
/* Year */
{
int year = tm.tm_year + 1900;
if (year > 1999) { /* year 2000 and later */
- res = ast_say_number(chan, year, ints, lang, (char *) NULL);
+ res = ast_say_number(chan, year, ints, lang, (char *) NULL);
} else {
if (year < 1100) {
/* I'm not going to handle 1100 and prior */
if (!res) {
res = wait_file(chan, ints, "digits/hundred", lang);
if (!res && year % 100 != 0) {
- res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL);
+ res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL);
}
}
}
/* Seconds */
res = wait_file(chan, ints, "digits/and", lang);
if (!res) {
- res = ast_say_number(chan, tm.tm_sec, ints, lang, "f");
+ res = ast_say_number(chan, tm.tm_sec, ints, lang, "f");
if (!res) {
res = wait_file(chan, ints, "digits/seconds", lang);
}
break;
case 'm':
/* Month enumerated */
- res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m");
+ res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m");
break;
case 'd':
case 'e':
/* First - Thirtyfirst */
- res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m");
+ res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m");
break;
case 'Y':
/* Year */
{
int year = tm.tm_year + 1900;
if (year > 1999) { /* year 2000 and later */
- res = ast_say_number(chan, year, ints, lang, (char *) NULL);
+ res = ast_say_number(chan, year, ints, lang, (char *) NULL);
} else {
if (year < 1100) {
/* I'm not going to handle 1100 and prior */
if (!res) {
res = wait_file(chan, ints, "digits/hundred", lang);
if (!res && year % 100 != 0) {
- res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL);
+ res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL);
}
}
}
case 'H':
case 'k':
/* 24-Hour */
- res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
+ res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
if (!res) {
res = wait_file(chan, ints, "digits/oclock", lang);
}
/* Seconds */
res = wait_file(chan, ints, "digits/and", lang);
if (!res) {
- res = ast_say_number(chan, tm.tm_sec, ints, lang, "f");
+ res = ast_say_number(chan, tm.tm_sec, ints, lang, "f");
if (!res) {
res = wait_file(chan, ints, tm.tm_sec == 1 ? "digits/second" : "digits/seconds", lang);
}
break;
case 'm':
/* Month enumerated */
- res = ast_say_number(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL);
+ res = ast_say_number(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL);
break;
case 'd':
case 'e':
/* First - Thirtyfirst */
- res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
+ res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
break;
case 'Y':
/* Year */
/*! \brief ast_say_date_with_format_he Say formatted date in Hebrew
*
- * \ref ast_say_date_with_format_en for the details of the options
+ * \ref ast_say_date_with_format_en for the details of the options
*
- * Changes from the English version:
+ * Changes from the English version:
*
* - don't replicate in here the logic of ast_say_number_full_he
*
*
* - The standard "long" format used in Hebrew is AdBY, rather than ABdY
*
- * \todo
+ * \todo
* - A "ha" is missing in the standard date format, before the 'd'.
* - The numbers of 3000--19000 are not handled well
*/
#define IL_DATE_STR "AdBY"
#define IL_TIME_STR "HM" /* NOTE: In Hebrew we do not support 12 hours, only 24. No AM or PM exists in the Hebrew language */
#define IL_DATE_STR_FULL IL_DATE_STR " 'digits/at' " IL_TIME_STR
- /* TODO: This whole function is cut&paste from
+ /* TODO: This whole function is cut&paste from
* ast_say_date_with_format_en . Is that considered acceptable?
**/
struct timeval when = { t, 0 };
break;
case 'd':
case 'e': /* Day of the month */
- /* I'm not sure exactly what the parameters
- * audiofd and ctrlfd to
- * ast_say_number_full_he mean, but it seems
- * safe to pass -1 there.
- *
- * At least in one of the pathes :-(
- */
+ /* I'm not sure exactly what the parameters
+ * audiofd and ctrlfd to
+ * ast_say_number_full_he mean, but it seems
+ * safe to pass -1 there.
+ *
+ * At least in one of the pathes :-(
+ */
res = ast_say_number_full_he(chan, tm.tm_mday, ints, lang, "m", -1, -1);
break;
case 'Y': /* Year */
case 'Q':
/* Shorthand for "Today", "Yesterday", or "date" */
case 'q':
- /* Shorthand for "" (today), "Yesterday", A
+ /* Shorthand for "" (today), "Yesterday", A
* (weekday), or "date" */
/* XXX As emphasized elsewhere, this should the native way in your
* language to say the date, with changes in what you say, depending
break;
case 'M':
/* Minute */
- res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
+ res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
break;
case 'P':
case 'p':
return res;
}
-/*! \brief French syntax
+/*! \brief French syntax
oclock = heure
*/
int ast_say_date_with_format_fr(struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
struct timeval now = ast_tvnow();
struct ast_tm tmnow;
time_t beg_today;
-
+
ast_localtime(&now, &tmnow, tzone);
/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
/* In any case, it saves not having to do ast_mktime() */
struct timeval now = ast_tvnow();
struct ast_tm tmnow;
time_t beg_today;
-
+
ast_localtime(&now, &tmnow, tzone);
/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
/* In any case, it saves not having to do ast_mktime() */
ast_copy_string(nextmsg, "digits/t-12", sizeof(nextmsg));
else if (tm.tm_hour > 12)
snprintf(nextmsg, sizeof(nextmsg), "digits/t-%d", tm.tm_hour - 12);
- else
+ else
snprintf(nextmsg, sizeof(nextmsg), "digits/t-%d", tm.tm_hour);
res = wait_file(chan, ints, nextmsg, lang);
if (tm.tm_hour != 0) {
snprintf(nextmsg, sizeof(nextmsg), "digits/t-%d", tm.tm_hour);
res = wait_file(chan, ints, nextmsg, lang);
- } else
+ } else
res = wait_file(chan, ints, "digits/t-24", lang);
break;
case 'M':
res = wait_file(chan, ints, "digits/100", lang);
}
} else
- res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
+ res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
break;
case 'P':
case 'p':
int ten, one;
ten = tm.tm_sec / 10;
one = tm.tm_sec % 10;
-
+
if (one > 1 && one < 5 && ten != 1)
res = wait_file(chan, ints, "digits/seconds", lang);
else
res = wait_file(chan, ints, "digits/pt-hora", lang);
if (tm.tm_hour != 1)
if (!res)
- res = wait_file(chan, ints, "digits/pt-sss", lang);
+ res = wait_file(chan, ints, "digits/pt-sss", lang);
} else {
- res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
+ res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
}
}
break;
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
- if (tm.tm_min > 0)
+ if (tm.tm_min > 0)
res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
return res;
}
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
- if (tm.tm_min > 0) {
+ if (tm.tm_min > 0) {
res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
if (!res)
res = ast_streamfile(chan, "digits/minute", lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
- if (tm.tm_min > 0)
+ if (tm.tm_min > 0)
res = ast_say_number(chan, tm.tm_min, ints, lang, NULL);
return res;
}
ast_localtime(&when, &tm, NULL);
res = ast_say_date(chan, t, ints, lang);
- if (!res)
+ if (!res)
ast_say_time(chan, t, ints, lang);
return res;
ast_localtime(&when, &tm, NULL);
res = ast_say_date(chan, t, ints, lang);
- if (!res)
+ if (!res)
ast_say_time(chan, t, ints, lang);
return res;
}
if (tm.tm_min > 0) {
if (!res)
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
- }
+ }
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
if (!res)
res = ast_waitstream(chan, ints);
}
- if (!res)
+ if (!res)
ast_say_time(chan, t, ints, lang);
return res;
}
ast_copy_string(fn, "digits/posor", sizeof(fn));
res = ast_streamfile(chan, fn, lang);
res = ast_say_number(chan, tm.tm_year + 1900 + 543, ints, lang, (char *) NULL);
- }
+ }
if (!res)
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
if (!res){
ast_copy_string(fn, "digits/wela", sizeof(fn));
res = ast_streamfile(chan, fn, lang);
- }
+ }
if (!res)
res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
if (!res)
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
- if (!res)
+ if (!res)
res = ast_waitstream(chan, ints);
}
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
if (!res)
res = wait_file(chan, ints, fn, lang);
-
+
} else if (daydiff) {
/* Just what day of the week */
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
/*! \brief Greek support
- * A list of the files that you need to create
- -> digits/xilia = "xilia"
- -> digits/myrio = "ekatomyrio"
- -> digits/thousands = "xiliades"
- -> digits/millions = "ektatomyria"
- -> digits/[1..12] :: A pronunciation of th digits form 1 to 12 e.g. "tria"
- -> digits/[10..100] :: A pronunciation of the tens from 10 to 90
- e.g. 80 = "ogdonta"
+ * A list of the files that you need to create
+ -> digits/xilia = "xilia"
+ -> digits/myrio = "ekatomyrio"
+ -> digits/thousands = "xiliades"
+ -> digits/millions = "ektatomyria"
+ -> digits/[1..12] :: A pronunciation of th digits form 1 to 12 e.g. "tria"
+ -> digits/[10..100] :: A pronunciation of the tens from 10 to 90
+ e.g. 80 = "ogdonta"
Here we must note that we use digits/tens/100 to utter "ekato"
and digits/hundred-100 to utter "ekaton"
- -> digits/hundred-[100...1000] :: A pronunciation of hundreds from 100 to 1000 e.g 400 =
- "terakosia". Here again we use hundreds/1000 for "xilia"
+ -> digits/hundred-[100...1000] :: A pronunciation of hundreds from 100 to 1000 e.g 400 =
+ "terakosia". Here again we use hundreds/1000 for "xilia"
and digits/thousnds for "xiliades"
*/
static int ast_say_number_full_gr(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
char fn[256] = "";
int i=0;
-
+
if (!num) {
ast_copy_string(fn, "digits/0", sizeof(fn));
res = ast_streamfile(chan, fn, ast_channel_language(chan));
} else if (num <= 100) {
/* 13 < num <= 100 */
snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
- num %= 10;
+ num %= 10;
} else if (num < 200) {
/* 100 < num < 200 */
snprintf(fn, sizeof(fn), "digits/hundred-100");
/*! \brief Greek support
*
* The format is weekday - day - month -year
- *
+ *
* A list of the files that you need to create
* digits/day-[1..7] : "Deytera .. Paraskeyh"
- * digits/months/1..12 : "Ianouariou .. Dekembriou"
+ * digits/months/1..12 : "Ianouariou .. Dekembriou"
Attention the months are in "gekinh klhsh"
*/
static int ast_say_date_gr(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
{
struct ast_tm tm;
struct timeval when = { t, 0 };
-
+
char fn[256];
int res = 0;
-
+
ast_localtime(&when, &tm, NULL);
/* W E E K - D A Y */
/* Y E A R */
if (!res)
res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
- return res;
+ return res;
}
-
+
/*! \brief Greek support
*
* A list of the files that you need to create
* - digits/female/1..4 : "Mia, dyo , treis, tesseris "
* - digits/kai : "KAI"
* - didgits : "h wra"
- * - digits/p-m : "meta meshmbrias"
+ * - digits/p-m : "meta meshmbrias"
* - digits/a-m : "pro meshmbrias"
*/
static int ast_say_time_gr(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
hour -= 12;
pm = 1;
}
-
+
res = gr_say_number_female(hour, chan, ints, lang);
if (tm.tm_min) {
if (!res)
break;
case 'Y':
/* Year */
-
+
ast_say_number_full_gr(chan, 1900+tm.tm_year, ints, ast_channel_language(chan), -1, -1);
break;
case 'I':
struct timeval now = ast_tvnow();
struct ast_tm tmnow;
time_t beg_today;
-
+
ast_localtime(&now, &tmnow, tzone);
/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
/* In any case, it saves not having to do ast_mktime() */
struct timeval now = ast_tvnow();
struct ast_tm tmnow;
time_t beg_today;
-
+
ast_localtime(&now, &tmnow, tzone);
/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
/* In any case, it saves not having to do ast_mktime() */
break;
case 'm':
/* Month enumerated */
- res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL);
+ res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL);
break;
case 'd':
case 'e':
/* 1 - 31 */
- res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
+ res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
break;
case 'Y':
/* Year */
sprintf(new_string, "digits/");
strncat(new_string, remaining, len); /* we can't sprintf() it, it's not null-terminated. */
-/* new_string[len + strlen("digits/")] = '\0'; */
+/* new_string[len + strlen("digits/")] = '\0'; */
if (!ast_streamfile(chan, new_string, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
-/*! \brief Georgian syntax. e.g. "oriatas xuti tslis 5 noemberi".
+/*! \brief Georgian syntax. e.g. "oriatas xuti tslis 5 noemberi".
Georgian support for date/time requires the following files (*.gsm):
if (!res) {
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
-/* if (!res)
- res = ast_waitstream(chan, ints);
+/* if (!res)
+ res = ast_waitstream(chan, ints);
*/
}
return res;
}
-/*! \brief
+/*! \brief
* In English, we use the plural for everything but one. For example:
* - 1 degree
* - 2 degrees
* - 5 degrees
* The filename for the plural form is generated by appending "s". Note that
- * purpose is to generate a unique filename, not to implement irregular
+ * purpose is to generate a unique filename, not to implement irregular
* declensions. Thus:
* - 1 man
* - 2 mans (the "mans" soundfile will of course say "men")
/*! \brief
* Counting of objects in slavic languages such as Russian and Ukrainian the
* rules are more complicated. There are two plural forms used in counting.
- * They are the genative singular which we represent with the suffix "x1" and
+ * They are the genative singular which we represent with the suffix "x1" and
* the genative plural which we represent with the suffix "x2". The base names
* of the soundfiles remain in English. For example:
* - 1 degree (soudfile says "gradus")
DEBUG_M(a) \
} while (0)
#else
-#define DEBUG(a)
+#define DEBUG(a)
#endif
#include <sys/time.h>
#include "asterisk/heap.h"
#include "asterisk/threadstorage.h"
-/*!
+/*!
* \brief Max num of schedule structs
*
* \note The max number of schedule structs to keep around
* already have too many cache entries
*/
-#ifdef SCHED_MAX_CACHE
+#ifdef SCHED_MAX_CACHE
if (con->schedccnt < SCHED_MAX_CACHE) {
AST_LIST_INSERT_HEAD(&con->schedc, tmp, list);
con->schedccnt++;
}
/*! \brief
- * Return the number of milliseconds
+ * Return the number of milliseconds
* until the next scheduled event
*/
int ast_sched_wait(struct ast_sched_context *con)
/*! \brief
* Take a sched structure and put it in the
* queue, such that the soonest event is
- * first in the list.
+ * first in the list.
*/
static void schedule(struct ast_sched_context *con, struct sched *s)
{
struct sched *cur;
int countlist[cbnames->numassocs + 1];
size_t heap_size;
-
+
memset(countlist, 0, sizeof(countlist));
ast_str_set(buf, 0, " Highwater = %d\n schedcnt = %d\n", con->highwater, con->schedcnt);
ast_str_append(buf, 0, " <unknown> : %d\n", countlist[cbnames->numassocs]);
}
-
+
/*! \brief Dump the contents of the scheduler to LOG_DEBUG */
void ast_sched_dump(struct ast_sched_context *con)
{
struct timeval delta;
q = ast_heap_peek(con->sched_heap, x);
delta = ast_tvsub(q->when, when);
- ast_debug(1, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n",
+ ast_debug(1, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n",
q->id,
q->callback,
q->data,
* have removed the first event and the rest is still there,
* so it's permissible for the callback to add new events, but
* trying to delete itself won't work because it isn't in
- * the schedule queue. If that's what it wants to do, it
+ * the schedule queue. If that's what it wants to do, it
* should return 0.
*/
/*! \file
*
* \brief Based on the RFC 6234
- *
+ *
* Copyright (c) 2011 IETF Trust and the persons identified as
* authors of the code. All rights reserved.
*
#include "asterisk/slinfactory.h"
#include "asterisk/translate.h"
-void ast_slinfactory_init(struct ast_slinfactory *sf)
+void ast_slinfactory_init(struct ast_slinfactory *sf)
{
memset(sf, 0, sizeof(*sf));
sf->offset = sf->hold;
return 0;
}
-void ast_slinfactory_destroy(struct ast_slinfactory *sf)
+void ast_slinfactory_destroy(struct ast_slinfactory *sf)
{
struct ast_frame *f;
if (!(begin_frame = ast_translate(sf->trans, f, 0))) {
return 0;
}
-
+
if (!(duped_frame = ast_frisolate(begin_frame))) {
return 0;
}
return x;
}
-int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples)
+int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples)
{
struct ast_frame *frame_ptr;
unsigned int sofar = 0, ineed, remain;
}
continue;
}
-
+
if ((frame_ptr = AST_LIST_REMOVE_HEAD(&sf->queue, frame_list))) {
frame_data = frame_ptr->data.ptr;
-
+
if (frame_ptr->samples <= ineed) {
memcpy(offset, frame_data, frame_ptr->samples * sizeof(*offset));
sofar += frame_ptr->samples;
* \brief DNS SRV Record Lookup Support for Asterisk
*
* \author Mark Spencer <markster@digium.com>
- *
+ *
* \arg See also \ref AstENUM
*
* \note Funding provided by nic.at
if (!(entry = ast_calloc(1, sizeof(*entry) + strlen(repl))))
return -1;
-
+
entry->priority = ntohs(srv->priority);
entry->weight = ntohs(srv->weight);
entry->port = ntohs(srv->port);
strcpy(entry->host, repl);
*result = entry;
-
+
return 0;
}
for (year = EPOCH_YEAR;
sp->timecnt + 2 <= TZ_MAX_TIMES;
++year) {
- time_t newfirst;
+ time_t newfirst;
starttime = transtime(janfirst, year, &start,
stdoffset);
}
/*
-** This function provides informaton about daylight savings time
-** for the given timezone. This includes whether it can determine
-** if daylight savings is used for this timezone, the UTC times for
-** when daylight savings transitions, and the offset in seconds from
-** UTC.
+** This function provides informaton about daylight savings time
+** for the given timezone. This includes whether it can determine
+** if daylight savings is used for this timezone, the UTC times for
+** when daylight savings transitions, and the offset in seconds from
+** UTC.
*/
void ast_get_dst_info(const time_t * const timep, int *dst_enabled, time_t *dst_start, time_t *dst_end, int *gmt_off, const char * const zone)
{
- int i;
+ int i;
int transition1 = -1;
int transition2 = -1;
time_t seconds;
int bounds_exceeded = 0;
time_t t = *timep;
const struct state *sp;
-
+
if (NULL == dst_enabled)
return;
*dst_enabled = 0;
if (NULL == dst_start || NULL == dst_end || NULL == gmt_off)
return;
- *gmt_off = 0;
-
+ *gmt_off = 0;
+
sp = ast_tzset(zone);
- if (NULL == sp)
+ if (NULL == sp)
return;
-
- /* If the desired time exceeds the bounds of the defined time transitions
- * then give give up on determining DST info and simply look for gmt offset
- * This requires that I adjust the given time using increments of Gregorian
- * repeats to place the time within the defined time transitions in the
- * timezone structure.
+
+ /* If the desired time exceeds the bounds of the defined time transitions
+ * then give give up on determining DST info and simply look for gmt offset
+ * This requires that I adjust the given time using increments of Gregorian
+ * repeats to place the time within the defined time transitions in the
+ * timezone structure.
*/
if ((sp->goback && t < sp->ats[0]) ||
(sp->goahead && t > sp->ats[sp->timecnt - 1])) {
t += seconds;
else
t -= seconds;
-
+
if (t < sp->ats[0] || t > sp->ats[sp->timecnt - 1])
return; /* "cannot happen" */
}
*gmt_off = sp->ttis[i].tt_gmtoff;
return;
- }
+ }
for (i = 1; i < sp->timecnt; ++i) {
if (t < sp->ats[i]) {
transition1 = sp->types[i - 1];
transition2 = sp->types[i];
break;
- }
+ }
}
- /* if I found transition times that do not bounded the given time and these correspond to
+ /* if I found transition times that do not bounded the given time and these correspond to
or the bounding zones do not reflect a changes in day light savings, then I do not have dst active */
if (i >= sp->timecnt || 0 > transition1 || 0 > transition2 ||
(sp->ttis[transition1].tt_isdst == sp->ttis[transition2].tt_isdst)) {
*dst_enabled = 0;
- *gmt_off = sp->ttis[sp->types[sp->timecnt -1]].tt_gmtoff;
+ *gmt_off = sp->ttis[sp->types[sp->timecnt -1]].tt_gmtoff;
} else {
/* I have valid daylight savings information. */
- if(sp->ttis[transition2].tt_isdst)
+ if(sp->ttis[transition2].tt_isdst)
*gmt_off = sp->ttis[transition1].tt_gmtoff;
- else
+ else
*gmt_off = sp->ttis[transition2].tt_gmtoff;
/* If I adjusted the time earlier, indicate that the dst is invalid */
*dst_end = sp->ats[i];
}
}
- }
+ }
return;
}
-/*! \file
+/*! \file
\brief Testing localtime functionality */
#include "localtime.c"
/*! \file
*
- * \brief Compatibility functions for strsep and strtoq missing on Solaris
+ * \brief Compatibility functions for strsep and strtoq missing on Solaris
*/
#include "asterisk.h"
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
+#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
int asprintf(char **str, const char *fmt, ...)
{
va_list ap;
return t;
}
-/* release task resources */
+/* release task resources */
static void *tps_task_free(struct tps_task *task)
{
if (task) {
}
/* taskprocessor tab completion */
-static char *tps_taskprocessor_tab_complete(struct ast_taskprocessor *p, struct ast_cli_args *a)
+static char *tps_taskprocessor_tab_complete(struct ast_taskprocessor *p, struct ast_cli_args *a)
{
int tklen;
int wordnum = 0;
switch (cmd) {
case CLI_INIT:
e->command = "core ping taskprocessor";
- e->usage =
+ e->usage =
"Usage: core ping taskprocessor <taskprocessor>\n"
" Displays the time required for a task to be processed\n";
return NULL;
delta = ast_tvsub(end, begin);
ast_cli(a->fd, "\n\t%24s ping time: %.1ld.%.6ld sec\n\n", name, (long)delta.tv_sec, (long int)delta.tv_usec);
ao2_ref(tps, -1);
- return CLI_SUCCESS;
+ return CLI_SUCCESS;
}
static char *cli_tps_report(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
switch (cmd) {
case CLI_INIT:
e->command = "core show taskprocessors";
- e->usage =
+ e->usage =
"Usage: core show taskprocessors\n"
" Shows a list of instantiated task processors and their statistics\n";
return NULL;
case CLI_GENERATE:
- return NULL;
+ return NULL;
}
if (a->argc != e->args)
ao2_ref(p, -1);
}
ao2_iterator_destroy(&i);
- tcount = ao2_container_count(tps_singletons);
+ tcount = ao2_container_count(tps_singletons);
ast_cli(a->fd, "\n\t+---------------------+-----------------+------------+-------------+\n\t%d taskprocessors\n\n", tcount);
- return CLI_SUCCESS;
+ return CLI_SUCCESS;
}
/* this is the task processing worker function */
}
while (i->poll_thread_run) {
- ast_mutex_lock(&i->taskprocessor_lock);
- if (!i->poll_thread_run) {
- ast_mutex_unlock(&i->taskprocessor_lock);
- break;
- }
- if (!(size = tps_taskprocessor_depth(i))) {
- ast_cond_wait(&i->poll_cond, &i->taskprocessor_lock);
- if (!i->poll_thread_run) {
- ast_mutex_unlock(&i->taskprocessor_lock);
- break;
+ ast_mutex_lock(&i->taskprocessor_lock);
+ if (!i->poll_thread_run) {
+ ast_mutex_unlock(&i->taskprocessor_lock);
+ break;
+ }
+ if (!(size = tps_taskprocessor_depth(i))) {
+ ast_cond_wait(&i->poll_cond, &i->taskprocessor_lock);
+ if (!i->poll_thread_run) {
+ ast_mutex_unlock(&i->taskprocessor_lock);
+ break;
}
- }
- ast_mutex_unlock(&i->taskprocessor_lock);
- /* stuff is in the queue */
- if (!(t = tps_taskprocessor_pop(i))) {
- ast_log(LOG_ERROR, "Wtf?? %d tasks in the queue, but we're popping blanks!\n", size);
- continue;
- }
- if (!t->execute) {
- ast_log(LOG_WARNING, "Task is missing a function to execute!\n");
- tps_task_free(t);
- continue;
- }
- t->execute(t->datap);
-
- ast_mutex_lock(&i->taskprocessor_lock);
- if (i->stats) {
- i->stats->_tasks_processed_count++;
- if (size > i->stats->max_qsize) {
- i->stats->max_qsize = size;
- }
- }
- ast_mutex_unlock(&i->taskprocessor_lock);
-
- tps_task_free(t);
- }
+ }
+ ast_mutex_unlock(&i->taskprocessor_lock);
+ /* stuff is in the queue */
+ if (!(t = tps_taskprocessor_pop(i))) {
+ ast_log(LOG_ERROR, "Wtf?? %d tasks in the queue, but we're popping blanks!\n", size);
+ continue;
+ }
+ if (!t->execute) {
+ ast_log(LOG_WARNING, "Task is missing a function to execute!\n");
+ tps_task_free(t);
+ continue;
+ }
+ t->execute(t->datap);
+
+ ast_mutex_lock(&i->taskprocessor_lock);
+ if (i->stats) {
+ i->stats->_tasks_processed_count++;
+ if (size > i->stats->max_qsize) {
+ i->stats->max_qsize = size;
+ }
+ }
+ ast_mutex_unlock(&i->taskprocessor_lock);
+
+ tps_task_free(t);
+ }
while ((t = tps_taskprocessor_pop(i))) {
tps_task_free(t);
}
}
/* Provide a reference to a taskprocessor. Create the taskprocessor if necessary, but don't
- * create the taskprocessor if we were told via ast_tps_options to return a reference only
+ * create the taskprocessor if we were told via ast_tps_options to return a reference only
* if it already exists */
struct ast_taskprocessor *ast_taskprocessor_get(const char *name, enum ast_tps_options create)
{
struct ast_taskprocessor *p, tmp_tps = {
.name = name,
};
-
+
if (ast_strlen_zero(name)) {
ast_log(LOG_ERROR, "requesting a nameless taskprocessor!!!\n");
return NULL;
return NULL;
}
-/* push the task into the taskprocessor queue */
+/* push the task into the taskprocessor queue */
int ast_taskprocessor_push(struct ast_taskprocessor *tps, int (*task_exe)(void *datap), void *datap)
{
struct tps_task *t;
/*! \file
*
- * \brief TTY/TDD Generation support
+ * \brief TTY/TDD Generation support
*
* \author Mark Spencer <markster@digium.com>
*
}
memcpy(buf, tdd->oldstuff, tdd->oldlen);
mylen += tdd->oldlen / 2;
- for (x = 0; x < len; x++)
+ for (x = 0; x < len; x++)
buf[x + tdd->oldlen / 2] = AST_MULAW(ubuf[x]);
c = res = 0;
while (mylen >= 1320) { /* has to have enough to work on */
tdd->oldlen = 0;
free(obuf);
if (res) {
- tdd->mode = 2;
+ tdd->mode = 2;
/* put it in mode where it
reliably puts teleprinter in correct shift mode */
return(c);
t = *cr * dr[bit] - *ci * di[bit];
*ci = *cr * di[bit] + *ci * dr[bit];
*cr = t;
-
+
t = 2.0 - (*cr * *cr + *ci * *ci);
*cr *= t;
*ci *= t;
return *cr;
-}
+}
#define PUT_BYTE(a) do { \
*(buf++) = (a); \
*(buf++) = AST_LIN2MU(__pas_idx); \
bytes++; \
} while(0)
-
+
#define PUT_TDD_MARKMS do { \
int x; \
for (x = 0; x < 8; x++) \
#define PUT_TDD(byte) do { \
int z; \
unsigned char b = (byte); \
- PUT_TDD_BAUD(0); /* Start bit */ \
+ PUT_TDD_BAUD(0); /* Start bit */ \
for (z = 0; z < 5; z++) { \
PUT_TDD_BAUD(b & 1); \
b >>= 1; \
} \
PUT_TDD_STOP; /* Stop bit */ \
-} while(0);
+} while(0);
/*! Generate TDD hold tone
* \param buf Result buffer
for(x = 0; str[x]; x++) {
/* Do synch for each 72th character */
- if ( (tdd->charnum++) % 72 == 0)
+ if ( (tdd->charnum++) % 72 == 0)
PUT_TDD(tdd->mode ? 27 /* FIGS */ : 31 /* LTRS */);
c = toupper(str[x]);
if ((i < (len - 2)) &&
(line[i + 1] == 0x5B)) {
switch (line[i + 2]) {
- case 0x30:
+ case 0x30:
case 0x31:
case 0x33:
continue;
}
}
-void *_ast_register_timing_interface(struct ast_timing_interface *funcs,
+void *_ast_register_timing_interface(struct ast_timing_interface *funcs,
struct ast_module *mod)
{
struct timing_holder *h;
if (sscanf(a->argv[2], "%30u", &rate) == 1) {
test_rate = rate;
} else {
- ast_cli(a->fd, "Invalid rate '%s', using default of %u\n", a->argv[2], test_rate);
+ ast_cli(a->fd, "Invalid rate '%s', using default of %u\n", a->argv[2], test_rate);
}
}
ast_timer_close(timer);
- ast_cli(a->fd, "It has been %" PRIi64 " milliseconds, and we got %d timer ticks\n",
+ ast_cli(a->fd, "It has been %" PRIi64 " milliseconds, and we got %d timer ticks\n",
ast_tvdiff_ms(end, start), count);
return CLI_SUCCESS;
*
* \brief Translate via the use of pseudo channels
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
*/
#include "asterisk.h"
return 0;
}
-/*!
+/*!
* \internal
* \brief converts index value back to format id
*/
* Asterisk -- A telephony toolkit for Linux.
*
* UDPTL support for T.38
- *
+ *
* Copyright (C) 2005, Steve Underwood, partly based on RTP code which is
* Copyright (C) 1999-2009, Digium, Inc.
*
* this code.
*/
-/*!
- * \file
+/*!
+ * \file
*
* \brief UDPTL support for T.38 faxing
- *
+ *
*
* \author Mark Spencer <markster@digium.com>
* \author Steve Underwood <steveu@coppice.org>
* \author Kevin P. Fleming <kpfleming@digium.com>
- *
+ *
* \page T38fax_udptl T.38 support :: UDPTL
*
* Asterisk supports T.38 fax passthrough, origination and termination. It does
*
* UDPTL is handled very much like RTP. It can be reinvited to go directly between
* the endpoints, without involving Asterisk in the media stream.
- *
+ *
* \b References:
* - chan_sip.c
* - udptl.c
//fprintf(stderr, "Fixed packet %d, len %d\n", j, l);
s->f[ifp_no].frametype = AST_FRAME_MODEM;
s->f[ifp_no].subclass.integer = AST_MODEM_T38;
-
+
s->f[ifp_no].mallocd = 0;
s->f[ifp_no].seqno = j;
s->f[ifp_no].datalen = s->rx[l].buf_len;
/* Decode the primary IFP packet */
s->f[ifp_no].frametype = AST_FRAME_MODEM;
s->f[ifp_no].subclass.integer = AST_MODEM_T38;
-
+
s->f[ifp_no].mallocd = 0;
s->f[ifp_no].seqno = seq_no;
s->f[ifp_no].datalen = ifp_len;
redundancy sets later on. */
s->tx[entry].buf_len = ifp_len;
memcpy(s->tx[entry].buf, ifp, ifp_len);
-
+
/* Build the UDPTLPacket */
len = 0;
udptl->error_correction_span = udptlfecspan;
udptl->error_correction_entries = udptlfecentries;
-
+
udptl->far_max_datagram = -1;
udptl->far_max_ifp = -1;
udptl->local_max_ifp = -1;
/* If there is no data length, return immediately */
if (f->datalen == 0)
return 0;
-
+
if ((f->frametype != AST_FRAME_MODEM) ||
(f->subclass.integer != AST_MODEM_T38)) {
ast_log(LOG_WARNING, "UDPTL (%s): UDPTL can only send T.38 data.\n",
LOG_TAG(s), ast_sockaddr_stringify(&s->them), seq, len);
}
}
-
+
return 0;
}
void *pvt0;
void *pvt1;
int to;
-
+
ast_channel_lock(c0);
while (ast_channel_trylock(c1)) {
ast_channel_unlock(c0);
ast_udptl_get_peer(p1, &t1);
ast_udptl_get_peer(p0, &t0);
if (ast_sockaddr_cmp(&t1, &ac1)) {
- ast_debug(1, "Oooh, '%s' changed end address to %s\n",
+ ast_debug(1, "Oooh, '%s' changed end address to %s\n",
ast_channel_name(c1), ast_sockaddr_stringify(&t1));
- ast_debug(1, "Oooh, '%s' was %s\n",
+ ast_debug(1, "Oooh, '%s' was %s\n",
ast_channel_name(c1), ast_sockaddr_stringify(&ac1));
ast_sockaddr_copy(&ac1, &t1);
}
if (ast_sockaddr_cmp(&t0, &ac0)) {
- ast_debug(1, "Oooh, '%s' changed end address to %s\n",
+ ast_debug(1, "Oooh, '%s' changed end address to %s\n",
ast_channel_name(c0), ast_sockaddr_stringify(&t0));
- ast_debug(1, "Oooh, '%s' was %s\n",
+ ast_debug(1, "Oooh, '%s' was %s\n",
ast_channel_name(c0), ast_sockaddr_stringify(&ac0));
ast_sockaddr_copy(&ac0, &t0);
}
switch (cmd) {
case CLI_INIT:
e->command = "udptl set debug {on|off|ip}";
- e->usage =
+ e->usage =
"Usage: udptl set debug {on|off|ip host[:port]}\n"
" Enable or disable dumping of UDPTL packets.\n"
" If ip is specified, limit the dumped packets to those to and from\n"
*
* \brief u-Law to Signed linear conversion
*
- * \author Mark Spencer <markster@digium.com>
+ * \author Mark Spencer <markster@digium.com>
*/
#include "asterisk.h"
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 };
int sign, exponent, mantissa;
unsigned char ulawbyte;
-
+
/* Get the sample into sign-magnitude. */
sign = (sample >> 8) & 0x80; /* set aside the sign */
if (sign != 0)
sample = -sample; /* get magnitude */
if (sample > CLIP)
sample = CLIP; /* clip the magnitude */
-
+
/* Convert from 16 bit linear to ulaw. */
sample = sample + BIAS;
exponent = exp_lut[(sample >> 7) & 0xFF];
mantissa = (sample >> (exponent + 3)) & 0x0F;
ulawbyte = ~(sign | (exponent << 4) | mantissa);
-
+
#ifdef ZEROTRAP
if (ulawbyte == 0)
ulawbyte = 0x02; /* optional CCITT trap */
#endif
-
+
return ulawbyte;
}
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 };
unsigned sign, exponent, mantissa, mag;
unsigned char ulawbyte;
-
+
/* Get the sample into sign-magnitude. */
ast_ulaw_get_sign_mag(sample, &sign, &mag);
if (mag > CLIP)
mag = CLIP; /* clip the magnitude */
-
+
sign = (sample >> 8) & 0x80; /* set aside the sign */
- if (sign != 0)
+ if (sign != 0)
sample = -sample; /* get magnitude */
if (sample > CLIP)
sample = CLIP; /* clip the magnitude */
-
+
/* Convert from 16 bit linear to ulaw. */
mag += BIAS;
exponent = exp_lut[(mag >> 7) & 0xFF];
mantissa = (mag >> (exponent + 3)) & 0x0F;
-
+
if (full_coding) {
/* full encoding, with sign and xform */
ulawbyte = ~(sign | (exponent << 4) | mantissa);
return ulawbyte;
}
-
+
static inline short ulaw2linear(unsigned char ulawbyte)
{
unsigned exponent, mantissa;
short sample;
static const short etab[]={0,132,396,924,1980,4092,8316,16764};
-
+
ulawbyte = ~ulawbyte;
exponent = (ulawbyte & 0x70) >> 4;
mantissa = ulawbyte & 0x0f;
void ast_ulaw_init(void)
{
int i;
-
+
/*
* Set up mu-law conversion table
*/
for (i = 0;i < 256;i++) {
short mu,e,f,y;
static const short etab[]={0,132,396,924,1980,4092,8316,16764};
-
+
mu = 255-i;
e = (mu & 0x70)/16;
f = mu & 0x0f;
__ast_lin2mu[((unsigned short)i) >> 2] = linear2ulaw(i);
}
#else
-
+
for (i = 0; i < 256; i++) {
__ast_mulaw[i] = ulaw2linear(i);
}
AST_LIN2MU_LOOKUP(i) = linear2ulaw(i, 0 /* half-cooked */);
}
#endif
-
+
#ifdef TEST_CODING_TABLES
for (i = -32768; i < 32768; ++i) {
#ifndef G711_NEW_ALGORITHM
unsigned char e2 = AST_LIN2MU(i);
short d2 = ulaw2linear(e2);
short d3 = AST_MULAW(e1);
-
+
if (e1 != e2 || d1 != d3 || d2 != d3) {
ast_log(LOG_WARNING, "u-Law coding tables test failed on %d: e1=%u, e2=%u, d1=%d, d2=%d\n",
i, (unsigned)e1, (unsigned)e2, (int)d1, (int)d2);
}
ast_log(LOG_NOTICE, "u-Law coding table test complete.\n");
#endif /* TEST_CODING_TABLES */
-
+
#ifdef TEST_TANDEM_TRANSCODING
/* tandem transcoding test */
for (i = -32768; i < 32768; ++i) {
short d2 = AST_MULAW(e2);
unsigned char e3 = AST_LIN2MU(d2);
short d3 = AST_MULAW(e3);
-
+
if (i < 0 && e1 == 0x7f && e2 == 0xff && e3 == 0xff)
continue; /* known and normal negative 0 case */
-
+
if (e1 != e2 || e2 != e3 || d1 != d2 || d2 != d3) {
ast_log(LOG_WARNING, "u-Law tandem transcoding test failed on %d: e1=%u, e2=%u, d1=%d, d2=%d, d3=%d\n",
i, (unsigned)e1, (unsigned)e2, (int)d1, (int)d2, (int)d3);
/*! \brief Reentrant replacement for gethostbyname for BSD-based systems.
\note This
-routine is derived from code originally written and placed in the public
+routine is derived from code originally written and placed in the public
domain by Enzo Michelangeli <em@em.no-ip.com> */
static int gethostbyname_r (const char *name, struct hostent *ret, char *buf,
- size_t buflen, struct hostent **result,
- int *h_errnop)
+ size_t buflen, struct hostent **result,
+ int *h_errnop)
{
int hsave;
struct hostent *ph;
#endif
-/*! \brief Re-entrant (thread safe) version of gethostbyname that replaces the
+/*! \brief Re-entrant (thread safe) version of gethostbyname that replaces the
standard gethostbyname (which is not thread safe)
*/
struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp)
if (inet_pton(AF_INET, host, hp->hp.h_addr) > 0)
return &hp->hp;
return NULL;
-
+
}
#ifdef HAVE_GETHOSTBYNAME_R_5
result = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &herrno);
uint8_t Message_Digest[20];
SHA1Reset(&sha);
-
+
SHA1Input(&sha, (const unsigned char *) input, strlen(input));
SHA1Result(&sha, Message_Digest);
bits += 6;
src++;
incnt++;
- /* If we have at least 8 bits left over, take that character
+ /* If we have at least 8 bits left over, take that character
off the top */
if (bits >= 8) {
bits -= 8;
}
}
if (bits && (cnt + 4 <= max)) {
- /* Add one last character for the remaining bits,
+ /* Add one last character for the remaining bits,
padding the rest with 0 */
byte <<= 24 - bits;
*dst++ = base64[(byte >> 18) & 0x3f];
#undef pthread_mutex_init
#undef pthread_mutex_destroy
-/*!
- * \brief Keep track of which locks a thread holds
+/*!
+ * \brief Keep track of which locks a thread holds
*
* There is an instance of this struct for every active thread
*/
* The index (num_locks - 1) has the info on the last one in the
* locks member */
unsigned int num_locks;
- /*! Protects the contents of the locks member
+ /*! Protects the contents of the locks member
* Intentionally not ast_mutex_t */
pthread_mutex_t lock;
AST_LIST_ENTRY(thr_lock_info) entry;
};
-/*!
- * \brief Locked when accessing the lock_infos list
+/*!
+ * \brief Locked when accessing the lock_infos list
*/
AST_MUTEX_DEFINE_STATIC(lock_infos_lock);
/*!
- * \brief A list of each thread's lock info
+ * \brief A list of each thread's lock info
*/
static AST_LIST_HEAD_NOLOCK_STATIC(lock_infos, thr_lock_info);
break;
}
- ast_log(LOG_ERROR,
- "Thread '%s' still has a lock! - '%s' (%p) from '%s' in %s:%d!\n",
+ ast_log(LOG_ERROR,
+ "Thread '%s' still has a lock! - '%s' (%p) from '%s' in %s:%d!\n",
lock_info->thread_name,
lock_info->locks[i].lock_name,
lock_info->locks[i].lock_addr,
if (i < lock_info->num_locks - 1) {
/* Not the last one ... *should* be rare! */
- memmove(&lock_info->locks[i], &lock_info->locks[i + 1],
+ memmove(&lock_info->locks[i], &lock_info->locks[i + 1],
(lock_info->num_locks - (i + 1)) * sizeof(lock_info->locks[0]));
}
if ((symbols = ast_bt_get_symbols(bt->addresses, bt->num_frames))) {
int frame_iterator;
-
+
for (frame_iterator = 0; frame_iterator < bt->num_frames; ++frame_iterator) {
ast_str_append(str, 0, "\t%s\n", symbols[frame_iterator]);
}
int j;
ast_mutex_t *lock;
struct ast_lock_track *lt;
-
- ast_str_append(str, 0, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n",
- lock_info->locks[i].pending > 0 ? "Waiting for " :
+
+ ast_str_append(str, 0, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n",
+ lock_info->locks[i].pending > 0 ? "Waiting for " :
lock_info->locks[i].pending < 0 ? "Tried and failed to get " : "", i,
- lock_info->locks[i].file,
+ lock_info->locks[i].file,
locktype2str(lock_info->locks[i].type),
lock_info->locks[i].line_num,
lock_info->locks[i].func, lock_info->locks[i].lock_name,
- lock_info->locks[i].lock_addr,
+ lock_info->locks[i].lock_addr,
lock_info->locks[i].times_locked);
#ifdef HAVE_BKTR
append_backtrace_information(str, lock_info->locks[i].backtrace);
#endif
-
+
if (!lock_info->locks[i].pending || lock_info->locks[i].pending == -1)
return;
-
+
/* We only have further details for mutexes right now */
if (lock_info->locks[i].type != AST_MUTEX)
return;
-
+
lock = lock_info->locks[i].lock_addr;
lt = lock->track;
ast_reentrancy_lock(lt);
ast_str_append(str, 0, "=== --- ---> Locked Here: %s line %d (%s)\n",
lt->file[j], lt->lineno[j], lt->func[j]);
}
- ast_reentrancy_unlock(lt);
+ ast_reentrancy_unlock(lt);
}
-/*! This function can help you find highly temporal locks; locks that happen for a
+/*! This function can help you find highly temporal locks; locks that happen for a
short time, but at unexpected times, usually at times that create a deadlock,
Why is this thing locked right then? Who is locking it? Who am I fighting
- with for this lock?
+ with for this lock?
To answer such questions, just call this routine before you would normally try
to aquire a lock. It doesn't do anything if the lock is not acquired. If the
ast_log(LOG_NOTICE,"Could not create str\n");
return;
}
-
+
pthread_mutex_lock(&lock_infos_lock.mutex);
AST_LIST_TRAVERSE(&lock_infos, lock_info, entry) {
return NULL;
}
- ast_str_append(&str, 0, "\n"
+ ast_str_append(&str, 0, "\n"
"=======================================================================\n"
"=== Currently Held Locks ==============================================\n"
"=======================================================================\n"
if ((errno = pthread_attr_setdetachstate(attr, PTHREAD_CREATE_DETACHED)))
ast_log(LOG_WARNING, "pthread_attr_setdetachstate: %s\n", strerror(errno));
- res = ast_pthread_create_stack(thread, attr, start_routine, data,
+ res = ast_pthread_create_stack(thread, attr, start_routine, data,
stacksize, file, caller, line, start_fn);
if (attr_destroy)
* If the descriptor is blocking, all assumptions on the guaranteed
* detail do not apply anymore.
*/
-int ast_carefulwrite(int fd, char *s, int len, int timeoutms)
+int ast_carefulwrite(int fd, char *s, int len, int timeoutms)
{
struct timeval start = ast_tvnow();
int res = 0;
elapsed = ast_tvdiff_ms(ast_tvnow(), start);
if (elapsed >= timeoutms) {
- /* We've taken too long to write
+ /* We've taken too long to write
* This is only an error condition if we haven't finished writing. */
res = len ? -1 : 0;
break;
elapsed = ast_tvdiff_ms(ast_tvnow(), start);
if (elapsed >= timeoutms) {
- /* We've taken too long to write
+ /* We've taken too long to write
* This is only an error condition if we haven't finished writing. */
n = len ? -1 : 0;
break;
char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
{
- char *dataPut = start;
+ char *dataPut = start;
int inEscape = 0;
int inQuotes = 0;
void *allocation;
unsigned int x;
-#if defined(__AST_DEBUG_MALLOC)
+#if defined(__AST_DEBUG_MALLOC)
if (!(allocation = __ast_calloc(num_structs, size_to_alloc, file, lineno, func))) {
return NULL;
}
{
#if defined(HAVE_IP_MTU_DISCOVER)
int val = IP_PMTUDISC_DONT;
-
+
if (setsockopt(sock, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val)))
ast_log(LOG_WARNING, "Unable to disable PMTU discovery. Large UDP packets may fail to be delivered when sent from this socket.\n");
#endif /* HAVE_IP_MTU_DISCOVER */
}
}
if (duplicate || strchr(globbuf.gl_pathv[i], '*')) {
- /* skip duplicates as well as pathnames not found
+ /* skip duplicates as well as pathnames not found
* (due to use of GLOB_NOCHECK in xml_pathmatch) */
continue;
}