Whitespace changes only

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@37345 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Tilghman Lesher 20 years ago
parent 4a3e227291
commit 229ab7d9cf

@ -423,3 +423,4 @@ int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr)
return 0; return 0;
return -1; return -1;
} }

@ -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;
} }
} }

59
tdd.c

@ -71,12 +71,20 @@ static int tdd_decode_baudot(struct tdd_state *tdd,unsigned char data) /* covert
'\n','$','4','\'',',','·',':','(', '\n','$','4','\'',',','·',':','(',
'5','+',')','2','·','6','0','1', '5','+',')','2','·','6','0','1',
'9','7','·','^','.','/','=','^' }; '9','7','·','^','.','/','=','^' };
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;
} }
@ -120,9 +128,7 @@ 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;
@ -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;
} }

@ -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;
} }

@ -94,13 +94,13 @@ void ast_ulaw_init(void)
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);
} }
} }

@ -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;
@ -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;
} }

Loading…
Cancel
Save