X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=adns.git;a=blobdiff_plain;f=client%2Fadh-query.c;h=d17beab05a6ec7b8a159180a571e6aa8e6671f41;hp=cc5dc122f2846f194aaee48244063b43b9e7b0d7;hb=849075a00676ad04776f4fe3902e23cc2d8f70a3;hpb=4b2c4f8a37e33604c1aeddafe49b7c33089692a4 diff --git a/client/adh-query.c b/client/adh-query.c index cc5dc12..d17beab 100644 --- a/client/adh-query.c +++ b/client/adh-query.c @@ -5,11 +5,11 @@ */ /* * This file is - * Copyright (C) 1997-1999 Ian Jackson + * Copyright (C) 1997-2000 Ian Jackson * * It is part of adns, which is - * Copyright (C) 1997-1999 Ian Jackson - * Copyright (C) 1999 Tony Finch + * Copyright (C) 1997-2000 Ian Jackson + * Copyright (C) 1999-2000 Tony Finch * * 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,16 +34,21 @@ struct outstanding_list outstanding; static unsigned long idcounter; void ensure_adns_init(void) { + adns_initflags initflags; int r; if (ads) return; if (signal(SIGPIPE,SIG_IGN) == SIG_ERR) sysfail("ignore SIGPIPE",errno); - r= adns_init(&ads, - adns_if_noautosys|adns_if_nosigpipe | - (ov_env ? 0 : adns_if_noenv) | - ov_verbose, - 0); + + initflags= adns_if_noautosys|adns_if_nosigpipe|ov_verbose; + if (!ov_env) initflags |= adns_if_noenv; + + if (config_text) { + r= adns_init_strcfg(&ads, initflags, stderr, config_text); + } else { + r= adns_init(&ads, initflags, 0); + } if (r) sysfail("adns_init",r); if (ov_format == fmt_default) @@ -79,7 +84,7 @@ static void prep_query(struct query_node **qun_r, int *quflags_r) { *qun_r= qun; } -void of_ptr(const struct optioninfo *oi, const char *arg) { +void of_ptr(const struct optioninfo *oi, const char *arg, const char *arg2) { struct query_node *qun; int quflags, r; struct sockaddr_in sa; @@ -101,6 +106,29 @@ void of_ptr(const struct optioninfo *oi, const char *arg) { LIST_LINK_TAIL(outstanding,qun); } +void of_reverse(const struct optioninfo *oi, const char *arg, const char *arg2) { + struct query_node *qun; + int quflags, r; + struct sockaddr_in sa; + + memset(&sa,0,sizeof(sa)); + sa.sin_family= AF_INET; + if (!inet_aton(arg,&sa.sin_addr)) usageerr("invalid IP address %s",arg); + + prep_query(&qun,&quflags); + qun->owner= xmalloc(strlen(arg) + strlen(arg2) + 2); + sprintf(qun->owner, "%s %s", arg,arg2); + r= adns_submit_reverse_any(ads, + (struct sockaddr*)&sa, arg2, + ov_type == adns_r_none ? adns_r_txt : ov_type, + quflags, + qun, + &qun->qu); + if (r) sysfail("adns_submit_reverse",r); + + LIST_LINK_TAIL(outstanding,qun); +} + void query_do(const char *domain) { struct query_node *qun; int quflags, r; @@ -120,6 +148,7 @@ void query_do(const char *domain) { static void dequeue_query(struct query_node *qun) { LIST_UNLINK(outstanding,qun); free(qun->id); + free(qun->owner); free(qun); } @@ -263,12 +292,12 @@ void query_done(struct query_node *qun, adns_answer *answer) { dequeue_query(qun); } -void of_asynch_id(const struct optioninfo *oi, const char *arg) { +void of_asynch_id(const struct optioninfo *oi, const char *arg, const char *arg2) { free(ov_id); ov_id= xstrsave(arg); } -void of_cancel_id(const struct optioninfo *oi, const char *arg) { +void of_cancel_id(const struct optioninfo *oi, const char *arg, const char *arg2) { struct query_node *qun; for (qun= outstanding.head;