mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-09 03:18:30 +00:00
Whitespace changes only
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@37345 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
9
acl.c
9
acl.c
@@ -90,7 +90,7 @@ struct my_ifreq {
|
|||||||
void ast_free_ha(struct ast_ha *ha)
|
void ast_free_ha(struct ast_ha *ha)
|
||||||
{
|
{
|
||||||
struct ast_ha *hal;
|
struct ast_ha *hal;
|
||||||
while(ha) {
|
while (ha) {
|
||||||
hal = ha;
|
hal = ha;
|
||||||
ha = ha->next;
|
ha = ha->next;
|
||||||
free(hal);
|
free(hal);
|
||||||
@@ -122,9 +122,9 @@ static struct ast_ha *ast_duplicate_ha(struct ast_ha *original)
|
|||||||
/* Used in chan_sip2 templates */
|
/* Used in chan_sip2 templates */
|
||||||
struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original)
|
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 *ret = NULL;
|
||||||
struct ast_ha *link,*prev=NULL;
|
struct ast_ha *link, *prev = NULL;
|
||||||
|
|
||||||
while (start) {
|
while (start) {
|
||||||
link = ast_duplicate_ha(start); /* Create copy of this object */
|
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 (!strchr(nm, '.')) {
|
||||||
if ((sscanf(nm, "%d", &x) == 1) && (x >= 0) && (x <= 32)) {
|
if ((sscanf(nm, "%d", &x) == 1) && (x >= 0) && (x <= 32)) {
|
||||||
y = 0;
|
y = 0;
|
||||||
for (z=0;z<x;z++) {
|
for (z = 0; z < x; z++) {
|
||||||
y >>= 1;
|
y >>= 1;
|
||||||
y |= 0x80000000;
|
y |= 0x80000000;
|
||||||
}
|
}
|
||||||
@@ -423,3 +423,4 @@ int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr)
|
|||||||
return 0;
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
50
dns.c
50
dns.c
@@ -48,40 +48,40 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#define MAX_SIZE 4096
|
#define MAX_SIZE 4096
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned id :16; /*!< query identification number */
|
unsigned id:16; /*!< query identification number */
|
||||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||||
/* fields in third byte */
|
/* fields in third byte */
|
||||||
unsigned qr: 1; /*!< response flag */
|
unsigned qr:1; /*!< response flag */
|
||||||
unsigned opcode: 4; /*!< purpose of message */
|
unsigned opcode:4; /*!< purpose of message */
|
||||||
unsigned aa: 1; /*!< authoritive answer */
|
unsigned aa:1; /*!< authoritive answer */
|
||||||
unsigned tc: 1; /*!< truncated message */
|
unsigned tc:1; /*!< truncated message */
|
||||||
unsigned rd: 1; /*!< recursion desired */
|
unsigned rd:1; /*!< recursion desired */
|
||||||
/* fields in fourth byte */
|
/* fields in fourth byte */
|
||||||
unsigned ra: 1; /*!< recursion available */
|
unsigned ra:1; /*!< recursion available */
|
||||||
unsigned unused :1; /*!< unused bits (MBZ as of 4.9.3a3) */
|
unsigned unused:1; /*!< unused bits (MBZ as of 4.9.3a3) */
|
||||||
unsigned ad: 1; /*!< authentic data from named */
|
unsigned ad:1; /*!< authentic data from named */
|
||||||
unsigned cd: 1; /*!< checking disabled by resolver */
|
unsigned cd:1; /*!< checking disabled by resolver */
|
||||||
unsigned rcode :4; /*!< response code */
|
unsigned rcode:4; /*!< response code */
|
||||||
#endif
|
#endif
|
||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN
|
#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN
|
||||||
/* fields in third byte */
|
/* fields in third byte */
|
||||||
unsigned rd :1; /*!< recursion desired */
|
unsigned rd:1; /*!< recursion desired */
|
||||||
unsigned tc :1; /*!< truncated message */
|
unsigned tc:1; /*!< truncated message */
|
||||||
unsigned aa :1; /*!< authoritive answer */
|
unsigned aa:1; /*!< authoritive answer */
|
||||||
unsigned opcode :4; /*!< purpose of message */
|
unsigned opcode:4; /*!< purpose of message */
|
||||||
unsigned qr :1; /*!< response flag */
|
unsigned qr:1; /*!< response flag */
|
||||||
/* fields in fourth byte */
|
/* fields in fourth byte */
|
||||||
unsigned rcode :4; /*!< response code */
|
unsigned rcode:4; /*!< response code */
|
||||||
unsigned cd: 1; /*!< checking disabled by resolver */
|
unsigned cd:1; /*!< checking disabled by resolver */
|
||||||
unsigned ad: 1; /*!< authentic data from named */
|
unsigned ad:1; /*!< authentic data from named */
|
||||||
unsigned unused :1; /*!< unused bits (MBZ as of 4.9.3a3) */
|
unsigned unused:1; /*!< unused bits (MBZ as of 4.9.3a3) */
|
||||||
unsigned ra :1; /*!< recursion available */
|
unsigned ra:1; /*!< recursion available */
|
||||||
#endif
|
#endif
|
||||||
/* remaining bytes */
|
/* remaining bytes */
|
||||||
unsigned qdcount :16; /*!< number of question entries */
|
unsigned qdcount:16; /*!< number of question entries */
|
||||||
unsigned ancount :16; /*!< number of answer entries */
|
unsigned ancount:16; /*!< number of answer entries */
|
||||||
unsigned nscount :16; /*!< number of authority entries */
|
unsigned nscount:16; /*!< number of authority entries */
|
||||||
unsigned arcount :16; /*!< number of resource entries */
|
unsigned arcount:16; /*!< number of resource entries */
|
||||||
} dns_HEADER;
|
} dns_HEADER;
|
||||||
|
|
||||||
struct dn_answer {
|
struct dn_answer {
|
||||||
|
|||||||
18
plc.c
18
plc.c
@@ -71,13 +71,13 @@ static void save_history(plc_state_t *s, int16_t *buf, int len)
|
|||||||
{
|
{
|
||||||
if (len >= PLC_HISTORY_LEN) {
|
if (len >= PLC_HISTORY_LEN) {
|
||||||
/* Just keep the last part of the new data, starting at the beginning of the buffer */
|
/* 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;
|
s->buf_ptr = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (s->buf_ptr + len > PLC_HISTORY_LEN) {
|
if (s->buf_ptr + len > PLC_HISTORY_LEN) {
|
||||||
/* Wraps around - must break into two sections */
|
/* 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);
|
len -= (PLC_HISTORY_LEN - s->buf_ptr);
|
||||||
memcpy(s->history, buf + (PLC_HISTORY_LEN - s->buf_ptr), sizeof(int16_t)*len);
|
memcpy(s->history, buf + (PLC_HISTORY_LEN - s->buf_ptr), sizeof(int16_t)*len);
|
||||||
s->buf_ptr = len;
|
s->buf_ptr = len;
|
||||||
@@ -97,8 +97,8 @@ static void normalise_history(plc_state_t *s)
|
|||||||
if (s->buf_ptr == 0)
|
if (s->buf_ptr == 0)
|
||||||
return;
|
return;
|
||||||
memcpy(tmp, s->history, sizeof(int16_t)*s->buf_ptr);
|
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, 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 + PLC_HISTORY_LEN - s->buf_ptr, tmp, sizeof(int16_t) * s->buf_ptr);
|
||||||
s->buf_ptr = 0;
|
s->buf_ptr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ int plc_rx(plc_state_t *s, int16_t amp[], int len)
|
|||||||
new_weight = new_step;
|
new_weight = new_step;
|
||||||
old_weight = (1.0 - new_step)*gain;
|
old_weight = (1.0 - new_step)*gain;
|
||||||
for (i = 0; i < pitch_overlap; i++) {
|
for (i = 0; i < pitch_overlap; i++) {
|
||||||
amp[i] = fsaturate(old_weight*s->pitchbuf[s->pitch_offset] + new_weight*amp[i]);
|
amp[i] = fsaturate(old_weight * s->pitchbuf[s->pitch_offset] + new_weight * amp[i]);
|
||||||
if (++s->pitch_offset >= s->pitch)
|
if (++s->pitch_offset >= s->pitch)
|
||||||
s->pitch_offset = 0;
|
s->pitch_offset = 0;
|
||||||
new_weight += new_step;
|
new_weight += new_step;
|
||||||
@@ -201,7 +201,7 @@ int plc_fillin(plc_state_t *s, int16_t amp[], int len)
|
|||||||
new_step = 1.0/pitch_overlap;
|
new_step = 1.0/pitch_overlap;
|
||||||
new_weight = new_step;
|
new_weight = new_step;
|
||||||
for ( ; i < s->pitch; i++) {
|
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;
|
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;
|
new_weight += new_step;
|
||||||
}
|
}
|
||||||
/* We should now be ready to fill in the gap with repeated, decaying cycles
|
/* 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
|
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. */
|
in the stream, reverse the last 1/4 wavelength, and OLA with that. */
|
||||||
gain = 1.0;
|
gain = 1.0;
|
||||||
new_step = 1.0/pitch_overlap;
|
new_step = 1.0 / pitch_overlap;
|
||||||
old_step = new_step;
|
old_step = new_step;
|
||||||
new_weight = new_step;
|
new_weight = new_step;
|
||||||
old_weight = 1.0 - new_step;
|
old_weight = 1.0 - new_step;
|
||||||
for (i = 0; i < pitch_overlap; 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]);
|
amp[i] = fsaturate(old_weight * s->history[PLC_HISTORY_LEN - 1 - i] + new_weight * s->pitchbuf[i]);
|
||||||
new_weight += new_step;
|
new_weight += new_step;
|
||||||
old_weight -= old_step;
|
old_weight -= old_step;
|
||||||
if (old_weight < 0.0)
|
if (old_weight < 0.0)
|
||||||
@@ -228,7 +228,7 @@ int plc_fillin(plc_state_t *s, int16_t amp[], int len)
|
|||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
for ( ; gain > 0.0 && i < len; i++) {
|
for ( ; gain > 0.0 && i < len; i++) {
|
||||||
amp[i] = s->pitchbuf[s->pitch_offset]*gain;
|
amp[i] = s->pitchbuf[s->pitch_offset] * gain;
|
||||||
gain -= ATTENUATION_INCREMENT;
|
gain -= ATTENUATION_INCREMENT;
|
||||||
if (++s->pitch_offset >= s->pitch)
|
if (++s->pitch_offset >= s->pitch)
|
||||||
s->pitch_offset = 0;
|
s->pitch_offset = 0;
|
||||||
|
|||||||
2
sched.c
2
sched.c
@@ -334,7 +334,7 @@ int ast_sched_runq(struct sched_context *con)
|
|||||||
DEBUG(ast_log(LOG_DEBUG, "ast_sched_runq()\n"));
|
DEBUG(ast_log(LOG_DEBUG, "ast_sched_runq()\n"));
|
||||||
|
|
||||||
ast_mutex_lock(&con->lock);
|
ast_mutex_lock(&con->lock);
|
||||||
for(;;) {
|
for (;;) {
|
||||||
if (AST_LIST_EMPTY(&con->schedq))
|
if (AST_LIST_EMPTY(&con->schedq))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
94
sha1.c
94
sha1.c
@@ -90,8 +90,7 @@ void SHA1ProcessMessageBlock(SHA1Context *);
|
|||||||
*/
|
*/
|
||||||
int SHA1Reset(SHA1Context *context)
|
int SHA1Reset(SHA1Context *context)
|
||||||
{
|
{
|
||||||
if (!context)
|
if (!context) {
|
||||||
{
|
|
||||||
return shaNull;
|
return shaNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,34 +134,27 @@ int SHA1Result( SHA1Context *context,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!context || !Message_Digest)
|
if (!context || !Message_Digest) {
|
||||||
{
|
|
||||||
return shaNull;
|
return shaNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->Corrupted)
|
if (context->Corrupted) {
|
||||||
{
|
|
||||||
return context->Corrupted;
|
return context->Corrupted;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context->Computed)
|
if (!context->Computed) {
|
||||||
{
|
|
||||||
SHA1PadMessage(context);
|
SHA1PadMessage(context);
|
||||||
for(i=0; i<64; ++i)
|
for (i = 0; i < 64; ++i) {
|
||||||
{
|
|
||||||
/* message may be sensitive, clear it out */
|
/* message may be sensitive, clear it out */
|
||||||
context->Message_Block[i] = 0;
|
context->Message_Block[i] = 0;
|
||||||
}
|
}
|
||||||
context->Length_Low = 0; /* and clear length */
|
context->Length_Low = 0; /* and clear length */
|
||||||
context->Length_High = 0;
|
context->Length_High = 0;
|
||||||
context->Computed = 1;
|
context->Computed = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < SHA1HashSize; ++i)
|
for (i = 0; i < SHA1HashSize; ++i) {
|
||||||
{
|
Message_Digest[i] = context->Intermediate_Hash[i >> 2] >> 8 * ( 3 - ( i & 0x03 ) );
|
||||||
Message_Digest[i] = context->Intermediate_Hash[i>>2]
|
|
||||||
>> 8 * ( 3 - ( i & 0x03 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return shaSuccess;
|
return shaSuccess;
|
||||||
@@ -188,48 +180,38 @@ int SHA1Result( SHA1Context *context,
|
|||||||
* sha Error Code.
|
* sha Error Code.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int SHA1Input( SHA1Context *context,
|
int SHA1Input(SHA1Context *context, const uint8_t *message_array, unsigned length)
|
||||||
const uint8_t *message_array,
|
|
||||||
unsigned length)
|
|
||||||
{
|
{
|
||||||
if (!length)
|
if (!length) {
|
||||||
{
|
|
||||||
return shaSuccess;
|
return shaSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context || !message_array)
|
if (!context || !message_array) {
|
||||||
{
|
|
||||||
return shaNull;
|
return shaNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->Computed)
|
if (context->Computed) {
|
||||||
{
|
|
||||||
context->Corrupted = shaStateError;
|
context->Corrupted = shaStateError;
|
||||||
return shaStateError;
|
return shaStateError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->Corrupted)
|
if (context->Corrupted) {
|
||||||
{
|
|
||||||
return context->Corrupted;
|
return context->Corrupted;
|
||||||
}
|
}
|
||||||
while(length-- && !context->Corrupted)
|
|
||||||
{
|
while (length-- && !context->Corrupted) {
|
||||||
context->Message_Block[context->Message_Block_Index++] =
|
context->Message_Block[context->Message_Block_Index++] = (*message_array & 0xFF);
|
||||||
(*message_array & 0xFF);
|
|
||||||
|
|
||||||
context->Length_Low += 8;
|
context->Length_Low += 8;
|
||||||
if (context->Length_Low == 0)
|
if (context->Length_Low == 0) {
|
||||||
{
|
|
||||||
context->Length_High++;
|
context->Length_High++;
|
||||||
if (context->Length_High == 0)
|
if (context->Length_High == 0) {
|
||||||
{
|
|
||||||
/* Message is too long */
|
/* Message is too long */
|
||||||
context->Corrupted = 1;
|
context->Corrupted = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->Message_Block_Index == 64)
|
if (context->Message_Block_Index == 64) {
|
||||||
{
|
|
||||||
SHA1ProcessMessageBlock(context);
|
SHA1ProcessMessageBlock(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,16 +257,14 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
|
|||||||
/*
|
/*
|
||||||
* Initialize the first 16 words in the array W
|
* Initialize the first 16 words in the array W
|
||||||
*/
|
*/
|
||||||
for(t = 0; t < 16; t++)
|
for (t = 0; t < 16; t++) {
|
||||||
{
|
|
||||||
W[t] = context->Message_Block[t * 4] << 24;
|
W[t] = context->Message_Block[t * 4] << 24;
|
||||||
W[t] |= context->Message_Block[t * 4 + 1] << 16;
|
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 + 2] << 8;
|
||||||
W[t] |= context->Message_Block[t * 4 + 3];
|
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]);
|
W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,10 +274,8 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
|
|||||||
D = context->Intermediate_Hash[3];
|
D = context->Intermediate_Hash[3];
|
||||||
E = context->Intermediate_Hash[4];
|
E = context->Intermediate_Hash[4];
|
||||||
|
|
||||||
for(t = 0; t < 20; t++)
|
for (t = 0; t < 20; t++) {
|
||||||
{
|
temp = SHA1CircularShift(5,A) + ((B & C) | ((~B) & D)) + E + W[t] + K[0];
|
||||||
temp = SHA1CircularShift(5,A) +
|
|
||||||
((B & C) | ((~B) & D)) + E + W[t] + K[0];
|
|
||||||
E = D;
|
E = D;
|
||||||
D = C;
|
D = C;
|
||||||
C = SHA1CircularShift(30,B);
|
C = SHA1CircularShift(30,B);
|
||||||
@@ -305,8 +283,7 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
|
|||||||
A = temp;
|
A = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(t = 20; t < 40; t++)
|
for (t = 20; t < 40; t++) {
|
||||||
{
|
|
||||||
temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
|
temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
|
||||||
E = D;
|
E = D;
|
||||||
D = C;
|
D = C;
|
||||||
@@ -315,10 +292,8 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
|
|||||||
A = temp;
|
A = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(t = 40; t < 60; t++)
|
for (t = 40; t < 60; t++) {
|
||||||
{
|
temp = SHA1CircularShift(5,A) + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
|
||||||
temp = SHA1CircularShift(5,A) +
|
|
||||||
((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
|
|
||||||
E = D;
|
E = D;
|
||||||
D = C;
|
D = C;
|
||||||
C = SHA1CircularShift(30,B);
|
C = SHA1CircularShift(30,B);
|
||||||
@@ -326,8 +301,7 @@ void SHA1ProcessMessageBlock(SHA1Context *context)
|
|||||||
A = temp;
|
A = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(t = 60; t < 80; t++)
|
for (t = 60; t < 80; t++) {
|
||||||
{
|
|
||||||
temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
|
temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
|
||||||
E = D;
|
E = D;
|
||||||
D = C;
|
D = C;
|
||||||
@@ -377,26 +351,20 @@ void SHA1PadMessage(SHA1Context *context)
|
|||||||
* block, process it, and then continue padding into a second
|
* block, process it, and then continue padding into a second
|
||||||
* block.
|
* block.
|
||||||
*/
|
*/
|
||||||
if (context->Message_Block_Index > 55)
|
if (context->Message_Block_Index > 55) {
|
||||||
{
|
|
||||||
context->Message_Block[context->Message_Block_Index++] = 0x80;
|
context->Message_Block[context->Message_Block_Index++] = 0x80;
|
||||||
while(context->Message_Block_Index < 64)
|
while (context->Message_Block_Index < 64) {
|
||||||
{
|
|
||||||
context->Message_Block[context->Message_Block_Index++] = 0;
|
context->Message_Block[context->Message_Block_Index++] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SHA1ProcessMessageBlock(context);
|
SHA1ProcessMessageBlock(context);
|
||||||
|
|
||||||
while(context->Message_Block_Index < 56)
|
while (context->Message_Block_Index < 56) {
|
||||||
{
|
|
||||||
context->Message_Block[context->Message_Block_Index++] = 0;
|
context->Message_Block[context->Message_Block_Index++] = 0;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
context->Message_Block[context->Message_Block_Index++] = 0x80;
|
context->Message_Block[context->Message_Block_Index++] = 0x80;
|
||||||
while(context->Message_Block_Index < 56)
|
while (context->Message_Block_Index < 56) {
|
||||||
{
|
|
||||||
context->Message_Block[context->Message_Block_Index++] = 0;
|
context->Message_Block[context->Message_Block_Index++] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
|
|||||||
|
|
||||||
if (frame) {
|
if (frame) {
|
||||||
int x = 0;
|
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++;
|
x++;
|
||||||
}
|
}
|
||||||
if (frame_ptr) {
|
if (frame_ptr) {
|
||||||
|
|||||||
79
tdd.c
79
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 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',
|
static char ltrs[32] = { '<','E','\n','A',' ','S','I','U',
|
||||||
'\n','D','R','J','N','F','C','K',
|
'\n','D','R','J','N','F','C','K',
|
||||||
'T','Z','L','W','H','Y','P','Q',
|
'T','Z','L','W','H','Y','P','Q',
|
||||||
'O','B','G','^','M','X','V','^'};
|
'O','B','G','^','M','X','V','^' };
|
||||||
static char figs[32]={'<','3','\n','-',' ',',','8','7',
|
static char figs[32] = { '<','3','\n','-',' ',',','8','7',
|
||||||
'\n','$','4','\'',',','<EFBFBD>',':','(',
|
'\n','$','4','\'',',','<EFBFBD>',':','(',
|
||||||
'5','+',')','2','<EFBFBD>','6','0','1',
|
'5','+',')','2','<EFBFBD>','6','0','1',
|
||||||
'9','7','<EFBFBD>','^','.','/','=','^'};
|
'9','7','<EFBFBD>','^','.','/','=','^' };
|
||||||
int d;
|
int d = 0; /* return 0 if not decodeable */
|
||||||
d=0; /* return 0 if not decodeable */
|
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case 0x1f : tdd->modo=0; break;
|
case 0x1f:
|
||||||
case 0x1b : tdd->modo=1; break;
|
tdd->modo = 0;
|
||||||
default: if (tdd->modo==0) d=ltrs[data]; else d=figs[data]; break;
|
break;
|
||||||
|
case 0x1b:
|
||||||
|
tdd->modo = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (tdd->modo == 0)
|
||||||
|
d = ltrs[data];
|
||||||
|
else
|
||||||
|
d = figs[data];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
@@ -119,10 +127,8 @@ int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len)
|
|||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int cnt;
|
int cnt;
|
||||||
while(len) {
|
while (len) {
|
||||||
cnt = len;
|
cnt = len > sizeof(ecdisa) ? sizeof(ecdisa) : len;
|
||||||
if (cnt > sizeof(ecdisa))
|
|
||||||
cnt = sizeof(ecdisa);
|
|
||||||
memcpy(outbuf + pos, ecdisa, cnt);
|
memcpy(outbuf + pos, ecdisa, cnt);
|
||||||
pos += cnt;
|
pos += cnt;
|
||||||
len -= 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);
|
memset(buf, 0, 2 * len + tdd->oldlen);
|
||||||
memcpy(buf, tdd->oldstuff, tdd->oldlen);
|
memcpy(buf, tdd->oldstuff, tdd->oldlen);
|
||||||
mylen += tdd->oldlen/2;
|
mylen += tdd->oldlen/2;
|
||||||
for (x=0;x<len;x++)
|
for (x = 0; x < len; x++)
|
||||||
buf[x+tdd->oldlen/2] = AST_MULAW(ubuf[x]);
|
buf[x + tdd->oldlen / 2] = AST_MULAW(ubuf[x]);
|
||||||
c = res = 0;
|
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;
|
olen = mylen;
|
||||||
res = fsk_serie(&tdd->fskd, buf, &mylen, &b);
|
res = fsk_serie(&tdd->fskd, buf, &mylen, &b);
|
||||||
if (mylen < 0) {
|
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);
|
free(obuf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -243,7 +249,7 @@ static inline float tdd_getcarrier(float *cr, float *ci, int bit)
|
|||||||
int z; \
|
int z; \
|
||||||
unsigned char b = (byte); \
|
unsigned char b = (byte); \
|
||||||
PUT_TDD_BAUD(0); /* Start bit */ \
|
PUT_TDD_BAUD(0); /* Start bit */ \
|
||||||
for (z=0;z<5;z++) { \
|
for (z = 0; z < 5; z++) { \
|
||||||
PUT_TDD_BAUD(b & 1); \
|
PUT_TDD_BAUD(b & 1); \
|
||||||
b >>= 1; \
|
b >>= 1; \
|
||||||
} \
|
} \
|
||||||
@@ -267,49 +273,41 @@ int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *str)
|
|||||||
#if 0
|
#if 0
|
||||||
printf("%c",c); fflush(stdout);
|
printf("%c",c); fflush(stdout);
|
||||||
#endif
|
#endif
|
||||||
if (c == 0) /* send null */
|
if (c == 0) { /* send null */
|
||||||
{
|
|
||||||
PUT_TDD(0);
|
PUT_TDD(0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c == '\r') /* send c/r */
|
if (c == '\r') { /* send c/r */
|
||||||
{
|
|
||||||
PUT_TDD(8);
|
PUT_TDD(8);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c == '\n') /* send c/r and l/f */
|
if (c == '\n') { /* send c/r and l/f */
|
||||||
{
|
|
||||||
PUT_TDD(8);
|
PUT_TDD(8);
|
||||||
PUT_TDD(2);
|
PUT_TDD(2);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c == ' ') /* send space */
|
if (c == ' ') { /* send space */
|
||||||
{
|
|
||||||
PUT_TDD(4);
|
PUT_TDD(4);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for(i = 0; i < 31; i++)
|
for (i = 0; i < 31; i++) {
|
||||||
{
|
if (lstr[i] == c)
|
||||||
if (lstr[i] == c) break;
|
break;
|
||||||
}
|
}
|
||||||
if (i < 31) /* if we found it */
|
if (i < 31) { /* if we found it */
|
||||||
{
|
if (tdd->mode) { /* if in figs mode, change it */
|
||||||
if (tdd->mode) /* if in figs mode, change it */
|
|
||||||
{
|
|
||||||
PUT_TDD(31); /* Send LTRS */
|
PUT_TDD(31); /* Send LTRS */
|
||||||
tdd->mode = 0;
|
tdd->mode = 0;
|
||||||
}
|
}
|
||||||
PUT_TDD(i);
|
PUT_TDD(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for(i = 0; i < 31; i++)
|
for (i = 0; i < 31; i++) {
|
||||||
{
|
if (fstr[i] == c)
|
||||||
if (fstr[i] == c) break;
|
break;
|
||||||
}
|
}
|
||||||
if (i < 31) /* if we found it */
|
if (i < 31) { /* if we found it */
|
||||||
{
|
if (tdd->mode != 1) { /* if in ltrs mode, change it */
|
||||||
if (tdd->mode != 1) /* if in ltrs mode, change it */
|
|
||||||
{
|
|
||||||
PUT_TDD(27); /* send FIGS */
|
PUT_TDD(27); /* send FIGS */
|
||||||
tdd->mode = 1;
|
tdd->mode = 1;
|
||||||
}
|
}
|
||||||
@@ -320,4 +318,3 @@ int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *str)
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
27
translate.c
27
translate.c
@@ -393,7 +393,7 @@ static void calc_cost(struct ast_translator *t, int seconds)
|
|||||||
}
|
}
|
||||||
framein(pvt, f);
|
framein(pvt, f);
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
while( (f = t->frameout(pvt))) {
|
while ((f = t->frameout(pvt))) {
|
||||||
sofar += f->samples;
|
sofar += f->samples;
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
}
|
}
|
||||||
@@ -443,7 +443,7 @@ static void rebuild_matrix(int samples)
|
|||||||
*/
|
*/
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
for (x=0; x < MAX_FORMAT; x++) { /* source format */
|
for (x = 0; x < MAX_FORMAT; x++) { /* source format */
|
||||||
for (y=0; y < MAX_FORMAT; y++) { /* intermediate format */
|
for (y=0; y < MAX_FORMAT; y++) { /* intermediate format */
|
||||||
if (x == y) /* skip ourselves */
|
if (x == y) /* skip ourselves */
|
||||||
continue;
|
continue;
|
||||||
@@ -490,19 +490,19 @@ static int show_translation(int fd, int argc, char *argv[])
|
|||||||
|
|
||||||
AST_LIST_LOCK(&translators);
|
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;
|
z = argv[3] ? atoi(argv[3]) : 1;
|
||||||
|
|
||||||
if (z <= 0) {
|
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;
|
z = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (z > MAX_RECALC) {
|
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;
|
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);
|
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() */
|
/* next 2 lines run faster than using ast_build_string() */
|
||||||
*buf++ = ' ';
|
*buf++ = ' ';
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
for (y=-1;y<SHOW_TRANS;y++) {
|
for (y = -1; y < SHOW_TRANS; y++) {
|
||||||
if (x >= 0 && y >= 0 && tr_matrix[x][y].step) /* XXX what is 99999 ? */
|
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);
|
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))) {
|
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) {
|
} else if (x != -1 && y != -1) {
|
||||||
ast_build_string(&buf, &left, " -");
|
ast_build_string(&buf, &left, " -");
|
||||||
} else {
|
} else {
|
||||||
@@ -586,12 +586,12 @@ int ast_register_translator(struct ast_translator *t, void *module)
|
|||||||
*/
|
*/
|
||||||
struct _test_align { void *a, *b; } p;
|
struct _test_align { void *a, *b; } p;
|
||||||
int align = (char *)&p.b - (char *)&p.a;
|
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)
|
if (t->frameout == NULL)
|
||||||
t->frameout = default_frameout;
|
t->frameout = default_frameout;
|
||||||
|
|
||||||
calc_cost(t,1);
|
calc_cost(t, 1);
|
||||||
if (option_verbose > 1) {
|
if (option_verbose > 1) {
|
||||||
char tmp[80];
|
char tmp[80];
|
||||||
ast_verbose(VERBOSE_PREFIX_2 "Registered translator '%s' from format %s to %s, cost %d\n",
|
ast_verbose(VERBOSE_PREFIX_2 "Registered translator '%s' from format %s to %s, cost %d\n",
|
||||||
@@ -641,7 +641,7 @@ int ast_translator_best_choice(int *dst, int *srcs)
|
|||||||
int common = (*dst) & (*srcs); /* are there common formats ? */
|
int common = (*dst) & (*srcs); /* are there common formats ? */
|
||||||
|
|
||||||
if (common) { /* yes, pick one and return */
|
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 */
|
if (cur & common) /* guaranteed to find one */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -650,10 +650,10 @@ int ast_translator_best_choice(int *dst, int *srcs)
|
|||||||
return 0;
|
return 0;
|
||||||
} else { /* No, we will need to translate */
|
} else { /* No, we will need to translate */
|
||||||
AST_LIST_LOCK(&translators);
|
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))
|
if (! (cur & *dst))
|
||||||
continue;
|
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 ||
|
if (!(*srcs & cursrc) || !tr_matrix[x][y].step ||
|
||||||
tr_matrix[x][y].cost > besttime)
|
tr_matrix[x][y].cost > besttime)
|
||||||
continue; /* not existing or no better */
|
continue; /* not existing or no better */
|
||||||
@@ -687,3 +687,4 @@ unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src)
|
|||||||
else
|
else
|
||||||
return tr_matrix[src][dest].multistep + 1;
|
return tr_matrix[src][dest].multistep + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
udptl.c
8
udptl.c
@@ -436,7 +436,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
|
|||||||
continue;
|
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;
|
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)
|
if (s->rx[k].buf_len <= 0)
|
||||||
which = (which == -1) ? k : -2;
|
which = (which == -1) ? k : -2;
|
||||||
}
|
}
|
||||||
@@ -444,7 +444,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
|
|||||||
/* Repairable */
|
/* 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];
|
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)
|
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[j] ^= (s->rx[k].buf_len > j) ? s->rx[k].buf[j] : 0;
|
||||||
}
|
}
|
||||||
s->rx[which].buf_len = s->rx[l].fec_len[m];
|
s->rx[which].buf_len = s->rx[l].fec_len[m];
|
||||||
@@ -935,7 +935,7 @@ void ast_udptl_proto_unregister(struct ast_udptl_protocol *proto)
|
|||||||
|
|
||||||
cur = protos;
|
cur = protos;
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
while(cur) {
|
while (cur) {
|
||||||
if (cur == proto) {
|
if (cur == proto) {
|
||||||
if (prev)
|
if (prev)
|
||||||
prev->next = proto->next;
|
prev->next = proto->next;
|
||||||
@@ -953,7 +953,7 @@ int ast_udptl_proto_register(struct ast_udptl_protocol *proto)
|
|||||||
struct ast_udptl_protocol *cur;
|
struct ast_udptl_protocol *cur;
|
||||||
|
|
||||||
cur = protos;
|
cur = protos;
|
||||||
while(cur) {
|
while (cur) {
|
||||||
if (cur->type == proto->type) {
|
if (cur->type == proto->type) {
|
||||||
ast_log(LOG_WARNING, "Tried to register same protocol '%s' twice\n", cur->type);
|
ast_log(LOG_WARNING, "Tried to register same protocol '%s' twice\n", cur->type);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
16
ulaw.c
16
ulaw.c
@@ -85,22 +85,22 @@ static unsigned char linear2ulaw(short sample)
|
|||||||
void ast_ulaw_init(void)
|
void ast_ulaw_init(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i = 0;i < 256;i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
short mu,e,f,y;
|
short mu, e, f, y;
|
||||||
static short etab[]={0,132,396,924,1980,4092,8316,16764};
|
static short etab[] = {0,132,396,924,1980,4092,8316,16764};
|
||||||
|
|
||||||
mu = 255-i;
|
mu = 255 - i;
|
||||||
e = (mu & 0x70)/16;
|
e = (mu & 0x70) / 16;
|
||||||
f = mu & 0x0f;
|
f = mu & 0x0f;
|
||||||
y = f * (1 << (e + 3));
|
y = f * (1 << (e + 3));
|
||||||
y += etab[e];
|
y += etab[e];
|
||||||
if (mu & 0x80) y = -y;
|
if (mu & 0x80)
|
||||||
|
y = -y;
|
||||||
__ast_mulaw[i] = y;
|
__ast_mulaw[i] = y;
|
||||||
}
|
}
|
||||||
/* set up the reverse (mu-law) conversion table */
|
/* 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);
|
__ast_lin2mu[((unsigned short)i) >> 2] = linear2ulaw(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
utils.c
22
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 */
|
/* here nbytes is the number of bytes required in buffer */
|
||||||
/* as a terminator must be there, the minimum value is ph->h_length */
|
/* as a terminator must be there, the minimum value is ph->h_length */
|
||||||
if(nbytes > buflen) {
|
if (nbytes > buflen) {
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
ast_mutex_unlock(&__mutex); /* end critical area */
|
ast_mutex_unlock(&__mutex); /* end critical area */
|
||||||
return ERANGE; /* not enough space in buf!! */
|
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 */
|
/* copy addresses */
|
||||||
q = (char **)buf; /* pointer to pointers area (type: char **) */
|
q = (char **)buf; /* pointer to pointers area (type: char **) */
|
||||||
ret->h_addr_list = q; /* update pointer to address list */
|
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++) {
|
for (p = ph->h_addr_list; *p != 0; p++) {
|
||||||
memcpy(pbuf, *p, ph->h_length); /* copy address bytes */
|
memcpy(pbuf, *p, ph->h_length); /* copy address bytes */
|
||||||
*q++ = pbuf; /* the pointer is the one inside buf... */
|
*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));
|
MD5Update(&md5, (unsigned char *)input, strlen(input));
|
||||||
MD5Final(digest, &md5);
|
MD5Final(digest, &md5);
|
||||||
ptr = output;
|
ptr = output;
|
||||||
for (x=0; x<16; x++)
|
for (x = 0; x < 16; x++)
|
||||||
ptr += sprintf(ptr, "%2.2x", digest[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;
|
int cntin = 0;
|
||||||
/* Reserve space for null byte at end of string */
|
/* Reserve space for null byte at end of string */
|
||||||
max--;
|
max--;
|
||||||
while((cntin < srclen) && (cnt < max)) {
|
while ((cntin < srclen) && (cnt < max)) {
|
||||||
byte <<= 8;
|
byte <<= 8;
|
||||||
byte |= *(src++);
|
byte |= *(src++);
|
||||||
bits += 8;
|
bits += 8;
|
||||||
@@ -405,7 +405,7 @@ static void base64_init(void)
|
|||||||
int x;
|
int x;
|
||||||
memset(b2a, -1, sizeof(b2a));
|
memset(b2a, -1, sizeof(b2a));
|
||||||
/* Initialize base-64 Conversion table */
|
/* Initialize base-64 Conversion table */
|
||||||
for (x=0;x<26;x++) {
|
for (x = 0; x < 26; x++) {
|
||||||
/* A-Z */
|
/* A-Z */
|
||||||
base64[x] = 'A' + x;
|
base64[x] = 'A' + x;
|
||||||
b2a['A' + x] = x;
|
b2a['A' + x] = x;
|
||||||
@@ -795,7 +795,7 @@ size_t strnlen(const char *s, size_t n)
|
|||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
for (len=0; len < n; len++)
|
for (len = 0; len < n; len++)
|
||||||
if (s[len] == '\0')
|
if (s[len] == '\0')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1038,10 +1038,10 @@ char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
|
|||||||
if (*start == '\\') {
|
if (*start == '\\') {
|
||||||
inEscape = 1; /* Do not copy \ into the data */
|
inEscape = 1; /* Do not copy \ into the data */
|
||||||
} else if (*start == '\'') {
|
} else if (*start == '\'') {
|
||||||
inQuotes = 1-inQuotes; /* Do not copy ' into the data */
|
inQuotes = 1 - inQuotes; /* Do not copy ' into the data */
|
||||||
} else {
|
} else {
|
||||||
/* Replace , with |, unless in quotes */
|
/* 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;
|
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;
|
int x, ofs = 0;
|
||||||
const char *src;
|
const char *src;
|
||||||
@@ -1058,7 +1058,7 @@ void ast_join(char *s, size_t len, char * const w[])
|
|||||||
/* Join words into a string */
|
/* Join words into a string */
|
||||||
if (!s)
|
if (!s)
|
||||||
return;
|
return;
|
||||||
for (x=0; ofs < len && w[x]; x++) {
|
for (x = 0; ofs < len && w[x]; x++) {
|
||||||
if (x > 0)
|
if (x > 0)
|
||||||
s[ofs++] = ' ';
|
s[ofs++] = ' ';
|
||||||
for (src = w[x]; *src && ofs < len; src++)
|
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 */
|
AST_MUTEX_DEFINE_STATIC(fetchadd_m); /* used for all fetc&add ops */
|
||||||
|
|
||||||
int ast_atomic_fetchadd_int_slow(volatile int *p, int v)
|
int ast_atomic_fetchadd_int_slow(volatile int *p, int v)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@@ -1191,3 +1192,4 @@ int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
|
|||||||
} else
|
} else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user