isc_result_t printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) { char servtext[ISC_SOCKADDR_FORMATSIZE]; /* I've we've gotten this far, we've reached a server. */ query_error = 0; debug("printmessage()"); isc_sockaddr_format(&query->sockaddr, servtext, sizeof(servtext)); printf("Server:\t\t%s\n", query->userarg); printf("Address:\t%s\n", servtext); puts(""); if (!short_form) { isc_boolean_t headers = ISC_TRUE; puts("------------"); /* detailheader(query, msg);*/ detailsection(query, msg, headers, DNS_SECTION_QUESTION); detailsection(query, msg, headers, DNS_SECTION_ANSWER); detailsection(query, msg, headers, DNS_SECTION_AUTHORITY); detailsection(query, msg, headers, DNS_SECTION_ADDITIONAL); puts("------------"); } if (msg->rcode != 0) { char nametext[DNS_NAME_FORMATSIZE]; dns_name_format(query->lookup->name, nametext, sizeof(nametext)); printf("** server can't find %s: %s\n", nametext, rcode_totext(msg->rcode)); debug("returning with rcode == 0"); /* the lookup failed */ print_error |= 1; return (ISC_R_SUCCESS); } if ((msg->flags & DNS_MESSAGEFLAG_AA) == 0) puts("Non-authoritative answer:"); if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ANSWER])) printsection(query, msg, headers, DNS_SECTION_ANSWER); else printf("*** Can't find %s: No answer\n", query->lookup->textname); if (((msg->flags & DNS_MESSAGEFLAG_AA) == 0) && (query->lookup->rdtype != dns_rdatatype_a)) { puts("\nAuthoritative answers can be found from:"); printsection(query, msg, headers, DNS_SECTION_AUTHORITY); printsection(query, msg, headers, DNS_SECTION_ADDITIONAL); } return (ISC_R_SUCCESS); }
int main(int argn, char **argv) { char buf[1024], sec[100], qry[100], manfile[100]; int retv; strsncpy(buf, getsenv("QUERY_STRING"), sizeof (buf)); if (strchr(buf, '&')) retv = getformarg(buf, sec, qry, 100); else if (strchr(buf, '+')) retv = geturlarg(buf, sec, qry, 100); else retv = -1; if (!retv) retv = testarg(sec, qry); if (!retv) { retv = getmanfile(sec, qry, manfile, sizeof (manfile)); if (retv) { printheader(); printf ("找不到与<font color=red>%s</font>相关的文档<br><br>\n", nohtml(qry)); } } if (retv) { printheader(); printsection(); printform(); return 0; } runman2html(manfile); return 0; }
isc_result_t printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) { char servtext[ISC_SOCKADDR_FORMATSIZE]; /* I've we've gotten this far, we've reached a server. */ query_error = 0; debug("printmessage()"); if(!default_lookups || query->lookup->rdtype == dns_rdatatype_a) { isc_sockaddr_format(&query->sockaddr, servtext, sizeof(servtext)); printf("Server:\t\t%s\n", query->userarg); printf("Address:\t%s\n", servtext); puts(""); } if (!short_form) { puts("------------"); /* detailheader(query, msg);*/ detailsection(query, msg, ISC_TRUE, DNS_SECTION_QUESTION); detailsection(query, msg, ISC_TRUE, DNS_SECTION_ANSWER); detailsection(query, msg, ISC_TRUE, DNS_SECTION_AUTHORITY); detailsection(query, msg, ISC_TRUE, DNS_SECTION_ADDITIONAL); puts("------------"); } if (msg->rcode != 0) { char nametext[DNS_NAME_FORMATSIZE]; dns_name_format(query->lookup->name, nametext, sizeof(nametext)); printf("** server can't find %s: %s\n", nametext, rcode_totext(msg->rcode)); debug("returning with rcode == 0"); /* the lookup failed */ print_error |= 1; return (ISC_R_SUCCESS); } if ( default_lookups && query->lookup->rdtype == dns_rdatatype_a) { char namestr[DNS_NAME_FORMATSIZE]; dig_lookup_t *lookup; dns_fixedname_t fixed; dns_name_t *name; /* Add AAAA lookup. */ dns_fixedname_init(&fixed); name = dns_fixedname_name(&fixed); dns_name_copy(query->lookup->name, name, NULL); chase_cnamechain(msg, name); dns_name_format(name, namestr, sizeof(namestr)); lookup = clone_lookup(query->lookup, ISC_FALSE); if (lookup != NULL) { strncpy(lookup->textname, namestr, sizeof(lookup->textname)); lookup->textname[sizeof(lookup->textname)-1] = 0; lookup->rdtype = dns_rdatatype_aaaa; lookup->rdtypeset = ISC_TRUE; lookup->origin = NULL; lookup->retries = tries; ISC_LIST_APPEND(lookup_list, lookup, link); } } if ((msg->flags & DNS_MESSAGEFLAG_AA) == 0 && ( !default_lookups || query->lookup->rdtype == dns_rdatatype_a) ) puts("Non-authoritative answer:"); if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ANSWER])) printsection(query, msg, headers, DNS_SECTION_ANSWER); else { if (default_lookups && query->lookup->rdtype == dns_rdatatype_a) a_noanswer = ISC_TRUE; else if (!default_lookups || (query->lookup->rdtype == dns_rdatatype_aaaa && a_noanswer ) ) printf("*** Can't find %s: No answer\n", query->lookup->textname); } if (((msg->flags & DNS_MESSAGEFLAG_AA) == 0) && (query->lookup->rdtype != dns_rdatatype_a) && (query->lookup->rdtype != dns_rdatatype_aaaa) ) { puts("\nAuthoritative answers can be found from:"); printsection(query, msg, headers, DNS_SECTION_AUTHORITY); printsection(query, msg, headers, DNS_SECTION_ADDITIONAL); } return (ISC_R_SUCCESS); }