mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-26 10:09:19 +02:00
cleaning
This commit is contained in:
parent
2e6e493549
commit
b52787a74b
28
read.c
28
read.c
|
@ -20,40 +20,42 @@ static int
|
||||||
readname_loop(char *packet, char **src, char *dst, size_t length, size_t loop)
|
readname_loop(char *packet, char **src, char *dst, size_t length, size_t loop)
|
||||||
{
|
{
|
||||||
char *dummy;
|
char *dummy;
|
||||||
|
char *s;
|
||||||
|
char *d;
|
||||||
int len;
|
int len;
|
||||||
char *p;
|
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
if (loop <= 0)
|
if (loop <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
p = *src;
|
s = *src;
|
||||||
while(*p && len < length - 2) {
|
d = dst;
|
||||||
c = *p++;
|
while(*s && len < length - 2) {
|
||||||
|
c = *s++;
|
||||||
|
|
||||||
/* is this a compressed label? */
|
/* is this a compressed label? */
|
||||||
if((c & 0xc0) == 0xc0) {
|
if((c & 0xc0) == 0xc0) {
|
||||||
dummy = packet + (((p[-1] & 0x3f) << 8) | p[0]);
|
dummy = packet + (((s[-1] & 0x3f) << 8) | s[0]);
|
||||||
len += readname_loop(packet, &dummy, dst, length - len, loop - 1);
|
len += readname_loop(packet, &dummy, d, length - len, loop - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(c && len < length - 2) {
|
while(c && len < length - 2) {
|
||||||
*dst++ = *p++;
|
*d++ = *s++;
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p != 0 && len < length - 2)
|
if (*s != 0 && len < length - 2)
|
||||||
*dst++ = '.';
|
*d++ = '.';
|
||||||
else
|
|
||||||
*dst++ = '\0';
|
|
||||||
}
|
}
|
||||||
(*src) = p+1;
|
(*src) = s+1;
|
||||||
|
|
||||||
return strlen(dst);
|
dst[len] = '\0';
|
||||||
|
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue