--- enum.c-orig 2005-11-09 04:47:52.000000000 +0000 +++ enum.c 2005-11-09 04:48:30.000000000 +0000 @@ -398,7 +398,7 @@ int i = 0; int z = 0; - if (number[0] == 'n') { + if (number[0] == 'n' && !strchr(options, 's')) { strncpy(naptrinput, number+1, sizeof(naptrinput)); } else { strncpy(naptrinput, number, sizeof(naptrinput)); @@ -415,11 +415,13 @@ context.naptr_rrs_count = 0; if (options != NULL){ - if (*options == 'c'){ + if (strchr(options, 'c')){ context.options = ENUMLOOKUP_OPTIONS_COUNT; context.position = 0; } else { - context.position = atoi(options); + char *p = options; + while(*p && !isdigit(*p)) p++; + context.position = atoi(p); if (context.position < 1) context.position = 1; } @@ -428,37 +430,44 @@ if (pos > 128) pos = 128; - /* ISN rewrite */ - p1 = strchr(number, '*'); - - if (number[0] == 'n') { /* do not perform ISN rewrite ('n' is testing flag) */ - p1 = NULL; - k = 1; /* strip 'n' from number */ - } - - if (p1 != NULL) { - p2 = p1+1; - while (p1 > number){ - p1--; - tmp[newpos++] = *p1; - tmp[newpos++] = '.'; - } - if (*p2) { - while(*p2 && newpos < 128){ - tmp[newpos++] = *p2; - p2++; - } - tmp[newpos++] = '.'; + if(strchr(options, 's') == NULL){ + /* ISN rewrite */ + p1 = strchr(number, '*'); + + if (number[0] == 'n') { /* do not perform ISN rewrite ('n' is testing flag) */ + p1 = NULL; + k = 1; /* strip 'n' from number */ } - } else { - while (pos >= k) { - if (isdigit(number[pos])) { - tmp[newpos++] = number[pos]; + if (p1 != NULL) { + p2 = p1+1; + while (p1 > number){ + p1--; + tmp[newpos++] = *p1; + tmp[newpos++] = '.'; + } + if (*p2) { + while(*p2 && newpos < 128){ + tmp[newpos++] = *p2; + p2++; + } tmp[newpos++] = '.'; } - pos--; + + } else { + while (pos >= k) { + if (isdigit(number[pos])) { + tmp[newpos++] = number[pos]; + tmp[newpos++] = '.'; + } + pos--; + } } + } else { + strncpy(tmp, number, sizeof(tmp)-1); + tmp[pos+1] = '.'; + tmp[pos+2] = 0; + newpos = pos+2; } if (chan && ast_autoservice_start(chan) < 0)