aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/alaw.c64
-rw-r--r--main/app.c22
-rw-r--r--main/astobj2.c22
-rw-r--r--main/callerid.c14
-rw-r--r--main/channel.c6
-rw-r--r--main/cli.c2
-rw-r--r--main/config.c22
-rw-r--r--main/cryptostub.c12
-rw-r--r--main/dial.c26
-rw-r--r--main/dlfcn.c306
-rw-r--r--main/dns.c6
-rw-r--r--main/dsp.c14
-rw-r--r--main/enum.c16
-rw-r--r--main/features.c43
-rw-r--r--main/file.c39
-rw-r--r--main/frame.c2
-rw-r--r--main/fskmodem.c75
-rw-r--r--main/image.c4
-rw-r--r--main/jitterbuf.c4
-rw-r--r--main/loader.c10
-rw-r--r--main/logger.c38
-rw-r--r--main/manager.c8
-rw-r--r--main/netsock.c2
-rw-r--r--main/pbx.c8
-rw-r--r--main/poll.c241
-rw-r--r--main/rtp.c10
-rw-r--r--main/say.c90
-rw-r--r--main/strcompat.c56
-rw-r--r--main/tdd.c20
-rw-r--r--main/term.c4
-rw-r--r--main/translate.c10
-rw-r--r--main/utils.c12
32 files changed, 547 insertions, 661 deletions
diff --git a/main/alaw.c b/main/alaw.c
index 8d3595206..367de0b77 100644
--- a/main/alaw.c
+++ b/main/alaw.c
@@ -34,31 +34,32 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static inline unsigned char linear2alaw(short int linear)
{
- int mask;
- int seg;
- int pcm_val;
- static int seg_end[8] =
+ int mask;
+ int seg;
+ int pcm_val;
+ static int seg_end[8] =
{
0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF
};
-
- pcm_val = linear;
- if (pcm_val >= 0) {
- /* Sign (7th) bit = 1 */
- mask = AMI_MASK | 0x80;
- } else {
- /* Sign bit = 0 */
- mask = AMI_MASK;
- pcm_val = -pcm_val;
- }
-
- /* Convert the scaled magnitude to segment number. */
- for (seg = 0; seg < 8; seg++) {
- if (pcm_val <= seg_end[seg])
- break;
- }
- /* Combine the sign, segment, and quantization bits. */
- return ((seg << 4) | ((pcm_val >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask;
+
+ pcm_val = linear;
+ if (pcm_val >= 0) {
+ /* Sign (7th) bit = 1 */
+ mask = AMI_MASK | 0x80;
+ } else {
+ /* Sign bit = 0 */
+ mask = AMI_MASK;
+ pcm_val = -pcm_val;
+ }
+
+ /* Convert the scaled magnitude to segment number. */
+ for (seg = 0; seg < 8; seg++) {
+ if (pcm_val <= seg_end[seg]) {
+ break;
+ }
+ }
+ /* Combine the sign, segment, and quantization bits. */
+ return ((seg << 4) | ((pcm_val >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask;
}
#else
static unsigned char linear2alaw(short sample, int full_coding)
@@ -107,15 +108,16 @@ static unsigned char linear2alaw(short sample, int full_coding)
#ifndef G711_NEW_ALGORITHM
static inline short int alaw2linear (unsigned char alaw)
{
- int i;
- int seg;
-
- alaw ^= AMI_MASK;
- i = ((alaw & 0x0F) << 4) + 8 /* rounding error */;
- seg = (((int) alaw & 0x70) >> 4);
- if (seg)
- i = (i + 0x100) << (seg - 1);
- return (short int) ((alaw & 0x80) ? i : -i);
+ int i;
+ int seg;
+
+ alaw ^= AMI_MASK;
+ i = ((alaw & 0x0F) << 4) + 8 /* rounding error */;
+ seg = (((int) alaw & 0x70) >> 4);
+ if (seg) {
+ i = (i + 0x100) << (seg - 1);
+ }
+ return (short int) ((alaw & 0x80) ? i : -i);
}
#else
static inline short alaw2linear(unsigned char alawbyte)
diff --git a/main/app.c b/main/app.c
index 6e09059e5..5c3f8a444 100644
--- a/main/app.c
+++ b/main/app.c
@@ -78,7 +78,7 @@ int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect,
if ((ts = ast_get_indication_tone(chan->zone, "dial")) && ts->data[0])
res = ast_playtones_start(chan, 0, ts->data, 0);
else
- ast_log(LOG_NOTICE,"Huh....? no dial for indications?\n");
+ ast_log(LOG_NOTICE, "Huh....? no dial for indications?\n");
for (x = strlen(collect); x < maxlen; ) {
res = ast_waitfordigit(chan, timeout);
@@ -118,7 +118,7 @@ int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxl
s[0] = '\0';
if (!prompt)
- prompt="";
+ prompt = "";
filename = ast_strdupa(prompt);
while ((front = strsep(&filename, "&"))) {
@@ -274,7 +274,7 @@ int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const ch
if ((res = ast_safe_sleep(chan, between)))
break;
} else
- ast_log(LOG_WARNING, "Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n",*ptr);
+ ast_log(LOG_WARNING, "Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n", *ptr);
}
if (peer) {
@@ -312,16 +312,16 @@ static int linear_generator(struct ast_channel *chan, void *data, int len, int s
short buf[2048 + AST_FRIENDLY_OFFSET / 2];
struct linear_state *ls = data;
struct ast_frame f = {
- .frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
- .data = buf + AST_FRIENDLY_OFFSET / 2,
+ .frametype = AST_FRAME_VOICE,
+ .subclass = AST_FORMAT_SLINEAR,
+ .data = buf + AST_FRIENDLY_OFFSET / 2,
.offset = AST_FRIENDLY_OFFSET,
- };
+ };
int res;
len = samples * 2;
if (len > sizeof(buf) - AST_FRIENDLY_OFFSET) {
- ast_log(LOG_WARNING, "Can't generate %d bytes of data!\n" ,len);
+ ast_log(LOG_WARNING, "Can't generate %d bytes of data!\n" , len);
len = sizeof(buf) - AST_FRIENDLY_OFFSET;
}
res = read(ls->fd, buf + AST_FRIENDLY_OFFSET/2, len);
@@ -430,7 +430,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
res = ast_answer(chan);
if (file) {
- if ((end = strchr(file,':'))) {
+ if ((end = strchr(file, ':'))) {
if (!strcasecmp(end, ":end")) {
*end = '\0';
end++;
@@ -974,7 +974,7 @@ int ast_app_group_discard(struct ast_channel *chan)
ast_free(gi);
}
}
- AST_RWLIST_TRAVERSE_SAFE_END;
+ AST_RWLIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&groups);
return 0;
@@ -1161,7 +1161,7 @@ static enum AST_LOCK_RESULT ast_lock_path_flock(const char *path)
time(&start);
while ((
#ifdef SOLARIS
- (res = fcntl(pl->fd, F_SETLK, fcntl(pl->fd,F_GETFL)|O_NONBLOCK)) < 0) &&
+ (res = fcntl(pl->fd, F_SETLK, fcntl(pl->fd, F_GETFL) | O_NONBLOCK)) < 0) &&
#else
(res = flock(pl->fd, LOCK_EX | LOCK_NB)) < 0) &&
#endif
diff --git a/main/astobj2.c b/main/astobj2.c
index 2d3611889..8c783955b 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -81,18 +81,18 @@ void ao2_bt(void) {}
void ao2_bt(void)
{
- int c, i;
+ int c, i;
#define N1 20
- void *addresses[N1];
- char **strings;
-
- c = backtrace(addresses, N1);
- strings = backtrace_symbols(addresses,c);
- ast_verbose("backtrace returned: %d\n", c);
- for(i = 0; i < c; i++) {
- ast_verbose("%d: %p %s\n", i, addresses[i], strings[i]);
- }
- free(strings);
+ void *addresses[N1];
+ char **strings;
+
+ c = backtrace(addresses, N1);
+ strings = backtrace_symbols(addresses,c);
+ ast_verbose("backtrace returned: %d\n", c);
+ for(i = 0; i < c; i++) {
+ ast_verbose("%d: %p %s\n", i, addresses[i], strings[i]);
+ }
+ free(strings);
}
#endif
diff --git a/main/callerid.c b/main/callerid.c
index c1d5e80b9..03e9c44f1 100644
--- a/main/callerid.c
+++ b/main/callerid.c
@@ -412,7 +412,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
/* length */
x++;
/* number type */
- switch (cid->rawdata[x]) {
+ switch (cid->rawdata[x]) {
case 0x00: /* unknown */
case 0x01: /* international number */
case 0x02: /* domestic number */
@@ -451,8 +451,8 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
case 'O': /* service not available */
case 'C': /* pay phone */
case 'S': /* service congested */
- cid->flags |= CID_UNKNOWN_NUMBER;
- ast_debug(2, "no cid reason:%c\n",cid->rawdata[x]);
+ cid->flags |= CID_UNKNOWN_NUMBER;
+ ast_debug(2, "no cid reason:%c\n", cid->rawdata[x]);
break ;
}
x++;
@@ -483,7 +483,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
x++;
/* numbering plan octed 4 */
x++;
- /* numbering plan octed 5 */
+ /* numbering plan octed 5 */
switch (cid->rawdata[x]) {
case 0x00: /* unknown */
case 0x01: /* recommendation E.164 ISDN */
@@ -772,7 +772,7 @@ static int callerid_genmsg(char *msg, int size, const char *number, const char *
int vmwi_generate(unsigned char *buf, int active, int mdmf, int codec)
{
unsigned char msg[256];
- int len=0;
+ int len = 0;
int sum;
int x;
int bytes = 0;
@@ -834,7 +834,7 @@ int vmwi_generate(unsigned char *buf, int active, int mdmf, int codec)
int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, int codec)
{
- int bytes=0;
+ int bytes = 0;
int x, sum;
int len;
@@ -881,7 +881,7 @@ int callerid_generate(unsigned char *buf, const char *number, const char *name,
*/
void ast_shrink_phone_number(char *n)
{
- int x, y=0;
+ int x, y = 0;
int bracketed = 0;
for (x = 0; n[x]; x++) {
diff --git a/main/channel.c b/main/channel.c
index 5742341c4..ecb12ac57 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -124,7 +124,7 @@ struct ast_chan_trace {
static AST_LIST_HEAD_NOLOCK_STATIC(backends, chanlist);
/*! \brief the list of channels we have. Note that the lock for this list is used for
- both the channels list and the backends list. */
+ both the channels list and the backends list. */
static AST_RWLIST_HEAD_STATIC(channels, ast_channel);
/*! \brief map AST_CAUSE's to readable string representations
@@ -3400,8 +3400,8 @@ int ast_call(struct ast_channel *chan, char *addr, int timeout)
\brief Transfer a call to dest, if the channel supports transfer
Called by:
- \arg app_transfer
- \arg the manager interface
+ \arg app_transfer
+ \arg the manager interface
*/
int ast_transfer(struct ast_channel *chan, char *dest)
{
diff --git a/main/cli.c b/main/cli.c
index 806542102..07ad7bcc6 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -509,7 +509,7 @@ static char * handle_showuptime(struct ast_cli_entry *e, int cmd, struct ast_cli
int printsec;
switch (cmd) {
- case CLI_INIT:
+ case CLI_INIT:
e->command = "core show uptime [seconds]";
e->usage =
"Usage: core show uptime [seconds]\n"
diff --git a/main/config.c b/main/config.c
index 055b63adb..bb469e12b 100644
--- a/main/config.c
+++ b/main/config.c
@@ -150,7 +150,7 @@ static int hash_string(const void *obj, const int flags)
total += tmp; /* multiply by 3 */
total <<= 2; /* multiply by 12 */
total += tmp; /* multiply by 13 */
-
+
total += ((unsigned int)(*str));
}
if (total < 0)
@@ -242,9 +242,9 @@ struct ast_variable *ast_variable_new(const char *name, const char *value, const
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
- instances is possible, I'd have
- to create a new master for each instance. */
+ * 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;
@@ -290,13 +290,13 @@ void ast_include_rename(struct ast_config *conf, const char *from_file, const ch
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
- the config file to disk, better riffle thru the data and make sure
- the file names are changed.
- */
+ * 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
+ * the config file to disk, better riffle thru the data and make sure
+ * the file names are changed.
+ */
/* file names are on categories, includes (of course), and on variables. So,
- traverse all this and swap names */
+ * traverse all this and swap names */
for (incl = conf->includes; incl; incl=incl->next) {
if (strcmp(incl->include_location_file,from_file) == 0) {
@@ -2154,7 +2154,7 @@ int ast_destroy_realtime(const char *family, const char *keyfield, const char *l
* See documentation in config.h
*/
int ast_parse_arg(const char *arg, enum ast_parse_flags flags,
- void *p_result, ...)
+ void *p_result, ...)
{
va_list ap;
int error = 0;
diff --git a/main/cryptostub.c b/main/cryptostub.c
index c3b59c7b3..ffdaa6635 100644
--- a/main/cryptostub.c
+++ b/main/cryptostub.c
@@ -39,22 +39,22 @@ static struct ast_key *stub_ast_key_get(const char *kname, int ktype)
#define build_stub(func_name,...) \
static int stub_ ## func_name(__VA_ARGS__) \
{ \
- ast_log(LOG_NOTICE, "Crypto support not loaded!\n"); \
- return -1; \
+ ast_log(LOG_NOTICE, "Crypto support not loaded!\n"); \
+ return -1; \
} \
\
int (*func_name)(__VA_ARGS__) = \
- stub_ ## func_name;
+ stub_ ## func_name;
#endif
#define build_stub(func_name,...) \
static int stub_##func_name(__VA_ARGS__) \
{ \
- ast_log(LOG_NOTICE, "Crypto support not loaded!\n"); \
- return -1; \
+ ast_log(LOG_NOTICE, "Crypto support not loaded!\n"); \
+ return -1; \
} \
\
int (*func_name)(__VA_ARGS__) = \
- stub_##func_name;
+ stub_##func_name;
struct ast_key *(*ast_key_get)(const char *key, int type) =
stub_ast_key_get;
diff --git a/main/dial.c b/main/dial.c
index b7dcec2ef..22472a89e 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -174,12 +174,13 @@ static const struct ast_option_types {
};
/*! \brief free the buffer if allocated, and set the pointer to the second arg */
-#define S_REPLACE(s, new_val) \
- do { \
- if (s) \
- free(s); \
- s = (new_val); \
- } while (0)
+#define S_REPLACE(s, new_val) \
+ do { \
+ if (s) { \
+ free(s); \
+ } \
+ s = (new_val); \
+ } while (0)
/*! \brief Maximum number of channels we can watch at a time */
#define AST_MAX_WATCHERS 256
@@ -871,7 +872,7 @@ int ast_dial_destroy(struct ast_dial *dial)
}
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])
@@ -954,7 +955,7 @@ int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option
if (channel->options[option])
return -1;
- /* Execute enable callback if it exists, if not simply make sure the value is set */
+ /* Execute enable callback if it exists, if not simply make sure the value is set */
if (option_types[option].enable)
channel->options[option] = option_types[option].enable(data);
else
@@ -970,9 +971,10 @@ int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option
*/
int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option)
{
- /* If the option is not enabled, return failure */
- if (!dial->options[option])
- return -1;
+ /* If the option is not enabled, return failure */
+ if (!dial->options[option]) {
+ return -1;
+ }
/* Execute callback of option to disable if it exists */
if (option_types[option].disable)
@@ -981,7 +983,7 @@ int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option o
/* Finally disable option on the structure */
dial->options[option] = NULL;
- return 0;
+ return 0;
}
/*! \brief Disables an option per channel
diff --git a/main/dlfcn.c b/main/dlfcn.c
index 802e7942f..4c3a1a99b 100644
--- a/main/dlfcn.c
+++ b/main/dlfcn.c
@@ -1,7 +1,7 @@
/*
Copyright (c) 2002 Jorge Acereda <jacereda@users.sourceforge.net> &
Peter O'Gorman <ogorman@users.sourceforge.net>
-
+
Portions may be copyright others, see the AUTHORS file included with this
distribution.
@@ -544,10 +544,9 @@ static inline const char *dyld_error_str()
const char *dyldfile;
const char* retStr = NULL;
NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr);
- if (dylderrstr && strlen(dylderrstr))
- {
- retStr = ast_malloc(strlen(dylderrstr) +1);
- strcpy((char*)retStr,dylderrstr);
+ if (dylderrstr && strlen(dylderrstr)) {
+ retStr = ast_malloc(strlen(dylderrstr) + 1);
+ strcpy((char*)retStr, dylderrstr);
}
return retStr;
}
@@ -564,51 +563,41 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
#endif
if (NULL == dls)
dls = RTLD_SELF;
- if ((RTLD_NEXT == dls) || (RTLD_SELF == dls))
- {
- if (dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage)
- {
+ if ((RTLD_NEXT == dls) || (RTLD_SELF == dls)) {
+ if (dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage) {
caller_mh = image_for_address(caller);
- if (RTLD_SELF == dls)
- {
+ if (RTLD_SELF == dls) {
/* FIXME: We should be using the NSModule api, if SELF is an MH_BUNDLE
* But it appears to work anyway, and looking at the code in dyld_libfuncs.c
* this is acceptable.
*/
- if (dyld_NSIsSymbolNameDefinedInImage(caller_mh, symbol))
- {
+ if (dyld_NSIsSymbolNameDefinedInImage(caller_mh, symbol)) {
nssym = dyld_NSLookupSymbolInImage(caller_mh,
symbol,
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
}
}
- if (!nssym)
- {
+ if (!nssym) {
if (RTLD_SELF == dls)
savedErrorStr = dyld_error_str();
nssym = search_linked_libs(caller_mh, symbol);
}
- }
- else
- {
+ } else {
if (canSetError)
error("RTLD_SELF and RTLD_NEXT are not supported");
return NULL;
}
}
- if (!nssym)
- {
+ if (!nssym) {
- if (RTLD_DEFAULT == dls)
- {
+ if (RTLD_DEFAULT == dls) {
dls = &mainStatus;
}
if (!isValidStatus(dls))
return NULL;
- if (dls->module != MAGIC_DYLIB_MOD)
- {
+ if (dls->module != MAGIC_DYLIB_MOD) {
nssym = NSLookupSymbolInModule(dls->module, symbol);
if (!nssym && NSIsSymbolNameDefined(symbol))
{
@@ -616,58 +605,43 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
savedErrorStr = dyld_error_str();
nssym = search_linked_libs(get_mach_header_from_NSModule(dls->module), symbol);
}
- }
- else if (dls->lib && dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage)
- {
- if (dyld_NSIsSymbolNameDefinedInImage(dls->lib, symbol))
- {
+ } else if (dls->lib && dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage) {
+ if (dyld_NSIsSymbolNameDefinedInImage(dls->lib, symbol)) {
nssym = dyld_NSLookupSymbolInImage(dls->lib,
symbol,
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
- }
- else if (NSIsSymbolNameDefined(symbol))
- {
+ } else if (NSIsSymbolNameDefined(symbol)) {
debug("Searching dependencies");
savedErrorStr = dyld_error_str();
nssym = search_linked_libs(dls->lib, symbol);
}
- }
- else if (dls->module == MAGIC_DYLIB_MOD)
- {
+ } else if (dls->module == MAGIC_DYLIB_MOD) {
/* Global context, use NSLookupAndBindSymbol */
- if (NSIsSymbolNameDefined(symbol))
- {
+ if (NSIsSymbolNameDefined(symbol)) {
/* There doesn't seem to be a return on error option for this call???
this is potentially broken, if binding fails, it will improperly
exit the application. */
nssym = NSLookupAndBindSymbol(symbol);
- }
- else
- {
+ } else {
if (savedErrorStr)
ast_free(savedErrorStr);
savedErrorStr = ast_malloc(256);
- snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol);
+ snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context", symbol);
}
}
}
/* Error reporting */
- if (!nssym)
- {
- if (!savedErrorStr || !strlen(savedErrorStr))
- {
+ if (!nssym) {
+ if (!savedErrorStr || !strlen(savedErrorStr)) {
if (savedErrorStr)
ast_free(savedErrorStr);
savedErrorStr = ast_malloc(256);
- snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol);
+ snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not found", symbol);
}
- if (canSetError)
- {
+ if (canSetError) {
error(savedErrorStr);
- }
- else
- {
+ } else {
debug(savedErrorStr);
}
if (savedErrorStr)
@@ -688,57 +662,48 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
const char *file;
void (*init) (void);
ofirc = NSCreateObjectFileImageFromFile(path, &ofi);
- switch (ofirc)
- {
- case NSObjectFileImageSuccess:
- break;
- case NSObjectFileImageInappropriateFile:
- if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage)
- {
- if (!isFlagSet(mode, RTLD_GLOBAL))
- {
- warning("trying to open a .dylib with RTLD_LOCAL");
- error("unable to open this file with RTLD_LOCAL");
- return NULL;
- }
- }
- else
- {
- error("opening this file is unsupported on this system");
+ switch (ofirc) {
+ case NSObjectFileImageSuccess:
+ break;
+ case NSObjectFileImageInappropriateFile:
+ if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage) {
+ if (!isFlagSet(mode, RTLD_GLOBAL)) {
+ warning("trying to open a .dylib with RTLD_LOCAL");
+ error("unable to open this file with RTLD_LOCAL");
return NULL;
}
- break;
- case NSObjectFileImageFailure:
- error("object file setup failure");
- return NULL;
- case NSObjectFileImageArch:
- error("no object for this architecture");
- return NULL;
- case NSObjectFileImageFormat:
- error("bad object file format");
- return NULL;
- case NSObjectFileImageAccess:
- error("can't read object file");
- return NULL;
- default:
- error("unknown error from NSCreateObjectFileImageFromFile()");
+ } else {
+ error("opening this file is unsupported on this system");
return NULL;
+ }
+ break;
+ case NSObjectFileImageFailure:
+ error("object file setup failure");
+ return NULL;
+ case NSObjectFileImageArch:
+ error("no object for this architecture");
+ return NULL;
+ case NSObjectFileImageFormat:
+ error("bad object file format");
+ return NULL;
+ case NSObjectFileImageAccess:
+ error("can't read object file");
+ return NULL;
+ default:
+ error("unknown error from NSCreateObjectFileImageFromFile()");
+ return NULL;
}
dls = lookupStatus(sbuf);
- if (!dls)
- {
+ if (!dls) {
dls = allocStatus();
}
- if (!dls)
- {
+ if (!dls) {
error("unable to allocate memory");
return NULL;
}
dls->lib = 0;
- if (ofirc == NSObjectFileImageInappropriateFile)
- {
- if ((dls->lib = dyld_NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR)))
- {
+ if (ofirc == NSObjectFileImageInappropriateFile) {
+ if ((dls->lib = dyld_NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR))) {
debug("Dynamic lib loaded at %ld", dls->lib);
ofi = MAGIC_DYLIB_OFI;
dls->module = MAGIC_DYLIB_MOD;
@@ -746,8 +711,7 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
/* Although it is possible with a bit of work to modify this so it works and
functions with RTLD_NOW, I don't deem it necessary at the moment */
}
- if (!(dls->module))
- {
+ if (!(dls->module)) {
NSLinkEditError(&ler, &lerno, &file, &errstr);
if (!errstr || (!strlen(errstr)))
error("Can't open this file type");
@@ -759,24 +723,19 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
}
return NULL;
}
- }
- else
- {
+ } else {
dls->module = NSLinkModule(ofi, path,
NSLINKMODULE_OPTION_RETURN_ON_ERROR |
NSLINKMODULE_OPTION_PRIVATE |
(isFlagSet(mode, RTLD_NOW) ? NSLINKMODULE_OPTION_BINDNOW : 0));
NSDestroyObjectFileImage(ofi);
- if (dls->module)
- {
+ if (dls->module) {
dls->lib = get_mach_header_from_NSModule(dls->module);
}
}
- if (!dls->module)
- {
+ if (!dls->module) {
NSLinkEditError(&ler, &lerno, &file, &errstr);
- if ((dls->flags & DL_IN_LIST) == 0)
- {
+ if ((dls->flags & DL_IN_LIST) == 0) {
ast_free(dls);
}
error(errstr);
@@ -785,8 +744,7 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
insertStatus(dls, sbuf);
dls = reference(dls, mode);
- if ((init = dlsymIntern(dls, "__init", 0)))
- {
+ if ((init = dlsymIntern(dls, "__init", 0))) {
debug("calling _init()");
init();
}
@@ -796,8 +754,7 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
static void dlcompat_init_func(void)
{
static int inited = 0;
- if (!inited)
- {
+ if (!inited) {
inited = 1;
_dyld_func_lookup("__dyld_NSAddImage", (unsigned long *)&dyld_NSAddImage);
_dyld_func_lookup("__dyld_NSIsSymbolNameDefinedInImage",
@@ -830,8 +787,7 @@ static void dlcompat_cleanup(void)
pthread_mutex_destroy(&dlcompat_mutex);
pthread_key_delete(dlerror_key);
next = stqueue;
- while (next && (next != &mainStatus))
- {
+ while (next && (next != &mainStatus)) {
dls = next;
next = dls->next;
ast_free(dls);
@@ -859,20 +815,18 @@ static inline void dolock(void)
int err = 0;
struct dlthread *tss;
tss = pthread_getspecific(dlerror_key);
- if (!tss)
- {
+ if (!tss) {
tss = ast_malloc(sizeof(*tss));
tss->lockcnt = 0;
tss->errset = 0;
- if (pthread_setspecific(dlerror_key, tss))
- {
- fprintf(stderr,"dlcompat: pthread_setspecific failed\n");
+ if (pthread_setspecific(dlerror_key, tss)) {
+ fprintf(stderr, "dlcompat: pthread_setspecific failed\n");
exit(1);
}
}
if (!tss->lockcnt)
err = pthread_mutex_lock(&dlcompat_mutex);
- tss->lockcnt = tss->lockcnt +1;
+ tss->lockcnt = tss->lockcnt + 1;
if (err)
exit(err);
}
@@ -897,41 +851,36 @@ void *dlopen(const char *path, int mode)
dlcompat_init_func(); /* Just in case */
dolock();
resetdlerror();
- if (!path)
- {
+ if (!path) {
dls = &mainStatus;
goto dlopenok;
}
- if (!(sbuf = findFile(path, &fullPath)))
- {
+ if (!(sbuf = findFile(path, &fullPath))) {
error("file \"%s\" not found", path);
goto dlopenerror;
}
/* Now checks that it hasn't been closed already */
- if ((dls = lookupStatus(sbuf)) && (dls->refs > 0))
- {
+ if ((dls = lookupStatus(sbuf)) && (dls->refs > 0)) {
/* debug("status found"); */
dls = reference(dls, mode);
goto dlopenok;
}
#ifdef RTLD_NOLOAD
- if (isFlagSet(mode, RTLD_NOLOAD))
- {
+ if (isFlagSet(mode, RTLD_NOLOAD)) {
error("no existing handle and RTLD_NOLOAD specified");
goto dlopenerror;
}
#endif
- if (isFlagSet(mode, RTLD_LAZY) && isFlagSet(mode, RTLD_NOW))
- {
+ if (isFlagSet(mode, RTLD_LAZY) && isFlagSet(mode, RTLD_NOW)) {
error("how can I load something both RTLD_LAZY and RTLD_NOW?");
goto dlopenerror;
}
dls = loadModule(fullPath, sbuf, mode);
- dlopenok:
+dlopenok:
dounlock();
return (void *)dls;
- dlopenerror:
+dlopenerror:
dounlock();
return NULL;
}
@@ -944,20 +893,17 @@ void *dlsym(void * dl_restrict handle, const char * dl_restrict symbol)
char *malloc_sym = NULL;
dolock();
malloc_sym = ast_malloc(sym_len + 2);
- if (malloc_sym)
- {
+ if (malloc_sym) {
sprintf(malloc_sym, "_%s", symbol);
value = dlsymIntern(handle, malloc_sym, 1);
ast_free(malloc_sym);
- }
- else
- {
+ } else {
error("Unable to allocate memory");
goto dlsymerror;
}
dounlock();
return value;
- dlsymerror:
+dlsymerror:
dounlock();
return NULL;
}
@@ -989,14 +935,11 @@ static void *dlsym_prepend_underscore_intern(void *handle, const char *symbol)
void *value = NULL;
char *malloc_sym = NULL;
malloc_sym = ast_malloc(sym_len + 2);
- if (malloc_sym)
- {
+ if (malloc_sym) {
sprintf(malloc_sym, "_%s", symbol);
value = dlsymIntern(handle, malloc_sym, 1);
ast_free(malloc_sym);
- }
- else
- {
+ } else {
error("Unable to allocate memory");
}
return value;
@@ -1038,37 +981,29 @@ int dlclose(void *handle)
struct dlstatus *dls = handle;
dolock();
resetdlerror();
- if (!isValidStatus(dls))
- {
+ if (!isValidStatus(dls)) {
goto dlcloseerror;
}
- if (dls->module == MAGIC_DYLIB_MOD)
- {
+ if (dls->module == MAGIC_DYLIB_MOD) {
const char *name;
- if (!dls->lib)
- {
+ if (!dls->lib) {
name = "global context";
- }
- else
- {
+ } else {
name = get_lib_name(dls->lib);
}
warning("trying to close a .dylib!");
error("Not closing \"%s\" - dynamic libraries cannot be closed", name);
goto dlcloseerror;
}
- if (!dls->module)
- {
+ if (!dls->module) {
error("module already closed");
goto dlcloseerror;
}
- if (dls->refs == 1)
- {
+ if (dls->refs == 1) {
unsigned long options = 0;
void (*fini) (void);
- if ((fini = dlsymIntern(dls, "__fini", 0)))
- {
+ if ((fini = dlsymIntern(dls, "__fini", 0))) {
debug("calling _fini()");
fini();
}
@@ -1083,8 +1018,7 @@ int dlclose(void *handle)
*/
if ((const struct section *)NULL !=
getsectbynamefromheader(get_mach_header_from_NSModule(dls->module),
- "__DATA", "__mod_term_func"))
- {
+ "__DATA", "__mod_term_func")) {
options |= NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED;
}
#endif
@@ -1092,8 +1026,7 @@ int dlclose(void *handle)
if (isFlagSet(dls->mode, RTLD_NODELETE))
options |= NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED;
#endif
- if (!NSUnLinkModule(dls->module, options))
- {
+ if (!NSUnLinkModule(dls->module, options)) {
error("unable to unlink module");
goto dlcloseerror;
}
@@ -1106,7 +1039,7 @@ int dlclose(void *handle)
}
dounlock();
return 0;
- dlcloseerror:
+dlcloseerror:
dounlock();
return 1;
}
@@ -1135,27 +1068,23 @@ const struct mach_header *image_for_address(const void *address)
struct mach_header *mh = 0;
struct load_command *lc = 0;
unsigned long addr = NULL;
- for (i = 0; i < count; i++)
- {
+ for (i = 0; i < count; i++) {
addr = (unsigned long)address - _dyld_get_image_vmaddr_slide(i);
mh = _dyld_get_image_header(i);
- if (mh)
- {
+ if (mh) {
lc = (struct load_command *)((char *)mh + sizeof(struct mach_header));
- for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *)((char *)lc + lc->cmdsize))
- {
+ for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *)((char *)lc + lc->cmdsize)) {
if (LC_SEGMENT == lc->cmd &&
addr >= ((struct segment_command *)lc)->vmaddr &&
addr <
- ((struct segment_command *)lc)->vmaddr + ((struct segment_command *)lc)->vmsize)
- {
+ ((struct segment_command *)lc)->vmaddr + ((struct segment_command *)lc)->vmsize) {
goto image_found;
}
}
}
mh = 0;
}
- image_found:
+image_found:
return mh;
}
@@ -1183,20 +1112,16 @@ int dladdr(const void * dl_restrict p, Dl_info * dl_restrict info)
/* Some of this was swiped from code posted by Douglas Davidson <ddavidso AT apple DOT com>
* to darwin-development AT lists DOT apple DOT com and slightly modified
*/
- for (i = 0; i < count; i++)
- {
+ for (i = 0; i < count; i++) {
addr = (unsigned long)p - _dyld_get_image_vmaddr_slide(i);
mh = _dyld_get_image_header(i);
- if (mh)
- {
+ if (mh) {
lc = (struct load_command *)((char *)mh + sizeof(struct mach_header));
- for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *)((char *)lc + lc->cmdsize))
- {
+ for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *)((char *)lc + lc->cmdsize)) {
if (LC_SEGMENT == lc->cmd &&
addr >= ((struct segment_command *)lc)->vmaddr &&
addr <
- ((struct segment_command *)lc)->vmaddr + ((struct segment_command *)lc)->vmsize)
- {
+ ((struct segment_command *)lc)->vmaddr + ((struct segment_command *)lc)->vmsize) {
info->dli_fname = _dyld_get_image_name(i);
info->dli_fbase = (void *)mh;
found = 1;
@@ -1207,16 +1132,13 @@ int dladdr(const void * dl_restrict p, Dl_info * dl_restrict info)
break;
}
}
- if (!found)
- {
+ if (!found) {
dounlock();
return 0;
}
lc = (struct load_command *)((char *)mh + sizeof(struct mach_header));
- for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *)((char *)lc + lc->cmdsize))
- {
- if (LC_SEGMENT == lc->cmd)
- {
+ for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *)((char *)lc + lc->cmdsize)) {
+ if (LC_SEGMENT == lc->cmd) {
if (!strcmp(((struct segment_command *)lc)->segname, "__LINKEDIT"))
break;
}
@@ -1227,10 +1149,8 @@ int dladdr(const void * dl_restrict p, Dl_info * dl_restrict info)
debug("table off %x", table_off);
lc = (struct load_command *)((char *)mh + sizeof(struct mach_header));
- for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *)((char *)lc + lc->cmdsize))
- {
- if (LC_SYMTAB == lc->cmd)
- {
+ for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *)((char *)lc + lc->cmdsize)) {
+ if (LC_SYMTAB == lc->cmd) {
struct nlist *symtable = (struct nlist *)(((struct symtab_command *)lc)->symoff + table_off);
unsigned long numsyms = ((struct symtab_command *)lc)->nsyms;
@@ -1238,26 +1158,22 @@ int dladdr(const void * dl_restrict p, Dl_info * dl_restrict info)
unsigned long diff = 0xffffffff;
unsigned long strtable = (unsigned long)(((struct symtab_command *)lc)->stroff + table_off);
debug("symtable %x", symtable);
- for (i = 0; i < numsyms; i++)
- {
+ for (i = 0; i < numsyms; i++) {
/* Ignore the following kinds of Symbols */
- if ((!symtable->n_value) /* Undefined */
- || (symtable->n_type >= N_PEXT) /* Debug symbol */
- || (!(symtable->n_type & N_EXT)) /* Local Symbol */
- )
- {
+ if ((!symtable->n_value) /* Undefined */
+ || (symtable->n_type >= N_PEXT) /* Debug symbol */
+ || (!(symtable->n_type & N_EXT)) /* Local Symbol */
+ ) {
symtable++;
continue;
}
- if ((addr >= symtable->n_value) && (diff >= (symtable->n_value - addr)))
- {
+ if ((addr >= symtable->n_value) && (diff >= (symtable->n_value - addr))) {
diff = (unsigned long)symtable->n_value - addr;
nearest = symtable;
}
symtable++;
}
- if (nearest)
- {
+ if (nearest) {
info->dli_saddr = nearest->n_value + ((void *)p - addr);
info->dli_sname = (char *)(strtable + nearest->n_un.n_strx);
}
diff --git a/main/dns.c b/main/dns.c
index 34212fdf1..f6dc407dd 100644
--- a/main/dns.c
+++ b/main/dns.c
@@ -274,12 +274,10 @@ int ast_search_dns(void *context,
if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) {
ast_log(LOG_WARNING, "DNS Parse error for %s\n", dname);
ret = -1;
- }
- else if (res == 0) {
+ } else if (res == 0) {
ast_debug(1, "No matches found in DNS for %s\n", dname);
ret = 0;
- }
- else
+ } else
ret = 1;
}
#ifdef HAVE_RES_NINIT
diff --git a/main/dsp.c b/main/dsp.c
index 070eb2a18..6945464d4 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -30,14 +30,14 @@
/* Some routines from tone_detect.c by Steven Underwood as published under the zapata library */
/*
tone_detect.c - General telephony tone detection, and specific
- detection of DTMF.
+ detection of DTMF.
- Copyright (C) 2001 Steve Underwood <steveu@coppice.org>
+ Copyright (C) 2001 Steve Underwood <steveu@coppice.org>
- Despite my general liking of the GPL, I place this code in the
- public domain for the benefit of all mankind - even the slimy
- ones who might try to proprietize my work and use it to my
- detriment.
+ Despite my general liking of the GPL, I place this code in the
+ public domain for the benefit of all mankind - even the slimy
+ ones who might try to proprietize my work and use it to my
+ detriment.
*/
#include "asterisk.h"
@@ -676,7 +676,7 @@ static int dtmf_detect(digit_detect_state_t *s, int16_t amp[], int samples,
#define MF_GSIZE 120
static int mf_detect(digit_detect_state_t *s, int16_t amp[],
- int samples, int digitmode, int *writeback)
+ int samples, int digitmode, int *writeback)
{
float energy[6];
int best;
diff --git a/main/enum.c b/main/enum.c
index b54580263..3f4266ac3 100644
--- a/main/enum.c
+++ b/main/enum.c
@@ -207,22 +207,22 @@ static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, unsigne
delim = regexp[0];
delim2 = strchr(regexp + 1, delim);
- if ((delim2 == NULL) || (regexp[regexp_len-1] != delim)) {
- ast_log(LOG_WARNING, "Regex delimiter error (on \"%s\").\n",regexp);
+ if ((delim2 == NULL) || (regexp[regexp_len - 1] != delim)) {
+ ast_log(LOG_WARNING, "Regex delimiter error (on \"%s\").\n", regexp);
return -1;
}
pattern = regexp + 1;
*delim2 = 0;
subst = delim2 + 1;
- regexp[regexp_len-1] = 0;
+ regexp[regexp_len - 1] = 0;
/*
* now do the regex wizardry.
*/
if (regcomp(&preg, pattern, REG_EXTENDED | REG_NEWLINE)) {
- ast_log(LOG_WARNING, "NAPTR Regex compilation error (regex = \"%s\").\n",regexp);
+ ast_log(LOG_WARNING, "NAPTR Regex compilation error (regex = \"%s\").\n", regexp);
return -1;
}
@@ -314,7 +314,7 @@ static int txt_callback(void *context, unsigned char *answer, int len, unsigned
ast_copy_string(c->txt, (const char *) answer, len < c->txtlen ? len : (c->txtlen));
/* just to be safe, let's make sure c->txt is null terminated */
- c->txt[(c->txtlen)-1] = '\0';
+ c->txt[(c->txtlen) - 1] = '\0';
return 1;
}
@@ -377,7 +377,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
if (!(context = ast_calloc(1, sizeof(*context))))
return -1;
- ast_copy_string(naptrinput, number[0] == 'n' ? number+1 : number, sizeof(naptrinput));
+ ast_copy_string(naptrinput, number[0] == 'n' ? number + 1 : number, sizeof(naptrinput));
context->naptrinput = naptrinput; /* The number */
context->dst = dst; /* Return string */
@@ -411,7 +411,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
}
if (p1 != NULL) {
- p2 = p1+1;
+ p2 = p1 + 1;
while (p1 > number){
p1--;
tmp[newpos++] = *p1;
@@ -501,7 +501,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
}
}
for (k = 0; k < context->naptr_rrs_count; k++) {
- if (context->naptr_rrs[k].sort_pos == context->position-1) {
+ if (context->naptr_rrs[k].sort_pos == context->position - 1) {
ast_copy_string(context->dst, context->naptr_rrs[k].result, dstlen);
ast_copy_string(context->tech, context->naptr_rrs[k].tech, techlen);
break;
diff --git a/main/features.c b/main/features.c
index 69aae8ca6..d26ac5b91 100644
--- a/main/features.c
+++ b/main/features.c
@@ -599,7 +599,7 @@ static void set_peers(struct ast_channel **caller, struct ast_channel **callee,
static int builtin_parkcall(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense, void *data)
{
struct ast_channel *parker;
- struct ast_channel *parkee;
+ struct ast_channel *parkee;
int res = 0;
set_peers(&parker, &parkee, peer, chan, sense);
@@ -842,9 +842,9 @@ static int builtin_disconnect(struct ast_channel *chan, struct ast_channel *peer
static int finishup(struct ast_channel *chan)
{
- ast_indicate(chan, AST_CONTROL_UNHOLD);
-
- return ast_autoservice_stop(chan);
+ ast_indicate(chan, AST_CONTROL_UNHOLD);
+
+ return ast_autoservice_stop(chan);
}
/*!
@@ -857,14 +857,17 @@ static int finishup(struct ast_channel *chan)
*/
static const char *real_ctx(struct ast_channel *transferer, struct ast_channel *transferee)
{
- const char *s = pbx_builtin_getvar_helper(transferer, "TRANSFER_CONTEXT");
- if (ast_strlen_zero(s))
- s = pbx_builtin_getvar_helper(transferee, "TRANSFER_CONTEXT");
- if (ast_strlen_zero(s)) /* Use the non-macro context to transfer the call XXX ? */
- s = transferer->macrocontext;
- if (ast_strlen_zero(s))
- s = transferer->context;
- return s;
+ const char *s = pbx_builtin_getvar_helper(transferer, "TRANSFER_CONTEXT");
+ if (ast_strlen_zero(s)) {
+ s = pbx_builtin_getvar_helper(transferee, "TRANSFER_CONTEXT");
+ }
+ if (ast_strlen_zero(s)) { /* Use the non-macro context to transfer the call XXX ? */
+ s = transferer->macrocontext;
+ }
+ if (ast_strlen_zero(s)) {
+ s = transferer->context;
+ }
+ return s;
}
/*!
@@ -1019,7 +1022,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
ast_debug(1, "Executing Attended Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense);
set_peers(&transferer, &transferee, peer, chan, sense);
- transferer_real_context = real_ctx(transferer, transferee);
+ transferer_real_context = real_ctx(transferer, transferee);
/* Start autoservice on chan while we talk to the originator */
ast_autoservice_start(transferee);
ast_indicate(transferee, AST_CONTROL_HOLD);
@@ -1035,10 +1038,10 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
/* this is specific of atxfer */
res = ast_app_dtget(transferer, transferer_real_context, xferto, sizeof(xferto), 100, transferdigittimeout);
- if (res < 0) { /* hangup, would be 0 for invalid and 1 for valid */
- finishup(transferee);
- return res;
- }
+ if (res < 0) { /* hangup, would be 0 for invalid and 1 for valid */
+ finishup(transferee);
+ return res;
+ }
if (res == 0) {
ast_log(LOG_WARNING, "Did not read data.\n");
finishup(transferee);
@@ -2473,7 +2476,7 @@ static int park_exec(struct ast_channel *chan, void *data)
if (res < 0)
error = 1;
}
- }
+ }
if (error) {
ast_log(LOG_WARNING, "Failed to play courtesy tone!\n");
ast_hangup(peer);
@@ -2857,7 +2860,7 @@ static char *handle_feature_show(struct ast_cli_entry *e, int cmd, struct ast_cl
return NULL;
case CLI_GENERATE:
return NULL;
- }
+ }
ast_cli(a->fd, format, "Builtin Feature", "Default", "Current");
ast_cli(a->fd, format, "---------------", "-------", "-------");
@@ -2908,7 +2911,7 @@ static char *handle_features_reload(struct ast_cli_entry *e, int cmd, struct ast
return NULL;
case CLI_GENERATE:
return NULL;
- }
+ }
load_config();
return CLI_SUCCESS;
diff --git a/main/file.c b/main/file.c
index 7968148a1..c16f25112 100644
--- a/main/file.c
+++ b/main/file.c
@@ -81,7 +81,7 @@ int __ast_format_register(const struct ast_format *f, struct ast_module *mod)
*/
struct _test_align { void *a, *b; } p;
int align = (char *)&p.b - (char *)&p.a;
- tmp->buf_size = ((f->buf_size + align - 1)/align)*align;
+ tmp->buf_size = ((f->buf_size + align - 1) / align) * align;
}
memset(&tmp->list, 0, sizeof(tmp->list));
@@ -283,9 +283,9 @@ static struct ast_filestream *get_filestream(struct ast_format *fmt, FILE *bfile
s->f = bfile;
if (fmt->desc_size)
- s->_private = ((char *)(s+1)) + fmt->buf_size;
+ s->_private = ((char *)(s + 1)) + fmt->buf_size;
if (fmt->buf_size)
- s->buf = (char *)(s+1);
+ s->buf = (char *)(s + 1);
s->fr.src = fmt->name;
return s;
}
@@ -302,22 +302,22 @@ static int fn_wrapper(struct ast_filestream *s, const char *comment, enum wrap_f
int ret = -1;
if (mode == WRAP_OPEN && f->open && f->open(s))
- ast_log(LOG_WARNING, "Unable to open format %s\n", f->name);
+ ast_log(LOG_WARNING, "Unable to open format %s\n", f->name);
else if (mode == WRAP_REWRITE && f->rewrite && f->rewrite(s, comment))
- ast_log(LOG_WARNING, "Unable to rewrite format %s\n", f->name);
+ ast_log(LOG_WARNING, "Unable to rewrite format %s\n", f->name);
else {
/* preliminary checks succeed. update usecount */
ast_module_ref(f->module);
ret = 0;
}
- return ret;
+ return ret;
}
static int rewrite_wrapper(struct ast_filestream *s, const char *comment)
{
return fn_wrapper(s, comment, WRAP_REWRITE);
}
-
+
static int open_wrapper(struct ast_filestream *s)
{
return fn_wrapper(s, NULL, WRAP_OPEN);
@@ -639,7 +639,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
ast_settimeout(s->owner, whennext, ast_fsread_audio, s);
else
#endif
- s->owner->streamid = ast_sched_add(s->owner->sched, whennext/8, ast_fsread_audio, s);
+ s->owner->streamid = ast_sched_add(s->owner->sched, whennext / 8, ast_fsread_audio, s);
s->lasttimeout = whennext;
return FSREAD_SUCCESS_NOSCHED;
}
@@ -772,8 +772,8 @@ int ast_closestream(struct ast_filestream *f)
if (f->realfilename && f->filename) {
size = strlen(f->filename) + strlen(f->realfilename) + 15;
cmd = alloca(size);
- memset(cmd,0,size);
- snprintf(cmd,size,"/bin/mv -f %s %s",f->filename,f->realfilename);
+ memset(cmd, 0, size);
+ snprintf(cmd, size, "/bin/mv -f %s %s", f->filename, f->realfilename);
ast_safe_system(cmd);
}
@@ -1114,9 +1114,9 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
}
} else {
res = fr->subclass;
- if (strchr(forward,res)) {
+ if (strchr(forward, res)) {
ast_stream_fastforward(c->stream, skip_ms);
- } else if (strchr(rewind,res)) {
+ } else if (strchr(rewind, res)) {
ast_stream_rewind(c->stream, skip_ms);
} else if (strchr(breakon, res)) {
ast_frfree(fr);
@@ -1197,13 +1197,14 @@ int ast_waitstream_exten(struct ast_channel *c, const char *context)
*/
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
{
- int res = 0;
- if (!ast_strlen_zero(file)) {
- res = ast_streamfile(chan, file, chan->language);
- if (!res)
- res = ast_waitstream(chan, digits);
- }
- return res;
+ int res = 0;
+ if (!ast_strlen_zero(file)) {
+ res = ast_streamfile(chan, file, chan->language);
+ if (!res) {
+ res = ast_waitstream(chan, digits);
+ }
+ }
+ return res;
}
static char *handle_cli_core_show_file_formats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
diff --git a/main/frame.c b/main/frame.c
index 304bd2716..940ff5c5c 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -1352,7 +1352,7 @@ static int speex_get_wb_sz_at(unsigned char *data, int len, int bit)
static int speex_samples(unsigned char *data, int len)
{
static int SpeexSubModeSz[] = {
- 5, 43, 119, 160,
+ 5, 43, 119, 160,
220, 300, 364, 492,
79, 0, 0, 0,
0, 0, 0, 0 };
diff --git a/main/fskmodem.c b/main/fskmodem.c
index e59024834..8f84f5800 100644
--- a/main/fskmodem.c
+++ b/main/fskmodem.c
@@ -98,21 +98,21 @@ static inline int ibpdfilter(struct filter_struct * fs, int in)
/* integer filter */
s = in * fs->icoefs[0];
- fs->ixv[(fs->ip+6)&7] = s;
+ 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];
+ 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++) {
+ 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]) *
(int64_t)(fs->icoefs[i]) /
(int64_t)(1024);
s += (int) s_interim;
}
- fs->iyv[ j & 7] = s;
+ fs->iyv[j & 7] = s;
fs->ip++;
fs->ip &= 7;
return s;
@@ -127,19 +127,20 @@ static inline int ibpfilter(struct filter_struct * fs, int in)
/* integer filter */
s = in * fs->icoefs[0] / 256;
- fs->ixv[(fs->ip+6) & 7] = s;
+ 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]);
+ 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]) *
+ 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;
+ s += (int) s_interim;
}
- fs->iyv[j&7]=s;
- fs->ip++; fs->ip &= 7;
+ fs->iyv[j & 7] = s;
+ fs->ip++;
+ fs->ip &= 7;
return s;
}
@@ -151,7 +152,7 @@ static inline int idemodulator(fsk_data *fskd, int *retval, int x)
is = ibpfilter(&fskd->space_filter, x);
im = ibpfilter(&fskd->mark_filter, x);
- ilin2 = ((im * im) - (is * is))/(256 * 256);
+ ilin2 = ((im * im) - (is * is)) / (256 * 256);
id = ibpdfilter(&fskd->demod_filter, ilin2);
@@ -166,25 +167,26 @@ static int get_bit_raw(fsk_data *fskd, short *buffer, int *len)
int ix;
/* PLL coeffs are set up in callerid_new */
- for (f = 0;;){
+ for (f = 0;;) {
if (idemodulator(fskd, &ix, IGET_SAMPLE)) return(-1);
- if ((ix * fskd->xi0)<0) { /* Transicion */
+ if ((ix * fskd->xi0) < 0) { /* Transicion */
if (!f) {
- if (fskd->icont<(fskd->pllispb2))
- fskd->icont+=fskd->pllids;
- else
- fskd->icont-=fskd->pllids;
+ if (fskd->icont < (fskd->pllispb2)) {
+ fskd->icont += fskd->pllids;
+ } else {
+ fskd->icont -= fskd->pllids;
+ }
f = 1;
}
}
- fskd->xi0=ix;
- fskd->icont+=32;
- if (fskd->icont>fskd->pllispb) {
- fskd->icont-=fskd->pllispb;
+ fskd->xi0 = ix;
+ fskd->icont += 32;
+ if (fskd->icont > fskd->pllispb) {
+ fskd->icont -= fskd->pllispb;
break;
}
}
- f=(ix>0)?0x80:0;
+ f = (ix > 0) ? 0x80 : 0;
return f;
}
@@ -253,7 +255,7 @@ int fsk_serial(fsk_data *fskd, short *buffer, int *len, int *outbyte)
beginning of a start bit in the TDD sceanario. It just looks for sufficient
level to maybe, perhaps, guess, maybe that its maybe the beginning of
a start bit, perhaps. This whole thing stinks! */
- beginlenx=beginlen; /* just to avoid unused war warnings */
+ beginlenx = beginlen; /* just to avoid unused war warnings */
if (idemodulator(fskd, &fskd->xi1, IGET_SAMPLE))
return -1;
samples++;
@@ -264,33 +266,34 @@ 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
- if (fskd->xi2 < 512)
- break;
+ if (fskd->xi2 < 512) {
+ break;
+ }
}
search_startbit3:
/* We await for 0.5 bits before using DPLL */
- i=fskd->ispb/2;
+ i = fskd->ispb / 2;
if (*len < i) {
fskd->state = STATE_SEARCH_STARTBIT3;
return 0;
}
- for (; i>0; i--) {
+ for (; i > 0; i--) {
if (idemodulator(fskd, &fskd->xi1, IGET_SAMPLE))
return(-1);
#if 0
printf("xi1 = %d ", fskd->xi1);
-#endif
+#endif
samples++;
}
/* x1 must be negative (start bit confirmation) */
- } while (fskd->xi1>0);
+ } while (fskd->xi1 > 0);
fskd->state = STATE_GET_BYTE;
getbyte:
@@ -304,7 +307,7 @@ getbyte:
if (*len < 80)
return 0;
}
-
+
/* Now we read the data bits */
j = fskd->nbit;
for (a = n1 = 0; j; j--) {
diff --git a/main/image.c b/main/image.c
index 7096311a2..c47f808a6 100644
--- a/main/image.c
+++ b/main/image.c
@@ -112,7 +112,7 @@ struct ast_frame *ast_read_image(char *filename, const char *preflang, int forma
if (i->format & format) {
char *stringp=NULL;
ast_copy_string(tmp, i->exts, sizeof(tmp));
- stringp=tmp;
+ stringp = tmp;
e = strsep(&stringp, "|");
while (e) {
make_filename(buf, sizeof(buf), filename, preflang, e);
@@ -138,7 +138,7 @@ struct ast_frame *ast_read_image(char *filename, const char *preflang, int forma
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);
diff --git a/main/jitterbuf.c b/main/jitterbuf.c
index 27b93a659..a7f3b2cd9 100644
--- a/main/jitterbuf.c
+++ b/main/jitterbuf.c
@@ -174,7 +174,7 @@ static int history_put(jitterbuf *jb, long ts, long now, long ms)
/* if the new delay would go into min */
if (delay < jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ-1])
goto invalidate;
-
+
/* or max.. */
if (delay > jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ-1])
goto invalidate;
@@ -715,7 +715,7 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, long now,
/* 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; */
diff --git a/main/loader.c b/main/loader.c
index 94a806a5a..43d254c6f 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -228,7 +228,7 @@ void __ast_module_user_hangup_all(struct ast_module *mod)
}
AST_LIST_UNLOCK(&mod->users);
- ast_update_use_count();
+ ast_update_use_count();
}
/*! \note
@@ -722,11 +722,11 @@ static enum ast_module_load_result load_resource(const char *resource_name, unsi
int ast_load_resource(const char *resource_name)
{
- AST_LIST_LOCK(&module_list);
- load_resource(resource_name, 0);
- AST_LIST_UNLOCK(&module_list);
+ AST_LIST_LOCK(&module_list);
+ load_resource(resource_name, 0);
+ AST_LIST_UNLOCK(&module_list);
- return 0;
+ return 0;
}
struct load_order_entry {
diff --git a/main/logger.c b/main/logger.c
index 59fad2840..b0b728b78 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -295,7 +295,7 @@ static struct logchannel *make_logchannel(const char *channel, const char *compo
} else {
if (channel[0] == '/') {
if (!ast_strlen_zero(hostname)) {
- snprintf(chan->filename, sizeof(chan->filename) - 1,"%s.%s", channel, hostname);
+ snprintf(chan->filename, sizeof(chan->filename), "%s.%s", channel, hostname);
} else {
ast_copy_string(chan->filename, channel, sizeof(chan->filename));
}
@@ -694,13 +694,13 @@ static char *handle_logger_show_channels(struct ast_cli_entry *e, int cmd, struc
case CLI_GENERATE:
return NULL;
}
- ast_cli(a->fd,FORMATL, "Channel", "Type", "Status");
+ ast_cli(a->fd, FORMATL, "Channel", "Type", "Status");
ast_cli(a->fd, "Configuration\n");
- ast_cli(a->fd,FORMATL, "-------", "----", "------");
+ ast_cli(a->fd, FORMATL, "-------", "----", "------");
ast_cli(a->fd, "-------------\n");
AST_RWLIST_RDLOCK(&logchannels);
AST_RWLIST_TRAVERSE(&logchannels, chan, list) {
- ast_cli(a->fd, FORMATL, chan->filename, chan->type==LOGTYPE_CONSOLE ? "Console" : (chan->type==LOGTYPE_SYSLOG ? "Syslog" : "File"),
+ ast_cli(a->fd, FORMATL, chan->filename, chan->type == LOGTYPE_CONSOLE ? "Console" : (chan->type == LOGTYPE_SYSLOG ? "Syslog" : "File"),
chan->disabled ? "Disabled" : "Enabled");
ast_cli(a->fd, " - ");
if (chan->logmask & (1 << __LOG_DEBUG))
@@ -764,10 +764,10 @@ static void ast_log_vsyslog(int level, const char *file, int line, const char *f
} else {
snprintf(buf, sizeof(buf), "%s[%ld]: %s:%d in %s: %s",
levels[level], (long)GETTID(), file, line, function, str);
- }
+ }
- term_strip(buf, buf, strlen(buf) + 1);
- syslog(syslog_level_map[level], "%s", buf);
+ term_strip(buf, buf, strlen(buf) + 1);
+ syslog(syslog_level_map[level], "%s", buf);
}
/*! \brief Print a normal log message to the channels */
@@ -912,7 +912,7 @@ int init_logger(void)
int res = 0;
/* auto rotate if sig SIGXFSZ comes a-knockin */
- (void) signal(SIGXFSZ,(void *) handle_SIGXFSZ);
+ (void) signal(SIGXFSZ, (void *) handle_SIGXFSZ);
/* start logger thread */
ast_cond_init(&logcond, NULL);
@@ -1117,19 +1117,19 @@ void ast_verbose(const char *fmt, ...)
if (!(buf = ast_str_thread_get(&verbose_buf, VERBOSE_BUF_INIT_SIZE)))
return;
- if (ast_opt_timestamp) {
- struct timeval tv;
- struct ast_tm tm;
- char date[40];
- char *datefmt;
+ if (ast_opt_timestamp) {
+ struct timeval tv;
+ struct ast_tm tm;
+ char date[40];
+ char *datefmt;
tv = ast_tvnow();
- ast_localtime(&tv, &tm, NULL);
- ast_strftime(date, sizeof(date), dateformat, &tm);
- datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
- sprintf(datefmt, "[%s] %s", date, fmt);
- fmt = datefmt;
- }
+ ast_localtime(&tv, &tm, NULL);
+ ast_strftime(date, sizeof(date), dateformat, &tm);
+ datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
+ sprintf(datefmt, "[%s] %s", date, fmt);
+ fmt = datefmt;
+ }
/* Build string */
va_start(ap, fmt);
diff --git a/main/manager.c b/main/manager.c
index f8267a4ca..da583155d 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -1354,10 +1354,10 @@ static int action_updateconfig(struct mansession *s, const struct message *m)
astman_send_error(s, m, "Filename not specified");
return 0;
}
- if (!(cfg = ast_config_load(sfn, config_flags))) {
- astman_send_error(s, m, "Config file not found");
- return 0;
- }
+ if (!(cfg = ast_config_load(sfn, config_flags))) {
+ astman_send_error(s, m, "Config file not found");
+ return 0;
+ }
result = handle_updates(s, m, cfg, dfn);
if (!result) {
ast_include_rename(cfg, sfn, dfn); /* change the include references from dfn to sfn, so things match up */
diff --git a/main/netsock.c b/main/netsock.c
index 27def180c..261e234d4 100644
--- a/main/netsock.c
+++ b/main/netsock.c
@@ -150,7 +150,7 @@ int ast_netsock_set_qos(int netsocket, int tos, int cos, const char *desc)
if ((res = setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))))
ast_log(LOG_WARNING, "Unable to set %s TOS to %d, may be you have no root privileges\n", desc, tos);
else if (tos)
- ast_verb(2, "Using %s TOS bits %d\n", desc, tos);
+ ast_verb(2, "Using %s TOS bits %d\n", desc, tos);
#if defined(linux)
if (setsockopt(netsocket, SOL_SOCKET, SO_PRIORITY, &cos, sizeof(cos)))
diff --git a/main/pbx.c b/main/pbx.c
index f638a4953..89d7d2f49 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -497,7 +497,7 @@ static struct pbx_builtin {
" At least a priority is required as an argument, or the goto will return a -1,\n"
"and the channel and call will be terminated.\n"
" If the location that is put into the channel information is bogus, and asterisk cannot\n"
- "find that location in the dialplan,\n"
+ "find that location in the dialplan,\n"
"then the execution engine will try to find and execute the code in the 'i' (invalid)\n"
"extension in the current context. If that does not exist, it will try to execute the\n"
"'h' extension. If either or neither the 'h' or 'i' extensions have been defined, the\n"
@@ -538,8 +538,8 @@ static struct pbx_builtin {
"by the condition is omitted, no jump is performed, and execution passes to the next\n"
"instruction. If the target jump location is bogus, the same actions would be taken as for\n"
"Goto.\n"
- "Further information on the time specification can be found in examples\n"
- "illustrating how to do time-based context includes in the dialplan.\n"
+ "Further information on the time specification can be found in examples\n"
+ "illustrating how to do time-based context includes in the dialplan.\n"
},
{ "ImportVar", pbx_builtin_importvar,
@@ -4257,7 +4257,7 @@ static char *complete_core_show_hint(const char *line, const char *word, int pos
}
AST_RWLIST_UNLOCK(&hints);
- return ret;
+ return ret;
}
/*! \brief handle_show_hint: CLI support for listing registered dial plan hint */
diff --git a/main/poll.c b/main/poll.c
index bd283866d..731dbcefb 100644
--- a/main/poll.c
+++ b/main/poll.c
@@ -108,46 +108,42 @@ static int map_poll_spec
fd_set *pExceptSet;
#endif
{
- register unsigned long i; /* loop control */
- register struct pollfd *pCur; /* current array element */
- register int max_fd = -1; /* return value */
-
- /*
- Map the poll() structures into the file descriptor sets required
- by select().
- */
- for (i = 0, pCur = pArray; i < n_fds; i++, pCur++)
- {
- /* Skip any bad FDs in the array. */
-
- if (pCur->fd < 0)
- continue;
-
- if (pCur->events & POLLIN)
- {
- /* "Input Ready" notification desired. */
- FD_SET (pCur->fd, pReadSet);
- }
-
- if (pCur->events & POLLOUT)
- {
- /* "Output Possible" notification desired. */
- FD_SET (pCur->fd, pWriteSet);
+ register unsigned long i; /* loop control */
+ register struct pollfd *pCur; /* current array element */
+ register int max_fd = -1; /* return value */
+
+ /*!\note
+ * Map the poll() structures into the file descriptor sets required
+ * by select().
+ */
+ for (i = 0, pCur = pArray; i < n_fds; i++, pCur++) {
+ /* Skip any bad FDs in the array. */
+
+ if (pCur->fd < 0)
+ continue;
+
+ if (pCur->events & POLLIN) {
+ /* "Input Ready" notification desired. */
+ FD_SET(pCur->fd, pReadSet);
+ }
+
+ if (pCur->events & POLLOUT) {
+ /* "Output Possible" notification desired. */
+ FD_SET(pCur->fd, pWriteSet);
+ }
+
+ if (pCur->events & POLLPRI) {
+ /*!\note
+ * "Exception Occurred" notification desired. (Exceptions
+ * include out of band data.)
+ */
+ FD_SET(pCur->fd, pExceptSet);
+ }
+
+ max_fd = MAX(max_fd, pCur->fd);
}
- if (pCur->events & POLLPRI)
- {
- /*
- "Exception Occurred" notification desired. (Exceptions
- include out of band data.
- */
- FD_SET (pCur->fd, pExceptSet);
- }
-
- max_fd = MAX (max_fd, pCur->fd);
- }
-
- return max_fd;
+ return max_fd;
}
static struct timeval *map_timeout
@@ -159,55 +155,53 @@ static struct timeval *map_timeout
struct timeval *pSelTimeout;
#endif
{
- struct timeval *pResult;
-
- /*
- Map the poll() timeout value into a select() timeout. The possible
- values of the poll() timeout value, and their meanings, are:
-
- VALUE MEANING
-
- -1 wait indefinitely (until signal occurs)
- 0 return immediately, don't block
- >0 wait specified number of milliseconds
-
- select() uses a "struct timeval", which specifies the timeout in
- seconds and microseconds, so the milliseconds value has to be mapped
- accordingly.
- */
-
- assert (pSelTimeout != (struct timeval *) NULL);
-
- switch (poll_timeout)
- {
+ struct timeval *pResult;
+
+ /*!\note
+ * Map the poll() timeout value into a select() timeout. The possible
+ * values of the poll() timeout value, and their meanings, are:
+ *
+ * VALUE MEANING
+ *
+ * -1 wait indefinitely (until signal occurs)
+ * 0 return immediately, don't block
+ * >0 wait specified number of milliseconds
+ *
+ * select() uses a "struct timeval", which specifies the timeout in
+ * seconds and microseconds, so the milliseconds value has to be mapped
+ * accordingly.
+ */
+
+ assert(pSelTimeout != (struct timeval *) NULL);
+
+ switch (poll_timeout) {
case -1:
- /*
- A NULL timeout structure tells select() to wait indefinitely.
- */
- pResult = (struct timeval *) NULL;
- break;
+ /*
+ * A NULL timeout structure tells select() to wait indefinitely.
+ */
+ pResult = (struct timeval *) NULL;
+ break;
case 0:
- /*
- "Return immediately" (test) is specified by all zeros in
- a timeval structure.
- */
- pSelTimeout->tv_sec = 0;
- pSelTimeout->tv_usec = 0;
- pResult = pSelTimeout;
- break;
+ /*
+ * "Return immediately" (test) is specified by all zeros in
+ * a timeval structure.
+ */
+ pSelTimeout->tv_sec = 0;
+ pSelTimeout->tv_usec = 0;
+ pResult = pSelTimeout;
+ break;
default:
- /* Wait the specified number of milliseconds. */
- pSelTimeout->tv_sec = poll_timeout / 1000; /* get seconds */
- poll_timeout %= 1000; /* remove seconds */
- pSelTimeout->tv_usec = poll_timeout * 1000; /* get microseconds */
- pResult = pSelTimeout;
- break;
- }
-
+ /* Wait the specified number of milliseconds. */
+ pSelTimeout->tv_sec = poll_timeout / 1000; /* get seconds */
+ poll_timeout %= 1000; /* remove seconds */
+ pSelTimeout->tv_usec = poll_timeout * 1000; /* get microseconds */
+ pResult = pSelTimeout;
+ break;
+ }
- return pResult;
+ return pResult;
}
static void map_select_results
@@ -226,30 +220,31 @@ static void map_select_results
fd_set *pExceptSet;
#endif
{
- register unsigned long i; /* loop control */
- register struct pollfd *pCur; /* current array element */
+ register unsigned long i; /* loop control */
+ register struct pollfd *pCur; /* current array element */
- for (i = 0, pCur = pArray; i < n_fds; i++, pCur++)
- {
- /* Skip any bad FDs in the array. */
+ for (i = 0, pCur = pArray; i < n_fds; i++, pCur++) {
+ /* Skip any bad FDs in the array. */
- if (pCur->fd < 0)
- continue;
+ if (pCur->fd < 0) {
+ continue;
+ }
- /* Exception events take priority over input events. */
+ /* Exception events take priority over input events. */
- pCur->revents = 0;
- if (FD_ISSET (pCur->fd, pExceptSet))
- pCur->revents |= POLLPRI;
+ pCur->revents = 0;
+ if (FD_ISSET (pCur->fd, pExceptSet)) {
+ pCur->revents |= POLLPRI;
+ } else if (FD_ISSET (pCur->fd, pReadSet)) {
+ pCur->revents |= POLLIN;
+ }
- else if (FD_ISSET (pCur->fd, pReadSet))
- pCur->revents |= POLLIN;
-
- if (FD_ISSET (pCur->fd, pWriteSet))
- pCur->revents |= POLLOUT;
- }
+ if (FD_ISSET (pCur->fd, pWriteSet)) {
+ pCur->revents |= POLLOUT;
+ }
+ }
- return;
+ return;
}
/*---------------------------------------------------------------------------*\
@@ -268,39 +263,35 @@ int poll
#endif
{
- fd_set read_descs; /* input file descs */
- fd_set write_descs; /* output file descs */
- fd_set except_descs; /* exception descs */
- struct timeval stime; /* select() timeout value */
- int ready_descriptors; /* function result */
- int max_fd; /* maximum fd value */
- struct timeval *pTimeout; /* actually passed */
-
- FD_ZERO (&read_descs);
- FD_ZERO (&write_descs);
- FD_ZERO (&except_descs);
+ fd_set read_descs; /* input file descs */
+ fd_set write_descs; /* output file descs */
+ fd_set except_descs; /* exception descs */
+ struct timeval stime; /* select() timeout value */
+ int ready_descriptors; /* function result */
+ int max_fd; /* maximum fd value */
+ struct timeval *pTimeout; /* actually passed */
- assert (pArray != (struct pollfd *) NULL);
+ FD_ZERO (&read_descs);
+ FD_ZERO (&write_descs);
+ FD_ZERO (&except_descs);
- /* Map the poll() file descriptor list in the select() data structures. */
+ assert(pArray != (struct pollfd *) NULL);
- max_fd = map_poll_spec (pArray, n_fds,
- &read_descs, &write_descs, &except_descs);
+ /* Map the poll() file descriptor list in the select() data structures. */
- /* Map the poll() timeout value in the select() timeout structure. */
+ max_fd = map_poll_spec(pArray, n_fds,
+ &read_descs, &write_descs, &except_descs);
- pTimeout = map_timeout (timeout, &stime);
+ /* Map the poll() timeout value in the select() timeout structure. */
+ pTimeout = map_timeout(timeout, &stime);
- /* Make the select() call. */
-
- ready_descriptors = select (max_fd + 1, &read_descs, &write_descs,
+ /* Make the select() call. */
+ ready_descriptors = select(max_fd + 1, &read_descs, &write_descs,
&except_descs, pTimeout);
- if (ready_descriptors >= 0)
- {
- map_select_results (pArray, n_fds,
- &read_descs, &write_descs, &except_descs);
- }
+ if (ready_descriptors >= 0) {
+ map_select_results(pArray, n_fds, &read_descs, &write_descs, &except_descs);
+ }
- return ready_descriptors;
+ return ready_descriptors;
}
diff --git a/main/rtp.c b/main/rtp.c
index 6e6004519..9777a5183 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -584,7 +584,7 @@ static int stun_get_mapped(struct stun_attr *attr, void *arg)
* \return 0 on success, other values on error.
*/
int ast_stun_request(int s, struct sockaddr_in *dst,
- const char *username, struct sockaddr_in *answer)
+ const char *username, struct sockaddr_in *answer)
{
struct stun_header *req;
unsigned char reqdata[1024];
@@ -1108,7 +1108,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
pt = (length & 0xff0000) >> 16;
rc = (length & 0x1f000000) >> 24;
length &= 0xffff;
-
+
if ((i + length) > packetwords) {
if (option_debug || rtpdebug)
ast_log(LOG_DEBUG, "RTCP Read too short\n");
@@ -1121,7 +1121,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
ast_verbose("Reception reports: %d\n", rc);
ast_verbose("SSRC of sender: %u\n", rtcpheader[i + 1]);
}
-
+
i += 2; /* Advance past header and ssrc */
switch (pt) {
@@ -1130,7 +1130,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
rtp->rtcp->spc = ntohl(rtcpheader[i+3]);
rtp->rtcp->soc = ntohl(rtcpheader[i + 4]);
rtp->rtcp->themrxlsr = ((ntohl(rtcpheader[i]) & 0x0000ffff) << 16) | ((ntohl(rtcpheader[i + 1]) & 0xffff0000) >> 16); /* Going to LSR in RR*/
-
+
if (rtcp_debug_test_addr(&sin)) {
ast_verbose("NTP timestamp: %lu.%010lu\n", (unsigned long) ntohl(rtcpheader[i]), (unsigned long) ntohl(rtcpheader[i + 1]) * 4096);
ast_verbose("RTP timestamp: %lu\n", (unsigned long) ntohl(rtcpheader[i + 2]));
@@ -1973,7 +1973,7 @@ void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt)
}
/*! \brief remove setting from payload type list if the rtpmap header indicates
- an unknown media type */
+ an unknown media type */
void ast_rtp_unset_m_type(struct ast_rtp* rtp, int pt)
{
rtp_bridge_lock(rtp);
diff --git a/main/say.c b/main/say.c
index fd03a28c6..9a8e7d536 100644
--- a/main/say.c
+++ b/main/say.c
@@ -1226,8 +1226,8 @@ What about:
*/
#define SAY_NUM_BUF_SIZE 256
static int ast_say_number_full_he(struct ast_channel *chan, int num,
- const char *ints, const char *language, const char *options,
- int audiofd, int ctrlfd)
+ const char *ints, const char *language, const char *options,
+ int audiofd, int ctrlfd)
{
int res = 0;
int state = 0; /* no need to save anything */
@@ -2301,7 +2301,7 @@ static int get_lastdigits_ru(int num) {
millions.gsm
1f.gsm (odna)
2f.gsm (dve)
-
+
where 'n' from 1 to 9
*/
static int ast_say_number_full_ru(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
@@ -2324,16 +2324,16 @@ static int ast_say_number_full_ru(struct ast_channel *chan, int num, const char
if (options && strlen(options) == 1 && num < 3) {
snprintf(fn, sizeof(fn), "digits/%d%s", num, options);
} else {
- snprintf(fn, sizeof(fn), "digits/%d", num);
+ snprintf(fn, sizeof(fn), "digits/%d", num);
}
num = 0;
- } else if (num < 100) {
+ } else if (num < 100) {
snprintf(fn, sizeof(fn), "digits/%d", num - (num % 10));
num %= 10;
- } else if (num < 1000){
+ } else if (num < 1000){
snprintf(fn, sizeof(fn), "digits/%d", num - (num % 100));
num %= 100;
- } else if (num < 1000000) { /* 1,000,000 */
+ } else if (num < 1000000) { /* 1,000,000 */
lastdigits = get_lastdigits_ru(num / 1000);
/* say thousands */
if (lastdigits < 3) {
@@ -4070,8 +4070,8 @@ int ast_say_date_with_format_th(struct ast_channel *chan, time_t time, const cha
#define IL_TIME_STR "IMp"
#define IL_DATE_STR_FULL IL_DATE_STR " 'digits/at' " IL_TIME_STR
int ast_say_date_with_format_he(struct ast_channel *chan, time_t time,
- const char *ints, const char *lang, const char *format,
- const char *timezone)
+ const char *ints, const char *lang, const char *format,
+ const char *timezone)
{
/* TODO: This whole function is cut&paste from
* ast_say_date_with_format_en . Is that considered acceptable?
@@ -4113,52 +4113,34 @@ int ast_say_date_with_format_he(struct ast_channel *chan, time_t time,
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 :-(
- */
- res = ast_say_number_full_he(chan, tm.tm_mday,
- ints, lang, "m", -1, -1
- );
+ res = ast_say_number_full_he(chan, tm.tm_mday, ints, lang, "m", -1, -1);
break;
case 'Y': /* Year */
- res = ast_say_number_full_he(chan, tm.tm_year+1900,
- ints, lang, "f", -1, -1
- );
+ res = ast_say_number_full_he(chan, tm.tm_year + 1900, ints, lang, "f", -1, -1);
break;
case 'I':
case 'l': /* 12-Hour */
{
int hour = tm.tm_hour;
- hour = hour%12;
- if (hour == 0) hour=12;
+ hour = hour % 12;
+ if (hour == 0)
+ hour = 12;
- res = ast_say_number_full_he(chan, hour,
- ints, lang, "f", -1, -1
- );
+ res = ast_say_number_full_he(chan, hour, ints, lang, "f", -1, -1);
}
break;
case 'H':
case 'k': /* 24-Hour */
/* With 'H' there is an 'oh' after a single-
* digit hour */
- if ((format[offset] == 'H') &&
- (tm.tm_hour <10)&&(tm.tm_hour>0)
- ) { /* e.g. oh-eight */
+ if ((format[offset] == 'H') && (tm.tm_hour < 10) && (tm.tm_hour > 0)) { /* e.g. oh-eight */
res = wait_file(chan, ints, "digits/oh", lang);
}
- res = ast_say_number_full_he(chan, tm.tm_hour,
- ints, lang, "f", -1, -1
- );
+ res = ast_say_number_full_he(chan, tm.tm_hour, ints, lang, "f", -1, -1);
break;
case 'M': /* Minute */
- res = ast_say_number_full_he(chan, tm.tm_min,
- ints, lang, "f", -1, -1
- );
+ res = ast_say_number_full_he(chan, tm.tm_min, ints, lang, "f", -1, -1);
break;
case 'P':
case 'p':
@@ -4173,7 +4155,7 @@ int ast_say_date_with_format_he(struct ast_channel *chan, time_t time,
/* Shorthand for "Today", "Yesterday", or "date" */
case 'q':
/* Shorthand for "" (today), "Yesterday", A
- * (weekday), or "date" */
+ * (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
* upon how recent the date is. XXX */
@@ -4190,25 +4172,16 @@ int ast_say_date_with_format_he(struct ast_channel *chan, time_t time,
if (beg_today < time) {
/* Today */
if (todo == 'Q') {
- res = wait_file(chan,
- ints,
- "digits/today",
- lang);
+ res = wait_file(chan, ints, "digits/today", lang);
}
} else if (beg_today - 86400 < time) {
/* Yesterday */
res = wait_file(chan, ints, "digits/yesterday", lang);
- } else if ((todo != 'Q') &&
- (beg_today - 86400 * 6 < time))
- {
+ } else if ((todo != 'Q') && (beg_today - 86400 * 6 < time)) {
/* Within the last week */
- res = ast_say_date_with_format_he(chan,
- time, ints, lang,
- "A", timezone);
+ res = ast_say_date_with_format_he(chan, time, ints, lang, "A", timezone);
} else {
- res = ast_say_date_with_format_he(chan,
- time, ints, lang,
- IL_DATE_STR, timezone);
+ res = ast_say_date_with_format_he(chan, time, ints, lang, IL_DATE_STR, timezone);
}
}
break;
@@ -4224,18 +4197,15 @@ int ast_say_date_with_format_he(struct ast_channel *chan, time_t time,
res = ast_say_date_with_format_he(chan, time, ints, lang, "HMS", timezone);
break;
/* c, x, and X seem useful for testing. Not sure
- * if thiey're good for the general public */
+ * if they're good for the general public */
case 'c':
- res = ast_say_date_with_format_he(chan, time,
- ints, lang, IL_DATE_STR_FULL, timezone);
+ res = ast_say_date_with_format_he(chan, time, ints, lang, IL_DATE_STR_FULL, timezone);
break;
case 'x':
- res = ast_say_date_with_format_he(chan, time,
- ints, lang, IL_DATE_STR, timezone);
+ res = ast_say_date_with_format_he(chan, time, ints, lang, IL_DATE_STR, timezone);
break;
case 'X': /* Currently not locale-dependent...*/
- res = ast_say_date_with_format_he(chan, time,
- ints, lang, IL_TIME_STR, timezone);
+ res = ast_say_date_with_format_he(chan, time, ints, lang, IL_TIME_STR, timezone);
break;
case ' ':
case ' ':
@@ -5705,9 +5675,9 @@ int ast_say_date_with_format_tw(struct ast_channel *chan, time_t time, const cha
}
break;
case 'H':
- if (tm.tm_hour < 10) {
- res = wait_file(chan, ints, "digits/0", lang);
- }
+ if (tm.tm_hour < 10) {
+ res = wait_file(chan, ints, "digits/0", lang);
+ }
case 'k':
/* 24-Hour */
if (!(tm.tm_hour % 10) || tm.tm_hour < 10) {
diff --git a/main/strcompat.c b/main/strcompat.c
index 37ee407cd..a3f0e1497 100644
--- a/main/strcompat.c
+++ b/main/strcompat.c
@@ -26,27 +26,27 @@
#ifndef HAVE_STRSEP
char *strsep(char **str, const char *delims)
{
- char *token;
-
- if (!*str) {
- /* No more tokens */
- return NULL;
- }
-
- token = *str;
- while (**str != '\0') {
- if (strchr(delims, **str)) {
- **str = '\0';
- (*str)++;
- return token;
- }
- (*str)++;
- }
-
- /* There is no other token */
- *str = NULL;
-
- return token;
+ char *token;
+
+ if (!*str) {
+ /* No more tokens */
+ return NULL;
+ }
+
+ token = *str;
+ while (**str != '\0') {
+ if (strchr(delims, **str)) {
+ **str = '\0';
+ (*str)++;
+ return token;
+ }
+ (*str)++;
+ }
+
+ /* There is no other token */
+ *str = NULL;
+
+ return token;
}
#endif
@@ -185,15 +185,15 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
int asprintf(char **str, const char *fmt, ...)
{
- va_list ap;
- int ret;
+ va_list ap;
+ int ret;
- *str = NULL;
- va_start(ap, fmt);
- ret = vasprintf(str, fmt, ap);
- va_end(ap);
+ *str = NULL;
+ va_start(ap, fmt);
+ ret = vasprintf(str, fmt, ap);
+ va_end(ap);
- return ret;
+ return ret;
}
#endif /* !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
diff --git a/main/tdd.c b/main/tdd.c
index 13dda7e11..e07d5b0d1 100644
--- a/main/tdd.c
+++ b/main/tdd.c
@@ -102,8 +102,8 @@ struct tdd_state *tdd_new(void)
tdd->fskd.ispb = 176; /* 45.5 baud */
/* Set up for 45.5 / 8000 freq *32 to allow ints */
tdd->fskd.pllispb = (int)((8000 * 32 * 2) / 90);
- tdd->fskd.pllids = tdd->fskd.pllispb/32;
- tdd->fskd.pllispb2 = tdd->fskd.pllispb/2;
+ tdd->fskd.pllids = tdd->fskd.pllispb / 32;
+ tdd->fskd.pllispb2 = tdd->fskd.pllispb / 2;
tdd->fskd.hdlc = 0; /* Async */
tdd->fskd.nbit = 5; /* 5 bits */
tdd->fskd.instop = 1; /* integer rep of 1.5 stop bits */
@@ -149,7 +149,7 @@ int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int len)
return -1;
}
memcpy(buf, tdd->oldstuff, tdd->oldlen);
- mylen += tdd->oldlen/2;
+ mylen += tdd->oldlen / 2;
for (x = 0; x < len; x++)
buf[x + tdd->oldlen / 2] = AST_MULAW(ubuf[x]);
c = res = 0;
@@ -171,7 +171,7 @@ int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int len)
/* Ignore invalid bytes */
if (b > 0x7f)
continue;
- c = tdd_decode_baudot(tdd,b);
+ c = tdd_decode_baudot(tdd, b);
if ((c < 1) || (c > 126))
continue; /* if not valid */
break;
@@ -224,7 +224,7 @@ static inline float tdd_getcarrier(float *cr, float *ci, int bit)
#define PUT_TDD_MARKMS do { \
int x; \
- for (x=0;x<8;x++) \
+ for (x = 0; x < 8; x++) \
PUT_AUDIO_SAMPLE(tdd_getcarrier(&cr, &ci, 1)); \
} while(0)
@@ -259,9 +259,9 @@ static inline float tdd_getcarrier(float *cr, float *ci, int bit)
/*! Generate TDD hold tone */
int tdd_gen_holdtone(unsigned char *buf)
{
- int bytes=0;
- float scont=0.0,cr=1.0,ci=0.0;
- while(scont < tddsb*10.0) {
+ int bytes = 0;
+ float scont = 0.0, cr = 1.0, ci=0.0;
+ while (scont < tddsb * 10.0) {
PUT_AUDIO_SAMPLE(tdd_getcarrier(&cr, &ci, 1));
scont += 1.0;
}
@@ -270,9 +270,9 @@ int tdd_gen_holdtone(unsigned char *buf)
int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *str)
{
- int bytes=0;
+ int bytes = 0;
int i,x;
- char c;
+ char c;
/*! Baudot letters */
static unsigned char lstr[31] = "\000E\nA SIU\rDRJNFCKTZLWHYPQOBG\000MXV";
/*! Baudot figures */
diff --git a/main/term.c b/main/term.c
index ea005aa31..260637930 100644
--- a/main/term.c
+++ b/main/term.c
@@ -53,7 +53,7 @@ static const char *termpath[] = {
/* Ripped off from Ross Ridge, but it's public domain code (libmytinfo) */
static short convshort(char *s)
{
- register int a,b;
+ register int a, b;
a = (int) s[0] & 0377;
b = (int) s[1] & 0377;
@@ -143,7 +143,7 @@ int ast_term_init(void)
char *term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
{
- int attr=0;
+ int attr = 0;
char tmp[40];
if (!vt100compat) {
ast_copy_string(outbuf, inbuf, maxout);
diff --git a/main/translate.c b/main/translate.c
index ace245424..83a93a4d2 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -202,7 +202,7 @@ static int framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
if (pvt->samples == samples)
ast_log(LOG_WARNING, "%s did not update samples %d\n",
pvt->t->name, pvt->samples);
- return ret;
+ return ret;
}
/*! \brief generic frameout routine.
@@ -654,10 +654,10 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
}
if (t->buf_size) {
- /*
- * Align buf_size properly, rounding up to the machine-specific
- * alignment for pointers.
- */
+ /*
+ * Align buf_size properly, rounding up to the machine-specific
+ * alignment for pointers.
+ */
struct _test_align { void *a, *b; } p;
int align = (char *)&p.b - (char *)&p.a;
diff --git a/main/utils.c b/main/utils.c
index f8421b0c5..7325963b7 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1400,12 +1400,12 @@ AST_MUTEX_DEFINE_STATIC(fetchadd_m); /* used for all fetc&add ops */
int ast_atomic_fetchadd_int_slow(volatile int *p, int v)
{
- int ret;
- ast_mutex_lock(&fetchadd_m);
- ret = *p;
- *p += v;
- ast_mutex_unlock(&fetchadd_m);
- return ret;
+ int ret;
+ ast_mutex_lock(&fetchadd_m);
+ ret = *p;
+ *p += v;
+ ast_mutex_unlock(&fetchadd_m);
+ return ret;
}
/*! \brief