@@ -20,11 +20,14 @@ #import "OFDNSResolverSettings.h" #import "OFArray.h" #import "OFCharacterSet.h" #import "OFDate.h" #import "OFDictionary.h" -#import "OFFile.h" +#ifdef OF_HAVE_FILES +# import "OFFile.h" +# import "OFFileManager.h" +#endif #import "OFLocale.h" #import "OFSocket+Private.h" #import "OFString.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" @@ -50,28 +53,24 @@ # define id id_3ds # include <3ds.h> # undef id #endif +#if defined(OF_AMIGAOS_M68K) || defined(OF_AMIGAOS4) +# define Class IntuitionClass +# include +# undef Class +#endif #ifdef OF_MORPHOS # include # include # include #endif #if defined(OF_HAIKU) # define HOSTS_PATH @"/system/settings/network/hosts" # define RESOLV_CONF_PATH @"/system/settings/network/resolv.conf" -#elif defined(OF_AMIGAOS4) -# define HOSTS_PATH @"DEVS:Internet/hosts" -#elif defined(OF_AMIGAOS) -# define HOSTS_PATH @"AmiTCP:db/hosts" -/* - * FIXME: The installer puts it there, but theoretically it could also be in - * AmiTCP:db/netdb or any of the files included there. - */ -# define RESOLV_CONF_PATH @"AmiTCP:db/netdb-myhost" #else # define HOSTS_PATH @"/etc/hosts" # define RESOLV_CONF_PATH @"/etc/resolv.conf" #endif @@ -121,10 +120,21 @@ return [OFString stringWithCString: hostname encoding: [OFLocale encoding]]; } #endif + +#ifdef OF_AMIGAOS_M68K +static bool +assignExists(const char *assign) +{ + struct DosList *list = LockDosList(LDF_ASSIGNS | LDF_READ); + bool found = (FindDosEntry(list, assign, LDF_ASSIGNS) != NULL); + UnLockDosList(LDF_ASSIGNS | LDF_READ); + return found; +} +#endif #ifdef OF_MORPHOS static OFString * arexxCommand(const char *port, const char *command) { @@ -320,11 +330,11 @@ _staticHosts = [staticHosts copy]; objc_autoreleasePoolPop(pool); } -# if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS4) +# ifndef OF_WINDOWS - (void)parseResolvConfOption: (OFString *)option { @try { if ([option hasPrefix: @"ndots:"]) { unsigned long long number; @@ -531,17 +541,26 @@ objc_autoreleasePoolPop(pool); } #endif -#ifdef OF_AMIGAOS4 -- (void)obtainAmigaOS4SystemConfig +#if defined(OF_AMIGAOS_M68K) || defined(OF_AMIGAOS4) +- (bool)obtainRoadshowSystemConfig { - OFMutableArray *nameServers = [OFMutableArray array]; - OFStringEncoding encoding = [OFLocale encoding]; - struct List *nameServerList = ObtainDomainNameServerList(); + OFMutableArray *nameServers; + OFStringEncoding encoding; + struct List *nameServerList; char buffer[MAXHOSTNAMELEN]; + LONG hasDNSAPI; + + if (SocketBaseTags(SBTM_GETREF(SBTC_HAVE_DNS_API), (ULONG)&hasDNSAPI, + TAG_END) != 0 || !hasDNSAPI) + return false; + + nameServers = [OFMutableArray array]; + encoding = [OFLocale encoding]; + nameServerList = ObtainDomainNameServerList(); if (nameServerList == NULL) @throw [OFOutOfMemoryException exception]; @try { @@ -571,10 +590,12 @@ } if (GetDefaultDomainName(buffer, sizeof(buffer))) _localDomain = [[OFString alloc] initWithCString: buffer encoding: encoding]; + + return true; } #endif #ifdef OF_NINTENDO_3DS - (void)obtainNintendo3DSSytemConfig @@ -622,10 +643,13 @@ - (void)reload { #ifdef OF_WINDOWS OFString *path = nil; #endif +#if (defined(OF_AMIGAOS_M68K) || defined(OF_AMIGAOS4)) && defined(OF_HAVE_FILES) + OFFileManager *fileManager = [OFFileManager defaultManager]; +#endif void *pool; /* * TODO: Rather than reparsing every time, check what actually changed * (mtime) and only reset those. @@ -663,13 +687,29 @@ # endif [self obtainWindowsSystemConfig]; #elif defined(OF_MORPHOS) [self obtainMorphOSSystemConfig]; -#elif defined(OF_AMIGAOS4) - [self parseHosts: HOSTS_PATH]; - [self obtainAmigaOS4SystemConfig]; +#elif defined(OF_AMIGAOS_M68K) || defined(OF_AMIGAOS4) +# ifdef OF_HAVE_FILES + if (![self obtainRoadshowSystemConfig]) { + if (assignExists("AmiTCP")) + /* + * FIXME: The installer puts it there, but theoretically + * it could also be in AmiTCP:db/netdb or any of + * the files included there. + */ + [self parseResolvConf: @"AmiTCP:db/netdb-myhost"]; + } + + if ([fileManager fileExistsAtPath: @"DEVS:Internet/hosts"]) + [self parseHosts: @"DEVS:Internet/hosts"]; + else if (assignExists("AmiTCP")) + [self parseHosts: @"AmiTCP:db/hosts"]; +# else + [self obtainRoadshowSystemConfig]; +# endif #elif defined(OF_NINTENDO_3DS) [self obtainNintendo3DSSytemConfig]; #elif defined(OF_HAVE_FILES) [self parseHosts: HOSTS_PATH]; [self parseResolvConf: RESOLV_CONF_PATH];