dig.c revision 550c92405fc1df47e725f2ecbaa5154c9239fcfd
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC")
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * Copyright (C) 2000-2003 Internet Software Consortium.
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * Permission to use, copy, modify, and/or distribute this software for any
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * purpose with or without fee is hereby granted, provided that the above
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * copyright notice and this permission notice appear in all copies.
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson * PERFORMANCE OF THIS SOFTWARE.
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson/* $Id: dig.c,v 1.245 2011/12/07 17:23:28 each Exp $ */
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson#define ADD_STRING(b, s) { \
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson if (strlen(s) >= isc_buffer_availablelength(b)) \
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssonstatic isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson ip6_int = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE,
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson multiline = ISC_FALSE, nottl = ISC_FALSE, noclass = ISC_FALSE,
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson onesoa = ISC_FALSE, rrcomments = ISC_FALSE, use_usec = ISC_FALSE;
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssonstatic isc_uint32_t splitwidth = 0xffffffff;
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson/*% opcode text */
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssonstatic const char * const opcodetext[] = {
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafsson/*% return code text */
e7a4f58d55042cbc981a70b5071aaea46b9ebf7fAndreas Gustafssonstatic const char * const rcodetext[] = {
const char *consttext;
char *deconsttext;
} totext;
ISC_PLATFORM_NORETURN_PRE static void
usage(void) {
version(void) {
help(void) {
#ifdef DIG_SIGCHASE
#if DIG_SIGCHASE_TD
stdout);
* Callback from dighost.c to print the received message.
if (use_usec)
if (!validated)
if (use_usec)
* Callback from dighost.c to print that it is trying a server.
static isc_result_t
return (result);
return (result);
if (use_usec)
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_SUCCESS);
return (result);
buf);
return (result);
return (result);
return (ISC_R_SUCCESS);
#ifdef DIG_SIGCHASE
unsigned int styleflags = 0;
return(ISC_FALSE);
if (nottl)
if (noclass)
if (rrcomments)
if (multiline) {
return(result);
* Callback from dighost.c to print the reply from a server
unsigned int styleflags = 0;
if (rrcomments)
if (nottl)
if (noclass)
if (multiline) {
if (!short_form)
flags = 0;
if (!headers) {
if (headers) {
goto repopulate_buffer;
goto cleanup;
if (!short_form) {
goto buftoosmall;
if (!short_form) {
goto buftoosmall;
goto buftoosmall;
if (!short_form) {
goto buftoosmall;
if (!short_form) {
goto buftoosmall;
if (headers) {
msg,
goto buftoosmall;
msg,
goto buftoosmall;
return (result);
int remaining;
if (printcmd) {
while (i < argc) {
if (first) {
#ifdef DIG_SIGCHASE
size_t n;
#define FULLCHECK(A) \
goto invalid_option; \
#define FULLCHECK2(A, B) \
goto invalid_option; \
switch (cmd[0]) {
goto invalid_option;
goto invalid_option;
goto need_value;
if (!state)
goto invalid_option;
goto invalid_option;
goto invalid_option;
goto invalid_option;
goto need_value;
if (!state)
goto invalid_option;
goto invalid_option;
if (!state) {
goto need_value;
goto need_value;
if (!state)
goto invalid_option;
if (state) {
goto invalid_option;
goto invalid_option;
goto invalid_option;
goto need_value;
if (!state)
goto invalid_option;
goto invalid_option;
goto invalid_option;
goto invalid_option;
if (state) {
goto invalid_option;
#ifdef DIG_SIGCHASE
goto invalid_option;
if (!state) {
splitwidth = 0;
if (splitwidth)
goto invalid_option;
if (!is_batchfile)
goto need_value;
if (!state)
goto invalid_option;
if (timeout == 0)
#if DIG_SIGCHASE_TD
if (state) {
goto need_value;
if (!state)
goto invalid_option;
#ifdef DIG_SIGCHASE
goto need_value;
if (!state)
goto invalid_option;
sizeof(trustedkey));
if (n >= sizeof(trustedkey))
goto invalid_option;
goto invalid_option;
if (!is_batchfile)
option);
usage();
static isc_boolean_t
switch (opt) {
if (have_ipv4) {
return (ISC_FALSE);
if (have_ipv6) {
return (ISC_FALSE);
return (ISC_FALSE);
help();
exit(0);
version();
exit(0);
return (ISC_FALSE);
goto invalid_option;
switch (opt) {
srcport = 0;
return (value_from_next);
value);
return (value_from_next);
return (value_from_next);
return (value_from_next);
return (value_from_next);
if (!config_only) {
if (*need_clone)
ISC_TRUE);
if (*firstarg) {
return (value_from_next);
value);
return (value_from_next);
usage();
usage();
digestbits = 0;
return (value_from_next);
if (*need_clone)
if (*firstarg) {
return (value_from_next);
usage();
return (ISC_FALSE);
int rc;
char **rv;
char *option;
int bargc;
int rc;
char **rv;
#ifndef NOPOSIX
char *homedir;
char *input;
if (!is_batchfile) {
#ifndef NOPOSIX
homedir);
if (n < sizeof(rcfile))
batchfp) != 0) {
bargc++;
for(i = 0; i < bargc; i++)
i, bargv[i]);
(char **)bargv);
lookup);
rc--;
rv++;
rc--;
rv++;
if (open_type_class) {
if (rdtype ==
if (!config_only) {
if (need_clone)
ISC_TRUE);
if (firstarg) {
goto next_line;
bargc++;
for(i = 0; i < bargc; i++)
if (need_clone)
if (firstarg) {
if (!need_clone)
* Callback from dighost.c to allow program-specific shutdown code.
dighost_shutdown(void) {
int bargc;
char *input;
bargc++;
for(i = 0; i < bargc; i++)
start_lookup();
setup_libs();
setup_system();
isc_app_run();
#ifdef DIG_SIGCHASE
cancel_all();
destroy_libs();
return (exitcode);