mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-12 04:48:51 +00:00
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:
82
enum.c
82
enum.c
@@ -105,7 +105,7 @@ static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, char *a
|
|||||||
char *oanswer = answer;
|
char *oanswer = answer;
|
||||||
char flags[512] = "";
|
char flags[512] = "";
|
||||||
char services[512] = "";
|
char services[512] = "";
|
||||||
unsigned char *p;
|
char *p;
|
||||||
char regexp[512] = "";
|
char regexp[512] = "";
|
||||||
char repl[512] = "";
|
char repl[512] = "";
|
||||||
char temp[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+");
|
p = strstr(services, "e2u+");
|
||||||
if(p == NULL)
|
if (p == NULL)
|
||||||
p = strstr(services, "E2U+");
|
p = strstr(services, "E2U+");
|
||||||
if(p){
|
if (p){
|
||||||
p = p + 4;
|
p = p + 4;
|
||||||
if(strchr(p, ':')){
|
if (strchr(p, ':')){
|
||||||
p = strchr(p, ':') + 1;
|
p = strchr(p, ':') + 1;
|
||||||
}
|
}
|
||||||
ast_copy_string(tech_return, p, sizeof(tech_return));
|
ast_copy_string(tech_return, p, sizeof(tech_return));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
p = strstr(services, "+e2u");
|
p = strstr(services, "+e2u");
|
||||||
if(p == NULL)
|
if (p == NULL)
|
||||||
p = strstr(services, "+E2U");
|
p = strstr(services, "+E2U");
|
||||||
if(p){
|
if (p) {
|
||||||
*p = 0;
|
*p = 0;
|
||||||
p = strchr(services, ':');
|
p = strchr(services, ':');
|
||||||
if(p)
|
if (p)
|
||||||
*p = 0;
|
*p = 0;
|
||||||
ast_copy_string(tech_return, services, sizeof(tech_return));
|
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 = temp;
|
||||||
d_len--;
|
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)) {
|
if ((subst[0] == '\\') && isdigit(subst[1]) && (pmatch[subst[1]-'0'].rm_so != -1)) {
|
||||||
backref = subst[1]-'0';
|
backref = subst[1]-'0';
|
||||||
size = pmatch[backref].rm_eo - pmatch[backref].rm_so;
|
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);
|
ast_copy_string(dst, temp, dstsize);
|
||||||
dst[dstsize - 1] = '\0';
|
dst[dstsize - 1] = '\0';
|
||||||
|
|
||||||
if(*tech != '\0'){ /* check if it is requested NAPTR */
|
if (*tech != '\0'){ /* check if it is requested NAPTR */
|
||||||
if(!strncasecmp(tech, "ALL", techsize)){
|
if (!strncasecmp(tech, "ALL", techsize)){
|
||||||
return 1; /* return or count any RR */
|
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);
|
ast_copy_string(tech, tech_return, techsize);
|
||||||
return 1; /* we got out RR */
|
return 1; /* we got out RR */
|
||||||
} else { /* go to the next RR in the DNS answer */
|
} 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);
|
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");
|
ast_log(LOG_WARNING, "Failed to parse naptr :(\n");
|
||||||
return -1;
|
return -1;
|
||||||
} else if(res > 0 && !ast_strlen_zero(c->dst)){ /* ok, we got needed NAPTR */
|
} else if (res > 0 && !ast_strlen_zero(c->dst)){ /* ok, we got needed NAPTR */
|
||||||
if(c->options & ENUMLOOKUP_OPTIONS_COUNT){ /* counting RRs */
|
if (c->options & ENUMLOOKUP_OPTIONS_COUNT){ /* counting RRs */
|
||||||
c->position++;
|
c->position++;
|
||||||
snprintf(c->dst, c->dstlen, "%d", c->position);
|
snprintf(c->dst, c->dstlen, "%d", c->position);
|
||||||
} else {
|
} else {
|
||||||
p = realloc(c->naptr_rrs, sizeof(struct enum_naptr_rr)*(c->naptr_rrs_count+1));
|
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;
|
c->naptr_rrs = (struct enum_naptr_rr*)p;
|
||||||
memcpy(&c->naptr_rrs[c->naptr_rrs_count].naptr, answer, sizeof(struct naptr));
|
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)); */
|
/* 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;
|
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);
|
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 i = 0;
|
||||||
int z = 0;
|
int z = 0;
|
||||||
|
|
||||||
if(number[0] == 'n'){
|
if (number[0] == 'n') {
|
||||||
strncpy(naptrinput, number+1, sizeof(naptrinput));
|
strncpy(naptrinput, number+1, sizeof(naptrinput));
|
||||||
} else {
|
} else {
|
||||||
strncpy(naptrinput, number, sizeof(naptrinput));
|
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 = NULL;
|
||||||
context.naptr_rrs_count = 0;
|
context.naptr_rrs_count = 0;
|
||||||
|
|
||||||
if(options != NULL){
|
if (options != NULL){
|
||||||
if(*options == 'c'){
|
if (*options == 'c'){
|
||||||
context.options = ENUMLOOKUP_OPTIONS_COUNT;
|
context.options = ENUMLOOKUP_OPTIONS_COUNT;
|
||||||
context.position = 0;
|
context.position = 0;
|
||||||
} else {
|
} else {
|
||||||
context.position = atoi(options);
|
context.position = atoi(options);
|
||||||
if(context.position < 1)
|
if (context.position < 1)
|
||||||
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 */
|
/* ISN rewrite */
|
||||||
p1 = strchr(number, '*');
|
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;
|
p1 = NULL;
|
||||||
k = 1; /* strip 'n' from number */
|
k = 1; /* strip 'n' from number */
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p1 != NULL){
|
if (p1 != NULL) {
|
||||||
p2 = p1+1;
|
p2 = p1+1;
|
||||||
while(p1 > number){
|
while (p1 > number){
|
||||||
p1--;
|
p1--;
|
||||||
tmp[newpos++] = *p1;
|
tmp[newpos++] = *p1;
|
||||||
tmp[newpos++] = '.';
|
tmp[newpos++] = '.';
|
||||||
}
|
}
|
||||||
if(*p2){
|
if (*p2) {
|
||||||
while(*p2 && newpos < 128){
|
while(*p2 && newpos < 128){
|
||||||
tmp[newpos++] = *p2;
|
tmp[newpos++] = *p2;
|
||||||
p2++;
|
p2++;
|
||||||
@@ -452,8 +452,8 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
while(pos >= k) {
|
while (pos >= k) {
|
||||||
if(isdigit(number[pos])){
|
if (isdigit(number[pos])) {
|
||||||
tmp[newpos++] = number[pos];
|
tmp[newpos++] = number[pos];
|
||||||
tmp[newpos++] = '.';
|
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)
|
if (chan && ast_autoservice_start(chan) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for(;;) {
|
for (;;) {
|
||||||
ast_mutex_lock(&enumlock);
|
ast_mutex_lock(&enumlock);
|
||||||
if (version != enumver) {
|
if (version != enumver) {
|
||||||
/* Ooh, a reload... */
|
/* Ooh, a reload... */
|
||||||
@@ -473,7 +473,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
|
|||||||
} else {
|
} else {
|
||||||
s = s->next;
|
s = s->next;
|
||||||
}
|
}
|
||||||
if(suffix != NULL){
|
if (suffix != NULL) {
|
||||||
strncpy(tmp + newpos, suffix, sizeof(tmp) - newpos - 1);
|
strncpy(tmp + newpos, suffix, sizeof(tmp) - newpos - 1);
|
||||||
} else if (s) {
|
} else if (s) {
|
||||||
strncpy(tmp + newpos, s->toplev, sizeof(tmp) - newpos - 1);
|
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);
|
ret = ast_search_dns(&context, tmp, C_IN, T_NAPTR, enum_callback);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
break;
|
break;
|
||||||
if(suffix != NULL)
|
if (suffix != NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -492,12 +492,12 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
|
|||||||
ret = 0;
|
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 */
|
/* sort array by NAPTR order/preference */
|
||||||
for(k=0; k<context.naptr_rrs_count; k++){
|
for (k=0; k<context.naptr_rrs_count; k++) {
|
||||||
for(i=0; i<context.naptr_rrs_count; i++){
|
for (i=0; i<context.naptr_rrs_count; i++) {
|
||||||
/* use order first and then preference to compare */
|
/* 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)
|
&& 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)
|
|| (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)){
|
&& 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;
|
context.naptr_rrs[i].sort_pos = z;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
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)) {
|
||||||
if((ntohs(context.naptr_rrs[k].naptr.pref) < ntohs(context.naptr_rrs[i].naptr.pref)
|
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)
|
&& 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)
|
|| (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)){
|
&& 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++){
|
for (k=0; k<context.naptr_rrs_count; k++) {
|
||||||
if(context.naptr_rrs[k].sort_pos == context.position-1){
|
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.dst, context.naptr_rrs[k].result, dstlen);
|
||||||
ast_copy_string(context.tech, context.naptr_rrs[k].tech, techlen);
|
ast_copy_string(context.tech, context.naptr_rrs[k].tech, techlen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if( !(context.options & ENUMLOOKUP_OPTIONS_COUNT) ) {
|
} else if (!(context.options & ENUMLOOKUP_OPTIONS_COUNT)) {
|
||||||
context.dst[0] = 0;
|
context.dst[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan)
|
if (chan)
|
||||||
ret |= ast_autoservice_stop(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].result);
|
||||||
free(context.naptr_rrs[k].tech);
|
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)
|
if (pos > 128)
|
||||||
pos = 128;
|
pos = 128;
|
||||||
while(pos >= 0) {
|
while (pos >= 0) {
|
||||||
tmp[newpos++] = number[pos--];
|
tmp[newpos++] = number[pos--];
|
||||||
tmp[newpos++] = '.';
|
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)
|
if (chan && ast_autoservice_start(chan) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for(;;) {
|
for (;;) {
|
||||||
ast_mutex_lock(&enumlock);
|
ast_mutex_lock(&enumlock);
|
||||||
if (version != enumver) {
|
if (version != enumver) {
|
||||||
/* Ooh, a reload... */
|
/* Ooh, a reload... */
|
||||||
|
|||||||
Reference in New Issue
Block a user