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)
#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)
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);
s[0] = '\0';
if (!prompt)
- prompt="";
+ prompt = "";
filename = ast_strdupa(prompt);
while ((front = strsep(&filename, "&"))) {
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) {
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);
res = ast_answer(chan);
if (file) {
- if ((end = strchr(file,':'))) {
+ if ((end = strchr(file, ':'))) {
if (!strcasecmp(end, ":end")) {
*end = '\0';
end++;
ast_free(gi);
}
}
- AST_RWLIST_TRAVERSE_SAFE_END;
+ AST_RWLIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&groups);
return 0;
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
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
/* length */
x++;
/* number type */
- switch (cid->rawdata[x]) {
+ switch (cid->rawdata[x]) {
case 0x00: /* unknown */
case 0x01: /* international number */
case 0x02: /* domestic number */
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++;
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 */
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;
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;
*/
void ast_shrink_phone_number(char *n)
{
- int x, y=0;
+ int x, y = 0;
int bracketed = 0;
for (x = 0; n[x]; x++) {
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
\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)
{
int printsec;
switch (cmd) {
- case CLI_INIT:
+ case CLI_INIT:
e->command = "core show uptime [seconds]";
e->usage =
"Usage: core show uptime [seconds]\n"
total += tmp; /* multiply by 3 */
total <<= 2; /* multiply by 12 */
total += tmp; /* multiply by 13 */
-
+
total += ((unsigned int)(*str));
}
if (total < 0)
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;
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) {
* 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;
#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;
};
/*! \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
}
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])
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
*/
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)
/* Finally disable option on the structure */
dial->options[option] = NULL;
- return 0;
+ return 0;
}
/*! \brief Disables an option per channel
/*
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.
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;
}
#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))
{
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)
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;
/* 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");
}
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);
insertStatus(dls, sbuf);
dls = reference(dls, mode);
- if ((init = dlsymIntern(dls, "__init", 0)))
- {
+ if ((init = dlsymIntern(dls, "__init", 0))) {
debug("calling _init()");
init();
}
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",
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);
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);
}
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;
}
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;
}
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;
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();
}
*/
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
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;
}
}
dounlock();
return 0;
- dlcloseerror:
+dlcloseerror:
dounlock();
return 1;
}
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;
}
/* 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;
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;
}
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;
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);
}
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
/* 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"
#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;
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;
}
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;
}
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 */
}
if (p1 != NULL) {
- p2 = p1+1;
+ p2 = p1 + 1;
while (p1 > number){
p1--;
tmp[newpos++] = *p1;
}
}
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;
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);
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);
}
/*!
*/
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;
}
/*!
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);
/* 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);
if (res < 0)
error = 1;
}
- }
+ }
if (error) {
ast_log(LOG_WARNING, "Failed to play courtesy tone!\n");
ast_hangup(peer);
return NULL;
case CLI_GENERATE:
return NULL;
- }
+ }
ast_cli(a->fd, format, "Builtin Feature", "Default", "Current");
ast_cli(a->fd, format, "---------------", "-------", "-------");
return NULL;
case CLI_GENERATE:
return NULL;
- }
+ }
load_config();
return CLI_SUCCESS;
*/
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));
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;
}
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);
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;
}
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);
}
}
} 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);
*/
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)
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 };
/* 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;
/* 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;
}
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);
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;
}
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++;
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:
if (*len < 80)
return 0;
}
-
+
/* Now we read the data bits */
j = fskd->nbit;
for (a = n1 = 0; j; j--) {
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);
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);
/* 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;
/* 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; */
}
AST_LIST_UNLOCK(&mod->users);
- ast_update_use_count();
+ ast_update_use_count();
}
/*! \note
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 {
} 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));
}
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))
} 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 */
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);
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);
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 */
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)))
" 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"
"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,
}
AST_RWLIST_UNLOCK(&hints);
- return ret;
+ return ret;
}
/*! \brief handle_show_hint: CLI support for listing registered dial plan hint */
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;
}
\f
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;
}
\f
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;
}
\f
/*---------------------------------------------------------------------------*\
#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;
}
* \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];
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");
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) {
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]));
}
/*! \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);
*/
#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 */
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)
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) {
#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?
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':
/* 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 */
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;
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 ' ':
}
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) {
#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
#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) */
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 */
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;
/* 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;
#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)
/*! 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;
}
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 */
/* 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;
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);
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.
}
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;
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