~andreserl/ubuntu/lucid/bind9/bind9-apport-533601

« back to all changes in this revision

Viewing changes to contrib/query-loc-0.4.0/query-loc.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones, LaMont Jones, Internet Software Consortium, Inc, localization folks
  • Date: 2008-08-02 14:20:20 UTC
  • mfrom: (1.2.1 upstream) (6.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080802142020-l1hon9jy8lbbjxmg
[LaMont Jones]

* default to using resolvconf if it is installed
* fix sonames and dependencies.  Closes: #149259, #492418
* Do not build-depend libcap2-dev on non-linux.  Closes: #493392
* drop unused query-loc manpage.  Closes: #492564
* lwresd: Deliver /etc/bind directory.  Closes: #490027
* fix query-source comment in default install

[Internet Software Consortium, Inc]

* 9.5.0-P2.  Closes: #492949

[localization folks]

* l10n: Spanish debconf translation.  Closes: #492425 (Ignacio Mondino)
* l10n: Swedish debconf templates.  Closes: #491369 (Martin Ågren)
* l10n: Japanese debconf translations.  Closes: #492048 (Hideki Yamane
  (Debian-JP))
* l10n: Finnish translation.  Closes: #490630 (Esko Arajärvi)
* l10n: Italian debconf translations.  Closes: #492587 (Alessandro Vietta)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include        "loc.h"
 
2
 
 
3
/* $Id: query-loc.c,v 1.1.2.1 2008/02/15 02:11:57 marka Exp $ */
 
4
 
 
5
/* Global variables */
 
6
char *progname;
 
7
short debug;
 
8
 
 
9
int
 
10
main (argc, argv)
 
11
     int argc;
 
12
     char *argv[];
 
13
{
 
14
  extern char *optarg;
 
15
  extern int optind;
 
16
 
 
17
  short verbose = FALSE;
 
18
  char *host;
 
19
 
 
20
  char ch;
 
21
 
 
22
  char *loc = NULL;
 
23
  struct in_addr addr;
 
24
  struct hostent *hp;
 
25
 
 
26
  progname = argv[0];
 
27
  while ((ch = getopt (argc, argv, "vd:")) != EOF)
 
28
    {
 
29
      switch (ch)
 
30
        {
 
31
        case 'v':
 
32
          verbose = TRUE;
 
33
          break;
 
34
        case 'd':
 
35
          debug = atoi (optarg);
 
36
          if (debug <= 0)
 
37
            {
 
38
              (void) fprintf (stderr,
 
39
                              "%s: illegal debug value.\n", progname);
 
40
              exit (2);
 
41
            }
 
42
          break;
 
43
        default:
 
44
          usage ();
 
45
        }
 
46
    }
 
47
  argc -= optind;
 
48
  argv += optind;
 
49
  if (argc != 1)
 
50
    {
 
51
      usage ();
 
52
    }
 
53
  if (verbose || debug)
 
54
    {
 
55
      printf ("\nThis is %s, version %s.\n\n", progname, VERSION);
 
56
    }
 
57
  host = argv[0];
 
58
  (void) res_init ();
 
59
 
 
60
  if ((addr.s_addr = inet_addr (host)) == INADDR_NONE)
 
61
    {
 
62
      if (debug >= 1)
 
63
        printf ("%s is a name\n", host);
 
64
      loc = getlocbyname (host, FALSE);
 
65
    }
 
66
  else
 
67
    {
 
68
      if (debug >= 1)
 
69
        printf ("%s is an IP address ", host);
 
70
      hp = (struct hostent *) gethostbyaddr
 
71
        ((char *) &addr, sizeof (addr), AF_INET);
 
72
      if (hp)
 
73
        {
 
74
          if (debug >= 1)
 
75
            printf ("and %s is its official name\n",
 
76
                    hp->h_name);
 
77
          loc = getlocbyname (hp->h_name, FALSE);
 
78
        }
 
79
      else
 
80
        {
 
81
          if (debug >= 1)
 
82
            printf ("which has no name\n");
 
83
          loc = getlocbyaddr (addr, NULL);
 
84
        }
 
85
    }
 
86
  if (loc == NULL)
 
87
    {
 
88
      printf ("No LOCation found for %s\n", host);
 
89
      exit (1);
 
90
    }
 
91
  else
 
92
    {
 
93
      if (verbose || debug)
 
94
        printf ("LOCation for %s is ", host);
 
95
      printf ("%s\n", loc);
 
96
      exit (0);
 
97
    }
 
98
}