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