2 Samba Unix/Linux SMB client library
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. */
21 #include "../utils/net.h"
23 int net_lookup_usage(int argc
, const char **argv
)
26 "net lookup host HOSTNAME <type>\n\tgives IP for a hostname\n\n"\
31 /* lookup a hostname giving an IP */
32 static int net_lookup_host(int argc
, const char **argv
)
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
));
47 d_printf("%s\n", inet_ntoa(ip
));
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
},
60 return net_run_function(argc
, argv
, func
, net_lookup_usage
);