Removed version number from file header.
[Samba/ekacnet.git] / source / utils / net_lookup.c
blobfd8b9d24ef85cdf22d1c8413bec94238596f9a7e
1 /*
2 Samba Unix/Linux SMB client library
3 net lookup command
4 Copyright (C) 2001 Andrew Tridgell (tridge@samba.org)
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 #include "includes.h"
21 #include "../utils/net.h"
23 int net_lookup_usage(int argc, const char **argv)
25 d_printf(
26 "net lookup host HOSTNAME <type>\n\tgives IP for a hostname\n\n"\
27 "\n");
28 return -1;
31 /* lookup a hostname giving an IP */
32 static int net_lookup_host(int argc, const char **argv)
34 struct in_addr ip;
35 int name_type = 0x20;
37 if (argc == 0) return net_lookup_usage(argc, argv);
38 if (argc > 1) name_type = strtol(argv[1], NULL, 0);
40 if (!resolve_name(argv[0], &ip, name_type)) {
41 /* we deliberately use DEBUG() here to send it to stderr
42 so scripts aren't mucked up */
43 DEBUG(0,("Didn't find %s#%02x\n", argv[0], name_type));
44 return -1;
47 d_printf("%s\n", inet_ntoa(ip));
48 return 0;
52 /* lookup hosts or IP addresses using internal samba lookup fns */
53 int net_lookup(int argc, const char **argv)
55 struct functable func[] = {
56 {"HOST", net_lookup_host},
57 {NULL, NULL}
60 return net_run_function(argc, argv, func, net_lookup_usage);