ObjFW  Check-in [40bf53792d]

Overview
Comment:OFDNSResolver: Do not use gethostname() on Wii

It's in the headers, but the symbol is missing.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 40bf53792d6fef2442ff85beb554189229daa503e262a7f39f9aac695ee9aebe
User & Date: js on 2018-08-20 01:24:44
Other Links: manifest | tags
Context
2018-08-25
15:53
OFDNSResolver: Obtain name servers on Nintendo 3DS check-in: 81674093ac user: js tags: trunk
2018-08-20
01:24
OFDNSResolver: Do not use gethostname() on Wii check-in: 40bf53792d user: js tags: trunk
2018-08-19
23:50
OFDNSResolver: Do not allow IPs as local domain check-in: 7050b3a480 user: js tags: trunk
Changes

Modified src/OFDNSResolver.m from [90b01a441b] to [fc33672140].

191
192
193
194
195
196
197

198
199
200
201
202
203
204
  didReceiveIntoBuffer: (unsigned char *)buffer
		length: (size_t)length
		sender: (of_socket_address_t)sender
	       context: (id)context
	     exception: (id)exception;
@end


static OFString *
domainFromHostname(void)
{
	char hostname[256];
	OFString *domain;

	if (gethostname(hostname, 256) != 0)







>







191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
  didReceiveIntoBuffer: (unsigned char *)buffer
		length: (size_t)length
		sender: (of_socket_address_t)sender
	       context: (id)context
	     exception: (id)exception;
@end

#ifndef OF_WII
static OFString *
domainFromHostname(void)
{
	char hostname[256];
	OFString *domain;

	if (gethostname(hostname, 256) != 0)
222
223
224
225
226
227
228

229
230
231
232
233
234
235
		if (pos == OF_NOT_FOUND)
			return nil;

		return [domain substringWithRange:
		    of_range(pos + 1, [domain length] - pos - 1)];
	}
}


static bool
isFQDN(OFString *host, OFDNSResolverSettings *settings)
{
	const char *UTF8String = [host UTF8String];
	size_t length = [host UTF8StringLength];
	unsigned int dots = 0;







>







223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
		if (pos == OF_NOT_FOUND)
			return nil;

		return [domain substringWithRange:
		    of_range(pos + 1, [domain length] - pos - 1)];
	}
}
#endif

static bool
isFQDN(OFString *host, OFDNSResolverSettings *settings)
{
	const char *UTF8String = [host UTF8String];
	size_t length = [host UTF8StringLength];
	unsigned int dots = 0;
853
854
855
856
857
858
859

860
861

862
863
864
865
866
867
868
#ifdef OF_HAVE_IPV6
		_nameServers = [[OFArray alloc]
		    initWithObjects: @"127.0.0.1", @"::1", nil];
#else
		_nameServers = [[OFArray alloc] initWithObject: @"127.0.0.1"];
#endif


	if (_localDomain == nil)
		_localDomain = [domainFromHostname() copy];


	if (_searchDomains == nil) {
		if (_localDomain != nil)
			_searchDomains = [[OFArray alloc]
			    initWithObject: _localDomain];
		else
			_searchDomains = [[OFArray alloc] init];







>


>







855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
#ifdef OF_HAVE_IPV6
		_nameServers = [[OFArray alloc]
		    initWithObjects: @"127.0.0.1", @"::1", nil];
#else
		_nameServers = [[OFArray alloc] initWithObject: @"127.0.0.1"];
#endif

#ifndef OF_WII
	if (_localDomain == nil)
		_localDomain = [domainFromHostname() copy];
#endif

	if (_searchDomains == nil) {
		if (_localDomain != nil)
			_searchDomains = [[OFArray alloc]
			    initWithObject: _localDomain];
		else
			_searchDomains = [[OFArray alloc] init];