fix some gcc4 pointer signedness warnings and clean up some formatting

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6628 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant 2005-09-23 02:40:38 +00:00
parent 8087701923
commit 21eb11c40e
1 changed files with 142 additions and 142 deletions

82
enum.c
View File

@ -105,7 +105,7 @@ static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, char *a
char *oanswer = answer;
char flags[512] = "";
char services[512] = "";
unsigned char *p;
char *p;
char regexp[512] = "";
char repl[512] = "";
char temp[512] = "";
@ -165,23 +165,23 @@ static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, char *a
}
p = strstr(services, "e2u+");
if(p == NULL)
if (p == NULL)
p = strstr(services, "E2U+");
if(p){
if (p){
p = p + 4;
if(strchr(p, ':')){
if (strchr(p, ':')){
p = strchr(p, ':') + 1;
}
ast_copy_string(tech_return, p, sizeof(tech_return));
} else {
p = strstr(services, "+e2u");
if(p == NULL)
if (p == NULL)
p = strstr(services, "+E2U");
if(p){
if (p) {
*p = 0;
p = strchr(services, ':');
if(p)
if (p)
*p = 0;
ast_copy_string(tech_return, services, sizeof(tech_return));
}
@ -240,7 +240,7 @@ static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, char *a
d = temp;
d_len--;
while( *subst && (d_len > 0) ) {
while (*subst && (d_len > 0)) {
if ((subst[0] == '\\') && isdigit(subst[1]) && (pmatch[subst[1]-'0'].rm_so != -1)) {
backref = subst[1]-'0';
size = pmatch[backref].rm_eo - pmatch[backref].rm_so;
@ -264,11 +264,11 @@ static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, char *a
ast_copy_string(dst, temp, dstsize);
dst[dstsize - 1] = '\0';
if(*tech != '\0'){ /* check if it is requested NAPTR */
if(!strncasecmp(tech, "ALL", techsize)){
if (*tech != '\0'){ /* check if it is requested NAPTR */
if (!strncasecmp(tech, "ALL", techsize)){
return 1; /* return or count any RR */
}
if(!strncasecmp(tech_return, tech, sizeof(tech_return)<techsize?sizeof(tech_return):techsize)){
if (!strncasecmp(tech_return, tech, sizeof(tech_return)<techsize?sizeof(tech_return):techsize)){
ast_copy_string(tech, tech_return, techsize);
return 1; /* we got out RR */
} else { /* go to the next RR in the DNS answer */
@ -350,16 +350,16 @@ static int enum_callback(void *context, char *answer, int len, char *fullanswer)
res = parse_naptr(c->dst, c->dstlen, c->tech, c->techlen, answer, len, c->naptrinput);
if(res < 0){
if (res < 0) {
ast_log(LOG_WARNING, "Failed to parse naptr :(\n");
return -1;
} else if(res > 0 && !ast_strlen_zero(c->dst)){ /* ok, we got needed NAPTR */
if(c->options & ENUMLOOKUP_OPTIONS_COUNT){ /* counting RRs */
} else if (res > 0 && !ast_strlen_zero(c->dst)){ /* ok, we got needed NAPTR */
if (c->options & ENUMLOOKUP_OPTIONS_COUNT){ /* counting RRs */
c->position++;
snprintf(c->dst, c->dstlen, "%d", c->position);
} else {
p = realloc(c->naptr_rrs, sizeof(struct enum_naptr_rr)*(c->naptr_rrs_count+1));
if(p){
if (p) {
c->naptr_rrs = (struct enum_naptr_rr*)p;
memcpy(&c->naptr_rrs[c->naptr_rrs_count].naptr, answer, sizeof(struct naptr));
/* printf("order=%d, pref=%d\n", ntohs(c->naptr_rrs[c->naptr_rrs_count].naptr.order), ntohs(c->naptr_rrs[c->naptr_rrs_count].naptr.pref)); */
@ -373,7 +373,7 @@ static int enum_callback(void *context, char *answer, int len, char *fullanswer)
return 0;
}
if(c->options & ENUMLOOKUP_OPTIONS_COUNT){ /* counting RRs */
if (c->options & ENUMLOOKUP_OPTIONS_COUNT) { /* counting RRs */
snprintf(c->dst, c->dstlen, "%d", c->position);
}
@ -398,7 +398,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
int i = 0;
int z = 0;
if(number[0] == 'n'){
if (number[0] == 'n') {
strncpy(naptrinput, number+1, sizeof(naptrinput));
} else {
strncpy(naptrinput, number, sizeof(naptrinput));
@ -414,13 +414,13 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
context.naptr_rrs = NULL;
context.naptr_rrs_count = 0;
if(options != NULL){
if(*options == 'c'){
if (options != NULL){
if (*options == 'c'){
context.options = ENUMLOOKUP_OPTIONS_COUNT;
context.position = 0;
} else {
context.position = atoi(options);
if(context.position < 1)
if (context.position < 1)
context.position = 1;
}
}
@ -431,19 +431,19 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
/* ISN rewrite */
p1 = strchr(number, '*');
if(number[0] == 'n'){ /* do not perform ISN rewrite ('n' is testing flag) */
if (number[0] == 'n') { /* do not perform ISN rewrite ('n' is testing flag) */
p1 = NULL;
k = 1; /* strip 'n' from number */
}
if(p1 != NULL){
if (p1 != NULL) {
p2 = p1+1;
while(p1 > number){
while (p1 > number){
p1--;
tmp[newpos++] = *p1;
tmp[newpos++] = '.';
}
if(*p2){
if (*p2) {
while(*p2 && newpos < 128){
tmp[newpos++] = *p2;
p2++;
@ -452,8 +452,8 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
}
} else {
while(pos >= k) {
if(isdigit(number[pos])){
while (pos >= k) {
if (isdigit(number[pos])) {
tmp[newpos++] = number[pos];
tmp[newpos++] = '.';
}
@ -464,7 +464,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
if (chan && ast_autoservice_start(chan) < 0)
return -1;
for(;;) {
for (;;) {
ast_mutex_lock(&enumlock);
if (version != enumver) {
/* Ooh, a reload... */
@ -473,7 +473,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
} else {
s = s->next;
}
if(suffix != NULL){
if (suffix != NULL) {
strncpy(tmp + newpos, suffix, sizeof(tmp) - newpos - 1);
} else if (s) {
strncpy(tmp + newpos, s->toplev, sizeof(tmp) - newpos - 1);
@ -484,7 +484,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
ret = ast_search_dns(&context, tmp, C_IN, T_NAPTR, enum_callback);
if (ret > 0)
break;
if(suffix != NULL)
if (suffix != NULL)
break;
}
if (ret < 0) {
@ -492,12 +492,12 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
ret = 0;
}
if(context.naptr_rrs_count >= context.position && ! (context.options & ENUMLOOKUP_OPTIONS_COUNT)){
if (context.naptr_rrs_count >= context.position && ! (context.options & ENUMLOOKUP_OPTIONS_COUNT)) {
/* sort array by NAPTR order/preference */
for(k=0; k<context.naptr_rrs_count; k++){
for(i=0; i<context.naptr_rrs_count; i++){
for (k=0; k<context.naptr_rrs_count; k++) {
for (i=0; i<context.naptr_rrs_count; i++) {
/* use order first and then preference to compare */
if((ntohs(context.naptr_rrs[k].naptr.order) < ntohs(context.naptr_rrs[i].naptr.order)
if ((ntohs(context.naptr_rrs[k].naptr.order) < ntohs(context.naptr_rrs[i].naptr.order)
&& context.naptr_rrs[k].sort_pos > context.naptr_rrs[i].sort_pos)
|| (ntohs(context.naptr_rrs[k].naptr.order) > ntohs(context.naptr_rrs[i].naptr.order)
&& context.naptr_rrs[k].sort_pos < context.naptr_rrs[i].sort_pos)){
@ -506,8 +506,8 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
context.naptr_rrs[i].sort_pos = z;
continue;
}
if(ntohs(context.naptr_rrs[k].naptr.order) == ntohs(context.naptr_rrs[i].naptr.order)){
if((ntohs(context.naptr_rrs[k].naptr.pref) < ntohs(context.naptr_rrs[i].naptr.pref)
if (ntohs(context.naptr_rrs[k].naptr.order) == ntohs(context.naptr_rrs[i].naptr.order)) {
if ((ntohs(context.naptr_rrs[k].naptr.pref) < ntohs(context.naptr_rrs[i].naptr.pref)
&& context.naptr_rrs[k].sort_pos > context.naptr_rrs[i].sort_pos)
|| (ntohs(context.naptr_rrs[k].naptr.pref) > ntohs(context.naptr_rrs[i].naptr.pref)
&& context.naptr_rrs[k].sort_pos < context.naptr_rrs[i].sort_pos)){
@ -518,21 +518,21 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
}
}
}
for(k=0; k<context.naptr_rrs_count; k++){
if(context.naptr_rrs[k].sort_pos == context.position-1){
for (k=0; k<context.naptr_rrs_count; k++) {
if (context.naptr_rrs[k].sort_pos == context.position-1) {
ast_copy_string(context.dst, context.naptr_rrs[k].result, dstlen);
ast_copy_string(context.tech, context.naptr_rrs[k].tech, techlen);
break;
}
}
} else if( !(context.options & ENUMLOOKUP_OPTIONS_COUNT) ) {
} else if (!(context.options & ENUMLOOKUP_OPTIONS_COUNT)) {
context.dst[0] = 0;
}
if (chan)
ret |= ast_autoservice_stop(chan);
for(k=0; k<context.naptr_rrs_count; k++){
for (k=0; k<context.naptr_rrs_count; k++) {
free(context.naptr_rrs[k].result);
free(context.naptr_rrs[k].tech);
}
@ -568,7 +568,7 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *dst, int dst
if (pos > 128)
pos = 128;
while(pos >= 0) {
while (pos >= 0) {
tmp[newpos++] = number[pos--];
tmp[newpos++] = '.';
}
@ -576,7 +576,7 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *dst, int dst
if (chan && ast_autoservice_start(chan) < 0)
return -1;
for(;;) {
for (;;) {
ast_mutex_lock(&enumlock);
if (version != enumver) {
/* Ooh, a reload... */