summaryrefslogtreecommitdiff
path: root/src/libs6dns
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-03-11 16:09:55 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-03-11 16:09:55 +0000
commit5ad27a3dc4b957191e2e657d41656810138ba789 (patch)
tree07e7e00ab43b74d6a3fdff9ad80e93882921adfa /src/libs6dns
parentf417b72c9489cd7c20b94eb8904a8911b7f6fd15 (diff)
downloads6-dns-5ad27a3dc4b957191e2e657d41656810138ba789.tar.xz
Adapt to skalibs-2.5.0.0
Diffstat (limited to 'src/libs6dns')
-rw-r--r--src/libs6dns/s6dns_analyze_packet.c7
-rw-r--r--src/libs6dns/s6dns_analyze_qtype_parse.c8
-rw-r--r--src/libs6dns/s6dns_analyze_record.c11
-rw-r--r--src/libs6dns/s6dns_analyze_record_strings.c2
-rw-r--r--src/libs6dns/s6dns_analyze_record_unknown.c4
-rw-r--r--src/libs6dns/s6dns_constants_error_str.c3
-rw-r--r--src/libs6dns/s6dns_debug_dumpdt_post_send.c2
-rw-r--r--src/libs6dns/s6dns_debug_dumpdt_pre_send.c8
-rw-r--r--src/libs6dns/s6dns_domain_arpafromip4.c10
-rw-r--r--src/libs6dns/s6dns_domain_arpafromip6.c6
-rw-r--r--src/libs6dns/s6dns_domain_decode.c2
-rw-r--r--src/libs6dns/s6dns_domain_encode.c6
-rw-r--r--src/libs6dns/s6dns_domain_encodelist.c2
-rw-r--r--src/libs6dns/s6dns_domain_fromstring.c6
-rw-r--r--src/libs6dns/s6dns_domain_fromstring_noqualify_encode.c2
-rw-r--r--src/libs6dns/s6dns_domain_fromstring_qualify_encode.c1
-rw-r--r--src/libs6dns/s6dns_domain_qualify.c9
-rw-r--r--src/libs6dns/s6dns_domain_tostring.c7
-rw-r--r--src/libs6dns/s6dns_engine.c41
-rw-r--r--src/libs6dns/s6dns_fmt_domainlist.c9
-rw-r--r--src/libs6dns/s6dns_fmt_hinfo.c7
-rw-r--r--src/libs6dns/s6dns_fmt_mx.c7
-rw-r--r--src/libs6dns/s6dns_fmt_soa.c17
-rw-r--r--src/libs6dns/s6dns_fmt_srv.c13
-rw-r--r--src/libs6dns/s6dns_message_counts_pack.c2
-rw-r--r--src/libs6dns/s6dns_message_counts_unpack.c2
-rw-r--r--src/libs6dns/s6dns_message_get_domain_internal.c7
-rw-r--r--src/libs6dns/s6dns_message_get_mx.c2
-rw-r--r--src/libs6dns/s6dns_message_get_soa.c2
-rw-r--r--src/libs6dns/s6dns_message_get_srv.c2
-rw-r--r--src/libs6dns/s6dns_message_get_string_internal.c9
-rw-r--r--src/libs6dns/s6dns_message_get_strings.c6
-rw-r--r--src/libs6dns/s6dns_message_header_pack.c2
-rw-r--r--src/libs6dns/s6dns_message_header_unpack.c2
-rw-r--r--src/libs6dns/s6dns_message_parse.c2
-rw-r--r--src/libs6dns/s6dns_message_parse_answer_domain.c2
-rw-r--r--src/libs6dns/s6dns_message_parse_answer_hinfo.c2
-rw-r--r--src/libs6dns/s6dns_message_parse_answer_mx.c2
-rw-r--r--src/libs6dns/s6dns_message_parse_answer_soa.c2
-rw-r--r--src/libs6dns/s6dns_message_parse_answer_srv.c2
-rw-r--r--src/libs6dns/s6dns_message_parse_answer_strings.c4
-rw-r--r--src/libs6dns/s6dns_message_parse_getrr.c3
-rw-r--r--src/libs6dns/s6dns_message_parse_skipqd.c2
-rw-r--r--src/libs6dns/s6dns_rci_init.c25
-rw-r--r--src/libs6dns/s6dns_resolve_dpag.c2
-rw-r--r--src/libs6dns/s6dns_resolve_mpag.c2
-rw-r--r--src/libs6dns/s6dns_resolve_name4.c2
-rw-r--r--src/libs6dns/s6dns_resolve_name6.c2
-rw-r--r--src/libs6dns/s6dns_resolve_parse.c2
-rw-r--r--src/libs6dns/s6dns_resolven_loop.c2
-rw-r--r--src/libs6dns/s6dns_resolven_parse.c4
-rw-r--r--src/libs6dns/s6dns_resolvenoq_aaaaa.c2
-rw-r--r--src/libs6dns/s6dns_resolveq.c6
-rw-r--r--src/libs6dns/s6dns_resolveq_aaaaa.c12
54 files changed, 150 insertions, 158 deletions
diff --git a/src/libs6dns/s6dns_analyze_packet.c b/src/libs6dns/s6dns_analyze_packet.c
index 11c14e6..57e7f95 100644
--- a/src/libs6dns/s6dns_analyze_packet.c
+++ b/src/libs6dns/s6dns_analyze_packet.c
@@ -1,18 +1,17 @@
/* ISC license. */
+#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/uint16.h>
-#include <skalibs/uint.h>
-#include <skalibs/bytestr.h>
+#include <skalibs/types.h>
#include <skalibs/genwrite.h>
#include <s6-dns/s6dns-constants.h>
#include <s6-dns/s6dns-domain.h>
#include <s6-dns/s6dns-message.h>
#include <s6-dns/s6dns-analyze.h>
-#define add(s) if ((*gp->put)(gp->target, (s), str_len(s)) < 0) return 0
+#define add(s) if ((*gp->put)(gp->target, (s), strlen(s)) < 0) return 0
#define addfmt(n) if ((*gp->put)(gp->target, fmt, uint_fmt(fmt, (n))) < 0) return 0
#define addfmt16(n) if ((*gp->put)(gp->target, fmt, uint16_fmt(fmt, (n))) < 0) return 0
diff --git a/src/libs6dns/s6dns_analyze_qtype_parse.c b/src/libs6dns/s6dns_analyze_qtype_parse.c
index 383dcde..8ae86ad 100644
--- a/src/libs6dns/s6dns_analyze_qtype_parse.c
+++ b/src/libs6dns/s6dns_analyze_qtype_parse.c
@@ -1,8 +1,8 @@
/* ISC license. */
#include <stdint.h>
-#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
+#include <strings.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-constants.h>
#include <s6-dns/s6dns-analyze.h>
@@ -40,8 +40,8 @@ uint16_t s6dns_analyze_qtype_parse (char const *s)
if (uint160_scan(s, &u)) return u ;
}
{
- register lookuptable_t const *p = table ;
- for (; p->text ; p++) if (case_equals(s, p->text)) return p->qtype ;
+ lookuptable_t const *p = table ;
+ for (; p->text ; p++) if (!strcasecmp(s, p->text)) return p->qtype ;
}
return 0 ;
}
diff --git a/src/libs6dns/s6dns_analyze_record.c b/src/libs6dns/s6dns_analyze_record.c
index ecc5c26..e2621f7 100644
--- a/src/libs6dns/s6dns_analyze_record.c
+++ b/src/libs6dns/s6dns_analyze_record.c
@@ -1,9 +1,8 @@
/* ISC license. */
+#include <string.h>
#include <stdint.h>
-#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
-#include <skalibs/bytestr.h>
+#include <skalibs/types.h>
#include <skalibs/genwrite.h>
#include <s6-dns/s6dns-domain.h>
#include <s6-dns/s6dns-message.h>
@@ -11,7 +10,7 @@
static s6dns_analyze_rtypetable_t const *rtypelookup (uint16_t rtype)
{
- register s6dns_analyze_rtypetable_t const *wut = s6dns_analyze_rtypetable ;
+ s6dns_analyze_rtypetable_t const *wut = s6dns_analyze_rtypetable ;
while (wut->rtype && wut->rtype != rtype) wut++ ;
return wut ;
}
@@ -21,7 +20,7 @@ int s6dns_analyze_record (genwrite_t *gp, s6dns_message_rr_t const *rr, char con
s6dns_analyze_rtypetable_t const *wut = rtypelookup(rr->rtype) ;
{
char buf[256] ;
- register unsigned int n = s6dns_domain_tostring(buf, 256, &rr->name) ;
+ unsigned int n = s6dns_domain_tostring(buf, 256, &rr->name) ;
if (!n) return 0 ;
if ((*gp->put)(gp->target, buf, n) < 0) return 0 ;
}
@@ -30,7 +29,7 @@ int s6dns_analyze_record (genwrite_t *gp, s6dns_message_rr_t const *rr, char con
if ((*gp->put)(gp->target, fmt, 1 + uint32_fmt(fmt+1, rr->ttl)) < 0) return 0 ;
}
if ((*gp->put)(gp->target, " ", 1) < 0) return 0 ;
- if ((*gp->put)(gp->target, wut->string, str_len(wut->string)) < 0) return 0 ;
+ if ((*gp->put)(gp->target, wut->string, strlen(wut->string)) < 0) return 0 ;
if ((*gp->put)(gp->target, " ", 1) < 0) return 0 ;
if (!(*wut->f)(gp, rr, packet, packetlen, pos)) return 0 ;
if ((*gp->put)(gp->target, "\n", 1) < 0) return 0 ;
diff --git a/src/libs6dns/s6dns_analyze_record_strings.c b/src/libs6dns/s6dns_analyze_record_strings.c
index c2aa15a..a5df9e6 100644
--- a/src/libs6dns/s6dns_analyze_record_strings.c
+++ b/src/libs6dns/s6dns_analyze_record_strings.c
@@ -13,7 +13,7 @@ int s6dns_analyze_record_strings (genwrite_t *gp, s6dns_message_rr_t const *rr,
stralloc sa = STRALLOC_ZERO ;
char buf[rr->rdlength] ;
unsigned int pos = start ;
- register int r = s6dns_message_get_strings(buf, rr->rdlength, packet, packetlen, &pos) ;
+ int r = s6dns_message_get_strings(buf, rr->rdlength, packet, packetlen, &pos) ;
if (r < 0) return 0 ;
if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ;
if (!string_quote(&sa, buf, r)) return 0 ;
diff --git a/src/libs6dns/s6dns_analyze_record_unknown.c b/src/libs6dns/s6dns_analyze_record_unknown.c
index 07b2941..8e27dc4 100644
--- a/src/libs6dns/s6dns_analyze_record_unknown.c
+++ b/src/libs6dns/s6dns_analyze_record_unknown.c
@@ -1,7 +1,7 @@
/* ISC license. */
#include <stdint.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/fmtscan.h>
#include <skalibs/genwrite.h>
#include <s6-dns/s6dns-message.h>
@@ -16,7 +16,7 @@ int s6dns_analyze_record_unknown (genwrite_t *gp, s6dns_message_rr_t const *rr,
if ((*gp->put)(gp->target, fmt, uint16_fmt(fmt, rr->rdlength)) < 0) return 0 ;
if ((*gp->put)(gp->target, ": ", 2) < 0) return 0 ;
{
- register uint16_t i = 0 ;
+ uint16_t i = 0 ;
for (; i < rr->rdlength ; i++)
if ((*gp->put)(gp->target, fmt, ucharn_fmt(fmt, packet + pos + i, 1)) < 0)
return 0 ;
diff --git a/src/libs6dns/s6dns_constants_error_str.c b/src/libs6dns/s6dns_constants_error_str.c
index 6d477c2..2c6c072 100644
--- a/src/libs6dns/s6dns_constants_error_str.c
+++ b/src/libs6dns/s6dns_constants_error_str.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <string.h>
#include <skalibs/error.h>
#include <s6-dns/s6dns-constants.h>
@@ -7,5 +8,5 @@ char const *s6dns_constants_error_str (int e)
{
s6dns_constants_error_message_t const *p = s6dns_constants_error ;
while ((p->num != e) && (p->num != -1)) p++ ;
- return p->num == -1 ? error_str(e) : p->string ;
+ return p->num == -1 ? strerror(e) : p->string ;
}
diff --git a/src/libs6dns/s6dns_debug_dumpdt_post_send.c b/src/libs6dns/s6dns_debug_dumpdt_post_send.c
index 5e7b60c..27e4ff9 100644
--- a/src/libs6dns/s6dns_debug_dumpdt_post_send.c
+++ b/src/libs6dns/s6dns_debug_dumpdt_post_send.c
@@ -2,7 +2,7 @@
#include <sys/types.h>
#include <stdint.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/djbtime.h>
#include <skalibs/genwrite.h>
#include <s6-dns/s6dns-engine.h>
diff --git a/src/libs6dns/s6dns_debug_dumpdt_pre_send.c b/src/libs6dns/s6dns_debug_dumpdt_pre_send.c
index 1cd6e6e..5e1c60a 100644
--- a/src/libs6dns/s6dns_debug_dumpdt_pre_send.c
+++ b/src/libs6dns/s6dns_debug_dumpdt_pre_send.c
@@ -8,7 +8,7 @@
#include <sys/types.h>
#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/fmtscan.h>
#include <skalibs/tai.h>
#include <skalibs/djbtime.h>
@@ -38,7 +38,7 @@ int s6dns_debug_dumpdt_pre_send (s6dns_engine_t const *dt, void *data)
if ((*gp->put)(gp->target, len ? "cache" : "server", len ? 5 : 6) < (len ? 5 : 6)) return 0 ;
if ((*gp->put)(gp->target, " ", 1) < 1) return 0 ;
len = s6dns_ipfmt(buf, s6dns_ip46list_ip(&dt->servers, dt->curserver), s6dns_ip46list_is6(&dt->servers, dt->curserver)) ;
- if ((*gp->put)(gp->target, buf, len) < (int)len) return 0 ;
+ if ((*gp->put)(gp->target, buf, len) < (ssize_t)len) return 0 ;
if ((*gp->put)(gp->target, " with deadline ", 15) < 15) return 0 ;
{
localtmn_t l ;
@@ -49,7 +49,7 @@ int s6dns_debug_dumpdt_pre_send (s6dns_engine_t const *dt, void *data)
}
else len = localtmn_fmt(buf, &l) ;
}
- if ((*gp->put)(gp->target, buf, len) < (int)len) return 0 ;
+ if ((*gp->put)(gp->target, buf, len) < (ssize_t)len) return 0 ;
if ((*gp->put)(gp->target, ", ", 2) < 2) return 0 ;
if (dt->flagstrict && (*gp->put)(gp->target, "strict, ", 8) < 8) return 0 ;
if ((*gp->put)(gp->target, "query id ", 9) < 9) return 0 ;
@@ -58,7 +58,7 @@ int s6dns_debug_dumpdt_pre_send (s6dns_engine_t const *dt, void *data)
uint16_unpack_big(dt->sa.s + 2, &id) ;
len = uint16_fmt(buf, id) ;
}
- if ((*gp->put)(gp->target, buf, len) < (int)len) return 0 ;
+ if ((*gp->put)(gp->target, buf, len) < (ssize_t)len) return 0 ;
if ((*gp->put)(gp->target, ":\n", 2) < 2) return 0 ;
if (!s6dns_analyze_packet(gp, dt->sa.s + 2, dt->querylen - 2, 1)) return 0 ;
if ((*gp->put)(gp->target, "\n", 1) < 1) return 0 ;
diff --git a/src/libs6dns/s6dns_domain_arpafromip4.c b/src/libs6dns/s6dns_domain_arpafromip4.c
index d77938f..07cd7bd 100644
--- a/src/libs6dns/s6dns_domain_arpafromip4.c
+++ b/src/libs6dns/s6dns_domain_arpafromip4.c
@@ -1,19 +1,19 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
-#include <skalibs/uint.h>
+#include <string.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-domain.h>
void s6dns_domain_arpafromip4 (s6dns_domain_t *d, char const *ip)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
d->len = 0 ;
d->s[d->len++] = '.' ;
for (; i < 4 ; i++)
{
- register unsigned int u = ((unsigned char *)ip)[3-i] ;
+ unsigned int u = ((unsigned char *)ip)[3-i] ;
d->len += uint_fmt(d->s + d->len, u) ;
d->s[d->len++] = '.' ;
}
- byte_copy(d->s + d->len, 13, "in-addr.arpa.") ; d->len += 13 ;
+ memcpy(d->s + d->len, "in-addr.arpa.", 13) ; d->len += 13 ;
}
diff --git a/src/libs6dns/s6dns_domain_arpafromip6.c b/src/libs6dns/s6dns_domain_arpafromip6.c
index 3b58127..594eb69 100644
--- a/src/libs6dns/s6dns_domain_arpafromip6.c
+++ b/src/libs6dns/s6dns_domain_arpafromip6.c
@@ -1,12 +1,12 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/fmtscan.h>
#include <s6-dns/s6dns-domain.h>
void s6dns_domain_arpafromip6 (s6dns_domain_t *d, char const *ip6, unsigned int mask)
{
- register unsigned int i ;
+ unsigned int i ;
if (mask > 128) mask = 128 ;
mask = mask ? 1 + ((mask-1) >> 2) : 0 ;
d->len = 0 ;
@@ -17,5 +17,5 @@ void s6dns_domain_arpafromip6 (s6dns_domain_t *d, char const *ip6, unsigned int
d->s[d->len++] = fmtscan_asc((i & 1) ? (c >> 4) : (c & 15)) ;
d->s[d->len++] = '.' ;
}
- byte_copy(d->s + d->len, 9, "ip6.arpa.") ; d->len += 9 ;
+ memcpy(d->s + d->len, "ip6.arpa.", 9) ; d->len += 9 ;
}
diff --git a/src/libs6dns/s6dns_domain_decode.c b/src/libs6dns/s6dns_domain_decode.c
index db4ccf5..440f672 100644
--- a/src/libs6dns/s6dns_domain_decode.c
+++ b/src/libs6dns/s6dns_domain_decode.c
@@ -20,7 +20,7 @@ int s6dns_domain_decode (s6dns_domain_t *d)
unsigned int pos = 0 ;
for (;;)
{
- register unsigned int r = s6dns_domain_label_decode(d->s + pos, max - pos) ;
+ unsigned int r = s6dns_domain_label_decode(d->s + pos, max - pos) ;
if (!r) return 0 ;
pos += r ;
if (r == 1) break ;
diff --git a/src/libs6dns/s6dns_domain_encode.c b/src/libs6dns/s6dns_domain_encode.c
index 61a790d..a551d23 100644
--- a/src/libs6dns/s6dns_domain_encode.c
+++ b/src/libs6dns/s6dns_domain_encode.c
@@ -6,12 +6,12 @@
int s6dns_domain_encode (s6dns_domain_t *d)
{
- register char *s = d->s ;
- register unsigned int len = d->len ;
+ char *s = d->s ;
+ unsigned int len = d->len ;
if (!d->len || (*s != '.')) return (errno = EINVAL, 0) ;
while (len > 1)
{
- register unsigned int n = byte_chr(s + 1, len - 1, '.') ;
+ unsigned int n = byte_chr(s + 1, len - 1, '.') ;
if (n > 63) return (errno = EINVAL, 0) ;
*s = n++ ; s += n ; len -= n ;
}
diff --git a/src/libs6dns/s6dns_domain_encodelist.c b/src/libs6dns/s6dns_domain_encodelist.c
index 23b4570..1f98dbc 100644
--- a/src/libs6dns/s6dns_domain_encodelist.c
+++ b/src/libs6dns/s6dns_domain_encodelist.c
@@ -4,7 +4,7 @@
unsigned int s6dns_domain_encodelist (s6dns_domain_t *list, unsigned int n)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < n ; i++)
if (!s6dns_domain_encode(list + i)) break ;
return i ;
diff --git a/src/libs6dns/s6dns_domain_fromstring.c b/src/libs6dns/s6dns_domain_fromstring.c
index 92f3117..b87ee10 100644
--- a/src/libs6dns/s6dns_domain_fromstring.c
+++ b/src/libs6dns/s6dns_domain_fromstring.c
@@ -1,14 +1,14 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/bytestr.h>
#include <s6-dns/s6dns-domain.h>
int s6dns_domain_fromstring (s6dns_domain_t *d, char const *s, size_t len)
{
- register size_t j = 1 ;
- register size_t i = 0 ;
+ size_t j = 1 ;
+ size_t i = 0 ;
unsigned int lastdot = 0 ;
d->s[0] = '.' ;
for (; i < len ; i++)
diff --git a/src/libs6dns/s6dns_domain_fromstring_noqualify_encode.c b/src/libs6dns/s6dns_domain_fromstring_noqualify_encode.c
index eb5b55a..96e9858 100644
--- a/src/libs6dns/s6dns_domain_fromstring_noqualify_encode.c
+++ b/src/libs6dns/s6dns_domain_fromstring_noqualify_encode.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <s6-dns/s6dns-domain.h>
int s6dns_domain_fromstring_noqualify_encode (s6dns_domain_t *d, char const *name, size_t len)
diff --git a/src/libs6dns/s6dns_domain_fromstring_qualify_encode.c b/src/libs6dns/s6dns_domain_fromstring_qualify_encode.c
index d57a521..cb958f0 100644
--- a/src/libs6dns/s6dns_domain_fromstring_qualify_encode.c
+++ b/src/libs6dns/s6dns_domain_fromstring_qualify_encode.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <string.h>
#include <s6-dns/s6dns-domain.h>
unsigned int s6dns_domain_fromstring_qualify_encode (s6dns_domain_t *list, char const *name, size_t len, char const *rules, unsigned int rulesnum)
diff --git a/src/libs6dns/s6dns_domain_qualify.c b/src/libs6dns/s6dns_domain_qualify.c
index 8f036be..ae66978 100644
--- a/src/libs6dns/s6dns_domain_qualify.c
+++ b/src/libs6dns/s6dns_domain_qualify.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <s6-dns/s6dns-domain.h>
unsigned int s6dns_domain_qualify (s6dns_domain_t *list, s6dns_domain_t const *d, char const *rules, unsigned int rulesnum)
@@ -15,14 +14,14 @@ unsigned int s6dns_domain_qualify (s6dns_domain_t *list, s6dns_domain_t const *d
}
else
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < rulesnum ; i++)
{
- size_t n = str_len(rules) ;
+ size_t n = strlen(rules) ;
if (d->len + n >= 254) return (errno = ENAMETOOLONG, 0) ;
list[i] = *d ;
list[i].s[d->len] = '.' ;
- byte_copy(list[i].s + d->len + 1, n, rules) ;
+ memcpy(list[i].s + d->len + 1, rules, n) ;
list[i].len += n+1 ;
rules += n+1 ;
}
diff --git a/src/libs6dns/s6dns_domain_tostring.c b/src/libs6dns/s6dns_domain_tostring.c
index d5de7ae..e11715b 100644
--- a/src/libs6dns/s6dns_domain_tostring.c
+++ b/src/libs6dns/s6dns_domain_tostring.c
@@ -1,13 +1,12 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <s6-dns/s6dns-domain.h>
unsigned int s6dns_domain_tostring (char *s, size_t max, s6dns_domain_t const *d)
{
- if ((unsigned int)d->len + 1 > max) return (errno = ENAMETOOLONG, 0) ;
+ if ((size_t)d->len + 1 > max) return (errno = ENAMETOOLONG, 0) ;
if (!d->len || (d->s[0] != '.')) return (errno = EINVAL, 0) ;
if (d->len == 1)
{
@@ -16,7 +15,7 @@ unsigned int s6dns_domain_tostring (char *s, size_t max, s6dns_domain_t const *d
}
else
{
- byte_copy(s, d->len - 1, d->s + 1) ;
+ memcpy(s, d->s + 1, d->len - 1) ;
return d->len - 1 ;
}
}
diff --git a/src/libs6dns/s6dns_engine.c b/src/libs6dns/s6dns_engine.c
index 71fc200..baf93b0 100644
--- a/src/libs6dns/s6dns_engine.c
+++ b/src/libs6dns/s6dns_engine.c
@@ -1,11 +1,12 @@
/* ISC license. */
#include <sys/types.h>
+#include <string.h>
+#include <strings.h>
#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/allreadwrite.h>
-#include <skalibs/bytestr.h>
#include <skalibs/error.h>
#include <skalibs/tai.h>
#include <skalibs/stralloc.h>
@@ -25,7 +26,7 @@
static inline int qdomain_diff (char const *s1, size_t n1, char const *s2, size_t n2)
{
- return (n1 < n2) ? -1 : (n1 > n2) ? 1 : case_diffb(s1, n1, s2) ;
+ return (n1 < n2) ? -1 : (n1 > n2) ? 1 : strncasecmp(s1, s2, n1) ;
}
static int relevant (char const *q, unsigned int qlen, char const *ans, unsigned int anslen, int strict)
@@ -56,7 +57,7 @@ static int relevant (char const *q, unsigned int qlen, char const *ans, unsigned
LOLDEBUG(" testing answer domain against query") ;
if (qdomain_diff(buf, n, q + 12, qlen - 16)) return 0 ;
LOLDEBUG(" testing answer qclass and qtype against query" ) ;
- if (byte_diff(q + qlen - 4, 4, ans + pos)) return 0 ;
+ if (memcmp(q + qlen - 4, ans + pos, 4)) return 0 ;
}
LOLDEBUG("relevant() returns 1") ;
return 1 ;
@@ -81,7 +82,7 @@ static int relevant (char const *q, unsigned int qlen, char const *ans, unsigned
static int randombind (int fd, int flag)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < 10 ; i++)
if (socketbind46(fd, S6DNS_ENGINE_LOCAL0, 1025 + random_uint32(64510), flag) >= 0) return 1 ;
return (socketbind46(fd, S6DNS_ENGINE_LOCAL0, 0, flag) >= 0) ;
@@ -96,14 +97,14 @@ static int thisudp (s6dns_engine_t *dt, tain_t const *stamp)
dt->curserver = 0 ;
if (++dt->protostate >= 4) return -2 ;
}
- if (byte_diff(s6dns_ip46list_ip(&dt->servers, dt->curserver), SKALIBS_IP_SIZE, S6DNS_ENGINE_LOCAL0)) break ;
+ if (memcmp(s6dns_ip46list_ip(&dt->servers, dt->curserver), S6DNS_ENGINE_LOCAL0, SKALIBS_IP_SIZE)) break ;
}
random_string(dt->sa.s + 2, 2) ; /* random query id */
dt->fd = socketudp46(s6dns_ip46list_is6(&dt->servers, dt->curserver)) ;
if (dt->fd < 0) return -1 ;
if (!randombind(dt->fd, s6dns_ip46list_is6(&dt->servers, dt->curserver)))
{
- register int e = errno ;
+ int e = errno ;
fd_close(dt->fd) ; dt->fd = -1 ;
errno = e ;
return -1 ;
@@ -111,7 +112,7 @@ static int thisudp (s6dns_engine_t *dt, tain_t const *stamp)
if ((socketconnect46(dt->fd, s6dns_ip46list_ip(&dt->servers, dt->curserver), 53, s6dns_ip46list_is6(&dt->servers, dt->curserver)) < 0)
&& (errno != EINPROGRESS))
{
- register int e = errno ;
+ int e = errno ;
fd_close(dt->fd) ; dt->fd = -1 ;
errno = e ;
return 0 ;
@@ -127,14 +128,14 @@ static int thisudp (s6dns_engine_t *dt, tain_t const *stamp)
static int thistcp (s6dns_engine_t *dt, tain_t const *stamp)
{
for (; dt->curserver < S6DNS_MAX_SERVERS ; dt->curserver++)
- if (byte_diff(s6dns_ip46list_ip(&dt->servers, dt->curserver), SKALIBS_IP_SIZE, S6DNS_ENGINE_LOCAL0)) break ;
+ if (memcmp(s6dns_ip46list_ip(&dt->servers, dt->curserver), S6DNS_ENGINE_LOCAL0, SKALIBS_IP_SIZE)) break ;
if (dt->curserver >= S6DNS_MAX_SERVERS) return -2 ;
random_string(dt->sa.s + 2, 2) ;
dt->fd = sockettcp46(s6dns_ip46list_is6(&dt->servers, dt->curserver)) ;
if (dt->fd < 0) return -1 ;
if (!randombind(dt->fd, s6dns_ip46list_is6(&dt->servers, dt->curserver)))
{
- register int e = errno ;
+ int e = errno ;
fd_close(dt->fd) ; dt->fd = -1 ;
errno = e ;
return -1 ;
@@ -142,7 +143,7 @@ static int thistcp (s6dns_engine_t *dt, tain_t const *stamp)
if ((socketconnect46(dt->fd, s6dns_ip46list_ip(&dt->servers, dt->curserver), 53, s6dns_ip46list_is6(&dt->servers, dt->curserver)) < 0)
&& (errno != EINPROGRESS))
{
- register int e = errno ;
+ int e = errno ;
fd_close(dt->fd) ; dt->fd = -1 ;
errno = e ;
return 0 ;
@@ -185,7 +186,7 @@ static void prepare_next (s6dns_engine_t *dt, tain_t const *stamp, int istcp)
static int s6dns_engine_write_udp (s6dns_engine_t *dt, tain_t const *stamp)
{
static unsigned int const s6dns_engine_udp_timeouts[4] = { 1, 3, 11, 45 } ;
- if (fd_send(dt->fd, dt->sa.s + 2, dt->querylen - 2, 0) < (int)(dt->querylen - 2))
+ if (fd_send(dt->fd, dt->sa.s + 2, dt->querylen - 2, 0) < (ssize_t)(dt->querylen - 2))
return (prepare_next(dt, stamp, 0), 0) ;
tain_addsec(&dt->localdeadline, stamp, s6dns_engine_udp_timeouts[dt->protostate]) ;
dt->flagwriting = 0 ;
@@ -197,7 +198,7 @@ static int s6dns_engine_write_udp (s6dns_engine_t *dt, tain_t const *stamp)
static int s6dns_engine_write_tcp (s6dns_engine_t *dt, tain_t const *stamp)
{
- unsigned int r ;
+ size_t r ;
r = allwrite(dt->fd, dt->sa.s + dt->protostate, dt->querylen - dt->protostate) ;
dt->protostate += r ;
if (r) dt->flagconnecting = 0 ;
@@ -220,7 +221,7 @@ static int s6dns_engine_read_udp (s6dns_engine_t *dt, tain_t const *stamp)
{
s6dns_message_header_t h ;
char buf[513] ;
- register ssize_t r = fd_recv(dt->fd, buf, 513, 0) ;
+ ssize_t r = fd_recv(dt->fd, buf, 513, 0) ;
if (r < 0) return (prepare_next(dt, stamp, 0), 0) ;
if ((r > 512) || (r < 12)) return (errno = EAGAIN, 0) ;
switch (relevant(dt->sa.s + 2, dt->querylen - 2, buf, r, dt->flagstrict))
@@ -249,12 +250,12 @@ static int s6dns_engine_read_udp (s6dns_engine_t *dt, tain_t const *stamp)
{
case 0 : case 3 : break ; /* normal operation */
case 1 : case 4 : case 5 :
- byte_zero(s6dns_ip46list_ip(&dt->servers, dt->curserver), SKALIBS_IP_SIZE) ; /* do not query it again */
+ memset(s6dns_ip46list_ip(&dt->servers, dt->curserver), 0, SKALIBS_IP_SIZE) ; /* do not query it again */
default : prepare_next(dt, stamp, 0) ; return 0 ;
}
if (!stralloc_copyb(&dt->sa, buf, r))
{
- register int e = errno ;
+ int e = errno ;
fd_close(dt->fd) ; dt->fd = -1 ;
errno = e ;
return 0 ;
@@ -267,7 +268,7 @@ static int s6dns_engine_read_udp (s6dns_engine_t *dt, tain_t const *stamp)
static int s6dns_engine_read_tcp (s6dns_engine_t *dt, tain_t const *stamp)
{
- register ssize_t r = sanitize_read(mininetstring_read(dt->fd, &dt->sa, &dt->protostate)) ;
+ ssize_t r = sanitize_read(mininetstring_read(dt->fd, &dt->sa, &dt->protostate)) ;
if (r < 0) return (prepare_next(dt, stamp, 1), 0) ;
else if (!r) return (errno = EAGAIN, 0) ;
else if ((dt->sa.len - dt->querylen) < 12)
@@ -292,7 +293,7 @@ static int s6dns_engine_read_tcp (s6dns_engine_t *dt, tain_t const *stamp)
{
case 0 : case 3 : break ; /* normal operation */
case 1 : case 4 : case 5 :
- byte_zero(s6dns_ip46list_ip(&dt->servers, dt->curserver), SKALIBS_IP_SIZE) ; /* do not query it again */
+ memset(s6dns_ip46list_ip(&dt->servers, dt->curserver), 0, SKALIBS_IP_SIZE) ; /* do not query it again */
default : goto badanswer ;
}
fd_close(dt->fd) ; dt->fd = -1 ;
@@ -310,10 +311,10 @@ void s6dns_engine_recycle (s6dns_engine_t *dt)
{
dt->sa.len = 0 ;
dt->querylen = 0 ;
- byte_zero(&dt->servers, sizeof(s6dns_ip46list_t)) ;
+ memset(&dt->servers, 0, sizeof(s6dns_ip46list_t)) ;
if (dt->fd >= 0)
{
- register int e = errno ;
+ int e = errno ;
fd_close(dt->fd) ; dt->fd = -1 ;
errno = e ;
}
diff --git a/src/libs6dns/s6dns_fmt_domainlist.c b/src/libs6dns/s6dns_fmt_domainlist.c
index 625e149..22d6f77 100644
--- a/src/libs6dns/s6dns_fmt_domainlist.c
+++ b/src/libs6dns/s6dns_fmt_domainlist.c
@@ -1,24 +1,23 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <s6-dns/s6dns-domain.h>
#include <s6-dns/s6dns-fmt.h>
size_t s6dns_fmt_domainlist (char *s, size_t max, s6dns_domain_t const *list, unsigned int n, char const *delim, size_t delimlen)
{
size_t len = 0 ;
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < n ; i++)
{
- register unsigned int r = s6dns_domain_tostring(s + len, max - len, list + i) ;
+ unsigned int r = s6dns_domain_tostring(s + len, max - len, list + i) ;
if (!r) return 0 ;
len += r ;
if (i+1 < n)
{
if (len + delimlen > max) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(s + len, delimlen, delim) ;
+ memcpy(s + len, delim, delimlen) ;
len += delimlen ;
}
}
diff --git a/src/libs6dns/s6dns_fmt_hinfo.c b/src/libs6dns/s6dns_fmt_hinfo.c
index 2389926..78bf414 100644
--- a/src/libs6dns/s6dns_fmt_hinfo.c
+++ b/src/libs6dns/s6dns_fmt_hinfo.c
@@ -1,16 +1,15 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <s6-dns/s6dns-message.h>
#include <s6-dns/s6dns-fmt.h>
size_t s6dns_fmt_hinfo (char *s, size_t max, s6dns_message_rr_hinfo_t const *hinfo)
{
if (hinfo->cpu.len + 1 + hinfo->os.len > max) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(s, hinfo->cpu.len, hinfo->cpu.s) ;
+ memcpy(s, hinfo->cpu.s, hinfo->cpu.len) ;
s[hinfo->cpu.len] = ' ' ;
- byte_copy(s + hinfo->cpu.len + 1, hinfo->os.len, hinfo->os.s) ;
+ memcpy(s + hinfo->cpu.len + 1, hinfo->os.s, hinfo->os.len) ;
return hinfo->cpu.len + 1 + hinfo->os.len ;
}
diff --git a/src/libs6dns/s6dns_fmt_mx.c b/src/libs6dns/s6dns_fmt_mx.c
index 303c545..938c478 100644
--- a/src/libs6dns/s6dns_fmt_mx.c
+++ b/src/libs6dns/s6dns_fmt_mx.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-message.h>
#include <s6-dns/s6dns-fmt.h>
@@ -15,6 +14,6 @@ size_t s6dns_fmt_mx (char *s, size_t max, s6dns_message_rr_mx_t const *mx)
fmt[len++] = ' ' ;
r = s6dns_domain_tostring(s + len, max - len, &mx->exchange) ;
if (!r) return 0 ;
- byte_copy(s, len, fmt) ;
+ memcpy(s, fmt, len) ;
return len + r ;
}
diff --git a/src/libs6dns/s6dns_fmt_soa.c b/src/libs6dns/s6dns_fmt_soa.c
index b07ae14..b9e0a42 100644
--- a/src/libs6dns/s6dns_fmt_soa.c
+++ b/src/libs6dns/s6dns_fmt_soa.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/uint32.h>
-#include <skalibs/bytestr.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-message.h>
#include <s6-dns/s6dns-fmt.h>
@@ -11,7 +10,7 @@ size_t s6dns_fmt_soa (char *s, size_t max, s6dns_message_rr_soa_t const *soa)
{
size_t len = 0 ;
char fmt[UINT32_FMT] ;
- register size_t r = s6dns_domain_tostring(s + len, max - len, &soa->mname) ;
+ size_t r = s6dns_domain_tostring(s + len, max - len, &soa->mname) ;
if (!r) return 0 ;
len += r ;
if (len >= max) return (errno = ENAMETOOLONG, 0) ;
@@ -23,23 +22,23 @@ size_t s6dns_fmt_soa (char *s, size_t max, s6dns_message_rr_soa_t const *soa)
s[len++] = ' ' ;
r = uint32_fmt(fmt, soa->serial) ;
if (len + r >= max) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(s + len, r, fmt) ;
+ memcpy(s + len, fmt, r) ;
len += r ; s[len++] = ' ' ;
r = uint32_fmt(fmt, soa->refresh) ;
if (len + r >= max) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(s + len, r, fmt) ;
+ memcpy(s + len, fmt, r) ;
len += r ; s[len++] = ' ' ;
r = uint32_fmt(fmt, soa->retry) ;
if (len + r >= max) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(s + len, r, fmt) ;
+ memcpy(s + len, fmt, r) ;
len += r ; s[len++] = ' ' ;
r = uint32_fmt(fmt, soa->expire) ;
if (len + r >= max) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(s + len, r, fmt) ;
+ memcpy(s + len, fmt, r) ;
len += r ; s[len++] = ' ' ;
r = uint32_fmt(fmt, soa->minimum) ;
if (len + r > max) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(s + len, r, fmt) ;
+ memcpy(s + len, fmt, r) ;
len += r ;
return len ;
}
diff --git a/src/libs6dns/s6dns_fmt_srv.c b/src/libs6dns/s6dns_fmt_srv.c
index 33bfd49..ee0d337 100644
--- a/src/libs6dns/s6dns_fmt_srv.c
+++ b/src/libs6dns/s6dns_fmt_srv.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-message.h>
#include <s6-dns/s6dns-fmt.h>
@@ -11,17 +10,17 @@ size_t s6dns_fmt_srv (char *s, size_t max, s6dns_message_rr_srv_t const *srv)
{
size_t len = 0 ;
char fmt[UINT16_FMT] ;
- register size_t r = uint16_fmt(fmt, srv->priority) ;
+ size_t r = uint16_fmt(fmt, srv->priority) ;
if (len + r >= max) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(s + len, r, fmt) ;
+ memcpy(s + len, fmt, r) ;
len += r ; s[len++] = ' ' ;
r = uint16_fmt(fmt, srv->weight) ;
if (len + r >= max) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(s + len, r, fmt) ;
+ memcpy(s + len, fmt, r) ;
len += r ; s[len++] = ' ' ;
r = uint16_fmt(fmt, srv->port) ;
if (len + r >= max) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(s + len, r, fmt) ;
+ memcpy(s + len, fmt, r) ;
len += r ; s[len++] = ' ' ;
r = s6dns_domain_tostring(s + len, max - len, &srv->target) ;
if (!r) return 0 ;
diff --git a/src/libs6dns/s6dns_message_counts_pack.c b/src/libs6dns/s6dns_message_counts_pack.c
index 51c0a78..512e8ae 100644
--- a/src/libs6dns/s6dns_message_counts_pack.c
+++ b/src/libs6dns/s6dns_message_counts_pack.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-message.h>
void s6dns_message_counts_pack (char *s, s6dns_message_counts_t const *counts)
diff --git a/src/libs6dns/s6dns_message_counts_unpack.c b/src/libs6dns/s6dns_message_counts_unpack.c
index 968e5eb..ad773ef 100644
--- a/src/libs6dns/s6dns_message_counts_unpack.c
+++ b/src/libs6dns/s6dns_message_counts_unpack.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-message.h>
void s6dns_message_counts_unpack (char const *s, s6dns_message_counts_t *counts)
diff --git a/src/libs6dns/s6dns_message_get_domain_internal.c b/src/libs6dns/s6dns_message_get_domain_internal.c
index 64e71dc..fd36e18 100644
--- a/src/libs6dns/s6dns_message_get_domain_internal.c
+++ b/src/libs6dns/s6dns_message_get_domain_internal.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/bytestr.h>
#include "s6dns-message-internal.h"
size_t s6dns_message_get_domain_internal (char *out, size_t outmax, char const *s, unsigned int len, unsigned int *pos)
@@ -11,7 +10,7 @@ size_t s6dns_message_get_domain_internal (char *out, size_t outmax, char const *
size_t w = 0 ; /* writing head */
unsigned int r = *pos ; /* reading head */
unsigned int jumps = 0 ;
- register int hasjumped = 0 ;
+ int hasjumped = 0 ;
for (;;)
{
unsigned char c ;
@@ -23,7 +22,7 @@ size_t s6dns_message_get_domain_internal (char *out, size_t outmax, char const *
if (out)
{
if (w + c > outmax) return (errno = ENAMETOOLONG, 0) ;
- byte_copy(out + w, c, s + r) ;
+ memcpy(out + w, s + r, c) ;
}
w += c ; r += c ; if (!hasjumped) *pos += c ;
if (c == 1) break ;
diff --git a/src/libs6dns/s6dns_message_get_mx.c b/src/libs6dns/s6dns_message_get_mx.c
index 6bca509..049999e 100644
--- a/src/libs6dns/s6dns_message_get_mx.c
+++ b/src/libs6dns/s6dns_message_get_mx.c
@@ -2,7 +2,7 @@
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-domain.h>
#include <s6-dns/s6dns-message.h>
diff --git a/src/libs6dns/s6dns_message_get_soa.c b/src/libs6dns/s6dns_message_get_soa.c
index c766231..5ba1239 100644
--- a/src/libs6dns/s6dns_message_get_soa.c
+++ b/src/libs6dns/s6dns_message_get_soa.c
@@ -2,7 +2,7 @@
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/uint32.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-message.h>
int s6dns_message_get_soa (s6dns_message_rr_soa_t *soa, char const *packet, unsigned int packetlen, unsigned int *pos)
diff --git a/src/libs6dns/s6dns_message_get_srv.c b/src/libs6dns/s6dns_message_get_srv.c
index 13ecf13..ff11b96 100644
--- a/src/libs6dns/s6dns_message_get_srv.c
+++ b/src/libs6dns/s6dns_message_get_srv.c
@@ -2,7 +2,7 @@
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-message.h>
int s6dns_message_get_srv (s6dns_message_rr_srv_t *srv, char const *packet, unsigned int packetlen, unsigned int *pos)
diff --git a/src/libs6dns/s6dns_message_get_string_internal.c b/src/libs6dns/s6dns_message_get_string_internal.c
index 7e4105b..9597c36 100644
--- a/src/libs6dns/s6dns_message_get_string_internal.c
+++ b/src/libs6dns/s6dns_message_get_string_internal.c
@@ -1,17 +1,16 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/bytestr.h>
#include "s6dns-message-internal.h"
int s6dns_message_get_string_internal (char *s, size_t max, char const *packet, unsigned int packetlen, unsigned int *pos)
{
- register unsigned char len = ((unsigned char const *)packet)[*pos] ;
+ unsigned char len = ((unsigned char const *)packet)[*pos] ;
if (*pos + len + 1 > packetlen) return (errno = EPROTO, -1) ;
if (len > max) return (errno = ENAMETOOLONG, -1) ;
- byte_copy(s, len, packet + *pos + 1) ;
+ memcpy(s, packet + *pos + 1, len) ;
*pos += len + 1 ;
- return (int)len ;
+ return len ;
}
diff --git a/src/libs6dns/s6dns_message_get_strings.c b/src/libs6dns/s6dns_message_get_strings.c
index 161b554..4627938 100644
--- a/src/libs6dns/s6dns_message_get_strings.c
+++ b/src/libs6dns/s6dns_message_get_strings.c
@@ -8,10 +8,10 @@ int s6dns_message_get_strings (char *s, unsigned int rdlength, char const *packe
unsigned int max = rdlength, len = 0 ;
while (rdlength)
{
- register unsigned int start = *pos ;
- register int r = s6dns_message_get_string_internal(s + len, max - len, packet, packetlen, pos) ;
+ unsigned int start = *pos ;
+ int r = s6dns_message_get_string_internal(s + len, max - len, packet, packetlen, pos) ;
if (r < 0) return -1 ;
len += r ; rdlength -= *pos - start ;
}
- return (int)len ;
+ return len ;
}
diff --git a/src/libs6dns/s6dns_message_header_pack.c b/src/libs6dns/s6dns_message_header_pack.c
index ff496fa..57ce350 100644
--- a/src/libs6dns/s6dns_message_header_pack.c
+++ b/src/libs6dns/s6dns_message_header_pack.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-message.h>
void s6dns_message_header_pack (char *s, s6dns_message_header_t const *h)
diff --git a/src/libs6dns/s6dns_message_header_unpack.c b/src/libs6dns/s6dns_message_header_unpack.c
index 819b953..9d68bad 100644
--- a/src/libs6dns/s6dns_message_header_unpack.c
+++ b/src/libs6dns/s6dns_message_header_unpack.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-message.h>
void s6dns_message_header_unpack (char const *s, s6dns_message_header_t *h)
diff --git a/src/libs6dns/s6dns_message_parse.c b/src/libs6dns/s6dns_message_parse.c
index eef9410..06b7677 100644
--- a/src/libs6dns/s6dns_message_parse.c
+++ b/src/libs6dns/s6dns_message_parse.c
@@ -28,7 +28,7 @@ int s6dns_message_parse (s6dns_message_header_t *h, char const *packet, unsigned
if (!s6dns_message_parse_getrr(&rr, packet, packetlen, &pos)) return 0 ;
if (rr.rclass == S6DNS_C_IN)
{
- register int r = (*f)(&rr, packet, packetlen, pos, section, data) ;
+ int r = (*f)(&rr, packet, packetlen, pos, section, data) ;
if (r < 1) return r ;
}
section = s6dns_message_parse_next(&counts, &rr, packet, packetlen, &pos) ;
diff --git a/src/libs6dns/s6dns_message_parse_answer_domain.c b/src/libs6dns/s6dns_message_parse_answer_domain.c
index d09abc9..3f25bd9 100644
--- a/src/libs6dns/s6dns_message_parse_answer_domain.c
+++ b/src/libs6dns/s6dns_message_parse_answer_domain.c
@@ -12,7 +12,7 @@ int s6dns_message_parse_answer_domain (s6dns_message_rr_t const *rr, char const
if ((section == 2) && (rr->rtype == data->rtype))
{
s6dns_domain_t d ;
- register unsigned int start = pos ;
+ unsigned int start = pos ;
if (!s6dns_message_get_domain(&d, packet, packetlen, &pos)) return 0 ;
if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ;
if (!genalloc_append(s6dns_domain_t, &data->ds, &d)) return -1 ;
diff --git a/src/libs6dns/s6dns_message_parse_answer_hinfo.c b/src/libs6dns/s6dns_message_parse_answer_hinfo.c
index aa53601..9ee84f7 100644
--- a/src/libs6dns/s6dns_message_parse_answer_hinfo.c
+++ b/src/libs6dns/s6dns_message_parse_answer_hinfo.c
@@ -12,7 +12,7 @@ int s6dns_message_parse_answer_hinfo (s6dns_message_rr_t const *rr, char const *
{
genalloc *data = stuff ;
s6dns_message_rr_hinfo_t hinfo ;
- register unsigned int start = pos ;
+ unsigned int start = pos ;
if (!s6dns_message_get_hinfo(&hinfo, packet, packetlen, &pos)) return 0 ;
if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ;
if (!genalloc_append(s6dns_message_rr_hinfo_t, data, &hinfo)) return -1 ;
diff --git a/src/libs6dns/s6dns_message_parse_answer_mx.c b/src/libs6dns/s6dns_message_parse_answer_mx.c
index 32f43c9..f9f6df8 100644
--- a/src/libs6dns/s6dns_message_parse_answer_mx.c
+++ b/src/libs6dns/s6dns_message_parse_answer_mx.c
@@ -12,7 +12,7 @@ int s6dns_message_parse_answer_mx (s6dns_message_rr_t const *rr, char const *pac
{
genalloc *data = stuff ;
s6dns_message_rr_mx_t mx ;
- register unsigned int start = pos ;
+ unsigned int start = pos ;
if (!s6dns_message_get_mx(&mx, packet, packetlen, &pos)) return 0 ;
if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ;
if (!genalloc_append(s6dns_message_rr_mx_t, data, &mx)) return -1 ;
diff --git a/src/libs6dns/s6dns_message_parse_answer_soa.c b/src/libs6dns/s6dns_message_parse_answer_soa.c
index 6c7b668..d78b0b2 100644
--- a/src/libs6dns/s6dns_message_parse_answer_soa.c
+++ b/src/libs6dns/s6dns_message_parse_answer_soa.c
@@ -12,7 +12,7 @@ int s6dns_message_parse_answer_soa (s6dns_message_rr_t const *rr, char const *pa
{
genalloc *data = stuff ;
s6dns_message_rr_soa_t soa ;
- register unsigned int start = pos ;
+ unsigned int start = pos ;
if (!s6dns_message_get_soa(&soa, packet, packetlen, &pos)) return 0 ;
if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ;
if (!genalloc_append(s6dns_message_rr_soa_t, data, &soa)) return -1 ;
diff --git a/src/libs6dns/s6dns_message_parse_answer_srv.c b/src/libs6dns/s6dns_message_parse_answer_srv.c
index 31be348..526d18c 100644
--- a/src/libs6dns/s6dns_message_parse_answer_srv.c
+++ b/src/libs6dns/s6dns_message_parse_answer_srv.c
@@ -12,7 +12,7 @@ int s6dns_message_parse_answer_srv (s6dns_message_rr_t const *rr, char const *pa
{
genalloc *data = stuff ;
s6dns_message_rr_srv_t srv ;
- register unsigned int start = pos ;
+ unsigned int start = pos ;
if (!s6dns_message_get_srv(&srv, packet, packetlen, &pos)) return 0 ;
if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ;
if (!genalloc_append(s6dns_message_rr_srv_t, data, &srv)) return -1 ;
diff --git a/src/libs6dns/s6dns_message_parse_answer_strings.c b/src/libs6dns/s6dns_message_parse_answer_strings.c
index f5ac783..66ed36b 100644
--- a/src/libs6dns/s6dns_message_parse_answer_strings.c
+++ b/src/libs6dns/s6dns_message_parse_answer_strings.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/error.h>
#include <skalibs/stralloc.h>
@@ -15,7 +15,7 @@ int s6dns_message_parse_answer_strings (s6dns_message_rr_t const *rr, char const
size_t base = data->sa.len ;
int wasnull = !data->sa.s ;
unsigned int start = pos ;
- register int r ;
+ int r ;
if (!stralloc_readyplus(&data->sa, rr->rdlength + 1)) return -1 ;
r = s6dns_message_get_strings(data->sa.s + data->sa.len, rr->rdlength, packet, packetlen, &pos) ;
if ((r < 0) || (rr->rdlength != pos - start))
diff --git a/src/libs6dns/s6dns_message_parse_getrr.c b/src/libs6dns/s6dns_message_parse_getrr.c
index 8db0c5d..86e5e59 100644
--- a/src/libs6dns/s6dns_message_parse_getrr.c
+++ b/src/libs6dns/s6dns_message_parse_getrr.c
@@ -2,8 +2,7 @@
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
+#include <skalibs/types.h>
#include <s6-dns/s6dns-message.h>
int s6dns_message_parse_getrr (s6dns_message_rr_t_ref rr, char const *packet, unsigned int packetlen, unsigned int *pos)
diff --git a/src/libs6dns/s6dns_message_parse_skipqd.c b/src/libs6dns/s6dns_message_parse_skipqd.c
index 9b8c222..95a4e40 100644
--- a/src/libs6dns/s6dns_message_parse_skipqd.c
+++ b/src/libs6dns/s6dns_message_parse_skipqd.c
@@ -7,7 +7,7 @@ unsigned int s6dns_message_parse_skipqd (s6dns_message_counts_t *counts, char co
{
for (;;)
{
- register unsigned int r = s6dns_message_counts_next(counts) ;
+ unsigned int r = s6dns_message_counts_next(counts) ;
if (r != 1) return r ;
if (!s6dns_message_get_domain_internal(0, 255, packet, packetlen, pos)) return 0 ;
*pos += 4 ;
diff --git a/src/libs6dns/s6dns_rci_init.c b/src/libs6dns/s6dns_rci_init.c
index e7d3676..4c51679 100644
--- a/src/libs6dns/s6dns_rci_init.c
+++ b/src/libs6dns/s6dns_rci_init.c
@@ -1,6 +1,7 @@
/* ISC license. */
#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/error.h>
#include <skalibs/bytestr.h>
@@ -15,7 +16,7 @@
static size_t readit (char const *file, char *buf, size_t max)
{
- register ssize_t r = openreadnclose(file, buf, max - 1) ;
+ ssize_t r = openreadnclose(file, buf, max - 1) ;
if (r < 0)
{
if (errno != ENOENT) return 0 ;
@@ -28,7 +29,7 @@ static size_t readit (char const *file, char *buf, size_t max)
static inline int s6dns_rci_init_servers (s6dns_rci_t *rci, char const *file, char *tmp, size_t max, size_t *size)
{
ip46_t tmplist[S6DNS_MAX_SERVERS] ;
- unsigned int num = 0 ;
+ size_t num = 0 ;
char const *x = env_get("DNSCACHEIP") ;
if (x) ip46_scanlist(tmplist, S6DNS_MAX_SERVERS, x, &num) ;
if (!num)
@@ -38,10 +39,10 @@ static inline int s6dns_rci_init_servers (s6dns_rci_t *rci, char const *file, ch
if (!*size) return 0 ;
while ((i < *size) && (num < S6DNS_MAX_SERVERS))
{
- register size_t j = byte_chr(tmp + i, *size - i, '\n') ;
- if ((i + j < *size) && (j > 13U) && !byte_diff("nameserver", 10, tmp + i))
+ size_t j = byte_chr(tmp + i, *size - i, '\n') ;
+ if ((i + j < *size) && (j > 13U) && !memcmp("nameserver", tmp + i, 10))
{
- register size_t k = 0 ;
+ size_t k = 0 ;
while ((tmp[i+10+k] == ' ') || (tmp[i+10+k] == '\t')) k++ ;
if (k && ip46_scan(tmp+i+10+k, tmplist + num)) num++ ;
}
@@ -51,18 +52,18 @@ static inline int s6dns_rci_init_servers (s6dns_rci_t *rci, char const *file, ch
if (!num)
{
num = 1 ;
- byte_copy(tmplist[0].ip, SKALIBS_IP_SIZE, S6DNS_LOCALHOST_IP) ;
+ memcpy(tmplist[0].ip, S6DNS_LOCALHOST_IP, SKALIBS_IP_SIZE) ;
#ifdef SKALIBS_IPV6_ENABLED
tmplist[0].is6 = 1 ;
#endif
}
{
- register unsigned int i = 0 ;
- byte_zero(&rci->servers, sizeof(s6dns_ip46list_t)) ;
+ unsigned int i = 0 ;
+ memset(&rci->servers, 0, sizeof(s6dns_ip46list_t)) ;
for (; i < num ; i++)
{
- byte_copy(rci->servers.ip + SKALIBS_IP_SIZE * i, SKALIBS_IP_SIZE, tmplist[i].ip) ;
+ memcpy(rci->servers.ip + SKALIBS_IP_SIZE * i, tmplist[i].ip, SKALIBS_IP_SIZE) ;
#ifdef SKALIBS_IPV6_ENABLED
if (ip46_is6(tmplist+i)) bitarray_set(rci->servers.is6, i) ;
#endif
@@ -81,7 +82,7 @@ static inline int stringrules (stralloc *rules, char const *s, unsigned int *num
while (c)
{
c = *s++ ;
- if (byte_chr(" \t\n\r", 5, c) < 5)
+ if (memchr(" \t\n\r", 5, c))
{
if (!crunching)
{
@@ -126,12 +127,12 @@ static inline int s6dns_rci_init_rules (s6dns_rci_t_ref rci, char const *file, c
{
size_t j = byte_chr(tmp + i, *size - i, '\n') ;
if ((i + j < *size) && (j > 8U)
- && (!byte_diff("domain", 6, tmp + i) || !byte_diff("search", 6, tmp + i))
+ && (!memcmp("domain", tmp + i, 6) || !memcmp("search", tmp + i, 6))
&& ((tmp[i+6] == ' ') || (tmp[i+6] == '\t') || (tmp[i+6] == '\r')))
{
size_t k = 0 ;
int copying = 0 ;
- register int notsearching = (tmp[i] != 's') ;
+ int notsearching = (tmp[i] != 's') ;
if (!stralloc_readyplus(&rci->rules, j)) return 0 ;
for (; 6 + k < j ; k++)
{
diff --git a/src/libs6dns/s6dns_resolve_dpag.c b/src/libs6dns/s6dns_resolve_dpag.c
index 0bc5a42..3eaa959 100644
--- a/src/libs6dns/s6dns_resolve_dpag.c
+++ b/src/libs6dns/s6dns_resolve_dpag.c
@@ -11,7 +11,7 @@
int s6dns_resolve_dpag_r (genalloc *ds, char const *name, unsigned int len, uint16_t qtype, int qualif, s6dns_engine_t *dt, s6dns_rci_t const *rci, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp)
{
s6dns_dpag_t data ;
- register int r ;
+ int r ;
data.ds = *ds ;
data.rtype = qtype ;
r = s6dns_resolve_r(name, len, qtype, &s6dns_message_parse_answer_domain, &data, qualif, dt, rci, dbh, deadline, stamp) ;
diff --git a/src/libs6dns/s6dns_resolve_mpag.c b/src/libs6dns/s6dns_resolve_mpag.c
index ca0ab1a..b9d64e3 100644
--- a/src/libs6dns/s6dns_resolve_mpag.c
+++ b/src/libs6dns/s6dns_resolve_mpag.c
@@ -12,7 +12,7 @@
int s6dns_resolve_mpag_r (stralloc *sa, genalloc *offsets, char const *name, unsigned int len, uint16_t qtype, s6dns_message_rr_func_t_ref parsefunc, int qualif, s6dns_engine_t *dt, s6dns_rci_t const *rci, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp)
{
s6dns_mpag_t data ;
- register int r ;
+ int r ;
data.sa = *sa ;
data.offsets = *offsets ;
data.rtype = qtype ;
diff --git a/src/libs6dns/s6dns_resolve_name4.c b/src/libs6dns/s6dns_resolve_name4.c
index 7bb504a..4dc47ba 100644
--- a/src/libs6dns/s6dns_resolve_name4.c
+++ b/src/libs6dns/s6dns_resolve_name4.c
@@ -12,7 +12,7 @@ int s6dns_resolve_name4_r (genalloc *list, char const *ip, s6dns_engine_t *dt, s
{
s6dns_dpag_t data ;
s6dns_domain_t d ;
- register int r ;
+ int r ;
s6dns_domain_arpafromip4(&d, ip) ;
s6dns_domain_encode(&d) ;
data.ds = *list ;
diff --git a/src/libs6dns/s6dns_resolve_name6.c b/src/libs6dns/s6dns_resolve_name6.c
index 1af3945..39cbd43 100644
--- a/src/libs6dns/s6dns_resolve_name6.c
+++ b/src/libs6dns/s6dns_resolve_name6.c
@@ -13,7 +13,7 @@ int s6dns_resolve_name6_r (genalloc *list, char const *ip, s6dns_engine_t *dt, s
{
s6dns_dpag_t data ;
s6dns_domain_t d ;
- register int r ;
+ int r ;
s6dns_domain_arpafromip6(&d, ip, 128) ;
s6dns_domain_encode(&d) ;
data.ds = *list ;
diff --git a/src/libs6dns/s6dns_resolve_parse.c b/src/libs6dns/s6dns_resolve_parse.c
index b2e4974..2abb237 100644
--- a/src/libs6dns/s6dns_resolve_parse.c
+++ b/src/libs6dns/s6dns_resolve_parse.c
@@ -10,7 +10,7 @@
int s6dns_resolve_parse_r (s6dns_domain_t const *d, uint16_t qtype, s6dns_message_rr_func_t_ref parsefunc, void *data, s6dns_engine_t *dt, s6dns_ip46list_t const *servers, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp)
{
- register int r ;
+ int r ;
if (!s6dns_resolve_core_r(d, qtype, dt, servers, dbh, deadline, stamp)) return -1 ;
{
s6dns_message_header_t h ;
diff --git a/src/libs6dns/s6dns_resolven_loop.c b/src/libs6dns/s6dns_resolven_loop.c
index 6e0c3b4..9fefbb6 100644
--- a/src/libs6dns/s6dns_resolven_loop.c
+++ b/src/libs6dns/s6dns_resolven_loop.c
@@ -50,5 +50,5 @@ int s6dns_resolven_loop (s6dns_engine_t *dt, unsigned int n, unsigned int or, ta
}
}
}
- return or ? (errno = ENOENT, -1) : (int)count ;
+ return or ? (errno = ENOENT, -1) : count ;
}
diff --git a/src/libs6dns/s6dns_resolven_parse.c b/src/libs6dns/s6dns_resolven_parse.c
index 78289bc..a53f605 100644
--- a/src/libs6dns/s6dns_resolven_parse.c
+++ b/src/libs6dns/s6dns_resolven_parse.c
@@ -11,7 +11,7 @@
int s6dns_resolven_parse_r (s6dns_resolve_t *list, unsigned int n, s6dns_ip46list_t const *servers, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp)
{
s6dns_engine_t dtl[n] ;
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < n ; i++) list[i].status = ECONNABORTED ;
for (i = 0 ; i < n ; i++)
{
@@ -33,7 +33,7 @@ int s6dns_resolven_parse_r (s6dns_resolve_t *list, unsigned int n, s6dns_ip46lis
else
{
s6dns_message_header_t h ;
- register int r = s6dns_message_parse(&h, s6dns_engine_packet(dtl + i), s6dns_engine_packetlen(dtl + i), list[i].parsefunc, list[i].data) ;
+ int r = s6dns_message_parse(&h, s6dns_engine_packet(dtl + i), s6dns_engine_packetlen(dtl + i), list[i].parsefunc, list[i].data) ;
if (r < 0) goto err ;
list[i].status = r ? 0 : errno ;
}
diff --git a/src/libs6dns/s6dns_resolvenoq_aaaaa.c b/src/libs6dns/s6dns_resolvenoq_aaaaa.c
index d10b20b..295be1b 100644
--- a/src/libs6dns/s6dns_resolvenoq_aaaaa.c
+++ b/src/libs6dns/s6dns_resolvenoq_aaaaa.c
@@ -38,7 +38,7 @@ int s6dns_resolvenoq_aaaaa_r (genalloc *ips, char const *name, unsigned int len,
{
int e = (!!sa[0].len << 1) | !!sa[1].len ;
size_t n = genalloc_len(ip46_t, ips) ;
- register size_t i = 0 ;
+ size_t i = 0 ;
for (; i < (sa[0].len >> 4) ; i++)
ip46_from_ip6(genalloc_s(ip46_t, ips) + n++, sa[0].s + (i << 4)) ;
for (i = 0 ; i < (sa[1].len >> 2) ; i++)
diff --git a/src/libs6dns/s6dns_resolveq.c b/src/libs6dns/s6dns_resolveq.c
index 7fad70f..eeb7335 100644
--- a/src/libs6dns/s6dns_resolveq.c
+++ b/src/libs6dns/s6dns_resolveq.c
@@ -16,7 +16,7 @@ int s6dns_resolveq_r (char const *name, unsigned int len, uint16_t qtype, s6dns_
unsigned int best = 0 ;
unsigned int n ;
int e = 0 ;
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
{
s6dns_domain_t domains[rci->rulesnum] ;
n = s6dns_domain_fromstring_qualify_encode(domains, name, len, rci->rules.s, rci->rulesnum) ;
@@ -47,14 +47,14 @@ int s6dns_resolveq_r (char const *name, unsigned int len, uint16_t qtype, s6dns_
for (;;)
{
- register int k = s6dns_resolven_loop(dtl, n, 1, deadline, stamp) ;
+ int k = s6dns_resolven_loop(dtl, n, 1, deadline, stamp) ;
if (k < 0) goto err ;
if ((unsigned int)k == best)
{
for (;; best++)
{
s6dns_message_header_t h ;
- register int r ;
+ int r ;
if (best >= n) goto notfound ;
if (error_isagain(dtl[best].status)) break ;
if (dtl[best].status) { errno = dtl[best].status ; goto err ; }
diff --git a/src/libs6dns/s6dns_resolveq_aaaaa.c b/src/libs6dns/s6dns_resolveq_aaaaa.c
index cbc853f..df65edf 100644
--- a/src/libs6dns/s6dns_resolveq_aaaaa.c
+++ b/src/libs6dns/s6dns_resolveq_aaaaa.c
@@ -20,7 +20,7 @@ int s6dns_resolveq_aaaaa_r (genalloc *ips, char const *name, unsigned int len, s
unsigned int best = 0 ;
unsigned int n ;
int e = 0 ;
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
{
s6dns_domain_t domains[rci->rulesnum] ;
n = s6dns_domain_fromstring_qualify_encode(domains, name, len, rci->rules.s, rci->rulesnum) ;
@@ -44,14 +44,14 @@ int s6dns_resolveq_aaaaa_r (genalloc *ips, char const *name, unsigned int len, s
for (;;)
{
- register int k = s6dns_resolven_loop(dtl, n << 1, 1, deadline, stamp) ;
+ int k = s6dns_resolven_loop(dtl, n << 1, 1, deadline, stamp) ;
if (k < 0) goto err ;
if ((unsigned int)k == best)
{
for (;; best++)
{
s6dns_message_header_t h ;
- register int r ;
+ int r ;
if (best >= n << 1) goto notfound ;
if (error_isagain(dtl[best].status)) break ;
if (dtl[best].status) { errno = dtl[best].status ; goto err ; }
@@ -75,9 +75,9 @@ int s6dns_resolveq_aaaaa_r (genalloc *ips, char const *name, unsigned int len, s
found:
s6dns_engine_freen(dtl, n<<1) ;
{
- register size_t len = data.len >> ((best & 1) ? 2 : 4) ;
- register size_t i = 0 ;
- register size_t base = genalloc_len(ip46_t, ips) ;
+ size_t len = data.len >> ((best & 1) ? 2 : 4) ;
+ size_t i = 0 ;
+ size_t base = genalloc_len(ip46_t, ips) ;
if (!genalloc_readyplus(ip46_t, ips, len)) return -1 ;
for (; i < len ; i++)
ip46_from_ip(genalloc_s(ip46_t, ips) + base + i, data.s + (i << ((best & 1) ? 2 : 4)), !(best & 1)) ;