mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 11:58:52 +00:00
Whitespace changes only
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@105840 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -54,9 +54,10 @@ static inline unsigned char linear2alaw(short int linear)
|
||||
|
||||
/* Convert the scaled magnitude to segment number. */
|
||||
for (seg = 0; seg < 8; seg++) {
|
||||
if (pcm_val <= seg_end[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;
|
||||
}
|
||||
@@ -113,8 +114,9 @@ static inline short int alaw2linear (unsigned char alaw)
|
||||
alaw ^= AMI_MASK;
|
||||
i = ((alaw & 0x0F) << 4) + 8 /* rounding error */;
|
||||
seg = (((int) alaw & 0x70) >> 4);
|
||||
if (seg)
|
||||
if (seg) {
|
||||
i = (i + 0x100) << (seg - 1);
|
||||
}
|
||||
return (short int) ((alaw & 0x80) ? i : -i);
|
||||
}
|
||||
#else
|
||||
|
@@ -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) {
|
||||
|
@@ -176,8 +176,9 @@ 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) \
|
||||
if (s) { \
|
||||
free(s); \
|
||||
} \
|
||||
s = (new_val); \
|
||||
} while (0)
|
||||
|
||||
@@ -971,8 +972,9 @@ 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])
|
||||
if (!dial->options[option]) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Execute callback of option to disable if it exists */
|
||||
if (option_types[option].disable)
|
||||
|
230
main/dlfcn.c
230
main/dlfcn.c
@@ -544,8 +544,7 @@ static inline const char *dyld_error_str()
|
||||
const char *dyldfile;
|
||||
const char* retStr = NULL;
|
||||
NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr);
|
||||
if (dylderrstr && strlen(dylderrstr))
|
||||
{
|
||||
if (dylderrstr && strlen(dylderrstr)) {
|
||||
retStr = ast_malloc(strlen(dylderrstr) + 1);
|
||||
strcpy((char*)retStr, dylderrstr);
|
||||
}
|
||||
@@ -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,35 +605,25 @@ 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);
|
||||
@@ -653,21 +632,16 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
|
||||
}
|
||||
}
|
||||
/* 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);
|
||||
}
|
||||
if (canSetError)
|
||||
{
|
||||
if (canSetError) {
|
||||
error(savedErrorStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
debug(savedErrorStr);
|
||||
}
|
||||
if (savedErrorStr)
|
||||
@@ -688,22 +662,17 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
|
||||
const char *file;
|
||||
void (*init) (void);
|
||||
ofirc = NSCreateObjectFileImageFromFile(path, &ofi);
|
||||
switch (ofirc)
|
||||
{
|
||||
switch (ofirc) {
|
||||
case NSObjectFileImageSuccess:
|
||||
break;
|
||||
case NSObjectFileImageInappropriateFile:
|
||||
if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage)
|
||||
{
|
||||
if (!isFlagSet(mode, RTLD_GLOBAL))
|
||||
{
|
||||
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
|
||||
{
|
||||
} else {
|
||||
error("opening this file is unsupported on this system");
|
||||
return NULL;
|
||||
}
|
||||
@@ -725,20 +694,16 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
|
||||
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,13 +815,11 @@ 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))
|
||||
{
|
||||
if (pthread_setspecific(dlerror_key, tss)) {
|
||||
fprintf(stderr, "dlcompat: pthread_setspecific failed\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -897,32 +851,27 @@ 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;
|
||||
}
|
||||
@@ -944,14 +893,11 @@ 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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1135,20 +1068,16 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -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 */
|
||||
)
|
||||
{
|
||||
) {
|
||||
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);
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -858,12 +858,15 @@ 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))
|
||||
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 ? */
|
||||
}
|
||||
if (ast_strlen_zero(s)) { /* Use the non-macro context to transfer the call XXX ? */
|
||||
s = transferer->macrocontext;
|
||||
if (ast_strlen_zero(s))
|
||||
}
|
||||
if (ast_strlen_zero(s)) {
|
||||
s = transferer->context;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@@ -1200,9 +1200,10 @@ int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *
|
||||
int res = 0;
|
||||
if (!ast_strlen_zero(file)) {
|
||||
res = ast_streamfile(chan, file, chan->language);
|
||||
if (!res)
|
||||
if (!res) {
|
||||
res = ast_waitstream(chan, digits);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@@ -139,7 +139,8 @@ static inline int ibpfilter(struct filter_struct * fs, int in)
|
||||
s += (int) s_interim;
|
||||
}
|
||||
fs->iyv[j & 7] = s;
|
||||
fs->ip++; fs->ip &= 7;
|
||||
fs->ip++;
|
||||
fs->ip &= 7;
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -170,10 +171,11 @@ static int get_bit_raw(fsk_data *fskd, short *buffer, int *len)
|
||||
if (idemodulator(fskd, &ix, IGET_SAMPLE)) return(-1);
|
||||
if ((ix * fskd->xi0) < 0) { /* Transicion */
|
||||
if (!f) {
|
||||
if (fskd->icont<(fskd->pllispb2))
|
||||
if (fskd->icont < (fskd->pllispb2)) {
|
||||
fskd->icont += fskd->pllids;
|
||||
else
|
||||
} else {
|
||||
fskd->icont -= fskd->pllids;
|
||||
}
|
||||
f = 1;
|
||||
}
|
||||
}
|
||||
@@ -269,9 +271,10 @@ search_startbit2:
|
||||
#if 0
|
||||
printf("xi2 = %d ", fskd->xi2);
|
||||
#endif
|
||||
if (fskd->xi2 < 512)
|
||||
if (fskd->xi2 < 512) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
search_startbit3:
|
||||
/* We await for 0.5 bits before using DPLL */
|
||||
i = fskd->ispb / 2;
|
||||
|
@@ -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));
|
||||
}
|
||||
|
83
main/poll.c
83
main/poll.c
@@ -112,34 +112,30 @@ static int map_poll_spec
|
||||
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().
|
||||
/*!\note
|
||||
* Map the poll() structures into the file descriptor sets required
|
||||
* by select().
|
||||
*/
|
||||
for (i = 0, pCur = pArray; i < n_fds; i++, pCur++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (pCur->events & POLLIN) {
|
||||
/* "Input Ready" notification desired. */
|
||||
FD_SET(pCur->fd, pReadSet);
|
||||
}
|
||||
|
||||
if (pCur->events & POLLOUT)
|
||||
{
|
||||
if (pCur->events & POLLOUT) {
|
||||
/* "Output Possible" notification desired. */
|
||||
FD_SET(pCur->fd, pWriteSet);
|
||||
}
|
||||
|
||||
if (pCur->events & POLLPRI)
|
||||
{
|
||||
/*
|
||||
"Exception Occurred" notification desired. (Exceptions
|
||||
include out of band data.
|
||||
if (pCur->events & POLLPRI) {
|
||||
/*!\note
|
||||
* "Exception Occurred" notification desired. (Exceptions
|
||||
* include out of band data.)
|
||||
*/
|
||||
FD_SET(pCur->fd, pExceptSet);
|
||||
}
|
||||
@@ -161,36 +157,35 @@ static struct timeval *map_timeout
|
||||
{
|
||||
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.
|
||||
/*!\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)
|
||||
{
|
||||
switch (poll_timeout) {
|
||||
case -1:
|
||||
/*
|
||||
A NULL timeout structure tells select() to wait indefinitely.
|
||||
* 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.
|
||||
* "Return immediately" (test) is specified by all zeros in
|
||||
* a timeval structure.
|
||||
*/
|
||||
pSelTimeout->tv_sec = 0;
|
||||
pSelTimeout->tv_usec = 0;
|
||||
@@ -206,7 +201,6 @@ static struct timeval *map_timeout
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return pResult;
|
||||
}
|
||||
|
||||
@@ -229,25 +223,26 @@ static void map_select_results
|
||||
register unsigned long i; /* loop control */
|
||||
register struct pollfd *pCur; /* current array element */
|
||||
|
||||
for (i = 0, pCur = pArray; i < n_fds; i++, pCur++)
|
||||
{
|
||||
for (i = 0, pCur = pArray; i < n_fds; i++, pCur++) {
|
||||
/* Skip any bad FDs in the array. */
|
||||
|
||||
if (pCur->fd < 0)
|
||||
if (pCur->fd < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Exception events take priority over input events. */
|
||||
|
||||
pCur->revents = 0;
|
||||
if (FD_ISSET (pCur->fd, pExceptSet))
|
||||
if (FD_ISSET (pCur->fd, pExceptSet)) {
|
||||
pCur->revents |= POLLPRI;
|
||||
|
||||
else if (FD_ISSET (pCur->fd, pReadSet))
|
||||
} else if (FD_ISSET (pCur->fd, pReadSet)) {
|
||||
pCur->revents |= POLLIN;
|
||||
}
|
||||
|
||||
if (FD_ISSET (pCur->fd, pWriteSet))
|
||||
if (FD_ISSET (pCur->fd, pWriteSet)) {
|
||||
pCur->revents |= POLLOUT;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -288,18 +283,14 @@ int poll
|
||||
&read_descs, &write_descs, &except_descs);
|
||||
|
||||
/* 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,
|
||||
&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;
|
||||
|
62
main/say.c
62
main/say.c
@@ -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;
|
||||
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':
|
||||
@@ -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 ' ':
|
||||
|
Reference in New Issue
Block a user