X-Git-Url: https://git.distorted.org.uk/~mdw/adns/blobdiff_plain/86e7b8d96483d2f55561aa76ac96e7663840b796..c7836bc9e8b0ed6a04e9008545e29de410d9693e:/src/general.c diff --git a/src/general.c b/src/general.c index 37edfa3..211b6d2 100644 --- a/src/general.c +++ b/src/general.c @@ -22,6 +22,7 @@ */ #include +#include #include @@ -46,7 +47,7 @@ void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent, adns__vbuf_init(&vb); fprintf(stderr,"%sQNAME=%s, QTYPE=%s", bef, - adns__diag_domain(qu->ads,-1,0, &vb,qu->flags, + adns__diag_domain(qu->ads,-1,0, &vb, qu->query_dgram,qu->query_dglen,DNS_HDRSIZE), qu->typei ? qu->typei->rrtname : ""); if (qu->typei && qu->typei->fmtname) @@ -138,11 +139,11 @@ void adns__vbuf_free(vbuf *vb) { /* Additional diagnostic functions */ -const char *adns__diag_domain(adns_state ads, int serv, adns_query qu, vbuf *vb, - int flags, const byte *dgram, int dglen, int cbyte) { +const char *adns__diag_domain(adns_state ads, int serv, adns_query qu, + vbuf *vb, const byte *dgram, int dglen, int cbyte) { adns_status st; - st= adns__parse_domain(ads,serv,qu,vb, flags,dgram,dglen,&cbyte,dglen); + st= adns__parse_domain(ads,serv,qu,vb, pdf_quoteok, dgram,dglen,&cbyte,dglen); if (st == adns_s_nolocalmem) { return ""; } @@ -199,24 +200,25 @@ static const struct sinfo { adns_status st; const char *string; } sinfos[]= { - SINFO( ok, "OK" ), - SINFO( timeout, "Timed out" ), - SINFO( nolocalmem, "Out of memory" ), - SINFO( allservfail, "No working nameservers" ), - SINFO( servfail, "Nameserver failure" ), - SINFO( notimplemented, "Query not implemented" ), - SINFO( refused, "Refused by nameserver" ), - SINFO( reasonunknown, "Reason unknown" ), - SINFO( norecurse, "Recursion denied by nameserver" ), - SINFO( serverfaulty, "Nameserver sent bad data" ), - SINFO( unknownreply, "Reply from nameserver not understood" ), - SINFO( invaliddata, "Invalid data" ), - SINFO( inconsistent, "Inconsistent data" ), - SINFO( cname, "RR refers to an alias" ), - SINFO( nxdomain, "No such domain" ), - SINFO( nodata, "No such data" ), - SINFO( invaliddomain, "Domain syntactically invalid" ), - SINFO( domaintoolong, "Domain name too long" ) + SINFO( ok, "OK" ), + SINFO( timeout, "Timed out" ), + SINFO( nolocalmem, "Out of memory" ), + SINFO( allservfail, "No working nameservers" ), + SINFO( servfail, "Nameserver failure" ), + SINFO( notimplemented, "Query not implemented" ), + SINFO( refused, "Refused by nameserver" ), + SINFO( reasonunknown, "Reason unknown" ), + SINFO( norecurse, "Recursion denied by nameserver" ), + SINFO( serverfaulty, "Nameserver sent bad data" ), + SINFO( unknownreply, "Reply from nameserver not understood" ), + SINFO( invaliddata, "Invalid data" ), + SINFO( inconsistent, "Inconsistent data" ), + SINFO( cname, "RR refers to an alias" ), + SINFO( invalidanswerdomain, "Received syntactically invalid domain" ), + SINFO( nxdomain, "No such domain" ), + SINFO( nodata, "No such data" ), + SINFO( invalidquerydomain, "Domain syntactically invalid" ), + SINFO( domaintoolong, "Domain name too long" ) }; static int si_compar(const void *key, const void *elem) { @@ -237,3 +239,19 @@ const char *adns_strerror(adns_status st) { snprintf(buf,sizeof(buf),"code %d",st); return buf; } + +void adns__isort(void *array, int nobjs, int sz, void *tempbuf, + int (*needswap)(const void *a, const void *b)) { + byte *data= array; + int i, place; + + for (i=0; i0 && needswap(data + (place-1)*sz, data + i*sz); place--); + + if (place != i) { + memcpy(tempbuf, data + i*sz, sz); + memmove(data + (place+1)*sz, data + place*sz, (i-place)*sz); + memcpy(data + place*sz, tempbuf, sz); + } + } +}