aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-07-10 19:05:48 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-07-10 19:05:48 +0000
commit9ded857bf6bed71f477322c64d4813ebb7856e37 (patch)
tree33176ce63675a2ab5cbbbf7cf1c5bc5f313bf7d1
parent0ba03dd946dd3a888651da225930033e0e26c973 (diff)
Whitespace changes only
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@37345 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--acl.c9
-rw-r--r--dns.c50
-rw-r--r--plc.c32
-rw-r--r--sched.c8
-rw-r--r--sha1.c256
-rw-r--r--slinfactory.c2
-rw-r--r--tdd.c135
-rw-r--r--translate.c53
-rw-r--r--udptl.c154
-rw-r--r--ulaw.c18
-rw-r--r--utils.c24
11 files changed, 355 insertions, 386 deletions
diff --git a/acl.c b/acl.c
index b3ca90362..15057aa24 100644
--- a/acl.c
+++ b/acl.c
@@ -90,7 +90,7 @@ struct my_ifreq {
void ast_free_ha(struct ast_ha *ha)
{
struct ast_ha *hal;
- while(ha) {
+ while (ha) {
hal = ha;
ha = ha->next;
free(hal);
@@ -122,9 +122,9 @@ static struct ast_ha *ast_duplicate_ha(struct ast_ha *original)
/* Used in chan_sip2 templates */
struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original)
{
- struct ast_ha *start=original;
+ struct ast_ha *start = original;
struct ast_ha *ret = NULL;
- struct ast_ha *link,*prev=NULL;
+ struct ast_ha *link, *prev = NULL;
while (start) {
link = ast_duplicate_ha(start); /* Create copy of this object */
@@ -167,7 +167,7 @@ struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path)
if (!strchr(nm, '.')) {
if ((sscanf(nm, "%d", &x) == 1) && (x >= 0) && (x <= 32)) {
y = 0;
- for (z=0;z<x;z++) {
+ for (z = 0; z < x; z++) {
y >>= 1;
y |= 0x80000000;
}
@@ -423,3 +423,4 @@ int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr)
return 0;
return -1;
}
+
diff --git a/dns.c b/dns.c
index d3393267e..d214ef3e9 100644
--- a/dns.c
+++ b/dns.c
@@ -48,40 +48,40 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define MAX_SIZE 4096
typedef struct {
- unsigned id :16; /*!< query identification number */
+ unsigned id:16; /*!< query identification number */
#if __BYTE_ORDER == __BIG_ENDIAN
/* fields in third byte */
- unsigned qr: 1; /*!< response flag */
- unsigned opcode: 4; /*!< purpose of message */
- unsigned aa: 1; /*!< authoritive answer */
- unsigned tc: 1; /*!< truncated message */
- unsigned rd: 1; /*!< recursion desired */
+ unsigned qr:1; /*!< response flag */
+ unsigned opcode:4; /*!< purpose of message */
+ unsigned aa:1; /*!< authoritive answer */
+ unsigned tc:1; /*!< truncated message */
+ unsigned rd:1; /*!< recursion desired */
/* fields in fourth byte */
- unsigned ra: 1; /*!< recursion available */
- unsigned unused :1; /*!< unused bits (MBZ as of 4.9.3a3) */
- unsigned ad: 1; /*!< authentic data from named */
- unsigned cd: 1; /*!< checking disabled by resolver */
- unsigned rcode :4; /*!< response code */
+ unsigned ra:1; /*!< recursion available */
+ unsigned unused:1; /*!< unused bits (MBZ as of 4.9.3a3) */
+ unsigned ad:1; /*!< authentic data from named */
+ unsigned cd:1; /*!< checking disabled by resolver */
+ unsigned rcode:4; /*!< response code */
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN
/* fields in third byte */
- unsigned rd :1; /*!< recursion desired */
- unsigned tc :1; /*!< truncated message */
- unsigned aa :1; /*!< authoritive answer */
- unsigned opcode :4; /*!< purpose of message */
- unsigned qr :1; /*!< response flag */
+ unsigned rd:1; /*!< recursion desired */
+ unsigned tc:1; /*!< truncated message */
+ unsigned aa:1; /*!< authoritive answer */
+ unsigned opcode:4; /*!< purpose of message */
+ unsigned qr:1; /*!< response flag */
/* fields in fourth byte */
- unsigned rcode :4; /*!< response code */
- unsigned cd: 1; /*!< checking disabled by resolver */
- unsigned ad: 1; /*!< authentic data from named */
- unsigned unused :1; /*!< unused bits (MBZ as of 4.9.3a3) */
- unsigned ra :1; /*!< recursion available */
+ unsigned rcode:4; /*!< response code */
+ unsigned cd:1; /*!< checking disabled by resolver */
+ unsigned ad:1; /*!< authentic data from named */
+ unsigned unused:1; /*!< unused bits (MBZ as of 4.9.3a3) */
+ unsigned ra:1; /*!< recursion available */
#endif
/* remaining bytes */
- unsigned qdcount :16; /*!< number of question entries */
- unsigned ancount :16; /*!< number of answer entries */
- unsigned nscount :16; /*!< number of authority entries */
- unsigned arcount :16; /*!< number of resource entries */
+ unsigned qdcount:16; /*!< number of question entries */
+ unsigned ancount:16; /*!< number of answer entries */
+ unsigned nscount:16; /*!< number of authority entries */
+ unsigned arcount:16; /*!< number of resource entries */
} dns_HEADER;
struct dn_answer {
diff --git a/plc.c b/plc.c
index 143c8adea..336a99030 100644
--- a/plc.c
+++ b/plc.c
@@ -71,13 +71,13 @@ static void save_history(plc_state_t *s, int16_t *buf, int len)
{
if (len >= PLC_HISTORY_LEN) {
/* Just keep the last part of the new data, starting at the beginning of the buffer */
- memcpy(s->history, buf + len - PLC_HISTORY_LEN, sizeof(int16_t)*PLC_HISTORY_LEN);
+ memcpy(s->history, buf + len - PLC_HISTORY_LEN, sizeof(int16_t) * PLC_HISTORY_LEN);
s->buf_ptr = 0;
return;
}
if (s->buf_ptr + len > PLC_HISTORY_LEN) {
/* Wraps around - must break into two sections */
- memcpy(s->history + s->buf_ptr, buf, sizeof(int16_t)*(PLC_HISTORY_LEN - s->buf_ptr));
+ memcpy(s->history + s->buf_ptr, buf, sizeof(int16_t) * (PLC_HISTORY_LEN - s->buf_ptr));
len -= (PLC_HISTORY_LEN - s->buf_ptr);
memcpy(s->history, buf + (PLC_HISTORY_LEN - s->buf_ptr), sizeof(int16_t)*len);
s->buf_ptr = len;
@@ -97,8 +97,8 @@ static void normalise_history(plc_state_t *s)
if (s->buf_ptr == 0)
return;
memcpy(tmp, s->history, sizeof(int16_t)*s->buf_ptr);
- memcpy(s->history, s->history + s->buf_ptr, sizeof(int16_t)*(PLC_HISTORY_LEN - s->buf_ptr));
- memcpy(s->history + PLC_HISTORY_LEN - s->buf_ptr, tmp, sizeof(int16_t)*s->buf_ptr);
+ memcpy(s->history, s->history + s->buf_ptr, sizeof(int16_t) * (PLC_HISTORY_LEN - s->buf_ptr));
+ memcpy(s->history + PLC_HISTORY_LEN - s->buf_ptr, tmp, sizeof(int16_t) * s->buf_ptr);
s->buf_ptr = 0;
}
@@ -114,9 +114,9 @@ static int __inline__ amdf_pitch(int min_pitch, int max_pitch, int16_t amp[], in
pitch = min_pitch;
min_acc = INT_MAX;
- for (i = max_pitch; i <= min_pitch; i++) {
+ for (i = max_pitch; i <= min_pitch; i++) {
acc = 0;
- for (j = 0; j < len; j++)
+ for (j = 0; j < len; j++)
acc += abs(amp[i + j] - amp[j]);
if (acc < min_acc) {
min_acc = acc;
@@ -154,8 +154,8 @@ int plc_rx(plc_state_t *s, int16_t amp[], int len)
old_step = new_step*gain;
new_weight = new_step;
old_weight = (1.0 - new_step)*gain;
- for (i = 0; i < pitch_overlap; i++) {
- amp[i] = fsaturate(old_weight*s->pitchbuf[s->pitch_offset] + new_weight*amp[i]);
+ for (i = 0; i < pitch_overlap; i++) {
+ amp[i] = fsaturate(old_weight * s->pitchbuf[s->pitch_offset] + new_weight * amp[i]);
if (++s->pitch_offset >= s->pitch)
s->pitch_offset = 0;
new_weight += new_step;
@@ -200,8 +200,8 @@ int plc_fillin(plc_state_t *s, int16_t amp[], int len)
/* The last 1/4 of the cycle is overlapped with the end of the previous cycle */
new_step = 1.0/pitch_overlap;
new_weight = new_step;
- for ( ; i < s->pitch; i++) {
- s->pitchbuf[i] = s->history[PLC_HISTORY_LEN - s->pitch + i]*(1.0 - new_weight) + s->history[PLC_HISTORY_LEN - 2*s->pitch + i]*new_weight;
+ for ( ; i < s->pitch; i++) {
+ s->pitchbuf[i] = s->history[PLC_HISTORY_LEN - s->pitch + i] * (1.0 - new_weight) + s->history[PLC_HISTORY_LEN - 2 * s->pitch + i]*new_weight;
new_weight += new_step;
}
/* We should now be ready to fill in the gap with repeated, decaying cycles
@@ -211,12 +211,12 @@ int plc_fillin(plc_state_t *s, int16_t amp[], int len)
it into the previous real data. To avoid the need to introduce a delay
in the stream, reverse the last 1/4 wavelength, and OLA with that. */
gain = 1.0;
- new_step = 1.0/pitch_overlap;
+ new_step = 1.0 / pitch_overlap;
old_step = new_step;
new_weight = new_step;
old_weight = 1.0 - new_step;
- for (i = 0; i < pitch_overlap; i++) {
- amp[i] = fsaturate(old_weight*s->history[PLC_HISTORY_LEN - 1 - i] + new_weight*s->pitchbuf[i]);
+ for (i = 0; i < pitch_overlap; i++) {
+ amp[i] = fsaturate(old_weight * s->history[PLC_HISTORY_LEN - 1 - i] + new_weight * s->pitchbuf[i]);
new_weight += new_step;
old_weight -= old_step;
if (old_weight < 0.0)
@@ -227,13 +227,13 @@ int plc_fillin(plc_state_t *s, int16_t amp[], int len)
gain = 1.0 - s->missing_samples*ATTENUATION_INCREMENT;
i = 0;
}
- for ( ; gain > 0.0 && i < len; i++) {
- amp[i] = s->pitchbuf[s->pitch_offset]*gain;
+ for ( ; gain > 0.0 && i < len; i++) {
+ amp[i] = s->pitchbuf[s->pitch_offset] * gain;
gain -= ATTENUATION_INCREMENT;
if (++s->pitch_offset >= s->pitch)
s->pitch_offset = 0;
}
- for ( ; i < len; i++)
+ for ( ; i < len; i++)
amp[i] = 0;
s->missing_samples += orig_len;
save_history(s, amp, len);
diff --git a/sched.c b/sched.c
index ee5ce383b..81a62507c 100644
--- a/sched.c
+++ b/sched.c
@@ -68,7 +68,7 @@ struct sched_context {
ast_mutex_t lock;
int eventcnt; /*!< Number of events processed */
int schedcnt; /*!< Number of outstanding schedule events */
- AST_LIST_HEAD_NOLOCK(, sched) schedq; /*!< Schedule entry and main queue */
+ AST_LIST_HEAD_NOLOCK(, sched) schedq; /*!< Schedule entry and main queue */
#ifdef SCHED_MAX_CACHE
AST_LIST_HEAD_NOLOCK(, sched) schedc; /*!< Cache of unused schedule structures and how many */
@@ -261,7 +261,7 @@ int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, vo
*/
int ast_sched_del(struct sched_context *con, int id)
{
- struct sched *s;
+ struct sched *s;
DEBUG(ast_log(LOG_DEBUG, "ast_sched_del()\n"));
@@ -309,7 +309,7 @@ void ast_sched_dump(const struct sched_context *con)
ast_log(LOG_DEBUG, "|ID Callback Data Time (sec:ms) |\n");
ast_log(LOG_DEBUG, "+-----+-----------------+-----------------+-----------------+\n");
AST_LIST_TRAVERSE(&con->schedq, q, list) {
- struct timeval delta = ast_tvsub(q->when, tv);
+ struct timeval delta = ast_tvsub(q->when, tv);
ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n",
q->id,
@@ -334,7 +334,7 @@ int ast_sched_runq(struct sched_context *con)
DEBUG(ast_log(LOG_DEBUG, "ast_sched_runq()\n"));
ast_mutex_lock(&con->lock);
- for(;;) {
+ for (;;) {
if (AST_LIST_EMPTY(&con->schedq))
break;
diff --git a/sha1.c b/sha1.c
index f81096a5d..16ddd6aa3 100644
--- a/sha1.c
+++ b/sha1.c
@@ -90,23 +90,22 @@ void SHA1ProcessMessageBlock(SHA1Context *);
*/
int SHA1Reset(SHA1Context *context)
{
- if (!context)
- {
- return shaNull;
+ if (!context) {
+ return shaNull;
}
- context->Length_Low = 0;
- context->Length_High = 0;
- context->Message_Block_Index = 0;
+ context->Length_Low = 0;
+ context->Length_High = 0;
+ context->Message_Block_Index = 0;
- context->Intermediate_Hash[0] = 0x67452301;
- context->Intermediate_Hash[1] = 0xEFCDAB89;
- context->Intermediate_Hash[2] = 0x98BADCFE;
- context->Intermediate_Hash[3] = 0x10325476;
- context->Intermediate_Hash[4] = 0xC3D2E1F0;
+ context->Intermediate_Hash[0] = 0x67452301;
+ context->Intermediate_Hash[1] = 0xEFCDAB89;
+ context->Intermediate_Hash[2] = 0x98BADCFE;
+ context->Intermediate_Hash[3] = 0x10325476;
+ context->Intermediate_Hash[4] = 0xC3D2E1F0;
- context->Computed = 0;
- context->Corrupted = 0;
+ context->Computed = 0;
+ context->Corrupted = 0;
return shaSuccess;
}
@@ -135,34 +134,27 @@ int SHA1Result( SHA1Context *context,
{
int i;
- if (!context || !Message_Digest)
- {
- return shaNull;
+ if (!context || !Message_Digest) {
+ return shaNull;
}
- if (context->Corrupted)
- {
- return context->Corrupted;
+ if (context->Corrupted) {
+ return context->Corrupted;
}
- if (!context->Computed)
- {
- SHA1PadMessage(context);
- for(i=0; i<64; ++i)
- {
- /* message may be sensitive, clear it out */
- context->Message_Block[i] = 0;
- }
- context->Length_Low = 0; /* and clear length */
- context->Length_High = 0;
- context->Computed = 1;
-
+ if (!context->Computed) {
+ SHA1PadMessage(context);
+ for (i = 0; i < 64; ++i) {
+ /* message may be sensitive, clear it out */
+ context->Message_Block[i] = 0;
+ }
+ context->Length_Low = 0; /* and clear length */
+ context->Length_High = 0;
+ context->Computed = 1;
}
- for(i = 0; i < SHA1HashSize; ++i)
- {
- Message_Digest[i] = context->Intermediate_Hash[i>>2]
- >> 8 * ( 3 - ( i & 0x03 ) );
+ for (i = 0; i < SHA1HashSize; ++i) {
+ Message_Digest[i] = context->Intermediate_Hash[i >> 2] >> 8 * ( 3 - ( i & 0x03 ) );
}
return shaSuccess;
@@ -188,52 +180,42 @@ int SHA1Result( SHA1Context *context,
* sha Error Code.
*
*/
-int SHA1Input( SHA1Context *context,
- const uint8_t *message_array,
- unsigned length)
+int SHA1Input(SHA1Context *context, const uint8_t *message_array, unsigned length)
{
- if (!length)
- {
- return shaSuccess;
+ if (!length) {
+ return shaSuccess;
}
- if (!context || !message_array)
- {
- return shaNull;
+ if (!context || !message_array) {
+ return shaNull;
}
- if (context->Computed)
- {
- context->Corrupted = shaStateError;
- return shaStateError;
+ if (context->Computed) {
+ context->Corrupted = shaStateError;
+ return shaStateError;
}
- if (context->Corrupted)
- {
- return context->Corrupted;
- }
- while(length-- && !context->Corrupted)
- {
- context->Message_Block[context->Message_Block_Index++] =
- (*message_array & 0xFF);
-
- context->Length_Low += 8;
- if (context->Length_Low == 0)
- {
- context->Length_High++;
- if (context->Length_High == 0)
- {
- /* Message is too long */
- context->Corrupted = 1;
- }
+ if (context->Corrupted) {
+ return context->Corrupted;
}
- if (context->Message_Block_Index == 64)
- {
- SHA1ProcessMessageBlock(context);
- }
+ while (length-- && !context->Corrupted) {
+ context->Message_Block[context->Message_Block_Index++] = (*message_array & 0xFF);
- message_array++;
+ context->Length_Low += 8;
+ if (context->Length_Low == 0) {
+ context->Length_High++;
+ if (context->Length_High == 0) {
+ /* Message is too long */
+ context->Corrupted = 1;
+ }
+ }
+
+ if (context->Message_Block_Index == 64) {
+ SHA1ProcessMessageBlock(context);
+ }
+
+ message_array++;
}
return shaSuccess;
@@ -261,30 +243,28 @@ int SHA1Input( SHA1Context *context,
*/
void SHA1ProcessMessageBlock(SHA1Context *context)
{
- const uint32_t K[] = { /* Constants defined in SHA-1 */
- 0x5A827999,
- 0x6ED9EBA1,
- 0x8F1BBCDC,
- 0xCA62C1D6
- };
+ const uint32_t K[] = { /* Constants defined in SHA-1 */
+ 0x5A827999,
+ 0x6ED9EBA1,
+ 0x8F1BBCDC,
+ 0xCA62C1D6
+ };
int t; /* Loop counter */
- uint32_t temp; /* Temporary word value */
- uint32_t W[80]; /* Word sequence */
- uint32_t A, B, C, D, E; /* Word buffers */
+ uint32_t temp; /* Temporary word value */
+ uint32_t W[80]; /* Word sequence */
+ uint32_t A, B, C, D, E; /* Word buffers */
/*
* Initialize the first 16 words in the array W
*/
- for(t = 0; t < 16; t++)
- {
- W[t] = context->Message_Block[t * 4] << 24;
- W[t] |= context->Message_Block[t * 4 + 1] << 16;
- W[t] |= context->Message_Block[t * 4 + 2] << 8;
- W[t] |= context->Message_Block[t * 4 + 3];
+ for (t = 0; t < 16; t++) {
+ W[t] = context->Message_Block[t * 4] << 24;
+ W[t] |= context->Message_Block[t * 4 + 1] << 16;
+ W[t] |= context->Message_Block[t * 4 + 2] << 8;
+ W[t] |= context->Message_Block[t * 4 + 3];
}
- for(t = 16; t < 80; t++)
- {
+ for (t = 16; t < 80; t++) {
W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
}
@@ -294,46 +274,40 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
D = context->Intermediate_Hash[3];
E = context->Intermediate_Hash[4];
- for(t = 0; t < 20; t++)
- {
- temp = SHA1CircularShift(5,A) +
- ((B & C) | ((~B) & D)) + E + W[t] + K[0];
- E = D;
- D = C;
- C = SHA1CircularShift(30,B);
- B = A;
- A = temp;
+ for (t = 0; t < 20; t++) {
+ temp = SHA1CircularShift(5,A) + ((B & C) | ((~B) & D)) + E + W[t] + K[0];
+ E = D;
+ D = C;
+ C = SHA1CircularShift(30,B);
+ B = A;
+ A = temp;
}
- for(t = 20; t < 40; t++)
- {
- temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
- E = D;
- D = C;
- C = SHA1CircularShift(30,B);
- B = A;
- A = temp;
+ for (t = 20; t < 40; t++) {
+ temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
+ E = D;
+ D = C;
+ C = SHA1CircularShift(30,B);
+ B = A;
+ A = temp;
}
- for(t = 40; t < 60; t++)
- {
- temp = SHA1CircularShift(5,A) +
- ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
- E = D;
- D = C;
- C = SHA1CircularShift(30,B);
- B = A;
- A = temp;
+ for (t = 40; t < 60; t++) {
+ temp = SHA1CircularShift(5,A) + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
+ E = D;
+ D = C;
+ C = SHA1CircularShift(30,B);
+ B = A;
+ A = temp;
}
- for(t = 60; t < 80; t++)
- {
- temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
- E = D;
- D = C;
- C = SHA1CircularShift(30,B);
- B = A;
- A = temp;
+ for (t = 60; t < 80; t++) {
+ temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
+ E = D;
+ D = C;
+ C = SHA1CircularShift(30,B);
+ B = A;
+ A = temp;
}
context->Intermediate_Hash[0] += A;
@@ -377,28 +351,22 @@ void SHA1PadMessage(SHA1Context *context)
* block, process it, and then continue padding into a second
* block.
*/
- if (context->Message_Block_Index > 55)
- {
- context->Message_Block[context->Message_Block_Index++] = 0x80;
- while(context->Message_Block_Index < 64)
- {
- context->Message_Block[context->Message_Block_Index++] = 0;
- }
-
- SHA1ProcessMessageBlock(context);
-
- while(context->Message_Block_Index < 56)
- {
- context->Message_Block[context->Message_Block_Index++] = 0;
- }
- }
- else
- {
- context->Message_Block[context->Message_Block_Index++] = 0x80;
- while(context->Message_Block_Index < 56)
- {
- context->Message_Block[context->Message_Block_Index++] = 0;
- }
+ if (context->Message_Block_Index > 55) {
+ context->Message_Block[context->Message_Block_Index++] = 0x80;
+ while (context->Message_Block_Index < 64) {
+ context->Message_Block[context->Message_Block_Index++] = 0;
+ }
+
+ SHA1ProcessMessageBlock(context);
+
+ while (context->Message_Block_Index < 56) {
+ context->Message_Block[context->Message_Block_Index++] = 0;
+ }
+ } else {
+ context->Message_Block[context->Message_Block_Index++] = 0x80;
+ while (context->Message_Block_Index < 56) {
+ context->Message_Block[context->Message_Block_Index++] = 0;
+ }
}
/*
diff --git a/slinfactory.c b/slinfactory.c
index 21dcdd067..56731266e 100644
--- a/slinfactory.c
+++ b/slinfactory.c
@@ -88,7 +88,7 @@ int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
if (frame) {
int x = 0;
- for (frame_ptr = sf->queue; frame_ptr && frame_ptr->next; frame_ptr=frame_ptr->next) {
+ for (frame_ptr = sf->queue; frame_ptr && frame_ptr->next; frame_ptr = frame_ptr->next) {
x++;
}
if (frame_ptr) {
diff --git a/tdd.c b/tdd.c
index 447059822..0d7405c8b 100644
--- a/tdd.c
+++ b/tdd.c
@@ -63,20 +63,28 @@ static float tddsb = 176.0; /* 45.5 baud */
static int tdd_decode_baudot(struct tdd_state *tdd,unsigned char data) /* covert baudot into ASCII */
{
- static char ltrs[32]={'<','E','\n','A',' ','S','I','U',
- '\n','D','R','J','N','F','C','K',
- 'T','Z','L','W','H','Y','P','Q',
- 'O','B','G','^','M','X','V','^'};
- static char figs[32]={'<','3','\n','-',' ',',','8','7',
- '\n','$','4','\'',',','·',':','(',
- '5','+',')','2','·','6','0','1',
- '9','7','·','^','.','/','=','^'};
- int d;
- d=0; /* return 0 if not decodeable */
+ static char ltrs[32] = { '<','E','\n','A',' ','S','I','U',
+ '\n','D','R','J','N','F','C','K',
+ 'T','Z','L','W','H','Y','P','Q',
+ 'O','B','G','^','M','X','V','^' };
+ static char figs[32] = { '<','3','\n','-',' ',',','8','7',
+ '\n','$','4','\'',',','·',':','(',
+ '5','+',')','2','·','6','0','1',
+ '9','7','·','^','.','/','=','^' };
+ int d = 0; /* return 0 if not decodeable */
switch (data) {
- case 0x1f : tdd->modo=0; break;
- case 0x1b : tdd->modo=1; break;
- default: if (tdd->modo==0) d=ltrs[data]; else d=figs[data]; break;
+ case 0x1f:
+ tdd->modo = 0;
+ break;
+ case 0x1b:
+ tdd->modo = 1;
+ break;
+ default:
+ if (tdd->modo == 0)
+ d = ltrs[data];
+ else
+ d = figs[data];
+ break;
}
return d;
}
@@ -96,16 +104,16 @@ struct tdd_state *tdd_new(void)
tdd = malloc(sizeof(struct tdd_state));
if (tdd) {
memset(tdd, 0, sizeof(struct tdd_state));
- tdd->fskd.spb = 176; /* 45.5 baud */
- tdd->fskd.hdlc = 0; /* Async */
- tdd->fskd.nbit = 5; /* 5 bits */
- tdd->fskd.nstop = 1.5; /* 1.5 stop bits */
- tdd->fskd.paridad = 0; /* No parity */
- tdd->fskd.bw=0; /* Filter 75 Hz */
- tdd->fskd.f_mark_idx = 0; /* 1400 Hz */
- tdd->fskd.f_space_idx = 1; /* 1800 Hz */
- tdd->fskd.pcola = 0; /* No clue */
- tdd->fskd.cont = 0; /* Digital PLL reset */
+ tdd->fskd.spb = 176; /* 45.5 baud */
+ tdd->fskd.hdlc = 0; /* Async */
+ tdd->fskd.nbit = 5; /* 5 bits */
+ tdd->fskd.nstop = 1.5; /* 1.5 stop bits */
+ tdd->fskd.paridad = 0; /* No parity */
+ tdd->fskd.bw=0; /* Filter 75 Hz */
+ tdd->fskd.f_mark_idx = 0; /* 1400 Hz */
+ tdd->fskd.f_space_idx = 1; /* 1800 Hz */
+ tdd->fskd.pcola = 0; /* No clue */
+ tdd->fskd.cont = 0; /* Digital PLL reset */
tdd->fskd.x0 = 0.0;
tdd->fskd.state = 0;
tdd->pos = 0;
@@ -119,10 +127,8 @@ int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len)
{
int pos = 0;
int cnt;
- while(len) {
- cnt = len;
- if (cnt > sizeof(ecdisa))
- cnt = sizeof(ecdisa);
+ while (len) {
+ cnt = len > sizeof(ecdisa) ? sizeof(ecdisa) : len;
memcpy(outbuf + pos, ecdisa, cnt);
pos += cnt;
len -= cnt;
@@ -146,14 +152,14 @@ int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int len)
memset(buf, 0, 2 * len + tdd->oldlen);
memcpy(buf, tdd->oldstuff, tdd->oldlen);
mylen += tdd->oldlen/2;
- for (x=0;x<len;x++)
- buf[x+tdd->oldlen/2] = AST_MULAW(ubuf[x]);
+ for (x = 0; x < len; x++)
+ buf[x + tdd->oldlen / 2] = AST_MULAW(ubuf[x]);
c = res = 0;
- while(mylen >= 1320) { /* has to have enough to work on */
+ while (mylen >= 1320) { /* has to have enough to work on */
olen = mylen;
res = fsk_serie(&tdd->fskd, buf, &mylen, &b);
if (mylen < 0) {
- ast_log(LOG_ERROR, "fsk_serie made mylen < 0 (%d) (olen was %d)\n", mylen,olen);
+ ast_log(LOG_ERROR, "fsk_serie made mylen < 0 (%d) (olen was %d)\n", mylen, olen);
free(obuf);
return -1;
}
@@ -178,7 +184,7 @@ int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int len)
} else
tdd->oldlen = 0;
free(obuf);
- if (res) {
+ if (res) {
tdd->mode = 2; /* put it in mode where it
reliably puts teleprinter in correct shift mode */
return(c);
@@ -243,7 +249,7 @@ static inline float tdd_getcarrier(float *cr, float *ci, int bit)
int z; \
unsigned char b = (byte); \
PUT_TDD_BAUD(0); /* Start bit */ \
- for (z=0;z<5;z++) { \
+ for (z = 0; z < 5; z++) { \
PUT_TDD_BAUD(b & 1); \
b >>= 1; \
} \
@@ -267,57 +273,48 @@ int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *str)
#if 0
printf("%c",c); fflush(stdout);
#endif
- if (c == 0) /* send null */
- {
+ if (c == 0) { /* send null */
PUT_TDD(0);
continue;
- }
- if (c == '\r') /* send c/r */
- {
+ }
+ if (c == '\r') { /* send c/r */
PUT_TDD(8);
continue;
- }
- if (c == '\n') /* send c/r and l/f */
- {
+ }
+ if (c == '\n') { /* send c/r and l/f */
PUT_TDD(8);
PUT_TDD(2);
continue;
- }
- if (c == ' ') /* send space */
- {
+ }
+ if (c == ' ') { /* send space */
PUT_TDD(4);
continue;
- }
- for(i = 0; i < 31; i++)
- {
- if (lstr[i] == c) break;
- }
- if (i < 31) /* if we found it */
- {
- if (tdd->mode) /* if in figs mode, change it */
- {
+ }
+ for (i = 0; i < 31; i++) {
+ if (lstr[i] == c)
+ break;
+ }
+ if (i < 31) { /* if we found it */
+ if (tdd->mode) { /* if in figs mode, change it */
PUT_TDD(31); /* Send LTRS */
tdd->mode = 0;
- }
+ }
PUT_TDD(i);
continue;
- }
- for(i = 0; i < 31; i++)
- {
- if (fstr[i] == c) break;
- }
- if (i < 31) /* if we found it */
- {
- if (tdd->mode != 1) /* if in ltrs mode, change it */
- {
- PUT_TDD(27); /* send FIGS */
+ }
+ for (i = 0; i < 31; i++) {
+ if (fstr[i] == c)
+ break;
+ }
+ if (i < 31) { /* if we found it */
+ if (tdd->mode != 1) { /* if in ltrs mode, change it */
+ PUT_TDD(27); /* send FIGS */
tdd->mode = 1;
- }
- PUT_TDD(i); /* send byte */
+ }
+ PUT_TDD(i); /* send byte */
continue;
- }
- }
+ }
+ }
return bytes;
}
-
diff --git a/translate.c b/translate.c
index a1651f2db..59d566db0 100644
--- a/translate.c
+++ b/translate.c
@@ -393,7 +393,7 @@ static void calc_cost(struct ast_translator *t, int seconds)
}
framein(pvt, f);
ast_frfree(f);
- while( (f = t->frameout(pvt))) {
+ while ((f = t->frameout(pvt))) {
sofar += f->samples;
ast_frfree(f);
}
@@ -412,9 +412,9 @@ static void calc_cost(struct ast_translator *t, int seconds)
static void rebuild_matrix(int samples)
{
struct ast_translator *t;
- int x; /* source format index */
- int y; /* intermediate format index */
- int z; /* destination format index */
+ int x; /* source format index */
+ int y; /* intermediate format index */
+ int z; /* destination format index */
if (option_debug)
ast_log(LOG_DEBUG, "Resetting translation matrix\n");
@@ -443,24 +443,24 @@ static void rebuild_matrix(int samples)
*/
for (;;) {
int changed = 0;
- for (x=0; x < MAX_FORMAT; x++) { /* source format */
- for (y=0; y < MAX_FORMAT; y++) { /* intermediate format */
- if (x == y) /* skip ourselves */
+ for (x = 0; x < MAX_FORMAT; x++) { /* source format */
+ for (y=0; y < MAX_FORMAT; y++) { /* intermediate format */
+ if (x == y) /* skip ourselves */
continue;
- for (z=0; z<MAX_FORMAT; z++) { /* dst format */
+ for (z=0; z<MAX_FORMAT; z++) { /* dst format */
int newcost;
- if (z == x || z == y) /* skip null conversions */
+ if (z == x || z == y) /* skip null conversions */
continue;
- if (!tr_matrix[x][y].step) /* no path from x to y */
+ if (!tr_matrix[x][y].step) /* no path from x to y */
continue;
- if (!tr_matrix[y][z].step) /* no path from y to z */
+ if (!tr_matrix[y][z].step) /* no path from y to z */
continue;
newcost = tr_matrix[x][y].cost + tr_matrix[y][z].cost;
if (tr_matrix[x][z].step && newcost >= tr_matrix[x][z].cost)
- continue; /* x->y->z is more expensive than
- * the existing path */
+ continue; /* x->y->z is more expensive than
+ * the existing path */
/* ok, we can get from x to z via y with a cost that
is the sum of the transition from x to y and
from y to z */
@@ -490,19 +490,19 @@ static int show_translation(int fd, int argc, char *argv[])
AST_LIST_LOCK(&translators);
- if (argv[2] && !strcasecmp(argv[2],"recalc")) {
+ if (argv[2] && !strcasecmp(argv[2], "recalc")) {
z = argv[3] ? atoi(argv[3]) : 1;
if (z <= 0) {
- ast_cli(fd," C'mon let's be serious here... defaulting to 1.\n");
+ ast_cli(fd, " C'mon let's be serious here... defaulting to 1.\n");
z = 1;
}
if (z > MAX_RECALC) {
- ast_cli(fd," Maximum limit of recalc exceeded by %d, truncating value to %d\n",z-MAX_RECALC,MAX_RECALC);
+ ast_cli(fd, " Maximum limit of recalc exceeded by %d, truncating value to %d\n", z - MAX_RECALC, MAX_RECALC);
z = MAX_RECALC;
}
- ast_cli(fd," Recalculating Codec Translation (number of sample seconds: %d)\n\n",z);
+ ast_cli(fd, " Recalculating Codec Translation (number of sample seconds: %d)\n\n", z);
rebuild_matrix(z);
}
@@ -515,11 +515,11 @@ static int show_translation(int fd, int argc, char *argv[])
/* next 2 lines run faster than using ast_build_string() */
*buf++ = ' ';
*buf = '\0';
- for (y=-1;y<SHOW_TRANS;y++) {
- if (x >= 0 && y >= 0 && tr_matrix[x][y].step) /* XXX what is 99999 ? */
+ for (y = -1; y < SHOW_TRANS; y++) {
+ if (x >= 0 && y >= 0 && tr_matrix[x][y].step) /* XXX what is 99999 ? */
ast_build_string(&buf, &left, " %5d", tr_matrix[x][y].cost >= 99999 ? 0 : tr_matrix[x][y].cost);
else if (((x == -1 && y >= 0) || (y == -1 && x >= 0))) {
- ast_build_string(&buf, &left, " %5s", ast_getformatname(1<<(x+y+1)) );
+ ast_build_string(&buf, &left, " %5s", ast_getformatname(1 << (x + y + 1)) );
} else if (x != -1 && y != -1) {
ast_build_string(&buf, &left, " -");
} else {
@@ -586,12 +586,12 @@ int ast_register_translator(struct ast_translator *t, void *module)
*/
struct _test_align { void *a, *b; } p;
int align = (char *)&p.b - (char *)&p.a;
- t->buf_size = ((t->buf_size + align - 1)/align)*align;
+ t->buf_size = ((t->buf_size + align - 1) / align) * align;
}
if (t->frameout == NULL)
t->frameout = default_frameout;
- calc_cost(t,1);
+ calc_cost(t, 1);
if (option_verbose > 1) {
char tmp[80];
ast_verbose(VERBOSE_PREFIX_2 "Registered translator '%s' from format %s to %s, cost %d\n",
@@ -641,19 +641,19 @@ int ast_translator_best_choice(int *dst, int *srcs)
int common = (*dst) & (*srcs); /* are there common formats ? */
if (common) { /* yes, pick one and return */
- for (cur = 1, y=0; y < MAX_FORMAT; cur <<=1, y++) {
+ for (cur = 1, y = 0; y < MAX_FORMAT; cur <<= 1, y++) {
if (cur & common) /* guaranteed to find one */
break;
}
/* We are done, this is a common format to both. */
- *srcs = *dst = cur;
+ *srcs = *dst = cur;
return 0;
} else { /* No, we will need to translate */
AST_LIST_LOCK(&translators);
- for (cur = 1, y=0; y < MAX_FORMAT; cur <<=1, y++) {
+ for (cur = 1, y = 0; y < MAX_FORMAT; cur <<= 1, y++) {
if (! (cur & *dst))
continue;
- for (cursrc = 1, x=0; x < MAX_FORMAT; cursrc <<= 1, x++) {
+ for (cursrc = 1, x = 0; x < MAX_FORMAT; cursrc <<= 1, x++) {
if (!(*srcs & cursrc) || !tr_matrix[x][y].step ||
tr_matrix[x][y].cost > besttime)
continue; /* not existing or no better */
@@ -687,3 +687,4 @@ unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src)
else
return tr_matrix[src][dest].multistep + 1;
}
+
diff --git a/udptl.c b/udptl.c
index 86fa42b5c..bb04e487d 100644
--- a/udptl.c
+++ b/udptl.c
@@ -57,8 +57,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static int udptlstart = 0;
static int udptlend = 0;
-static int udptldebug = 0; /* Are we debugging? */
-static struct sockaddr_in udptldebugaddr; /* Debug packets to/from this host */
+static int udptldebug = 0; /* Are we debugging? */
+static struct sockaddr_in udptldebugaddr; /* Debug packets to/from this host */
#ifdef SO_NO_CHECK
static int nochecksums = 0;
#endif
@@ -150,7 +150,7 @@ static inline int udptl_debug_test_addr(struct sockaddr_in *addr)
if (((ntohs(udptldebugaddr.sin_port) != 0)
&& (udptldebugaddr.sin_port != addr->sin_port))
|| (udptldebugaddr.sin_addr.s_addr != addr->sin_addr.s_addr))
- return 0;
+ return 0;
}
return 1;
}
@@ -190,7 +190,7 @@ static int decode_open_type(uint8_t *buf, int limit, int *len, const uint8_t **p
int i;
const uint8_t **pbuf;
- for (octet_idx = 0, *p_num_octets = 0; ; octet_idx += octet_cnt) {
+ for (octet_idx = 0, *p_num_octets = 0; ; octet_idx += octet_cnt) {
if ((stat = decode_length(buf, limit, len, &octet_cnt)) < 0)
return -1;
if (octet_cnt > 0) {
@@ -232,7 +232,7 @@ static int encode_length(uint8_t *buf, int *len, int value)
return value;
}
/* Fragmentation */
- multiplier = (value < 0x10000) ? (value >> 14) : 4;
+ multiplier = (value < 0x10000) ? (value >> 14) : 4;
/* Set the first 2 bits of the octet */
buf[*len] = 0xC0 | multiplier;
(*len)++;
@@ -253,7 +253,7 @@ static int encode_open_type(uint8_t *buf, int *len, const uint8_t *data, int num
num_octets = 1;
}
/* Encode the open type */
- for (octet_idx = 0; ; num_octets -= enclen, octet_idx += enclen) {
+ for (octet_idx = 0; ; num_octets -= enclen, octet_idx += enclen) {
if ((enclen = encode_length(buf, len, num_octets)) < 0)
return -1;
if (enclen > 0) {
@@ -320,7 +320,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
do {
if ((stat2 = decode_length(buf, len, &ptr, &count)) < 0)
return -1;
- for (i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
if ((stat = decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i])) != 0)
return -1;
}
@@ -328,7 +328,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
}
while (stat2 > 0);
/* Step through in reverse order, so we go oldest to newest */
- for (i = total_count; i > 0; i--) {
+ for (i = total_count; i > 0; i--) {
if (seq_no - i >= s->rx_seq_no) {
/* This one wasn't seen before */
/* Decode the secondary IFP packet */
@@ -378,7 +378,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
if (ifp_len > LOCAL_FAX_MAX_DATAGRAM)
return -1;
/* Update any missed slots in the buffer */
- for ( ; seq_no > s->rx_seq_no; s->rx_seq_no++) {
+ for ( ; seq_no > s->rx_seq_no; s->rx_seq_no++) {
x = s->rx_seq_no & UDPTL_BUF_MASK;
s->rx[x].buf_len = -1;
s->rx[x].fec_len[0] = 0;
@@ -413,7 +413,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
s->rx[x].fec_entries = entries;
/* Decode the elements */
- for (i = 0; i < entries; i++) {
+ for (i = 0; i < entries; i++) {
if ((stat = decode_open_type(buf, len, &ptr, &data, &s->rx[x].fec_len[i])) != 0)
return -1;
if (s->rx[x].fec_len[i] > LOCAL_FAX_MAX_DATAGRAM)
@@ -423,29 +423,29 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
memcpy(s->rx[x].fec[i], data, s->rx[x].fec_len[i]);
#if 0
fprintf(stderr, "FEC: ");
- for (j = 0; j < s->rx[x].fec_len[i]; j++)
+ for (j = 0; j < s->rx[x].fec_len[i]; j++)
fprintf(stderr, "%02X ", data[j]);
fprintf(stderr, "\n");
#endif
- }
+ }
/* See if we can reconstruct anything which is missing */
/* TODO: this does not comprehensively hunt back and repair everything that is possible */
- for (l = x; l != ((x - (16 - span*entries)) & UDPTL_BUF_MASK); l = (l - 1) & UDPTL_BUF_MASK) {
+ for (l = x; l != ((x - (16 - span*entries)) & UDPTL_BUF_MASK); l = (l - 1) & UDPTL_BUF_MASK) {
if (s->rx[l].fec_len[0] <= 0)
continue;
- for (m = 0; m < s->rx[l].fec_entries; m++) {
+ for (m = 0; m < s->rx[l].fec_entries; m++) {
limit = (l + m) & UDPTL_BUF_MASK;
- for (which = -1, k = (limit - s->rx[l].fec_span*s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit; k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK) {
+ for (which = -1, k = (limit - s->rx[l].fec_span * s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit; k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK) {
if (s->rx[k].buf_len <= 0)
- which = (which == -1) ? k : -2;
+ which = (which == -1) ? k : -2;
}
if (which >= 0) {
/* Repairable */
- for (j = 0; j < s->rx[l].fec_len[m]; j++) {
+ for (j = 0; j < s->rx[l].fec_len[m]; j++) {
s->rx[which].buf[j] = s->rx[l].fec[m][j];
- for (k = (limit - s->rx[l].fec_span*s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit; k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK)
- s->rx[which].buf[j] ^= (s->rx[k].buf_len > j) ? s->rx[k].buf[j] : 0;
+ for (k = (limit - s->rx[l].fec_span * s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit; k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK)
+ s->rx[which].buf[j] ^= (s->rx[k].buf_len > j) ? s->rx[k].buf[j] : 0;
}
s->rx[which].buf_len = s->rx[l].fec_len[m];
repaired[which] = TRUE;
@@ -453,7 +453,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
}
}
/* Now play any new packets forwards in time */
- for (l = (x + 1) & UDPTL_BUF_MASK, j = seq_no - UDPTL_BUF_MASK; l != x; l = (l + 1) & UDPTL_BUF_MASK, j++) {
+ for (l = (x + 1) & UDPTL_BUF_MASK, j = seq_no - UDPTL_BUF_MASK; l != x; l = (l + 1) & UDPTL_BUF_MASK, j++) {
if (repaired[l]) {
//fprintf(stderr, "Fixed packet %d, len %d\n", j, l);
s->f[ifp_no].frametype = AST_FRAME_MODEM;
@@ -553,7 +553,7 @@ static int udptl_build_packet(struct ast_udptl *s, uint8_t *buf, uint8_t *ifp, i
if (encode_length(buf, &len, entries) < 0)
return -1;
/* Encode the elements */
- for (i = 0; i < entries; i++) {
+ for (i = 0; i < entries; i++) {
j = (entry - i - 1) & UDPTL_BUF_MASK;
if (encode_open_type(buf, &len, s->tx[j].buf, s->tx[j].buf_len) < 0)
return -1;
@@ -577,19 +577,19 @@ static int udptl_build_packet(struct ast_udptl *s, uint8_t *buf, uint8_t *ifp, i
/* The number of entries is defined as a length, but will only ever be a small
value. Treat it as such. */
buf[len++] = entries;
- for (m = 0; m < entries; m++) {
+ for (m = 0; m < entries; m++) {
/* Make an XOR'ed entry the maximum length */
limit = (entry + m) & UDPTL_BUF_MASK;
high_tide = 0;
- for (i = (limit - span*entries) & UDPTL_BUF_MASK; i != limit; i = (i + entries) & UDPTL_BUF_MASK) {
+ for (i = (limit - span*entries) & UDPTL_BUF_MASK; i != limit; i = (i + entries) & UDPTL_BUF_MASK) {
if (high_tide < s->tx[i].buf_len) {
- for (j = 0; j < high_tide; j++)
+ for (j = 0; j < high_tide; j++)
fec[j] ^= s->tx[i].buf[j];
- for ( ; j < s->tx[i].buf_len; j++)
+ for ( ; j < s->tx[i].buf_len; j++)
fec[j] = s->tx[i].buf[j];
high_tide = s->tx[i].buf_len;
} else {
- for (j = 0; j < s->tx[i].buf_len; j++)
+ for (j = 0; j < s->tx[i].buf_len; j++)
fec[j] ^= s->tx[i].buf[j];
}
}
@@ -700,68 +700,68 @@ void ast_udptl_offered_from_local(struct ast_udptl* udptl, int local)
int ast_udptl_get_error_correction_scheme(struct ast_udptl* udptl)
{
- if (udptl)
- return udptl->error_correction_scheme;
- else {
- ast_log(LOG_WARNING, "udptl structure is null\n");
- return -1;
- }
+ if (udptl)
+ return udptl->error_correction_scheme;
+ else {
+ ast_log(LOG_WARNING, "udptl structure is null\n");
+ return -1;
+ }
}
void ast_udptl_set_error_correction_scheme(struct ast_udptl* udptl, int ec)
{
- if (udptl) {
- switch (ec) {
- case UDPTL_ERROR_CORRECTION_FEC:
- udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_FEC;
- break;
- case UDPTL_ERROR_CORRECTION_REDUNDANCY:
- udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_REDUNDANCY;
- break;
- case UDPTL_ERROR_CORRECTION_NONE:
- udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_NONE;
- break;
- default:
- ast_log(LOG_WARNING, "error correction parameter invalid");
- };
- } else
- ast_log(LOG_WARNING, "udptl structure is null\n");
+ if (udptl) {
+ switch (ec) {
+ case UDPTL_ERROR_CORRECTION_FEC:
+ udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_FEC;
+ break;
+ case UDPTL_ERROR_CORRECTION_REDUNDANCY:
+ udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_REDUNDANCY;
+ break;
+ case UDPTL_ERROR_CORRECTION_NONE:
+ udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_NONE;
+ break;
+ default:
+ ast_log(LOG_WARNING, "error correction parameter invalid");
+ };
+ } else
+ ast_log(LOG_WARNING, "udptl structure is null\n");
}
int ast_udptl_get_local_max_datagram(struct ast_udptl* udptl)
{
- if (udptl)
- return udptl->local_max_datagram_size;
- else {
- ast_log(LOG_WARNING, "udptl structure is null\n");
- return -1;
- }
+ if (udptl)
+ return udptl->local_max_datagram_size;
+ else {
+ ast_log(LOG_WARNING, "udptl structure is null\n");
+ return -1;
+ }
}
int ast_udptl_get_far_max_datagram(struct ast_udptl* udptl)
{
- if (udptl)
- return udptl->far_max_datagram_size;
- else {
- ast_log(LOG_WARNING, "udptl structure is null\n");
- return -1;
- }
+ if (udptl)
+ return udptl->far_max_datagram_size;
+ else {
+ ast_log(LOG_WARNING, "udptl structure is null\n");
+ return -1;
+ }
}
void ast_udptl_set_local_max_datagram(struct ast_udptl* udptl, int max_datagram)
{
- if (udptl)
- udptl->local_max_datagram_size = max_datagram;
- else
- ast_log(LOG_WARNING, "udptl structure is null\n");
+ if (udptl)
+ udptl->local_max_datagram_size = max_datagram;
+ else
+ ast_log(LOG_WARNING, "udptl structure is null\n");
}
void ast_udptl_set_far_max_datagram(struct ast_udptl* udptl, int max_datagram)
{
- if (udptl)
- udptl->far_max_datagram_size = max_datagram;
- else
- ast_log(LOG_WARNING, "udptl structure is null\n");
+ if (udptl)
+ udptl->far_max_datagram_size = max_datagram;
+ else
+ ast_log(LOG_WARNING, "udptl structure is null\n");
}
struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int callbackmode, struct in_addr addr)
@@ -789,7 +789,7 @@ struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched, struc
memset(&udptl->rx, 0, sizeof(udptl->rx));
memset(&udptl->tx, 0, sizeof(udptl->tx));
- for (i = 0; i <= UDPTL_BUF_MASK; i++) {
+ for (i = 0; i <= UDPTL_BUF_MASK; i++) {
udptl->rx[i].buf_len = -1;
udptl->tx[i].buf_len = -1;
}
@@ -913,7 +913,7 @@ int ast_udptl_write(struct ast_udptl *s, struct ast_frame *f)
/* Cook up the UDPTL packet, with the relevant EC info. */
len = udptl_build_packet(s, buf, f->data, f->datalen);
- if (len > 0 && s->them.sin_port && s->them.sin_addr.s_addr) {
+ if (len > 0 && s->them.sin_port && s->them.sin_addr.s_addr) {
if ((res = sendto(s->fd, buf, len, 0, (struct sockaddr *) &s->them, sizeof(s->them))) < 0)
ast_log(LOG_NOTICE, "UDPTL Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->them.sin_addr), ntohs(s->them.sin_port), strerror(errno));
#if 0
@@ -935,7 +935,7 @@ void ast_udptl_proto_unregister(struct ast_udptl_protocol *proto)
cur = protos;
prev = NULL;
- while(cur) {
+ while (cur) {
if (cur == proto) {
if (prev)
prev->next = proto->next;
@@ -953,7 +953,7 @@ int ast_udptl_proto_register(struct ast_udptl_protocol *proto)
struct ast_udptl_protocol *cur;
cur = protos;
- while(cur) {
+ while (cur) {
if (cur->type == proto->type) {
ast_log(LOG_WARNING, "Tried to register same protocol '%s' twice\n", cur->type);
return -1;
@@ -1044,7 +1044,7 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
cs[1] = c1;
cs[2] = NULL;
for (;;) {
- if ((c0->tech_pvt != pvt0) ||
+ if ((c0->tech_pvt != pvt0) ||
(c1->tech_pvt != pvt1) ||
(c0->masq || c0->masqr || c1->masq || c1->masqr)) {
ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n");
@@ -1147,7 +1147,7 @@ static int udptl_do_debug(int fd, int argc, char *argv[])
ast_cli(fd, "UDPTL Debugging Enabled\n");
return RESULT_SUCCESS;
}
-
+
static int udptl_no_debug(int fd, int argc, char *argv[])
{
if (argc !=3)
@@ -1165,13 +1165,13 @@ static char no_debug_usage[] =
"Usage: udptl no debug\n"
" Disable all UDPTL debugging\n";
-static struct ast_cli_entry cli_debug_ip =
+static struct ast_cli_entry cli_debug_ip =
{{ "udptl", "debug", "ip", NULL } , udptl_do_debug, "Enable UDPTL debugging on IP", debug_usage };
-static struct ast_cli_entry cli_debug =
+static struct ast_cli_entry cli_debug =
{{ "udptl", "debug", NULL } , udptl_do_debug, "Enable UDPTL debugging", debug_usage };
-static struct ast_cli_entry cli_no_debug =
+static struct ast_cli_entry cli_no_debug =
{{ "udptl", "no", "debug", NULL } , udptl_no_debug, "Disable UDPTL debugging", no_debug_usage };
void ast_udptl_reload(void)
diff --git a/ulaw.c b/ulaw.c
index a2e4d831e..2735f6cce 100644
--- a/ulaw.c
+++ b/ulaw.c
@@ -85,22 +85,22 @@ static unsigned char linear2ulaw(short sample)
void ast_ulaw_init(void)
{
int i;
- for(i = 0;i < 256;i++) {
- short mu,e,f,y;
- static short etab[]={0,132,396,924,1980,4092,8316,16764};
+ for (i = 0; i < 256; i++) {
+ short mu, e, f, y;
+ static short etab[] = {0,132,396,924,1980,4092,8316,16764};
- mu = 255-i;
- e = (mu & 0x70)/16;
+ mu = 255 - i;
+ e = (mu & 0x70) / 16;
f = mu & 0x0f;
y = f * (1 << (e + 3));
y += etab[e];
- if (mu & 0x80) y = -y;
- __ast_mulaw[i] = y;
+ if (mu & 0x80)
+ y = -y;
+ __ast_mulaw[i] = y;
}
/* set up the reverse (mu-law) conversion table */
- for(i = -32768; i < 32768; i++) {
+ for (i = -32768; i < 32768; i++) {
__ast_lin2mu[((unsigned short)i) >> 2] = linear2ulaw(i);
}
-
}
diff --git a/utils.c b/utils.c
index 51e9e8c13..bdb022e42 100644
--- a/utils.c
+++ b/utils.c
@@ -112,7 +112,7 @@ static int gethostbyname_r (const char *name, struct hostent *ret, char *buf,
/* here nbytes is the number of bytes required in buffer */
/* as a terminator must be there, the minimum value is ph->h_length */
- if(nbytes > buflen) {
+ if (nbytes > buflen) {
*result = NULL;
ast_mutex_unlock(&__mutex); /* end critical area */
return ERANGE; /* not enough space in buf!! */
@@ -136,7 +136,7 @@ static int gethostbyname_r (const char *name, struct hostent *ret, char *buf,
/* copy addresses */
q = (char **)buf; /* pointer to pointers area (type: char **) */
ret->h_addr_list = q; /* update pointer to address list */
- pbuf = buf + ((naddr+naliases+2)*sizeof(*p)); /* skip that area */
+ pbuf = buf + ((naddr + naliases + 2) * sizeof(*p)); /* skip that area */
for (p = ph->h_addr_list; *p != 0; p++) {
memcpy(pbuf, *p, ph->h_length); /* copy address bytes */
*q++ = pbuf; /* the pointer is the one inside buf... */
@@ -294,7 +294,7 @@ void ast_md5_hash(char *output, char *input)
MD5Update(&md5, (unsigned char *)input, strlen(input));
MD5Final(digest, &md5);
ptr = output;
- for (x=0; x<16; x++)
+ for (x = 0; x < 16; x++)
ptr += sprintf(ptr, "%2.2x", digest[x]);
}
@@ -353,7 +353,7 @@ int ast_base64encode_full(char *dst, const unsigned char *src, int srclen, int m
int cntin = 0;
/* Reserve space for null byte at end of string */
max--;
- while((cntin < srclen) && (cnt < max)) {
+ while ((cntin < srclen) && (cnt < max)) {
byte <<= 8;
byte |= *(src++);
bits += 8;
@@ -405,7 +405,7 @@ static void base64_init(void)
int x;
memset(b2a, -1, sizeof(b2a));
/* Initialize base-64 Conversion table */
- for (x=0;x<26;x++) {
+ for (x = 0; x < 26; x++) {
/* A-Z */
base64[x] = 'A' + x;
b2a['A' + x] = x;
@@ -795,7 +795,7 @@ size_t strnlen(const char *s, size_t n)
{
size_t len;
- for (len=0; len < n; len++)
+ for (len = 0; len < n; len++)
if (s[len] == '\0')
break;
@@ -1034,14 +1034,14 @@ char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
if (inEscape) {
*dataPut++ = *start; /* Always goes verbatim */
inEscape = 0;
- } else {
+ } else {
if (*start == '\\') {
inEscape = 1; /* Do not copy \ into the data */
} else if (*start == '\'') {
- inQuotes = 1-inQuotes; /* Do not copy ' into the data */
+ inQuotes = 1 - inQuotes; /* Do not copy ' into the data */
} else {
/* Replace , with |, unless in quotes */
- *dataPut++ = inQuotes ? *start : ((*start==find) ? replace_with : *start);
+ *dataPut++ = inQuotes ? *start : ((*start == find) ? replace_with : *start);
}
}
}
@@ -1050,7 +1050,7 @@ char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
return dataPut;
}
-void ast_join(char *s, size_t len, char * const w[])
+void ast_join(char *s, size_t len, const char *w[])
{
int x, ofs = 0;
const char *src;
@@ -1058,7 +1058,7 @@ void ast_join(char *s, size_t len, char * const w[])
/* Join words into a string */
if (!s)
return;
- for (x=0; ofs < len && w[x]; x++) {
+ for (x = 0; ofs < len && w[x]; x++) {
if (x > 0)
s[ofs++] = ' ';
for (src = w[x]; *src && ofs < len; src++)
@@ -1156,6 +1156,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
}
AST_MUTEX_DEFINE_STATIC(fetchadd_m); /* used for all fetc&add ops */
+
int ast_atomic_fetchadd_int_slow(volatile int *p, int v)
{
int ret;
@@ -1191,3 +1192,4 @@ int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
} else
return -1;
}
+