2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 1992-1998
5 Copyright (C) Jeremy Allison 1998-2002
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.
23 #include "system/network.h"
24 #include "system/filesys.h"
27 The idea is that this file will eventually have wrappers around all
28 important system calls in samba. The aims are:
30 - to enable easier porting by putting OS dependent stuff in here
32 - to allow for hooks into other "pseudo-filesystems"
34 - to allow easier integration of things like the japanese extensions
36 - to support the philosophy of Samba to expose the features of
37 the OS within the SMB model. In general whatever file/printer/variable
38 expansions/etc make sense to the OS should be acceptable to Samba.
41 /**************************************************************************
42 A wrapper for gethostbyname() that tries avoids looking up hostnames
43 in the root domain, which can cause dial-on-demand links to come up for no
45 ****************************************************************************/
47 struct hostent *sys_gethostbyname(const char *name)
49 #ifdef REDUCE_ROOT_DNS_LOOKUPS
50 char query[256], hostname[256];
53 /* Does this name have any dots in it? If so, make no change */
55 if (strchr_m(name, '.'))
56 return(gethostbyname(name));
58 /* Get my hostname, which should have domain name
59 attached. If not, just do the gethostname on the
63 gethostname(hostname, sizeof(hostname) - 1);
64 hostname[sizeof(hostname) - 1] = 0;
65 if ((domain = strchr_m(hostname, '.')) == NULL)
66 return(gethostbyname(name));
68 /* Attach domain name to query and do modified query.
69 If names too large, just do gethostname on the
73 if((strlen(name) + strlen(domain)) >= sizeof(query))
74 return(gethostbyname(name));
76 slprintf(query, sizeof(query)-1, "%s%s", name, domain);
77 return(gethostbyname(query));
78 #else /* REDUCE_ROOT_DNS_LOOKUPS */
79 return(gethostbyname(name));
80 #endif /* REDUCE_ROOT_DNS_LOOKUPS */
83 const char *sys_inet_ntoa(struct ipv4_addr in)
87 return inet_ntoa(in2);
90 struct ipv4_addr sys_inet_makeaddr(int net, int host)
94 in = inet_makeaddr(net, host);