static void DNSServiceRegisterDispose(mDNS_DirectOP *op) { mDNS_DirectOP_Register *x = (mDNS_DirectOP_Register*)op; x->autorename = mDNSfalse; // If mDNS_DeregisterService() returns mStatus_NoError, that means that the service was found in the list, // is sending its goodbye packet, and we'll get an mStatus_MemFree message when we can free the memory. // If mDNS_DeregisterService() returns an error, it means that the service had already been removed from // the list, so we should go ahead and free the memory right now if (mDNS_DeregisterService(&mDNSStorage, &x->s) != mStatus_NoError) FreeDNSServiceRegistration(x); }
mDNSlocal void RegCallback(mDNS *const m, ServiceRecordSet *const sr, mStatus result) { mDNS_DirectOP_Register *x = (mDNS_DirectOP_Register*)sr->ServiceContext; domainlabel name; domainname type, dom; char namestr[MAX_DOMAIN_LABEL+1]; // Unescaped name: up to 63 bytes plus C-string terminating NULL. char typestr[MAX_ESCAPED_DOMAIN_NAME]; char domstr [MAX_ESCAPED_DOMAIN_NAME]; if (!DeconstructServiceName(sr->RR_SRV.resrec.name, &name, &type, &dom)) return; if (!ConvertDomainLabelToCString_unescaped(&name, namestr)) return; if (!ConvertDomainNameToCString(&type, typestr)) return; if (!ConvertDomainNameToCString(&dom, domstr)) return; if (result == mStatus_NoError) { if (x->callback) x->callback((DNSServiceRef)x, 0, result, namestr, typestr, domstr, x->context); } else if (result == mStatus_NameConflict) { if (x->autoname) mDNS_RenameAndReregisterService(m, sr, mDNSNULL); else if (x->autorename) { IncrementLabelSuffix(&x->name, mDNStrue); mDNS_RenameAndReregisterService(m, &x->s, &x->name); } else if (x->callback) x->callback((DNSServiceRef)x, 0, result, namestr, typestr, domstr, x->context); } else if (result == mStatus_MemFree) { if (x->autorename) { x->autorename = mDNSfalse; x->name = mDNSStorage.nicelabel; mDNS_RenameAndReregisterService(m, &x->s, &x->name); } else FreeDNSServiceRegistration(x); } }