-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCvtAddr.c
More file actions
47 lines (37 loc) · 1.16 KB
/
Copy pathCvtAddr.c
File metadata and controls
47 lines (37 loc) · 1.16 KB
1
#include <string.h>#include "AddressXlation.h"#include "CvtAddr.h"pascal void DNRResultProc(struct hostInfo *hInfoPtr,char *userDataPtr);/* ConvertStringToAddr is a simple call to get a host's IP number, given the name of the host.*/OSErr ConvertStringToAddr(char *name,unsigned long *netNum, void(*giveTime)()){ struct hostInfo hInfo; OSErr result; char done = 0x00; extern Boolean gCancel; if ((result = OpenResolver(nil)) == noErr) { result = StrToAddr(name,&hInfo,DNRResultProc,&done); if (result == cacheFault) while (!done) (*giveTime)(); /* wait for cache fault resolver to be called by interrupt */ CloseResolver(); if ((hInfo.rtnCode == noErr) || (hInfo.rtnCode == cacheFault)) { *netNum = hInfo.addr[0]; strcpy(name,hInfo.cname); name[strlen(name)-1] = '\0'; return noErr; } } *netNum = 0; return result;}/* This is the completion routine used for name-resolver calls. It sets the userDataPtr flag to indicate the call has completed.*/pascal void DNRResultProc(struct hostInfo *hInfoPtr,char *userDataPtr){#pragma unused (hInfoPtr) *userDataPtr = 0xff; /* setting the use data to non-zero means we're done */}