res = jbimpl->get(jbobj, &f, now, interpolation_len);
- switch(res) {
+ switch (res) {
case JB_IMPL_OK:
/* deliver the frame */
ast_write(chan, f);
};
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;
+ 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;
+ 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;
i = ((alaw & 0x0F) << 4);
seg = (((int) alaw & 0x70) >> 4);
if (seg)
- i = (i + 0x100) << (seg - 1);
+ i = (i + 0x100) << (seg - 1);
return (short int) ((alaw & 0x80) ? i : -i);
}
/*
* Set up mu-law conversion table
*/
- for(i = 0;i < 256;i++)
- {
+ for (i = 0; i < 256; i++) {
__ast_alaw[i] = alaw2linear(i);
- }
- /* set up the reverse (mu-law) conversion table */
- for(i = -32768; i < 32768; i++)
- {
+ }
+ /* set up the reverse (mu-law) conversion table */
+ for (i = -32768; i < 32768; i++) {
__ast_lin2a[((unsigned short)i) >> 3] = linear2alaw(i);
- }
+ }
}
char *c;
char *n;
- switch(option->action) {
+ switch (option->action) {
case AST_ACTION_UPONE:
return RES_UPONE;
case AST_ACTION_EXIT:
return -1;
}
}
- while(!res) {
- while(menu->options[pos].option) {
+ while (!res) {
+ while (menu->options[pos].option) {
if (!strcasecmp(menu->options[pos].option, exten)) {
res = ivr_dispatch(chan, menu->options + pos, exten, cbdata);
if (option_debug)
execl("/bin/sh", "/bin/sh", "-c", s, (char *) NULL);
_exit(1);
} else if (pid > 0) {
- for(;;) {
+ for (;;) {
res = wait4(pid, &status, 0, &rusage);
if (res > -1) {
res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
ast_copy_string(hostname, "<Unknown>", sizeof(hostname));
snprintf(tmp, sizeof(tmp), "%s/%ld/%s\n", hostname, (long)ast_mainpid, ASTERISK_VERSION);
fdprint(con->fd, tmp);
- for(;;) {
+ for (;;) {
fds[0].fd = con->fd;
fds[0].events = POLLIN;
fds[0].revents = 0;
static void *autoservice_run(void *ign)
{
- for(;;) {
+ for (;;) {
struct ast_channel *mons[MAX_AUTOMONS];
struct ast_channel *chan;
struct asent *as;
AST_LIST_UNLOCK(&aslist);
/* Wait for it to un-block */
- while(ast_test_flag(chan, AST_FLAG_BLOCKING))
+ while (ast_test_flag(chan, AST_FLAG_BLOCKING))
usleep(1000);
return res;
}
cid->skipflag = 0 ;
/* caller id retrieval */
- switch(cid->sawflag) {
+ switch (cid->sawflag) {
case 0: /* DLE */
if (b == 0x10) {
cid->sawflag = 1;
/* Ignore invalid bytes */
if (b > 0xff)
continue;
- switch(cid->sawflag) {
+ switch (cid->sawflag) {
case 0: /* Look for flag */
if (b == 'U')
cid->sawflag = 2;
/* MDMF */
/* Go through each element and process */
for (x = 0; x < cid->pos;) {
- switch(cid->rawdata[x++]) {
+ switch (cid->rawdata[x++]) {
case 1:
/* Date */
break;
}
}
sum = 0;
- for (x=0; x<len; x++)
+ for (x = 0; x < len; x++)
sum += msg[x];
sum = (256 - (sum & 255));
msg[len++] = sum;
/* Wait a half a second */
- for (x=0; x<4000; x++)
+ for (x = 0; x < 4000; x++)
PUT_BYTE(0x7f);
/* Transmit 30 0x55's (looks like a square wave) for channel seizure */
- for (x=0; x<30; x++)
+ for (x = 0; x < 30; x++)
PUT_CLID(0x55);
/* Send 170ms of callerid marks */
- for (x=0; x<170; x++)
+ for (x = 0; x < 170; x++)
PUT_CLID_MARKMS;
- for (x=0; x<len; x++) {
+ for (x = 0; x < len; x++) {
PUT_CLID(msg[x]);
}
/* Send 50 more ms of marks */
- for (x=0; x<50; x++)
+ for (x = 0; x < 50; x++)
PUT_CLID_MARKMS;
return bytes;
}
len = callerid_genmsg(msg, sizeof(msg), number, name, flags);
if (!callwaiting) {
/* Wait a half a second */
- for (x=0; x<4000; x++)
+ for (x = 0; x < 4000; x++)
PUT_BYTE(0x7f);
/* Transmit 30 0x55's (looks like a square wave) for channel seizure */
- for (x=0; x<30; x++)
+ for (x = 0; x < 30; x++)
PUT_CLID(0x55);
}
/* Send 150ms of callerid marks */
- for (x=0; x<150; x++)
+ for (x = 0; x < 150; x++)
PUT_CLID_MARKMS;
/* Send 0x80 indicating MDMF format */
PUT_CLID(0x80);
PUT_CLID(len);
sum = 0x80 + strlen(msg);
/* Put each character of message and update checksum */
- for (x=0; x<len; x++) {
+ for (x = 0; x < len; x++) {
PUT_CLID(msg[x]);
sum += msg[x];
}
PUT_CLID(256 - (sum & 255));
/* Send 50 more ms of marks */
- for (x=0; x<50; x++)
+ for (x = 0; x < 50; x++)
PUT_CLID_MARKMS;
return bytes;
int x, y=0;
int bracketed = 0;
- for (x=0; n[x]; x++) {
- switch(n[x]) {
+ for (x = 0; n[x]; x++) {
+ switch (n[x]) {
case '[':
bracketed++;
n[y++] = n[x];
if (ast_strlen_zero(exten))
return 0;
- for (x=0; exten[x]; x++)
+ for (x = 0; exten[x]; x++)
if (!strchr(valid, exten[x]))
return 0;
return 1;
struct varshead *headp;
int x;
- for(x = 0; cdr_readonly_vars[x]; x++) {
+ for (x = 0; cdr_readonly_vars[x]; x++) {
if (!strcasecmp(name, cdr_readonly_vars[x])) {
ast_log(LOG_ERROR, "Attempt to set the '%s' read-only variable!.\n", name);
return -1;
int res = 0;
for (; cdr; cdr = cdr->next) {
- switch(cause) {
+ switch (cause) {
case AST_CAUSE_BUSY:
ast_cdr_busy(cdr);
break;
/*! Converts AMA flag to printable string */
char *ast_cdr_flags2str(int flag)
{
- switch(flag) {
+ switch (flag) {
case AST_CDR_OMIT:
return "OMIT";
case AST_CDR_BILLING:
int schedms;
int numevents = 0;
- for(;;) {
+ for (;;) {
struct timeval now;
schedms = ast_sched_wait(sched);
/* this shouldn't happen, but provide a 1 second default just in case */
{
char *buf;
- switch(state) {
+ switch (state) {
case AST_STATE_DOWN:
return "Down";
case AST_STATE_RESERVED:
/*! \brief Gives the string form of a given transfer capability */
char *ast_transfercapability2str(int transfercapability)
{
- switch(transfercapability) {
+ switch (transfercapability) {
case AST_TRANS_CAP_SPEECH:
return "SPEECH";
case AST_TRANS_CAP_DIGITAL:
return -1;
}
- switch(chan->_state) {
+ switch (chan->_state) {
case AST_STATE_RINGING:
case AST_STATE_RING:
if (chan->tech->answer)
if (!f)
return -1;
- switch(f->frametype) {
+ switch (f->frametype) {
case AST_FRAME_DTMF:
res = f->subclass;
ast_frfree(f);
return res;
case AST_FRAME_CONTROL:
- switch(f->subclass) {
+ switch (f->subclass) {
case AST_CONTROL_HANGUP:
ast_frfree(f);
return -1;
if (chan->fout & DEBUGCHAN_FLAG)
ast_frame_dump(chan->name, fr, ">>");
CHECK_BLOCKING(chan);
- switch(fr->frametype) {
+ switch (fr->frametype) {
case AST_FRAME_CONTROL:
res = (chan->tech->indicate == NULL) ? 0 :
chan->tech->indicate(chan, fr->subclass, fr->data, fr->datalen);
for (x = e->args; x < a->argc; x++) {
int res = ast_module_reload(a->argv[x]);
/* XXX reload has multiple error returns, including -1 on error and 2 on success */
- switch(res) {
+ switch (res) {
case 0:
ast_cli(a->fd, "No such module '%s'\n", a->argv[x]);
break;
ast_cli(fd, "%s is not a known channel\n", argv[3]);
return RESULT_SUCCESS;
}
- if(c->cdr) {
+ if (c->cdr) {
elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec;
hour = elapsed_seconds / 3600;
min = (elapsed_seconds % 3600) / 60;
( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
- if(pbx_builtin_serialize_variables(c, &out))
+ if (pbx_builtin_serialize_variables(c, &out))
ast_cli(fd," Variables:\n%s\n", out->str);
- if(c->cdr && ast_cdr_serialize_variables(c->cdr, &out, '=', '\n', 1))
+ if (c->cdr && ast_cdr_serialize_variables(c->cdr, &out, '=', '\n', 1))
ast_cli(fd," CDR Variables:\n%s\n", out->str);
ast_channel_unlock(c);
struct ast_cli_entry *cand = NULL, *e=NULL;
struct cli_iterator i = { NULL, NULL};
- while( (e = cli_next(&i)) ) {
+ while ( (e = cli_next(&i)) ) {
/* word-by word regexp comparison */
char * const *src = cmds;
char * const *dst = e->cmda;
{
struct ast_variable *vn;
- while(v) {
+ while (v) {
vn = v;
v = v->next;
free(vn);
{
struct ast_category *prev=NULL, *cat;
cat = cfg->root;
- while(cat) {
+ while (cat) {
if (cat->name == category) {
ast_variables_destroy(cat->root);
if (prev) {
prev = NULL;
cat = cfg->root;
- while(cat) {
+ while (cat) {
if (!strcasecmp(cat->name, category)) {
ast_variables_destroy(cat->root);
if (prev) {
return;
cat = cfg->root;
- while(cat) {
+ while (cat) {
ast_variables_destroy(cat->root);
catn = cat;
cat = cat->next;
if (withcomments && lline_buffer && lline_buffer[0] ) {
newcat->sameline = ALLOC_COMMENT(lline_buffer);
}
- if( withcomments )
+ if ( withcomments )
CB_RESET();
/* If there are options or categories to inherit from, process them now */
/* A directive */
cur++;
c = cur;
- while(*c && (*c > 32)) c++;
+ while (*c && (*c > 32)) c++;
if (*c) {
*c = '\0';
/* Find real argument */
} else
c = NULL;
do_include = !strcasecmp(cur, "include");
- if(!do_include)
+ if (!do_include)
do_exec = !strcasecmp(cur, "exec");
else
do_exec = 0;
if (do_include || do_exec) {
if (c) {
/* Strip off leading and trailing "'s and <>'s */
- while((*c == '<') || (*c == '>') || (*c == '\"')) c++;
+ while ((*c == '<') || (*c == '>') || (*c == '\"')) c++;
/* Get rid of leading mess */
cur = c;
while (!ast_strlen_zero(cur)) {
exec_file[0] = '\0';
/* A #include */
do_include = ast_config_internal_load(cur, cfg, withcomments) ? 1 : 0;
- if(!ast_strlen_zero(exec_file))
+ if (!ast_strlen_zero(exec_file))
unlink(exec_file);
- if(!do_include)
+ if (!do_include)
return 0;
} else {
if (withcomments && lline_buffer && lline_buffer[0] ) {
v->sameline = ALLOC_COMMENT(lline_buffer);
}
- if( withcomments )
+ if ( withcomments )
CB_RESET();
} else {
ast_log(LOG_DEBUG, "Parsing %s\n", fn);
if (option_verbose > 1)
ast_verbose("Found\n");
- while(!feof(f)) {
+ while (!feof(f)) {
lineno++;
if (fgets(buf, sizeof(buf), f)) {
if ( withcomments ) {
/* Yuck, gotta memmove */
memmove(comment_p - 1, comment_p, strlen(comment_p) + 1);
new_buf = comment_p;
- } else if(comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) {
+ } else if (comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) {
/* Meta-Comment start detected ";--" */
if (comment < MAX_NESTED_COMMENTS) {
*comment_p = '\0';
new_buf = comment_p + 1;
}
}
- if( withcomments && comment && !process_buf )
+ if ( withcomments && comment && !process_buf )
{
CB_ADD(buf); /* the whole line is a comment, store it */
}
}
}
fclose(f);
- } while(0);
+ } while (0);
if (comment) {
ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment]);
}
fprintf(f, ";! Creation Date: %s", date);
fprintf(f, ";!\n");
cat = cfg->root;
- while(cat) {
+ while (cat) {
/* Dump section with any appropriate comment */
for (cmt = cat->precomments; cmt; cmt=cmt->next)
{
if (!cat->precomments)
fprintf(f,"\n");
fprintf(f, "[%s]", cat->name);
- for(cmt = cat->sameline; cmt; cmt=cmt->next)
+ for (cmt = cat->sameline; cmt; cmt=cmt->next)
{
fprintf(f,"%s", cmt->cmt);
}
if (!cat->sameline)
fprintf(f,"\n");
var = cat->root;
- while(var) {
+ while (var) {
for (cmt = var->precomments; cmt; cmt=cmt->next)
{
if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
}
if (provider) {
- if(option_debug > 2)
+ if (option_debug > 2)
ast_log(LOG_DEBUG, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number);
return getproviderstate(provider, number);
}
AST_LIST_LOCK(&devstate_provs);
AST_LIST_TRAVERSE_SAFE_BEGIN(&devstate_provs, devprov, list) {
- if(option_debug > 4)
+ if (option_debug > 4)
ast_log(LOG_DEBUG, "Checking provider %s with %s\n", devprov->label, provider);
if (!strcasecmp(devprov->label, provider)) {
struct state_change *cur;
AST_LIST_LOCK(&state_changes);
- for(;;) {
+ for (;;) {
/* the list lock will _always_ be held at this point in the loop */
cur = AST_LIST_REMOVE_HEAD(&state_changes, list);
if (cur) {
int pass;
int newstate = DSP_TONE_STATE_SILENCE;
int res = 0;
- while(len) {
+ while (len) {
/* Take the lesser of the number of samples we need and what we have */
pass = len;
if (pass > dsp->gsamp_size - dsp->gsamps)
printf("%.2e %.2e %.2e %.2e %.2e %.2e %.2e %.2e %.2e\n",
hz[HZ_350], hz[HZ_425], hz[HZ_440], hz[HZ_480], hz[HZ_620], hz[HZ_950], hz[HZ_1400], hz[HZ_1800], dsp->genergy);
#endif
- switch(dsp->progmode) {
+ switch (dsp->progmode) {
case PROG_MODE_NA:
if (pair_there(hz[HZ_480], hz[HZ_620], hz[HZ_350], hz[HZ_440], dsp->genergy)) {
newstate = DSP_TONE_STATE_BUSY;
#define FIX_INF(inf) do { \
if (writeback) { \
- switch(inf->subclass) { \
+ switch (inf->subclass) { \
case AST_FORMAT_SLINEAR: \
break; \
case AST_FORMAT_ULAW: \
odata = af->data;
len = af->datalen;
/* Make sure we have short data */
- switch(af->subclass) {
+ switch (af->subclass) {
case AST_FORMAT_SLINEAR:
shortdata = af->data;
len = af->datalen / 2;
if ((dsp->features & DSP_FEATURE_CALL_PROGRESS)) {
res = __ast_dsp_call_progress(dsp, shortdata, len);
if (res) {
- switch(res) {
+ switch (res) {
case AST_CONTROL_ANSWER:
case AST_CONTROL_BUSY:
case AST_CONTROL_RINGING:
tmp[newpos++] = '.';
}
if (*p2) {
- while(*p2 && newpos < 128){
+ while (*p2 && newpos < 128){
tmp[newpos++] = *p2;
p2++;
}
/* Destroy existing list */
ast_mutex_lock(&enumlock);
s = toplevs;
- while(s) {
+ while (s) {
sl = s;
s = s->next;
free(sl);
if (cfg) {
sl = NULL;
v = ast_variable_browse(cfg, "general");
- while(v) {
+ while (v) {
if (!strcasecmp(v->name, "search")) {
s = enum_newtoplev(v->value);
if (s) {
struct ast_filestream *s = data;
int whennext = 0;
- while(!whennext) {
+ while (!whennext) {
struct ast_frame *fr = s->fmt->read(s, &whennext);
if (!fr /* stream complete */ || ast_write(s->owner, fr) /* error writing */) {
if (fr)
struct ast_frame *fr = ast_read(c);
if (!fr)
return -1;
- switch(fr->frametype) {
+ switch (fr->frametype) {
case AST_FRAME_DTMF_END:
if (context) {
const char exten[2] = { fr->subclass, '\0' };
}
break;
case AST_FRAME_CONTROL:
- switch(fr->subclass) {
+ switch (fr->subclass) {
case AST_CONTROL_HANGUP:
case AST_CONTROL_BUSY:
case AST_CONTROL_CONGESTION:
int x;
char *ret = "unknown";
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
- if(AST_FORMAT_LIST[x].visible && AST_FORMAT_LIST[x].bits == format) {
+ if (AST_FORMAT_LIST[x].visible && AST_FORMAT_LIST[x].bits == format) {
ret = AST_FORMAT_LIST[x].name;
break;
}
int x;
for (x = 0; x < sizeof(ast_codec_alias_table) / sizeof(ast_codec_alias_table[0]); x++) {
- if(!strcmp(in,ast_codec_alias_table[x].alias))
+ if (!strcmp(in,ast_codec_alias_table[x].alias))
return ast_codec_alias_table[x].realname;
}
return in;
all = strcasecmp(name, "all") ? 0 : 1;
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
- if(AST_FORMAT_LIST[x].visible && (all ||
+ if (AST_FORMAT_LIST[x].visible && (all ||
!strcasecmp(AST_FORMAT_LIST[x].name,name) ||
!strcasecmp(AST_FORMAT_LIST[x].name,ast_expand_codec_alias(name)))) {
format |= AST_FORMAT_LIST[x].bits;
- if(!all)
+ if (!all)
break;
}
}
int x;
char *ret = "unknown";
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
- if(AST_FORMAT_LIST[x].visible && AST_FORMAT_LIST[x].bits == codec) {
+ if (AST_FORMAT_LIST[x].visible && AST_FORMAT_LIST[x].bits == codec) {
ret = AST_FORMAT_LIST[x].desc;
break;
}
int x, differential = (int) 'A', mem;
char *from, *to;
- if(right) {
+ if (right) {
from = pref->order;
to = buf;
mem = size;
memset(to, 0, mem);
for (x = 0; x < 32 ; x++) {
- if(!from[x])
+ if (!from[x])
break;
to[x] = right ? (from[x] + differential) : (from[x] - differential);
}
buf[0] = '(';
total_len--;
for(x = 0; x < 32 ; x++) {
- if(total_len <= 0)
+ if (total_len <= 0)
break;
- if(!(codec = ast_codec_pref_index(pref,x)))
+ if (!(codec = ast_codec_pref_index(pref,x)))
break;
- if((formatname = ast_getformatname(codec))) {
+ if ((formatname = ast_getformatname(codec))) {
slen = strlen(formatname);
- if(slen > total_len)
+ if (slen > total_len)
break;
strncat(buf,formatname,total_len);
total_len -= slen;
}
- if(total_len && x < 31 && ast_codec_pref_index(pref , x + 1)) {
+ if (total_len && x < 31 && ast_codec_pref_index(pref , x + 1)) {
strncat(buf,"|",total_len);
total_len--;
}
}
- if(total_len) {
+ if (total_len) {
strncat(buf,")",total_len);
total_len--;
}
int slot = 0;
- if((index >= 0) && (index < sizeof(pref->order))) {
+ if ((index >= 0) && (index < sizeof(pref->order))) {
slot = pref->order[index];
}
int slot;
int size;
- if(!pref->order[0])
+ if (!pref->order[0])
return;
memcpy(&oldorder, pref, sizeof(oldorder));
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
slot = oldorder.order[x];
size = oldorder.framing[x];
- if(! slot)
+ if (! slot)
break;
- if(AST_FORMAT_LIST[slot-1].bits != format) {
+ if (AST_FORMAT_LIST[slot-1].bits != format) {
pref->order[y] = slot;
pref->framing[y++] = size;
}
ast_codec_pref_remove(pref, format);
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
- if(AST_FORMAT_LIST[x].bits == format) {
+ if (AST_FORMAT_LIST[x].bits == format) {
newindex = x + 1;
break;
}
}
- if(newindex) {
+ if (newindex) {
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
- if(!pref->order[x]) {
+ if (!pref->order[x]) {
pref->order[x] = newindex;
break;
}
int x, index = -1;
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
- if(AST_FORMAT_LIST[x].bits == format) {
+ if (AST_FORMAT_LIST[x].bits == format) {
index = x;
break;
}
}
- if(index < 0)
+ if (index < 0)
return -1;
/* size validation */
- if(!framems)
+ if (!framems)
framems = AST_FORMAT_LIST[index].def_ms;
- if(AST_FORMAT_LIST[index].inc_ms && framems % AST_FORMAT_LIST[index].inc_ms) /* avoid division by zero */
+ if (AST_FORMAT_LIST[index].inc_ms && framems % AST_FORMAT_LIST[index].inc_ms) /* avoid division by zero */
framems -= framems % AST_FORMAT_LIST[index].inc_ms;
- if(framems < AST_FORMAT_LIST[index].min_ms)
+ if (framems < AST_FORMAT_LIST[index].min_ms)
framems = AST_FORMAT_LIST[index].min_ms;
- if(framems > AST_FORMAT_LIST[index].max_ms)
+ if (framems > AST_FORMAT_LIST[index].max_ms)
framems = AST_FORMAT_LIST[index].max_ms;
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
- if(pref->order[x] == (index + 1)) {
+ if (pref->order[x] == (index + 1)) {
pref->framing[x] = framems;
break;
}
struct ast_format_list fmt = { 0, };
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
- if(AST_FORMAT_LIST[x].bits == format) {
+ if (AST_FORMAT_LIST[x].bits == format) {
fmt = AST_FORMAT_LIST[x];
index = x;
break;
}
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
- if(pref->order[x] == (index + 1)) {
+ if (pref->order[x] == (index + 1)) {
framems = pref->framing[x];
break;
}
}
/* size validation */
- if(!framems)
+ if (!framems)
framems = AST_FORMAT_LIST[index].def_ms;
- if(AST_FORMAT_LIST[index].inc_ms && framems % AST_FORMAT_LIST[index].inc_ms) /* avoid division by zero */
+ if (AST_FORMAT_LIST[index].inc_ms && framems % AST_FORMAT_LIST[index].inc_ms) /* avoid division by zero */
framems -= framems % AST_FORMAT_LIST[index].inc_ms;
- if(framems < AST_FORMAT_LIST[index].min_ms)
+ if (framems < AST_FORMAT_LIST[index].min_ms)
framems = AST_FORMAT_LIST[index].min_ms;
- if(framems > AST_FORMAT_LIST[index].max_ms)
+ if (framems > AST_FORMAT_LIST[index].max_ms)
framems = AST_FORMAT_LIST[index].max_ms;
fmt.cur_ms = framems;
break;
}
}
- if(ret & AST_FORMAT_AUDIO_MASK)
+ if (ret & AST_FORMAT_AUDIO_MASK)
return ret;
if (option_debug > 3)
int samples = 0;
int olen;
- switch(fskd->state) {
+ switch (fskd->state) {
/* Pick up where we left off */
case STATE_SEARCH_STARTBIT2:
goto search_startbit2;
of a transmission (what a LOSING design), we cant do it this elegantly */
/*
if (demodulator(zap,&x1)) return(-1);
- for(;;) {
+ for (;;) {
if (demodulator(zap,&x2)) return(-1);
if (x1>0 && x2<0) break;
x1 = x2;
if (demodulator(fskd, &fskd->x1, GET_SAMPLE))
return -1;
samples++;
- for(;;) {
+ for (;;) {
search_startbit2:
if (!*len) {
fskd->state = STATE_SEARCH_STARTBIT2;
fskd->state = STATE_SEARCH_STARTBIT3;
return 0;
}
- for(;i;i--) {
+ for (; i; i--) {
if (demodulator(fskd, &fskd->x1, GET_SAMPLE))
return(-1);
#if 0
ast_copy_string(tmp, i->exts, sizeof(tmp));
stringp=tmp;
e = strsep(&stringp, "|");
- while(e) {
+ while (e) {
make_filename(buf, sizeof(buf), filename, preflang, e);
if ((len = file_exists(buf))) {
found = i;
* At least one event
*/
origcnt = ioc->fdcnt;
- for(x = 0; x < origcnt; x++) {
+ for (x = 0; x < origcnt; x++) {
/* Yes, it is possible for an entry to be deleted and still have an
event waiting if it occurs after the original calling id */
if (ioc->fds[x].revents && ioc->ior[x].id) {
if (thists && thists < lastts) jb_warn("XXXX timestamp roll-back!!!\n");
lastts = thists;
#endif
- if(ret == JB_INTERP)
+ if (ret == JB_INTERP)
frameout->ms = jb->info.last_voice_ms;
return ret;
* syslog.facility => level,level,level
*/
facility = strchr(channel, '.');
- if(!facility++ || !facility) {
+ if (!facility++ || !facility) {
facility = "local0";
}
openlog("asterisk", LOG_PID, chan->facility);
} else {
if (channel[0] == '/') {
- if(!ast_strlen_zero(hostname)) {
+ if (!ast_strlen_zero(hostname)) {
snprintf(chan->filename, sizeof(chan->filename) - 1,"%s.%s", channel, hostname);
} else {
ast_copy_string(chan->filename, channel, sizeof(chan->filename));
}
}
- if(!ast_strlen_zero(hostname)) {
+ if (!ast_strlen_zero(hostname)) {
snprintf(chan->filename, sizeof(chan->filename), "%s/%s.%s", ast_config_AST_LOG_DIR, channel, hostname);
} else {
snprintf(chan->filename, sizeof(chan->filename), "%s/%s", ast_config_AST_LOG_DIR, channel);
static int handle_logger_reload(int fd, int argc, char *argv[])
{
- if(reload_logger(0)) {
+ if (reload_logger(0)) {
ast_cli(fd, "Failed to reload the logger\n");
return RESULT_FAILURE;
} else
static int handle_logger_rotate(int fd, int argc, char *argv[])
{
- if(reload_logger(1)) {
+ if (reload_logger(1)) {
ast_cli(fd, "Failed to reload the logger and rotate log files\n");
return RESULT_FAILURE;
} else
nextexp = NULL;
nextthing = strchr(whereweare, '$');
if (nextthing) {
- switch(nextthing[1]) {
+ switch (nextthing[1]) {
case '{':
nextvar = nextthing;
pos = nextvar - whereweare;
needsub = 0;
/* Find the end of it */
- while(brackets && *vare) {
+ while (brackets && *vare) {
if ((vare[0] == '$') && (vare[1] == '[')) {
needsub++;
brackets++;
if (c->cdr && ast_opt_end_cdr_before_h_exten)
ast_cdr_end(c->cdr);
set_ext_pri(c, "h", 1);
- while(ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) {
+ while (ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) {
if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num))) {
/* Something bad happened, or a hangup has been requested. */
if (option_debug)
int count=0;
while (*src && (count < len - 1)) {
- switch(*src) {
+ switch (*src) {
case ' ':
/* otherwise exten => [a-b],1,... doesn't work */
/* case '-': */
if (option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", chan->name);
- if(chan->cdr) { /* update the cdr */
+ if (chan->cdr) { /* update the cdr */
/* here we update the status of the call, which sould be busy.
* if that fails then we set the status to failed */
if (ast_cdr_disposition(chan->cdr, chan->hangupcause))
ast_log(LOG_WARNING, "%s already has a call record??\n", chan->name);
} else {
chan->cdr = ast_cdr_alloc(); /* allocate a cdr for the channel */
- if(!chan->cdr) {
+ if (!chan->cdr) {
/* allocation of the cdr failed */
free(chan->pbx);
res = -1;
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
- while(!res && (num || playh)) {
+ while (!res && (num || playh)) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
}
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
- while(!res && (num || playh)) {
+ while (!res && (num || playh)) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
num -= left * (exp10_int(length-1));
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) {
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
} else {
if (options && !strncasecmp(options, "n",1)) cn = -1;
- while(!res && (num || playh || playa )) {
+ while (!res && (num || playh || playa )) {
/* The grammar for Danish numbers is the same as for English except
* for the following:
* - 1 exists in both commune ("en", file "1N") and neuter ("et", file "1")
}
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
if (options && (!strncasecmp(options, "f",1)))
mf = -1;
- while(!res && num) {
+ while (!res && num) {
/* The grammar for German numbers is the same as for English except
* for the following:
* - numbers 20 through 99 are said in reverse order, i.e. 21 is
res = -1;
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
- while(!res && (num || playh || playa )) {
+ while (!res && (num || playh || playa )) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
if (options && !strncasecmp(options, "f",1))
mf = -1;
- while(!res && (num || playh || playa)) {
+ while (!res && (num || playh || playa)) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
res = -1;
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
mf = -1;
/* Do we have work to do? */
- while(!res && (num || (state>0) )) {
+ while (!res && (num || (state>0) )) {
/* first type of work: play a second sound. In this loop
* we can only play one sound file at a time. Thus playing
* a second one requires repeating the loop just for the
res = -1;
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
So the right file is provided.
*/
- while(!res && (num || playh)) {
+ while (!res && (num || playh)) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
}
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
if (options && !strncasecmp(options, "n",1)) cn = -1;
- while(!res && (num || playh || playa )) {
+ while (!res && (num || playh || playa )) {
/* The grammar for Norwegian numbers is the same as for English except
* for the following:
* - 1 exists in both commune ("en", file "1") and neuter ("ett", file "1N")
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
if (options && !strncasecmp(options, "f",1))
mf = -1;
- while(!res && num ) {
+ while (!res && num ) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
if (options && !strncasecmp(options, "n",1)) cn = -1;
- while(!res && (num || playh)) {
+ while (!res && (num || playh)) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
}
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
- while(!res && (num || playh)) {
+ while (!res && (num || playh)) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
}
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
- while(!res && (num)) {
+ while (!res && (num)) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
num = 0;
}
} else if (num < 20) {
- if(options && strlen(options) == 1 && num < 3) {
+ if (options && strlen(options) == 1 && num < 3) {
snprintf(fn, sizeof(fn), "digits/%d%s", num, options);
} else {
snprintf(fn, sizeof(fn), "digits/%d", num);
int res = 0, t = 0;
char fn[256] = "";
- while(!res && num) {
+ while (!res && num) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
if ( num > INT_MIN ) {
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
- while(!res && num) {
+ while (!res && num) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
if ( num > INT_MIN ) {
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
- while(!res && num) {
+ while (!res && num) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
if ( num > INT_MIN ) {
} else {
snprintf(nextmsg,sizeof(nextmsg), "digits/h-%dh", tm.tm_mday - (tm.tm_mday % 10));
res = wait_file(chan,ints,nextmsg,lang);
- if(!res) {
+ if (!res) {
snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday % 10);
res = wait_file(chan,ints,nextmsg,lang);
}
return ast_waitstream(chan, ints);
}
- while(!res && num ) {
+ while (!res && num ) {
i++;
if (num < 13) {
snprintf(fn, sizeof(fn), "digits/%d", num);
}
}
if (!res) {
- if(!ast_streamfile(chan, fn, language)) {
+ if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
pure integer */
s = host;
res = 0;
- while(s && *s) {
+ while (s && *s) {
if (*s == '.')
dots++;
else if (!isdigit(*s))
unsigned int byte = 0;
unsigned int bits = 0;
int incnt = 0;
- while(*src && (cnt < max)) {
+ while (*src && (cnt < max)) {
/* Shift in 6 bits of input */
byte <<= 6;
byte |= (b2a[(int)(*src)]) & 0x3f;