[asterisk-commits] trunk r37345 - /trunk/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Jul 10 12:05:49 MST 2006
Author: tilghman
Date: Mon Jul 10 14:05:48 2006
New Revision: 37345
URL: http://svn.digium.com/view/asterisk?rev=37345&view=rev
Log:
Whitespace changes only
Modified:
trunk/acl.c
trunk/dns.c
trunk/plc.c
trunk/sched.c
trunk/sha1.c
trunk/slinfactory.c
trunk/tdd.c
trunk/translate.c
trunk/udptl.c
trunk/ulaw.c
trunk/utils.c
Modified: trunk/acl.c
URL: http://svn.digium.com/view/asterisk/trunk/acl.c?rev=37345&r1=37344&r2=37345&view=diff
==============================================================================
--- trunk/acl.c (original)
+++ trunk/acl.c Mon Jul 10 14:05:48 2006
@@ -90,7 +90,7 @@
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 @@
/* 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 @@
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 @@
return 0;
return -1;
}
+
Modified: trunk/dns.c
URL: http://svn.digium.com/view/asterisk/trunk/dns.c?rev=37345&r1=37344&r2=37345&view=diff
==============================================================================
--- trunk/dns.c (original)
+++ trunk/dns.c Mon Jul 10 14:05:48 2006
@@ -48,40 +48,40 @@
#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 {
Modified: trunk/plc.c
URL: http://svn.digium.com/view/asterisk/trunk/plc.c?rev=37345&r1=37344&r2=37345&view=diff
==============================================================================
--- trunk/plc.c (original)
+++ trunk/plc.c Mon Jul 10 14:05:48 2006
@@ -71,13 +71,13 @@
{
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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);
Modified: trunk/sched.c
URL: http://svn.digium.com/view/asterisk/trunk/sched.c?rev=37345&r1=37344&r2=37345&view=diff
==============================================================================
--- trunk/sched.c (original)
+++ trunk/sched.c Mon Jul 10 14:05:48 2006
@@ -68,7 +68,7 @@
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_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 @@
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 @@
DEBUG(ast_log(LOG_DEBUG, "ast_sched_runq()\n"));
ast_mutex_lock(&con->lock);
- for(;;) {
+ for (;;) {
if (AST_LIST_EMPTY(&con->schedq))
break;
Modified: trunk/sha1.c
URL: http://svn.digium.com/view/asterisk/trunk/sha1.c?rev=37345&r1=37344&r2=37345&view=diff
==============================================================================
--- trunk/sha1.c (original)
+++ trunk/sha1.c Mon Jul 10 14:05:48 2006
@@ -90,23 +90,22 @@
*/
int SHA1Reset(SHA1Context *context)
{
- if (!context)
- {
- return shaNull;
- }
-
- 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->Computed = 0;
- context->Corrupted = 0;
+ if (!context) {
+ return shaNull;
+ }
+
+ 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->Computed = 0;
+ context->Corrupted = 0;
return shaSuccess;
}
@@ -135,34 +134,27 @@
{
int i;
- if (!context || !Message_Digest)
- {
- return shaNull;
- }
-
- 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;
-
- }
-
- for(i = 0; i < SHA1HashSize; ++i)
- {
- Message_Digest[i] = context->Intermediate_Hash[i>>2]
- >> 8 * ( 3 - ( i & 0x03 ) );
+ if (!context || !Message_Digest) {
+ return shaNull;
+ }
+
+ 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;
+ }
+
+ for (i = 0; i < SHA1HashSize; ++i) {
+ Message_Digest[i] = context->Intermediate_Hash[i >> 2] >> 8 * ( 3 - ( i & 0x03 ) );
}
return shaSuccess;
@@ -188,52 +180,42 @@
* sha Error Code.
*
*/
-int SHA1Input( SHA1Context *context,
- const uint8_t *message_array,
- unsigned length)
-{
- if (!length)
- {
- return shaSuccess;
- }
-
- if (!context || !message_array)
- {
- return shaNull;
- }
-
- 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->Message_Block_Index == 64)
- {
- SHA1ProcessMessageBlock(context);
- }
-
- message_array++;
+int SHA1Input(SHA1Context *context, const uint8_t *message_array, unsigned length)
+{
+ if (!length) {
+ return shaSuccess;
+ }
+
+ if (!context || !message_array) {
+ return shaNull;
+ }
+
+ 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->Message_Block_Index == 64) {
+ SHA1ProcessMessageBlock(context);
+ }
+
+ message_array++;
}
return shaSuccess;
@@ -261,30 +243,28 @@
*/
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 = 16; t < 80; t++)
- {
+ 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++) {
W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
}
@@ -294,46 +274,40 @@
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 = 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 = 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 = 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 = 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;
}
context->Intermediate_Hash[0] += A;
@@ -377,28 +351,22 @@
* 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;
+ }
}
/*
Modified: trunk/slinfactory.c
URL: http://svn.digium.com/view/asterisk/trunk/slinfactory.c?rev=37345&r1=37344&r2=37345&view=diff
==============================================================================
--- trunk/slinfactory.c (original)
+++ trunk/slinfactory.c Mon Jul 10 14:05:48 2006
@@ -88,7 +88,7 @@
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) {
Modified: trunk/tdd.c
URL: http://svn.digium.com/view/asterisk/trunk/tdd.c?rev=37345&r1=37344&r2=37345&view=diff
==============================================================================
--- trunk/tdd.c (original)
+++ trunk/tdd.c Mon Jul 10 14:05:48 2006
@@ -63,20 +63,28 @@
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 @@
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 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 @@
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 @@
} 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 @@
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 @@
#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 */
- continue;
- }
- }
+ }
+ PUT_TDD(i); /* send byte */
+ continue;
+ }
+ }
return bytes;
}
-
Modified: trunk/translate.c
URL: http://svn.digium.com/view/asterisk/trunk/translate.c?rev=37345&r1=37344&r2=37345&view=diff
==============================================================================
--- trunk/translate.c (original)
+++ trunk/translate.c Mon Jul 10 14:05:48 2006
@@ -393,7 +393,7 @@
}
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 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 @@
*/
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 @@
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 @@
/* 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 @@
*/
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 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 @@
else
return tr_matrix[src][dest].multistep + 1;
}
+
Modified: trunk/udptl.c
URL: http://svn.digium.com/view/asterisk/trunk/udptl.c?rev=37345&r1=37344&r2=37345&view=diff
==============================================================================
--- trunk/udptl.c (original)
+++ trunk/udptl.c Mon Jul 10 14:05:48 2006
@@ -57,8 +57,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
}
}
/* 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 @@
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 @@
/* 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 @@
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)
{
[... 258 lines stripped ...]
More information about the asterisk-commits
mailing list