X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=client%2Fadnstest.c;h=88875d2c43eabd767acce5e15b66cb33150313ee;hb=16cf5367e3a455f322328315f3c13ed23d68b690;hp=eb9dccfa1d95dcd0170bf0a1be0d2df6d2bec29f;hpb=207130d4245886159b76eca6df889a23eee13ed6;p=adns.git diff --git a/client/adnstest.c b/client/adnstest.c index eb9dccf..88875d2 100644 --- a/client/adnstest.c +++ b/client/adnstest.c @@ -27,13 +27,24 @@ #include #include #include -#include + +#include "adns.h" + +#include "config.h" #ifndef OUTPUTSTREAM # define OUTPUTSTREAM stdout #endif -#include "adns.h" +#ifndef HAVE_POLL +#undef poll +int poll(struct pollfd *ufds, int nfds, int timeout) { + fputs("poll(2) not supported on this system\n",stderr); + exit(3); +} +#define adns_beforepoll(a,b,c,d,e) 0 +#define adns_afterpoll(a,b,c,d) 0 +#endif static void failure_status(const char *what, adns_status st) { fprintf(stderr,"adns failure: %s: %s\n",what,adns_strerror(st)); @@ -138,7 +149,7 @@ int main(int argc, char *const *argv) { initflagsnum= strtoul(initflags,&ep,0); if (*ep == ',') { owninitflags= ep+1; - if (!consistsof(owninitflags,"p")) { + if (!consistsof(owninitflags,"ps")) { fputs("unknown owninitflag\n",stderr); exit(4); } @@ -162,6 +173,7 @@ int main(int argc, char *const *argv) { " [ :,... ]\n" " [ [[,]/] ... ]\n" "initflags: p use poll(2) instead of select(2)\n" + " s use adns_wait with specified query, instead of 0\n" "queryflags: a print status abbrevs instead of strings\n", stderr); exit(4); @@ -252,8 +264,13 @@ int main(int argc, char *const *argv) { } if (!mcw) break; - mc= mcw; - qu= mcw->qu; + if (strchr(owninitflags,'s')) { + qu= mcw->qu; + mc= mcw; + } else { + qu= 0; + mc= 0; + } if (strchr(owninitflags,'p')) { for (;;) { @@ -278,7 +295,11 @@ int main(int argc, char *const *argv) { } if (r) failure_errno("wait/check",r); - assert(mcr==mc); + if (mc) assert(mcr==mc); + else mc= mcr; + assert(qu==mc->qu); + assert(!mc->doneyet); + fdom_split(mc->fdom,&domain,&qflags,ownflags,sizeof(ownflags)); if (gettimeofday(&now,0)) { perror("gettimeofday"); exit(3); }