AmendHub

Download:

jcs

/

wikipedia

/

amendments

/

38

dnr: Sync with upstream


jcs made amendment 38 about 1 year ago
--- dnr.c Wed Aug 31 17:42:22 2022 +++ dnr.c Wed Mar 8 10:07:56 2023 @@ -6,21 +6,14 @@ * Modifications by Jim Matthews, Dartmouth College, 5/91 */ -/* - * TODO: update to avoid having to include MacTraps2 for: - * CloseWD - * HOpenResFile - * FindFolder - * GetWDInfo - */ - #include <OSUtils.h> #include <Files.h> #include <Folders.h> #include <GestaltEqu.h> #include <Traps.h> -#include "dnr.h" +#include "AddressXlation.h" +#include "tcp.h" #define OPENRESOLVER 1 #define CLOSERESOLVER 2 @@ -38,7 +31,6 @@ void GetCPanelFolder(short *vRefNumP, long *dirIDP); short SearchFolderForDNRP(long targetType, long targetCreator, short vRefNum, long dirID); short OpenOurRF(void); -pascal void StrToAddrMarkDone(struct hostInfo *hi, char *data); Handle dnr = nil; @@ -122,7 +114,7 @@ SearchFolderForDNRP(long targetType, long targetCreato short refnum; fi.fileParam.ioCompletion = nil; - fi.fileParam.ioNamePtr = filename; + fi.fileParam.ioNamePtr = (StringPtr)&filename; fi.fileParam.ioVRefNum = vRefNum; fi.fileParam.ioDirID = dirID; fi.fileParam.ioFDirIndex = 1; @@ -316,15 +308,8 @@ MXInfo(char *hostName, struct returnRec *returnRecPtr, } #endif -pascal void -StrToAddrMarkDone(struct hostInfo *hi, char *data) -{ - volatile int *done = (int *)data; - *done = 1; -} - OSErr -ResolveName(char *name, unsigned long *ipAddress) +DNSResolveName(char **name, unsigned long *ipAddress, void (*yielder)(void)) { OSErr osErr; struct hostInfo aHostInfo; @@ -334,13 +319,15 @@ ResolveName(char *name, unsigned long *ipAddress) if (osErr) return osErr; - osErr = StrToAddr(name, &aHostInfo, (ResultProcPtr)StrToAddrMarkDone, + osErr = StrToAddr(*name, &aHostInfo, (ResultProcPtr)StrToAddrMarkDone, (char *)&done); if (osErr == cacheFault) { /* StrToAddrMarkDone will set done when DNS resolution finishes */ - while (!done) - ; + while (!done) { + if (yielder != NULL) + yielder(); + } } if ((aHostInfo.rtnCode == noErr) || (aHostInfo.rtnCode == cacheFault)) {