⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 query-loc.c

📁 bind 源码 最新实现 linux/unix/windows平台
💻 C
字号:
#include        "loc.h"/* $Id: query-loc.c,v 1.1.2.1 2005/04/01 06:14:01 marka Exp $ *//* Global variables */char *progname;short debug;intmain (argc, argv)     int argc;     char *argv[];{  extern char *optarg;  extern int optind;  short verbose = FALSE;  char *host;  char ch;  char *loc = NULL;  struct in_addr addr;  struct hostent *hp;  progname = argv[0];  while ((ch = getopt (argc, argv, "vd:")) != EOF)    {      switch (ch)	{	case 'v':	  verbose = TRUE;	  break;	case 'd':	  debug = atoi (optarg);	  if (debug <= 0)	    {	      (void) fprintf (stderr,			      "%s: illegal debug value.\n", progname);	      exit (2);	    }	  break;	default:	  usage ();	}    }  argc -= optind;  argv += optind;  if (argc != 1)    {      usage ();    }  if (verbose || debug)    {      printf ("\nThis is %s, version %s.\n\n", progname, VERSION);    }  host = argv[0];  (void) res_init ();  if ((addr.s_addr = inet_addr (host)) == INADDR_NONE)    {      if (debug >= 1)	printf ("%s is a name\n", host);      loc = getlocbyname (host, FALSE);    }  else    {      if (debug >= 1)	printf ("%s is an IP address ", host);      hp = (struct hostent *) gethostbyaddr	((char *) &addr, sizeof (addr), AF_INET);      if (hp)	{	  if (debug >= 1)	    printf ("and %s is its official name\n",		    hp->h_name);	  loc = getlocbyname (hp->h_name, FALSE);	}      else	{	  if (debug >= 1)	    printf ("which has no name\n");	  loc = getlocbyaddr (addr, NULL);	}    }  if (loc == NULL)    {      printf ("No LOCation found for %s\n", host);      exit (1);    }  else    {      if (verbose || debug)	printf ("LOCation for %s is ", host);      printf ("%s\n", loc);      exit (0);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -