Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Convert NULL strings to undefined in callbacks.

Closes #32
  • Loading branch information...
commit 0969712cfe8b2e8985fa1bfe043f118c10725212 1 parent 5a1512f
@agnat authored
View
6 src/dns_service_browse.cpp
@@ -28,9 +28,9 @@ OnServiceChanged(DNSServiceRef sdRef, DNSServiceFlags flags,
args[1] = Integer::New(flags);
args[2] = Integer::New(interfaceIndex);
args[3] = Integer::New(errorCode);
- args[4] = String::New(serviceName);
- args[5] = String::New(serviceType);
- args[6] = String::New(replyDomain);
+ args[4] = stringOrUndefined(serviceName);
+ args[5] = stringOrUndefined(serviceType);
+ args[6] = stringOrUndefined(replyDomain);
if (serviceRef->GetContext().IsEmpty()) {
args[7] = Local<Value>::New(Undefined());
} else {
View
2  src/dns_service_enumerate_domains.cpp
@@ -24,7 +24,7 @@ OnEnumeration(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceInde
args[1] = Integer::New(flags);
args[2] = Integer::New(interfaceIndex);
args[3] = Integer::New(errorCode);
- args[4] = String::New(replyDomain);
+ args[4] = stringOrUndefined(replyDomain);
args[5] = Local<Value>::New(serviceRef->GetContext());
callback->Call(this_, argc, args);
}
View
2  src/dns_service_get_addr_info.cpp
@@ -38,7 +38,7 @@ OnAddressInfo(DNSServiceRef sdRef, DNSServiceFlags flags,
args[1] = Integer::New(flags);
args[2] = Integer::New(interfaceIndex);
args[3] = Integer::New(errorCode);
- args[4] = String::New(hostname);
+ args[4] = stringOrUndefined(hostname);
args[5] = String::Empty();
char ip[INET6_ADDRSTRLEN];
struct sockaddr_in *a4;
View
6 src/dns_service_register.cpp
@@ -37,9 +37,9 @@ OnServiceRegistered(DNSServiceRef sdRef, DNSServiceFlags flags,
args[0] = Local<Object>::New(serviceRef->handle_);
args[1] = Integer::New(flags);
args[2] = Integer::New(errorCode);
- args[3] = String::New(name);
- args[4] = String::New(serviceType);
- args[5] = String::New(domain);
+ args[3] = stringOrUndefined(name);
+ args[4] = stringOrUndefined(serviceType);
+ args[5] = stringOrUndefined(domain);
if (serviceRef->GetContext().IsEmpty()) {
args[6] = Local<Value>::New(Undefined());
} else {
View
4 src/dns_service_resolve.cpp
@@ -37,8 +37,8 @@ OnResolve(DNSServiceRef sdRef, DNSServiceFlags flags,
args[1] = Integer::New(flags);
args[2] = Integer::New(interfaceIndex);
args[3] = Integer::New(errorCode);
- args[4] = String::New(fullname);
- args[5] = String::New(hosttarget);
+ args[4] = stringOrUndefined(fullname);
+ args[5] = stringOrUndefined(hosttarget);
args[6] = Integer::New( ntohs(port) );
Buffer * buffer = Buffer::New(txtLen);
memcpy(Buffer::Data(buffer->handle_), txtRecord, txtLen);
View
6 src/mdns_utils.hpp
@@ -51,6 +51,12 @@ throwArgumentCountMismatchException(v8::Arguments const& args, size_t expectedCo
return throwError(msg.str().c_str());
}
+inline
+v8::Local<v8::Value>
+stringOrUndefined(const char * str) {
+ return v8::Local<v8::Value>::New(str ? v8::String::New(str) : v8::Undefined());
+}
+
} // end of namespace node_mdns
#endif // NODE_MDNS_UTILS_INCLUDED
Please sign in to comment.
Something went wrong with that request. Please try again.