X-Git-Url: https://git.distorted.org.uk/~mdw/adns/blobdiff_plain/ea1e31e326a99219a0a6edf28a75845b79b74893..a719a4bedec2bc512b7f95f7446e02f6662ebbc7:/src/general.c diff --git a/src/general.c b/src/general.c index fbab698..33946ad 100644 --- a/src/general.c +++ b/src/general.c @@ -4,7 +4,7 @@ * - vbuf handling */ /* - * This file is part of adns, which is Copyright (C) 1997, 1998 Ian Jackson + * This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,33 +34,36 @@ void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent, int serv, adns_query qu, const char *fmt, va_list al) { const char *bef, *aft; vbuf vb; - if (!(ads->iflags & adns_if_debug) && (!prevent || (ads->iflags & prevent))) return; + + if (!ads->diagfile || + (!(ads->iflags & adns_if_debug) && (!prevent || (ads->iflags & prevent)))) + return; - fprintf(stderr,"adns%s: ",pfx); + fprintf(ads->diagfile,"adns%s: ",pfx); - vfprintf(stderr,fmt,al); + vfprintf(ads->diagfile,fmt,al); bef= " ("; aft= "\n"; if (qu && qu->query_dgram) { adns__vbuf_init(&vb); - fprintf(stderr,"%sQNAME=%s, QTYPE=%s", + fprintf(ads->diagfile,"%sQNAME=%s, QTYPE=%s", bef, 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) - fprintf(stderr,"(%s)",qu->typei->fmtname); + fprintf(ads->diagfile,"(%s)",qu->typei->fmtname); bef=", "; aft=")\n"; } if (serv>=0) { - fprintf(stderr,"%sNS=%s",bef,inet_ntoa(ads->servers[serv].addr)); + fprintf(ads->diagfile,"%sNS=%s",bef,inet_ntoa(ads->servers[serv].addr)); bef=", "; aft=")\n"; } - fputs(aft,stderr); + fputs(aft,ads->diagfile); } void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt, ...) { @@ -251,13 +254,15 @@ const char *adns_strerror(adns_status st) { } void adns__isort(void *array, int nobjs, int sz, void *tempbuf, - int (*needswap)(const void *a, const void *b)) { + int (*needswap)(void *context, const void *a, const void *b), + void *context) { byte *data= array; int i, place; for (i=0; i0 && needswap(data + (place-1)*sz, data + i*sz); place--); - + for (place= i; + place>0 && needswap(context, 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);