cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhigg...@apache.org
Subject [12/51] [partial] CB-6346 - Add node_modules to source control
Date Thu, 27 Mar 2014 15:08:26 GMT
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/net-ping/node_modules/raw-socket/src/raw.cc
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/net-ping/node_modules/raw-socket/src/raw.cc b/blackberry10/node_modules/net-ping/node_modules/raw-socket/src/raw.cc
new file mode 100644
index 0000000..e712760
--- /dev/null
+++ b/blackberry10/node_modules/net-ping/node_modules/raw-socket/src/raw.cc
@@ -0,0 +1,771 @@
+#ifndef RAW_CC
+#define RAW_CC
+
+#include <node.h>
+#include <node_buffer.h>
+
+#include <stdio.h>
+#include <string.h>
+#include "raw.h"
+
+#ifdef _WIN32
+static char errbuf[1024];
+#endif
+const char* raw_strerror (int code) {
+#ifdef _WIN32
+	if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, 0, code, 0, errbuf,
+			1024, NULL)) {
+		return errbuf;
+	} else {
+		strcpy (errbuf, "Unknown error");
+		return errbuf;
+	}
+#else
+	return strerror (code);
+#endif
+}
+
+static uint16_t checksum (uint16_t start_with, unsigned char *buffer,
+		size_t length) {
+	unsigned i;
+	uint32_t sum = start_with > 0 ? ~start_with & 0xffff : 0;
+
+	for (i = 0; i < (length & ~1U); i += 2) {
+		sum += (uint16_t) ntohs (*((uint16_t *) (buffer + i)));
+		if (sum > 0xffff)
+			sum -= 0xffff;
+	}
+	if (i < length) {
+		sum += buffer [i] << 8;
+		if (sum > 0xffff)
+			sum -= 0xffff;
+	}
+	
+	return ~sum & 0xffff;
+}
+
+namespace raw {
+
+static Persistent<String> CloseSymbol;
+static Persistent<String> EmitSymbol;
+static Persistent<String> ErrorSymbol;
+static Persistent<String> RecvReadySymbol;
+static Persistent<String> SendReadySymbol;
+
+void InitAll (Handle<Object> target) {
+	CloseSymbol = NODE_PSYMBOL("close");
+	EmitSymbol = NODE_PSYMBOL("emit");
+	ErrorSymbol = NODE_PSYMBOL("error");
+	RecvReadySymbol = NODE_PSYMBOL("recvReady");
+	SendReadySymbol = NODE_PSYMBOL("sendReady");
+
+	ExportConstants (target);
+	ExportFunctions (target);
+
+	SocketWrap::Init (target);
+}
+
+NODE_MODULE(raw, InitAll)
+
+Handle<Value> CreateChecksum (const Arguments& args) {
+	HandleScope scope;
+	
+	if (args.Length () < 2) {
+		ThrowException (Exception::Error (String::New (
+				"At least one argument is required")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[0]->IsUint32 ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Start with argument must be an unsigned integer")));
+		return scope.Close (args.This ());
+	}
+	
+	uint16_t start_with = args[0]->ToUint32 ()->Value ();
+
+	if (start_with > 65535) {
+		ThrowException (Exception::TypeError (String::New (
+				"Start with argument cannot be larger than 65535")));
+		return scope.Close (args.This ());
+	}
+
+	if (! node::Buffer::HasInstance (args[1])) {
+		ThrowException (Exception::TypeError (String::New (
+				"Buffer argument must be a node Buffer object")));
+		return scope.Close (args.This ());
+	}
+	
+	Local<Object> buffer = args[1]->ToObject ();
+	char *data = node::Buffer::Data (buffer);
+	size_t length = node::Buffer::Length (buffer);
+	unsigned int offset = 0;
+	
+	if (args.Length () > 2) {
+		if (! args[2]->IsUint32 ()) {
+			ThrowException (Exception::TypeError (String::New (
+					"Offset argument must be an unsigned integer")));
+			return scope.Close (args.This ());
+		}
+		offset = args[2]->ToUint32 ()->Value ();
+		if (offset >= length) {
+			ThrowException (Exception::RangeError (String::New (
+					"Offset argument must be smaller than length of the buffer")));
+			return scope.Close (args.This ());
+		}
+	}
+	
+	if (args.Length () > 3) {
+		if (! args[3]->IsUint32 ()) {
+			ThrowException (Exception::TypeError (String::New (
+					"Length argument must be an unsigned integer")));
+			return scope.Close (args.This ());
+		}
+		unsigned int new_length = args[3]->ToUint32 ()->Value ();
+		if (new_length > length) {
+			ThrowException (Exception::RangeError (String::New (
+					"Length argument must be smaller than length of the buffer")));
+			return scope.Close (args.This ());
+		}
+		length = new_length;
+	}
+	
+	uint16_t sum = checksum (start_with, (unsigned char *) data + offset,
+			length);
+
+	Local<Integer> number = Integer::NewFromUnsigned (sum);
+	
+	return scope.Close (number);
+}
+
+Handle<Value> Htonl (const Arguments& args) {
+	HandleScope scope;
+
+	if (args.Length () < 1) {
+		ThrowException (Exception::Error (String::New (
+				"One arguments is required")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[0]->IsUint32 ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Number must be a 32 unsigned integer")));
+		return scope.Close (args.This ());
+	}
+
+	unsigned int number = args[0]->ToUint32 ()->Value ();
+	Local<Integer> converted = Integer::NewFromUnsigned (htonl (number));
+
+	return scope.Close (converted);
+}
+
+Handle<Value> Htons (const Arguments& args) {
+	HandleScope scope;
+	
+	if (args.Length () < 1) {
+		ThrowException (Exception::Error (String::New (
+				"One arguments is required")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[0]->IsUint32 ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Number must be a 16 unsigned integer")));
+		return scope.Close (args.This ());
+	}
+	
+	unsigned int number = args[0]->ToUint32 ()->Value ();
+	if (number > 65535) {
+		ThrowException (Exception::RangeError (String::New (
+				"Number cannot be larger than 65535")));
+		return scope.Close (args.This ());
+	}
+	Local<Integer> converted = Integer::NewFromUnsigned (htons (number));
+
+	return scope.Close (converted);
+}
+
+Handle<Value> Ntohl (const Arguments& args) {
+	HandleScope scope;
+	
+	if (args.Length () < 1) {
+		ThrowException (Exception::Error (String::New (
+				"One arguments is required")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[0]->IsUint32 ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Number must be a 32 unsigned integer")));
+		return scope.Close (args.This ());
+	}
+
+	unsigned int number = args[0]->ToUint32 ()->Value ();
+	Local<Integer> converted = Integer::NewFromUnsigned (ntohl (number));
+
+	return scope.Close (converted);
+}
+
+Handle<Value> Ntohs (const Arguments& args) {
+	HandleScope scope;
+	
+	if (args.Length () < 1) {
+		ThrowException (Exception::Error (String::New (
+				"One arguments is required")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[0]->IsUint32 ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Number must be a 16 unsigned integer")));
+		return scope.Close (args.This ());
+	}
+	
+	unsigned int number = args[0]->ToUint32 ()->Value ();
+	if (number > 65535) {
+		ThrowException (Exception::RangeError (String::New (
+				"Number cannot be larger than 65535")));
+		return scope.Close (args.This ());
+	}
+	Local<Integer> converted = Integer::NewFromUnsigned (htons (number));
+
+	return scope.Close (converted);
+}
+
+void ExportConstants (Handle<Object> target) {
+	Local<Object> socket_level = Object::New ();
+	Local<Object> socket_option = Object::New ();
+
+	target->Set (String::NewSymbol ("SocketLevel"), socket_level);
+	target->Set (String::NewSymbol ("SocketOption"), socket_option);
+
+	socket_level->Set (String::NewSymbol ("SOL_SOCKET"), Number::New (SOL_SOCKET));
+	socket_level->Set (String::NewSymbol ("IPPROTO_IP"), Number::New (IPPROTO_IP));
+	socket_level->Set (String::NewSymbol ("IPPROTO_IPV6"), Number::New (IPPROTO_IPV6));
+
+	socket_option->Set (String::NewSymbol ("SO_BROADCAST"), Number::New (SO_BROADCAST));
+	socket_option->Set (String::NewSymbol ("SO_RCVBUF"), Number::New (SO_RCVBUF));
+	socket_option->Set (String::NewSymbol ("SO_RCVTIMEO"), Number::New (SO_RCVTIMEO));
+	socket_option->Set (String::NewSymbol ("SO_SNDBUF"), Number::New (SO_SNDBUF));
+	socket_option->Set (String::NewSymbol ("SO_SNDTIMEO"), Number::New (SO_SNDTIMEO));
+
+	socket_option->Set (String::NewSymbol ("IP_HDRINCL"), Number::New (IP_HDRINCL));
+	socket_option->Set (String::NewSymbol ("IP_OPTIONS"), Number::New (IP_OPTIONS));
+	socket_option->Set (String::NewSymbol ("IP_TOS"), Number::New (IP_TOS));
+	socket_option->Set (String::NewSymbol ("IP_TTL"), Number::New (IP_TTL));
+
+#ifdef _WIN32
+	socket_option->Set (String::NewSymbol ("IPV6_HDRINCL"), Number::New (IPV6_HDRINCL));
+#endif
+	socket_option->Set (String::NewSymbol ("IPV6_TTL"), Number::New (IPV6_UNICAST_HOPS));
+	socket_option->Set (String::NewSymbol ("IPV6_UNICAST_HOPS"), Number::New (IPV6_UNICAST_HOPS));
+	socket_option->Set (String::NewSymbol ("IPV6_V6ONLY"), Number::New (IPV6_V6ONLY));
+}
+
+void ExportFunctions (Handle<Object> target) {
+	target->Set (String::NewSymbol ("createChecksum"), FunctionTemplate::New (CreateChecksum)->GetFunction ());
+	
+	target->Set (String::NewSymbol ("htonl"), FunctionTemplate::New (Htonl)->GetFunction ());
+	target->Set (String::NewSymbol ("htons"), FunctionTemplate::New (Htons)->GetFunction ());
+	target->Set (String::NewSymbol ("ntohl"), FunctionTemplate::New (Ntohl)->GetFunction ());
+	target->Set (String::NewSymbol ("ntohs"), FunctionTemplate::New (Ntohs)->GetFunction ());
+}
+
+void SocketWrap::Init (Handle<Object> target) {
+	HandleScope scope;
+	
+	Local<FunctionTemplate> tpl = FunctionTemplate::New (New);
+	
+	tpl->InstanceTemplate ()->SetInternalFieldCount (1);
+	tpl->SetClassName (String::NewSymbol ("SocketWrap"));
+	
+	NODE_SET_PROTOTYPE_METHOD(tpl, "close", Close);
+	NODE_SET_PROTOTYPE_METHOD(tpl, "getOption", GetOption);
+	NODE_SET_PROTOTYPE_METHOD(tpl, "pause", Pause);
+	NODE_SET_PROTOTYPE_METHOD(tpl, "recv", Recv);
+	NODE_SET_PROTOTYPE_METHOD(tpl, "send", Send);
+	NODE_SET_PROTOTYPE_METHOD(tpl, "setOption", SetOption);
+
+	target->Set (String::NewSymbol ("SocketWrap"), tpl->GetFunction ());
+}
+
+SocketWrap::SocketWrap () {}
+
+SocketWrap::~SocketWrap () {
+	this->CloseSocket ();
+}
+
+Handle<Value> SocketWrap::Close (const Arguments& args) {
+	HandleScope scope;
+	SocketWrap* socket = SocketWrap::Unwrap<SocketWrap> (args.This ());
+	
+	socket->CloseSocket ();
+
+	return scope.Close (args.This ());
+}
+
+void SocketWrap::CloseSocket (void) {
+	HandleScope scope;
+	
+	if (this->poll_initialised_) {
+		uv_poll_stop (&this->poll_watcher_);
+		closesocket (this->poll_fd_);
+		this->poll_fd_ = INVALID_SOCKET;
+
+		uv_close ((uv_handle_t *) &this->poll_watcher_, OnClose);
+		this->poll_initialised_ = false;
+	}
+
+	Local<Value> emit = this->handle_->Get (EmitSymbol);
+	Local<Function> cb = emit.As<Function> ();
+
+	Local<Value> args[1];
+	args[0] = Local<Value>::New (CloseSymbol);
+
+	cb->Call (this->handle_, 1, args);
+}
+
+int SocketWrap::CreateSocket (void) {
+	if (this->poll_initialised_)
+		return 0;
+	
+	if ((this->poll_fd_ = socket (this->family_, SOCK_RAW, this->protocol_))
+			== INVALID_SOCKET)
+		return SOCKET_ERRNO;
+
+#ifdef _WIN32
+	unsigned long flag = 1;
+	if (ioctlsocket (this->poll_fd_, FIONBIO, &flag) == SOCKET_ERROR)
+		return SOCKET_ERRNO;
+#else
+	int flag = 1;
+	if ((flag = fcntl (this->poll_fd_, F_GETFL, 0)) == SOCKET_ERROR)
+		return SOCKET_ERRNO;
+	if (fcntl (this->poll_fd_, F_SETFL, flag | O_NONBLOCK) == SOCKET_ERROR)
+		return SOCKET_ERRNO;
+#endif
+
+	uv_poll_init_socket (uv_default_loop (), &this->poll_watcher_,
+			this->poll_fd_);
+	this->poll_watcher_.data = this;
+	uv_poll_start (&this->poll_watcher_, UV_READABLE, IoEvent);
+	
+	this->poll_initialised_ = true;
+	
+	return 0;
+}
+
+Handle<Value> SocketWrap::GetOption (const Arguments& args) {
+	HandleScope scope;
+	SocketWrap* socket = SocketWrap::Unwrap<SocketWrap> (args.This ());
+	
+	if (args.Length () < 3) {
+		ThrowException (Exception::Error (String::New (
+				"Three arguments are required")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[0]->IsNumber ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Level argument must be a number")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[1]->IsNumber ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Option argument must be a number")));
+		return scope.Close (args.This ());
+	}
+
+	int level = args[0]->ToInt32 ()->Value ();
+	int option = args[1]->ToInt32 ()->Value ();
+	SOCKET_OPT_TYPE val = NULL;
+	unsigned int ival = 0;
+	SOCKET_LEN_TYPE len;
+
+	if (! node::Buffer::HasInstance (args[2])) {
+		ThrowException (Exception::TypeError (String::New (
+				"Value argument must be a node Buffer object if length is "
+				"provided")));
+		return scope.Close (args.This ());
+	}
+	
+	Local<Object> buffer = args[2]->ToObject ();
+	val = node::Buffer::Data (buffer);
+
+	if (! args[3]->IsInt32 ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Length argument must be an unsigned integer")));
+		return scope.Close (args.This ());
+	}
+
+	len = (SOCKET_LEN_TYPE) node::Buffer::Length (buffer);
+
+	int rc = getsockopt (socket->poll_fd_, level, option,
+			(val ? val : (SOCKET_OPT_TYPE) &ival), &len);
+
+	if (rc == SOCKET_ERROR) {
+		ThrowException (Exception::Error (String::New (
+				raw_strerror (SOCKET_ERRNO))));
+		return scope.Close (args.This ());
+	}
+	
+	Local<Number> got = Integer::NewFromUnsigned (len);
+	return scope.Close (got);
+}
+
+void SocketWrap::HandleIOEvent (int status, int revents) {
+	HandleScope scope;
+
+	if (status) {
+		Local<Value> emit = this->handle_->Get (EmitSymbol);
+		Local<Function> cb = emit.As<Function> ();
+
+		Local<Value> args[2];
+		args[0] = Local<Value>::New (ErrorSymbol);
+		args[1] = Exception::Error (String::New (
+				raw_strerror (uv_last_error (uv_default_loop ()).code)));
+		
+		cb->Call (this->handle_, 2, args);
+	} else {
+		Local<Value> emit = this->handle_->Get (EmitSymbol);
+		Local<Function> cb = emit.As<Function> ();
+
+		Local<Value> args[1];
+		if (revents & UV_READABLE)
+			args[0] = Local<Value>::New (RecvReadySymbol);
+		else
+			args[0] = Local<Value>::New (SendReadySymbol);
+
+		cb->Call (this->handle_, 1, args);
+	}
+}
+
+Handle<Value> SocketWrap::New (const Arguments& args) {
+	HandleScope scope;
+	SocketWrap* socket = new SocketWrap ();
+	int rc, family = AF_INET;
+	
+	if (args.Length () < 1) {
+		ThrowException (Exception::Error (String::New (
+				"One argument is required")));
+		return scope.Close (args.This ());
+	}
+	
+	if (! args[0]->IsUint32 ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Protocol argument must be an unsigned integer")));
+		return scope.Close (args.This ());
+	} else {
+		socket->protocol_ = args[0]->ToUint32 ()->Value ();
+	}
+
+	if (args.Length () > 1) {
+		if (! args[1]->IsUint32 ()) {
+			ThrowException (Exception::TypeError (String::New (
+					"Address family argument must be an unsigned integer")));
+			return scope.Close (args.This ());
+		} else {
+			if (args[1]->ToUint32 ()->Value () == 2)
+				family = AF_INET6;
+		}
+	}
+	
+	socket->family_ = family;
+	
+	socket->poll_initialised_ = false;
+	
+	socket->no_ip_header_ = false;
+
+	rc = socket->CreateSocket ();
+	if (rc != 0) {
+		ThrowException (Exception::Error (String::New (raw_strerror (rc))));
+		return scope.Close (args.This ());
+	}
+
+	socket->Wrap (args.This ());
+
+	return scope.Close (args.This ());
+}
+
+void SocketWrap::OnClose (uv_handle_t *handle) {
+	// We can re-use the socket so we won't actually do anything here
+}
+
+Handle<Value> SocketWrap::Pause (const Arguments& args) {
+	HandleScope scope;
+	SocketWrap* socket = SocketWrap::Unwrap<SocketWrap> (args.This ());
+
+	if (args.Length () < 2) {
+		ThrowException (Exception::Error (String::New (
+				"Two arguments are required")));
+		return scope.Close (args.This ());
+	}
+	
+	if (! args[0]->IsBoolean ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Recv argument must be a boolean")));
+		return scope.Close (args.This ());
+	}
+	bool pause_recv = args[0]->ToBoolean ()->Value ();
+
+	if (! args[0]->IsBoolean ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Send argument must be a boolean")));
+		return scope.Close (args.This ());
+	}
+	bool pause_send = args[0]->ToBoolean ()->Value ();
+	
+	int events = (pause_recv ? 0 : UV_READABLE)
+			| (pause_send ? 0 : UV_WRITABLE);
+
+	uv_poll_stop (&socket->poll_watcher_);
+	uv_poll_start (&socket->poll_watcher_, events, IoEvent);
+	
+	return scope.Close (args.This ());
+}
+
+Handle<Value> SocketWrap::Recv (const Arguments& args) {
+	HandleScope scope;
+	SocketWrap* socket = SocketWrap::Unwrap<SocketWrap> (args.This ());
+	Local<Object> buffer;
+	sockaddr_in sin_address;
+	sockaddr_in6 sin6_address;
+	char addr[50];
+	int rc;
+#ifdef _WIN32
+	int sin_length = socket->family_ == AF_INET6
+			? sizeof (sin6_address)
+			: sizeof (sin_address);
+#else
+	socklen_t sin_length = socket->family_ == AF_INET6
+			? sizeof (sin6_address)
+			: sizeof (sin_address);
+#endif
+	
+	if (args.Length () < 2) {
+		ThrowException (Exception::Error (String::New (
+				"Five arguments are required")));
+		return scope.Close (args.This ());
+	}
+	
+	if (! node::Buffer::HasInstance (args[0])) {
+		ThrowException (Exception::TypeError (String::New (
+				"Buffer argument must be a node Buffer object")));
+		return scope.Close (args.This ());
+	} else {
+		buffer = args[0]->ToObject ();
+	}
+
+	if (! args[1]->IsFunction ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Callback argument must be a function")));
+		return scope.Close (args.This ());
+	}
+
+	rc = socket->CreateSocket ();
+	if (rc != 0) {
+		ThrowException (Exception::Error (String::New (raw_strerror (errno))));
+		return scope.Close (args.This ());
+	}
+
+	if (socket->family_ == AF_INET6) {
+		memset (&sin6_address, 0, sizeof (sin6_address));
+		rc = recvfrom (socket->poll_fd_, node::Buffer::Data (buffer),
+				(int) node::Buffer::Length (buffer), 0, (sockaddr *) &sin6_address,
+				&sin_length);
+	} else {
+		memset (&sin_address, 0, sizeof (sin_address));
+		rc = recvfrom (socket->poll_fd_, node::Buffer::Data (buffer),
+				(int) node::Buffer::Length (buffer), 0, (sockaddr *) &sin_address,
+				&sin_length);
+	}
+	
+	if (rc == SOCKET_ERROR) {
+		ThrowException (Exception::Error (String::New (raw_strerror (
+				SOCKET_ERRNO))));
+		return scope.Close (args.This ());
+	}
+	
+	if (socket->family_ == AF_INET6)
+		uv_ip6_name (&sin6_address, addr, 50);
+	else
+		uv_ip4_name (&sin_address, addr, 50);
+	
+	Local<Function> cb = Local<Function>::Cast (args[1]);
+	const unsigned argc = 3;
+	Local<Value> argv[argc];
+	argv[0] = args[0];
+	argv[1] = Number::New (rc);
+	argv[2] = String::New (addr);
+	cb->Call (Context::GetCurrent ()->Global (), argc, argv);
+	
+	return scope.Close (args.This ());
+}
+
+Handle<Value> SocketWrap::Send (const Arguments& args) {
+	HandleScope scope;
+	SocketWrap* socket = SocketWrap::Unwrap<SocketWrap> (args.This ());
+	Local<Object> buffer;
+	uint32_t offset;
+	uint32_t length;
+	int rc;
+	char *data;
+	
+	if (args.Length () < 5) {
+		ThrowException (Exception::Error (String::New (
+				"Five arguments are required")));
+		return scope.Close (args.This ());
+	}
+	
+	if (! node::Buffer::HasInstance (args[0])) {
+		ThrowException (Exception::TypeError (String::New (
+				"Buffer argument must be a node Buffer object")));
+		return scope.Close (args.This ());
+	}
+	
+	if (! args[1]->IsUint32 ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Offset argument must be an unsigned integer")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[2]->IsUint32 ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Length argument must be an unsigned integer")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[3]->IsString ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Address argument must be a string")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[4]->IsFunction ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Callback argument must be a function")));
+		return scope.Close (args.This ());
+	}
+
+	rc = socket->CreateSocket ();
+	if (rc != 0) {
+		ThrowException (Exception::Error (String::New (raw_strerror (errno))));
+		return scope.Close (args.This ());
+	}
+	
+	buffer = args[0]->ToObject ();
+	offset = args[1]->ToUint32 ()->Value ();
+	length = args[2]->ToUint32 ()->Value ();
+	String::AsciiValue address (args[3]);
+
+	data = node::Buffer::Data (buffer) + offset;
+	
+	if (socket->family_ == AF_INET6) {
+		struct sockaddr_in6 addr = uv_ip6_addr (*address, 0);
+		rc = sendto (socket->poll_fd_, data, length, 0,
+				(struct sockaddr *) &addr, sizeof (addr));
+	} else {
+		struct sockaddr_in addr = uv_ip4_addr (*address, 0);
+		rc = sendto (socket->poll_fd_, data, length, 0,
+				(struct sockaddr *) &addr, sizeof (addr));
+	}
+	
+	if (rc == SOCKET_ERROR) {
+		ThrowException (Exception::Error (String::New (raw_strerror (
+				SOCKET_ERRNO))));
+		return scope.Close (args.This ());
+	}
+	
+	Local<Function> cb = Local<Function>::Cast (args[4]);
+	const unsigned argc = 1;
+	Local<Value> argv[argc];
+	argv[0] = Number::New (rc);
+	cb->Call (Context::GetCurrent ()->Global (), argc, argv);
+	
+	return scope.Close (args.This ());
+}
+
+Handle<Value> SocketWrap::SetOption (const Arguments& args) {
+	HandleScope scope;
+	SocketWrap* socket = SocketWrap::Unwrap<SocketWrap> (args.This ());
+	
+	if (args.Length () < 3) {
+		ThrowException (Exception::Error (String::New (
+				"Three or four arguments are required")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[0]->IsNumber ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Level argument must be a number")));
+		return scope.Close (args.This ());
+	}
+
+	if (! args[1]->IsNumber ()) {
+		ThrowException (Exception::TypeError (String::New (
+				"Option argument must be a number")));
+		return scope.Close (args.This ());
+	}
+
+	int level = args[0]->ToInt32 ()->Value ();
+	int option = args[1]->ToInt32 ()->Value ();
+	SOCKET_OPT_TYPE val = NULL;
+	unsigned int ival = 0;
+	SOCKET_LEN_TYPE len;
+
+	if (args.Length () > 3) {
+		if (! node::Buffer::HasInstance (args[2])) {
+			ThrowException (Exception::TypeError (String::New (
+					"Value argument must be a node Buffer object if length is "
+					"provided")));
+			return scope.Close (args.This ());
+		}
+		
+		Local<Object> buffer = args[2]->ToObject ();
+		val = node::Buffer::Data (buffer);
+
+		if (! args[3]->IsInt32 ()) {
+			ThrowException (Exception::TypeError (String::New (
+					"Length argument must be an unsigned integer")));
+			return scope.Close (args.This ());
+		}
+
+		len = args[3]->ToInt32 ()->Value ();
+
+		if (len > node::Buffer::Length (buffer)) {
+			ThrowException (Exception::TypeError (String::New (
+					"Length argument is larger than buffer length")));
+			return scope.Close (args.This ());
+		}
+	} else {
+		if (! args[2]->IsUint32 ()) {
+			ThrowException (Exception::TypeError (String::New (
+					"Value argument must be a unsigned integer")));
+			return scope.Close (args.This ());
+		}
+
+		ival = args[2]->ToUint32 ()->Value ();
+		len = 4;
+	}
+
+	int rc = setsockopt (socket->poll_fd_, level, option,
+			(val ? val : (SOCKET_OPT_TYPE) &ival), len);
+
+	if (rc == SOCKET_ERROR) {
+		ThrowException (Exception::Error (String::New (
+				raw_strerror (SOCKET_ERRNO))));
+		return scope.Close (args.This ());
+	}
+	
+	return scope.Close (args.This ());
+}
+
+static void IoEvent (uv_poll_t* watcher, int status, int revents) {
+	SocketWrap *socket = static_cast<SocketWrap*>(watcher->data);
+	socket->HandleIOEvent (status, revents);
+}
+
+}; /* namespace raw */
+
+#endif /* RAW_CC */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/net-ping/node_modules/raw-socket/src/raw.h
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/net-ping/node_modules/raw-socket/src/raw.h b/blackberry10/node_modules/net-ping/node_modules/raw-socket/src/raw.h
new file mode 100644
index 0000000..a446fe9
--- /dev/null
+++ b/blackberry10/node_modules/net-ping/node_modules/raw-socket/src/raw.h
@@ -0,0 +1,100 @@
+#ifndef RAW_H
+#define RAW_H
+
+/**
+ ** The following warnings are displayed during compilation on win32 platforms
+ ** using node-gyp:
+ **
+ **  - C++ exception handler used, but unwind semantics are not enabled.
+ **  - no definition for inline function 'v8::Persistent<T> \
+ **       v8::Persistent<T>::New(v8::Handle<T>)'
+ **
+ ** There don't seem to be any issues which would suggest these are real
+ ** problems, so we've disabled them for now.
+ **/
+#ifdef _WIN32
+#pragma warning(disable:4506;disable:4530)
+#endif
+
+#include <string>
+
+#include <node.h>
+
+#ifdef _WIN32
+#include <winsock2.h>
+#include <Ws2tcpip.h>
+#define SOCKET_ERRNO WSAGetLastError()
+#define SOCKET_OPT_TYPE char *
+#define SOCKET_LEN_TYPE int
+#else
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <fcntl.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#define SOCKET int
+#define SOCKET_ERROR -1
+#define SOCKET_ERRNO errno
+#define INVALID_SOCKET -1
+#define closesocket close
+#define SOCKET_OPT_TYPE void *
+#define SOCKET_LEN_TYPE socklen_t
+#endif
+
+using namespace v8;
+
+namespace raw {
+
+Handle<Value> CreateChecksum (const Arguments& args);
+
+void ExportConstants (Handle<Object> target);
+void ExportFunctions (Handle<Object> target);
+
+Handle<Value> Htonl (const Arguments& args);
+Handle<Value> Htons (const Arguments& args);
+Handle<Value> Ntohl (const Arguments& args);
+Handle<Value> Ntohs (const Arguments& args);
+
+class SocketWrap : public node::ObjectWrap {
+public:
+	void HandleIOEvent (int status, int revents);
+	static void Init (Handle<Object> target);
+
+private:
+	SocketWrap ();
+	~SocketWrap ();
+
+	static Handle<Value> Close (const Arguments& args);
+
+	void CloseSocket (void);
+	
+	int CreateSocket (void);
+
+	static Handle<Value> GetOption (const Arguments& args);
+
+	static Handle<Value> New (const Arguments& args);
+
+	static void OnClose (uv_handle_t *handle);
+
+	static Handle<Value> Pause (const Arguments& args);
+	static Handle<Value> Recv (const Arguments& args);
+	static Handle<Value> Send (const Arguments& args);
+	static Handle<Value> SetOption (const Arguments& args);
+
+	bool no_ip_header_;
+
+	uint32_t family_;
+	uint32_t protocol_;
+
+	SOCKET poll_fd_;
+	uv_poll_t poll_watcher_;
+	bool poll_initialised_;
+};
+
+static void IoEvent (uv_poll_t* watcher, int status, int revents);
+
+}; /* namespace raw */
+
+#endif /* RAW_H */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/net-ping/package.json
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/net-ping/package.json b/blackberry10/node_modules/net-ping/package.json
new file mode 100644
index 0000000..649fb17
--- /dev/null
+++ b/blackberry10/node_modules/net-ping/package.json
@@ -0,0 +1,48 @@
+{
+  "name": "net-ping",
+  "version": "1.1.9",
+  "description": "Ping and trace route to many hosts at once.",
+  "main": "index.js",
+  "directories": {
+    "example": "example"
+  },
+  "dependencies": {
+    "raw-socket": "*"
+  },
+  "contributors": [
+    {
+      "name": "Stephen Vickers",
+      "email": "stephen.vickers.sv@gmail.com"
+    }
+  ],
+  "repository": {
+    "type": "mercurial",
+    "url": "https://bitbucket.org/stephenwvickers/node-net-ping"
+  },
+  "keywords": [
+    "echo",
+    "icmp",
+    "monitor",
+    "monitoring",
+    "net",
+    "network",
+    "ping",
+    "trace",
+    "trace-route",
+    "traceroute",
+    "tracert"
+  ],
+  "author": {
+    "name": "Stephen Vickers",
+    "email": "stephen.vickers.sv@gmail.com"
+  },
+  "license": "MIT",
+  "readme": "\n# net-ping - [homepage][homepage]\n\nThis module implements ICMP Echo (ping) support for [Node.js][nodejs].\n\nThis module is installed using [node package manager (npm)][npm]:\n\n    npm install net-ping\n\nIt is loaded using the `require()` function:\n\n    var ping = require (\"net-ping\");\n\nA ping session can then be created to ping or trace route to many hosts:\n\n    var session = ping.createSession ();\n\n    session.pingHost (target, function (error, target) {\n        if (error)\n            console.log (target + \": \" + error.toString ());\n        else\n            console.log (target + \": Alive\");\n    });\n\n[homepage]: http://re-tool.org \"Homepage\"\n[nodejs]: http://nodejs.org \"Node.js\"\n[npm]: https://npmjs.org/ \"npm\"\n\n# Network Protocol Support\n\nThis module supports IPv4 using the ICMP, and IPv6 using the ICMPv6.\n\n# Error Handling\n\nEach request exposed by this module requires one or more mandatory callback\nfunctions.  Callback funct
 ions are typically provided an `error` argument.\n\nAll errors are sub-classes of the `Error` class.  For timed out errors the\nerror passed to the callback function will be an instance of the\n`ping.RequestTimedOutError` class, with the exposed `message` attribute set\nto `Request timed out`.\n\nThis makes it easy to determine if a host responded, a time out occurred, or\nwhether an error response was received:\n\n    session.pingHost (\"1.2.3.4\", function (error, target) {\n        if (error)\n            if (error instanceof ping.RequestTimedOutError)\n                console.log (target + \": Not alive\");\n            else\n                console.log (target + \": \" + error.toString ());\n        else\n            console.log (target + \": Alive\");\n    });\n\nIn addition to the the `ping.RequestTimedOutError` class, the following errors\nare also exported by this module to wrap ICMP error responses:\n\n * `DestinationUnreachableError`\n * `PacketTooBigError`\n * `Parameter
 ProblemError`\n * `RedirectReceivedError`\n * `SourceQuenchError`\n * `TimeExceededError`\n\nThese errors are typically reported by hosts other than the intended target.\nIn all cases each class exposes a `source` attribute which will specify the\nhost who reported the error (which could be the intended target).  This will\nalso be included in the errors `message` attribute, i.e.:\n\n    $ sudo node example/ping-ttl.js 1 192.168.2.10 192.168.2.20 192.168.2.30\n    192.168.2.10: Alive\n    192.168.2.20: TimeExceededError: Time exceeded (source=192.168.1.1)\n    192.168.2.30: Not alive\n\nThe `Session` class will emit an `error` event for any other error not\ndirectly associated with a request.  This is typically an instance of the\n`Error` class with the errors `message` attribute specifying the reason.\n\n# Packet Size\n\nBy default ICMP echo request packets sent by this module are 16 bytes in size.\nSome implementations cannot cope with such small ICMP echo requests.  For\nexample,
  some implementations will return an ICMP echo reply, but will include\nan incorrect ICMP checksum.\n\nThis module exposes a `packetSize` option to the `createSession()` method which\nspecifies how big ICMP echo request packets should be:\n\n    var session = ping.createSession ({packetSize: 64});\n\n# Round Trip Times\n\nSome callbacks used by methods exposed by this module provide two instances of\nthe JavaScript `Date` class specifying when the first ping was sent for a\nrequest, and when a request completed.\n\nThese parameters are typically named `sent` and `rcvd`, and are provided to\nhelp round trip time calculation.\n\nA request can complete in one of two ways.  In the first, a ping response is\nreceived and `rcvd - sent` will yield the round trip time for the request in\nmilliseconds.\n\nIn the second, no ping response is received resulting in a request time out.\nIn this case `rcvd - sent` will yield the total time spent waiting for each\nretry to timeout if any.  For exam
 ple, if the `retries` option to the\n`createSession()` method was specified as `2` and `timeout` as `2000` then\n`rcvd - sent` will yield more than `6000` milliseconds.\n\nAlthough this module provides instances of the `Date` class to help round trip\ntime calculation the dates and times represented in each instance should not be\nconsidered 100% accurate.\n\nEnvironmental conditions can affect when a date and time is actually\ncalculated, e.g. garbage collection introducing a delay or the receipt of many\npackets at once.  There are also a number of functions through which received\npackets must pass, which can also introduce a slight variable delay.\n\nThroughout development experience has shown that, in general the smaller the\nround trip time the less accurate it will be - but the information is still\nuseful nonetheless.\n\n# Constants\n\nThe following sections describe constants exported and used by this module.\n\n## ping.NetworkProtocol\n\nThis object contains constants whic
 h can be used for the `networkProtocol`\noption to the `createSession()` function exposed by this module.  This option\nspecifies the IP protocol version to use when creating the raw socket.\n\nThe following constants are defined in this object:\n\n * `IPv4` - IPv4 protocol\n * `IPv6` - IPv6 protocol\n\n# Using This Module\n\nThe `Session` class is used to issue ping and trace route requests to many\nhosts.  This module exports the `createSession()` function which is used to\ncreate instances of the `Session` class.\n\n## ping.createSession ([options])\n\nThe `createSession()` function instantiates and returns an instance of the\n`Session` class:\n\n    // Default options\n    var options = {\n        networkProtocol: ping.NetworkProtocol.IPv4,\n        packetSize: 16,\n        retries: 1,\n        sessionId: (process.pid % 65535),\n        timeout: 2000,\n        ttl: 128\n    };\n    \n    var session = ping.createSession (options);\n\nThe optional `options` parameter is an object
 , and can contain the following\nitems:\n\n * `networkProtocol` - Either the constant `ping.NetworkProtocol.IPv4` or the\n   constant `ping.NetworkProtocol.IPv6`, defaults to the constant\n   `ping.NetworkProtocol.IPv4`\n * `packetSize` - How many bytes each ICMP echo request packet should be,\n   defaults to `16`, if the value specified is less that `12` then the value\n   `12` will be used (8 bytes are required for the ICMP packet itself, then 4\n   bytes are required to encode a unique session ID in the request and response\n   packets)\n * `retries` - Number of times to re-send a ping requests, defaults to `1`\n * `sessionId` - A unique ID used to identify request and response packets sent\n   by this instance of the `Session` class, valid numbers are in the range of\n   `1` to `65535`, defaults to the value of `process.pid % 65535`\n * `timeout` - Number of milliseconds to wait for a response before re-trying\n   or failing, defaults to `2000`\n * `ttl` - Value to use for the I
 P header time to live field, defaults to `128`\n\nAfter creating the ping `Session` object an underlying raw socket will be\ncreated.  If the underlying raw socket cannot be opened an exception with be\nthrown.  The error will be an instance of the `Error` class.\n\nSeperate instances of the `Session` class must be created for IPv4 and IPv6.\n\n## session.on (\"close\", callback)\n\nThe `close` event is emitted by the session when the underlying raw socket\nis closed.\n\nNo arguments are passed to the callback.\n\nThe following example prints a message to the console when the underlying raw\nsocket is closed:\n\n    session.on (\"close\", function () {\n        console.log (\"socket closed\");\n    });\n\n## session.on (\"error\", callback)\n\nThe `error` event is emitted by the session when the underlying raw socket\nemits an error.\n\nThe following arguments will be passed to the `callback` function:\n\n * `error` - An instance of the `Error` class, the exposed `message` attribute
 \n   will contain a detailed error message.\n\nThe following example prints a message to the console when an error occurs\nwith the underlying raw socket, the session is then closed:\n\n    session.on (\"error\", function (error) {\n        console.log (error.toString ());\n        session.close ();\n    });\n\n## session.close ()\n\nThe `close()` method closes the underlying raw socket, and cancels all\noutstanding requsts.\n\nThe calback function for each outstanding ping requests will be called.  The\nerror parameter will be an instance of the `Error` class, and the `message`\nattribute set to `Socket forcibly closed`.\n\nThe sessoin can be re-used simply by submitting more ping requests, a new raw\nsocket will be created to serve the new ping requests.  This is a way in which\nto clear outstanding requests.\n\nThe following example submits a ping request and prints the target which\nsuccessfully responded first, and then closes the session which will clear the\nother outstanding
  ping requests.\n\n    var targets = [\"1.1.1.1\", \"2.2.2.2\", \"3.3.3.3\"];\n    \n    for (var i = 0; i < targets.length; i++) {\n        session.pingHost (targets[i], function (error, target) {\n            if (! error) {\n                console.log (target);\n                session.close (); \n            }\n        });\n    }\n\n## session.pingHost (target, callback)\n\nThe `pingHost()` method sends a ping request to a remote host.\n\nThe `target` parameter is the dotted quad formatted IP address of the target\nhost for IPv4 sessions, or the compressed formatted IP address of the target\nhost for IPv6 sessions.\n\nThe `callback` function is called once the ping requests is complete.  The\nfollowing arguments will be passed to the `callback` function:\n\n * `error` - Instance of the `Error` class or a sub-class, or `null` if no\n   error occurred\n * `target` - The target parameter as specified in the request\n   still be the target host and NOT the responding gateway\n * `se
 nt` - An instance of the `Date` class specifying when the first ping\n   was sent for this request (refer to the Round Trip Time section for more\n   information)\n * `rcvd` - An instance of the `Date` class specifying when the request\n   completed (refer to the Round Trip Time section for more information)\n\nThe following example sends a ping request to a remote host:\n\n    var target = \"fe80::a00:27ff:fe2a:3427\";\n\n    session.pingHost (target, function (error, target, sent, rcvd) {\n        var ms = rcvd - sent;\n        if (error)\n            console.log (target + \": \" + error.toString ());\n        else\n            console.log (target + \": Alive (ms=\" + ms + \")\");\n    });\n\n## session.traceRoute (target, ttl, feedCallback, doneCallback)\n\nThe `traceRoute()` method provides similar functionality to the trace route\nutility typically provided with most networked operating systems.\n\nThe `target` parameter is the dotted quad formatted IP address of the target\nho
 st for IPv4 sessions, or the compressed formatted IP address of the target\nhost for IPv6 sessions.  The optional `ttl` parameter specifies the maximum\nnumber of hops used by the trace route and defaults to the `ttl` options\nparameter as defined by the `createSession()` method.\n\nSome hosts do not respond to ping requests when the time to live is `0`, that\nis they will not send back an time exceeded error response.  Instead of\nstopping the trace route at the first time out this method will move on to the\nnext hop, by increasing the time to live by 1.  It will do this 2 times,\nmeaning that a trace route will continue until the target host responds or at\nmost 3 request time outs are experienced.\n\nEach requst is subject to the `retries` and `timeout` option parameters to the\n`createSession()` method.  That is, requests will be retried per hop as per\nthese parameters.\n\nThis method will not call a single callback once the trace route is complete.\nInstead the `feedCallback`
  function will be called each time a ping response is\nreceived or a time out occurs. The following arguments will be passed to the\n`feedCallback` function:\n\n * `error` - Instance of the `Error` class or a sub-class, or `null` if no\n   error occurred\n * `target` - The target parameter as specified in the request\n * `ttl` - The time to live used in the request which triggered this respinse\n * `sent` - An instance of the `Date` class specifying when the first ping\n   was sent for this request (refer to the Round Trip Time section for more\n   information)\n * `rcvd` - An instance of the `Date` class specifying when the request\n   completed (refer to the Round Trip Time section for more information)\n\nOnce a ping response has been received from the target, or more than three\nrequest timed out errors are experienced, the `doneCallback` function will be\ncalled. The following arguments will be passed to the `doneCallback` function:\n\n * `error` - Instance of the `Error` class
  or a sub-class, or `null` if no\n   error occurred\n * `target` - The target parameter as specified in the request\n\nOnce the `doneCallback` function has been called the request is complete and\nthe `requestCallback` function will no longer be called.\n\nIf the `feedCallback` function returns a true value when called the trace route\nwill stop and the `doneCallback` will be called.\n\nThe following example initiates a trace route to a remote host:\n\n    function doneCb (error, target) {\n        if (error)\n            console.log (target + \": \" + error.toString ());\n        else\n            console.log (target + \": Done\");\n    }\n\n    function feedCb (error, target, ttl, sent, rcvd) {\n        var ms = rcvd - sent;\n        if (error) {\n            if (error instanceof ping.TimeExceededError) {\n                console.log (target + \": \" + error.source + \" (ttl=\"\n                        + ttl + \" ms=\" + ms +\")\");\n            } else {\n                console.l
 og (target + \": \" + error.toString ()\n                        + \" (ttl=\" + ttl + \" ms=\" + ms +\")\");\n            }\n        } else {\n            console.log (target + \": \" + target + \" (ttl=\" + ttl\n                    + \" ms=\" + ms +\")\");\n        }\n    }\n\n    session.traceRoute (\"192.168.10.10\", 10, feedCb, doneCb);\n\n# Example Programs\n\nExample programs are included under the modules `example` directory.\n\n# Bugs & Known Issues\n\nNone, yet!\n\nBug reports should be sent to <stephen.vickers.sv@gmail.com>.\n\n# Changes\n\n## Version 1.0.0 - 03/02/2013\n\n * Initial release\n\n## Version 1.0.1 - 04/02/2013\n\n * Minor corrections to the README.md\n * Add note to README.md about error handling\n * Timed out errors are now instances of the `ping.RequestTimedOutError`\n   object\n\n## Version 1.0.2 - 11/02/2013\n\n * The RequestTimedOutError class is not being exported\n\n## Version 1.1.0 - 13/02/2013\n\n * Support IPv6\n\n## Version 1.1.1 - 15/02/2013\n\n *
  The `ping.Session.close()` method was not undefining the sessions raw\n   socket after closing\n * Return self from the `pingHost()` method to chain method calls \n\n## Version 1.1.2 - 04/03/2013\n\n * Use the `raw.Socket.pauseRecv()` and `raw.Socket.resumeRecv()` methods\n   instead of closing a socket when there are no more outstanding requests\n\n## Version 1.1.3 - 07/03/2013\n\n * Sessions were limited to sending 65535 ping requests\n\n## Version 1.1.4 - 09/04/2013\n\n * Add the `packetSize` option to the `createSession()` method to specify how\n   many bytes each ICMP echo request packet should be\n\n## Version 1.1.5 - 17/05/2013\n\n * Incorrectly parsing ICMP error responses resulting in responses matching\n   the wrong request\n * Use a unique session ID per instance of the `Session` class to identify\n   requests and responses sent by a session\n * Added the (internal) `_debugRequest()` and `_debugResponse()` methods, and\n   the `_debug` option to the `createSession()` met
 hod\n * Added example programs `ping-ttl.js` and `ping6-ttl.js`\n * Use MIT license instead of GPL\n\n## Version 1.1.6 - 17/05/2013\n\n * Session IDs are now 2 bytes (previously 1 byte), and request IDs are also\n   now 2 bytes (previously 3 bytes)\n * Each ICMP error response now has an associated error class (e.g. the\n   `Time exceeded` response maps onto the `ping.TimeExceededError` class)\n * Call request callbacks with an error when there are no free request IDs\n   because of too many outstanding requests\n\n## Version 1.1.7 - 19/05/2013\n\n * Added the `traceRoute()` method\n * Added the `ttl` option parameter to the `createSession()` method, and\n   updated the example programs `ping-ttl.js` and `ping6-ttl.js` to use it\n * Response callback for `pingHost()` now includes two instances of the\n   `Date` class to specify when a request was sent and a response received\n\n## Version 1.1.8 - 01/07/2013\n\n * Use `raw.Socket.createChecksum()` instead of automatic checksum genera
 tion\n\n## Version 1.1.9 - 01/07/2013\n\n * Use `raw.Socket.writeChecksum()` instead of manually rendering checksums\n\n# Roadmap\n\nSuggestions and requirements should be sent to <stephen.vickers.sv@gmail.com>.\n\n# License\n\nCopyright (c) 2013 Stephen Vickers\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNE
 SS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n# Author\n\nStephen Vickers <stephen.vickers.sv@gmail.com>\n",
+  "readmeFilename": "README.md",
+  "_id": "net-ping@1.1.9",
+  "dist": {
+    "shasum": "7e70d3a2a766b060d281b17686e94ff4948e26c0"
+  },
+  "_from": "net-ping@",
+  "_resolved": "https://registry.npmjs.org/net-ping/-/net-ping-1.1.9.tgz"
+}

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/.npmignore
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/.npmignore b/blackberry10/node_modules/plugman/.npmignore
new file mode 100644
index 0000000..9daa824
--- /dev/null
+++ b/blackberry10/node_modules/plugman/.npmignore
@@ -0,0 +1,2 @@
+.DS_Store
+node_modules

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/.reviewboardrc
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/.reviewboardrc b/blackberry10/node_modules/plugman/.reviewboardrc
new file mode 100644
index 0000000..30e9587
--- /dev/null
+++ b/blackberry10/node_modules/plugman/.reviewboardrc
@@ -0,0 +1,8 @@
+#
+# Settings for post-review (used for uploading diffs to reviews.apache.org).
+#
+GUESS_FIELDS = True
+OPEN_BROWSER = True
+TARGET_GROUPS = 'cordova'
+REVIEWBOARD_URL = 'http://reviews.apache.org'
+

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/LICENSE
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/LICENSE b/blackberry10/node_modules/plugman/LICENSE
new file mode 100644
index 0000000..45f03a3
--- /dev/null
+++ b/blackberry10/node_modules/plugman/LICENSE
@@ -0,0 +1,14 @@
+   Copyright 2012 Andrew Lunny, Adobe Systems
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/README.md
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/README.md b/blackberry10/node_modules/plugman/README.md
new file mode 100644
index 0000000..5f366e4
--- /dev/null
+++ b/blackberry10/node_modules/plugman/README.md
@@ -0,0 +1,163 @@
+# plugman
+
+A command line tool to install and uninstall plugins for use with [Apache Cordova](http://cordova.io) projects.
+
+This document defines tool usage.
+
+## Plugin Specification
+
+--&gt; [plugin_spec.md](plugin_spec.md) &lt;--
+
+## Quickstart
+
+    npm install -g plugman
+
+## Design Goals
+
+* Facilitate programmatic installation and manipulation of plugins
+* Detail the dependencies and components of individual plugins
+* Allow code reuse between different target platforms
+
+## Supported Platforms
+
+* iOS
+* Android
+* BlackBerry 10
+* Windows Phone (7+8)
+
+## Command Line Usage
+
+    plugman --platform <ios|android|blackberry10|wp7|wp8> --project <directory> --plugin <name|url|path> [--plugins_dir <directory>] [--www <directory>] [--variable <name>=<value> [--variable <name>=<value> ...]]
+    plugman --uninstall --platform <ios|android|blackberr10|wp7|wp8> --project <directory> --plugin <id> [--www <directory>] [--plugins_dir <directory>]
+
+* Using minimum parameters, installs a plugin into a cordova project. You must specify a platform and cordova project location for that platform. You also must specify a plugin, with the different `--plugin` parameter forms being:
+  * `name`: The directory name where the plugin contents exist. This must be an existing directory under the `--plugins_dir` path (see below for more info).
+  * `url`: A URL starting with https:// or git://, pointing to a valid git repository that is clonable and contains a `plugin.xml` file. The contents of this repository would be copied into the `--plugins_dir`.
+  * `path`: A path to a directory containing a valid plugin which includes a `plugin.xml` file. This path's contents will be copied into the `--plugins_dir`.
+* `--uninstall`: Uninstalls an already-`--install`'ed plugin from a cordova project. Specify the plugin ID.
+
+Other parameters: 
+
+* `--plugins_dir` defaults to `<project>/cordova/plugins`, but can be any directory containing a subdirectory for each fetched plugin.
+* `--www` defaults to the project's `www` folder location, but can be any directory that is to be used as cordova project application web assets.
+* `--variable` allows to specify certain variables at install time, necessary for certain plugins requiring API keys or other custom, user-defined parameters. Please see the [plugin specification](plugin_spec.md) for more information.
+
+## Node Module Usage
+
+    node
+    > require('plugman')
+    { install: [Function: installPlugin],
+      uninstall: [Function: uninstallPlugin],
+      fetch: [Function: fetchPlugin],
+      prepare: [Function: handlePrepare] }
+
+### `install` method
+
+    module.exports = function installPlugin(platform, project_dir, id, plugins_dir, subdir, cli_variables, www_dir, callback) {
+
+Installs a plugin into a specified cordova project of a specified platform.
+
+ * `platform`: one of `android`, `ios`, `blackberry10`, `wp7` or `wp8`
+ * `project_dir`: path to an instance of the above specified platform's cordova project
+ * `id`: a string representing the `id` of the plugin, a path to a cordova plugin with a valid `plugin.xml` file, or an `https://` or `git://` url to a git repository of a valid cordova plugin
+ * `plugins_dir`: path to directory where plugins will be stored, defaults to `<project_dir>/cordova/plugins`
+ * `subdir`: subdirectory within the plugin directory to consider as plugin directory root, defaults to `.`
+ * `cli_variables`: an object mapping cordova plugin specification variable namess (see [plugin specification](plugin_spec.md)) to values 
+ * `www_dir`: path to directory where web assets are to be copied to, defaults to the specified project directory's `www` dir (dependent on platform)
+ * `callback`: callback to invoke once complete. If specified, will pass in an error object as a first parameter if the action failed. If not and an error occurs, `plugman` will throw the error
+
+### `uninstall` method
+
+    module.exports = function uninstallPlugin(platform, project_dir, id, plugins_dir, cli_variables, www_dir, callback) {
+
+Uninstalls a previously-installed cordova plugin from a specified cordova project of a specified platform.
+
+ * `platform`: one of `android`, `ios`, `blackberry10`, `wp7` or `wp8`
+ * `project_dir`: path to an instance of the above specified platform's cordova project
+ * `id`: a string representing the `id` of the plugin
+ * `plugins_dir`: path to directory where plugins are stored, defaults to `<project_dir>/cordova/plugins`
+ * `subdir`: subdirectory within the plugin directory to consider as plugin directory root, defaults to `.`
+ * `cli_variables`: an object mapping cordova plugin specification variable namess (see [plugin specification](plugin_spec.md)) to values 
+ * `www_dir`: path to directory where web assets are to be copied to, defaults to the specified project directory's `www` dir (dependent on platform)
+ * `callback`: callback to invoke once complete. If specified, will pass in an error object as a first parameter if the action failed. If not and an error occurs, `plugman` will throw the error
+
+### `fetch` method
+
+Copies a cordova plugin into a single location that plugman uses to track which plugins are installed into a project.
+
+    module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, subdir, git_ref, callback) {
+
+ * `plugin_dir`: path or URL to a plugin directory/repository
+ * `plugins_dir`: path housing all plugins used in this project
+ * `link`: if `plugin_dir` points to a local path, will create a symbolic link to that folder instead of copying into `plugins_dir`, defaults to `false`
+ * `subdir`: subdirectory within the plugin directory to consider as plugin directory root, defaults to `.`
+ * `gitref`: if `plugin_dir` points to a URL, this value will be used to pass into `git checkout` after the repository is cloned, defaults to `HEAD`
+ * `callback`: callback to invoke once complete. If specified, will pass in an error object as a first parameter if the action failed. If not and an error occurs, `plugman` will throw the error
+
+### `prepare` method
+
+Finalizes plugin installation by making configuration file changes and setting up a JavaScript loader for js-module support.
+
+    module.exports = function handlePrepare(project_dir, platform, plugins_dir) {
+
+ * `project_dir`: path to an instance of the above specified platform's cordova project
+ * `platform`: one of `android`, `ios`, `blackberry10`, `wp7` or `wp8`
+ * `plugins_dir`: path housing all plugins used in this project
+
+## Example Plugins
+
+- Google has a [bunch of plugins](https://github.com/MobileChromeApps/chrome-cordova/tree/master/plugins) which are maintained actively by a contributor to plugman
+- Adobe maintains plugins for its Build cloud service, which are open sourced and [available on GitHub](https://github.com/phonegap-build)
+- BlackBerry has a [bunch of plugins](https://github.com/blackberry/cordova-blackberry/tree/master/blackberry10/plugins) offering deep platform integration
+
+## Development
+
+Basic installation:
+
+    git clone https://git-wip-us.apache.org/repos/asf/cordova-plugman.git
+    cd cordova-plugman
+    npm install -g
+
+Linking the global executable to the git repo:
+
+    git clone https://git-wip-us.apache.org/repos/asf/cordova-plugman.git
+    cd cordova-plugman
+    npm install
+    sudo npm link
+
+### Running Tests
+
+    npm test
+
+## Plugin Directory Structure
+
+A plugin is typically a combination of some web/www code, and some native code.
+However, plugins may have only one of these things - a plugin could be a single
+JavaScript file, or some native code with no corresponding JavaScript.
+
+Here is a sample plugin named foo with android and ios platforms support, and 2 www assets.
+
+```
+foo-plugin/
+|- plugin.xml     # xml-based manifest
+|- src/           # native source for each platform
+|  |- android/
+|  |  `- Foo.java
+|  `- ios/
+|     |- CDVFoo.h
+|     `- CDVFoo.m
+|- README.md
+`- www/
+   |- foo.js
+   `- foo.png
+```
+
+This structure is suggested, but not required.
+
+## Contributors
+
+See the [package.json](package.json) file for attribution notes.
+
+## License
+
+Apache License 2.0

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/doc/help.txt
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/doc/help.txt b/blackberry10/node_modules/plugman/doc/help.txt
new file mode 100644
index 0000000..412b3ba
--- /dev/null
+++ b/blackberry10/node_modules/plugman/doc/help.txt
@@ -0,0 +1,35 @@
+plugman installs and uninstalls plugin.xml-compatible cordova plugins into cordova-generated projects.
+
+Usage
+=====
+
+Install a plugin
+----------------
+
+    $ plugman --platform <platform> --project <directory> --plugin <plugin> [--variable NAME=VALUE]
+
+Parameters: 
+
+ - <platform>: One of android, ios, blackberry10, wp7 or wp8
+ - project <directory>: Path reference to a cordova-generated project of the platform you specify
+ - plugin <plugin>: One of a path reference to a local copy of a plugin, or a remote https: or git: URL pointing to a cordova plugin
+ - variable NAME=VALUE: Some plugins require install-time variables to be defined. These could be things like API keys/tokens or other app-specific variables.
+
+Uninstall a plugin
+------------------
+
+    $ plugman --uninstall --platform <platform> --project <directory> --plugin <plugin-id>
+
+Parameters:
+ - plugin <plugin-id>: The plugin to remove, identified by its id (see the plugin.xml's <plugin id> attribute)
+
+Optional parameters
+-------------------
+
+ - www <directory>: www assets for the plugin will be installed into this directory. Default is to install into the standard www directory for the platform specified
+ - plugins_dir <directory>: a copy of the plugin will be stored in this directory. Default is to install into the <project directory>/plugins folder
+
+Optional flags
+--------------
+
+ --debug : Verbose mode

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/main.js
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/main.js b/blackberry10/node_modules/plugman/main.js
new file mode 100755
index 0000000..4361aba
--- /dev/null
+++ b/blackberry10/node_modules/plugman/main.js
@@ -0,0 +1,95 @@
+#!/usr/bin/env node
+/*
+ *
+ * Copyright 2013 Anis Kadri
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+// copyright (c) 2013 Andrew Lunny, Adobe Systems
+var path = require('path')
+    , url = require('url')
+    , package = require(path.join(__dirname, 'package'))
+    , nopt = require('nopt')
+    , plugins = require('./src/util/plugins')
+    , plugman = require('./plugman');
+
+var known_opts = { 'platform' : [ 'ios', 'android', 'blackberry10', 'wp7', 'wp8' ]
+            , 'project' : path
+            , 'plugin' : [String, path, url]
+            , 'install' : Boolean
+            , 'uninstall' : Boolean
+            , 'v' : Boolean
+            , 'debug' : Boolean
+            , 'plugins': path
+            , 'link': Boolean
+            , 'variable' : Array
+            , 'www': path
+            }, shortHands = { 'var' : 'variable' };
+
+var cli_opts = nopt(known_opts);
+
+// Default the plugins_dir to './cordova/plugins'.
+var plugins_dir;
+
+// Without these arguments, the commands will fail and print the usage anyway.
+if (cli_opts.plugins_dir || cli_opts.project) {
+    plugins_dir = typeof cli_opts.plugins_dir == 'string' ?
+        cli_opts.plugins_dir :
+        path.join(cli_opts.project, 'cordova', 'plugins');
+}
+
+process.on('uncaughtException', function(error){
+    if (cli_opts.debug) {
+        console.error(error.stack);
+    } else {
+        console.error(error.message);
+    }
+    process.exit(1);
+});
+
+// Set up appropriate logging based on events
+if (cli_opts.debug) {
+    plugman.on('log', console.log);
+}
+plugman.on('warn', console.warn);
+plugman.on('error', console.error);
+plugman.on('results', console.log);
+
+if (cli_opts.v) {
+    console.log(package.name + ' version ' + package.version);
+}
+else if (!cli_opts.platform || !cli_opts.project || !cli_opts.plugin) {
+    console.log(plugman.help());
+}
+else if (cli_opts.uninstall) {
+    plugman.uninstall(cli_opts.platform, cli_opts.project, cli_opts.plugin, plugins_dir, { www_dir: cli_opts.www });
+}
+else {
+    var cli_variables = {}
+    if (cli_opts.variable) {
+        cli_opts.variable.forEach(function (variable) {
+            var tokens = variable.split('=');
+            var key = tokens.shift().toUpperCase();
+            if (/^[\w-_]+$/.test(key)) cli_variables[key] = tokens.join('=');
+        });
+    }
+    var opts = {
+        subdir: '.',
+        cli_variables: cli_variables,
+        www_dir: cli_opts.www
+    };
+    plugman.install(cli_opts.platform, cli_opts.project, cli_opts.plugin, plugins_dir, opts);
+}

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/.bin/nopt
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/.bin/nopt b/blackberry10/node_modules/plugman/node_modules/.bin/nopt
new file mode 120000
index 0000000..6b6566e
--- /dev/null
+++ b/blackberry10/node_modules/plugman/node_modules/.bin/nopt
@@ -0,0 +1 @@
+../nopt/bin/nopt.js
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/.bin/semver
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/.bin/semver b/blackberry10/node_modules/plugman/node_modules/.bin/semver
new file mode 120000
index 0000000..317eb29
--- /dev/null
+++ b/blackberry10/node_modules/plugman/node_modules/.bin/semver
@@ -0,0 +1 @@
+../semver/bin/semver
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/.npmignore
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/.npmignore b/blackberry10/node_modules/plugman/node_modules/bplist-parser/.npmignore
new file mode 100644
index 0000000..a9b46ea
--- /dev/null
+++ b/blackberry10/node_modules/plugman/node_modules/bplist-parser/.npmignore
@@ -0,0 +1,8 @@
+/build/*
+node_modules
+*.node
+*.sh
+*.swp
+.lock*
+npm-debug.log
+.idea

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/README.md
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/README.md b/blackberry10/node_modules/plugman/node_modules/bplist-parser/README.md
new file mode 100644
index 0000000..37e5e1c
--- /dev/null
+++ b/blackberry10/node_modules/plugman/node_modules/bplist-parser/README.md
@@ -0,0 +1,47 @@
+bplist-parser
+=============
+
+Binary Mac OS X Plist (property list) parser.
+
+## Installation
+
+```bash
+$ npm install bplist-parser
+```
+
+## Quick Examples
+
+```javascript
+var bplist = require('bplist-parser');
+
+bplist.parseFile('myPlist.bplist', function(err, obj) {
+  if (err) throw err;
+
+  console.log(JSON.stringify(obj));
+});
+```
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2012 Near Infinity Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/bplistParser.js
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/bplistParser.js b/blackberry10/node_modules/plugman/node_modules/bplist-parser/bplistParser.js
new file mode 100644
index 0000000..573f513
--- /dev/null
+++ b/blackberry10/node_modules/plugman/node_modules/bplist-parser/bplistParser.js
@@ -0,0 +1,309 @@
+'use strict';
+
+// adapted from http://code.google.com/p/plist/source/browse/trunk/src/com/dd/plist/BinaryPropertyListParser.java
+
+var fs = require('fs');
+var debug = false;
+
+exports.maxObjectSize = 100 * 1000 * 1000; // 100Meg
+
+// EPOCH = new SimpleDateFormat("yyyy MM dd zzz").parse("2001 01 01 GMT").getTime();
+// ...but that's annoying in a static initializer because it can throw exceptions, ick.
+// So we just hardcode the correct value.
+var EPOCH = 978307200000;
+
+var parseFile = exports.parseFile = function (fileName, callback) {
+  fs.readFile(fileName, function (err, data) {
+    if (err) {
+      return callback(err);
+    }
+    try {
+      var result = parseBuffer(data);
+      return callback(null, result);
+    } catch (ex) {
+      return callback(ex);
+    }
+  });
+};
+
+var parseBuffer = exports.parseBuffer = function (buffer) {
+  var result = {};
+
+  // check header
+  var header = buffer.slice(0, 'bplist'.length).toString('utf8');
+  if (header !== 'bplist') {
+    throw new Error("Invalid binary plist. Expected 'bplist' at offset 0.");
+  }
+
+  // Handle trailer, last 32 bytes of the file
+  var trailer = buffer.slice(buffer.length - 32, buffer.length);
+  // 6 null bytes (index 0 to 5)
+  var offsetSize = trailer.readUInt8(6);
+  if (debug) {
+    console.log("offsetSize: " + offsetSize);
+  }
+  var objectRefSize = trailer.readUInt8(7);
+  if (debug) {
+    console.log("objectRefSize: " + objectRefSize);
+  }
+  var numObjects = readUInt64BE(trailer, 8);
+  if (debug) {
+    console.log("numObjects: " + numObjects);
+  }
+  var topObject = readUInt64BE(trailer, 16);
+  if (debug) {
+    console.log("topObject: " + topObject);
+  }
+  var offsetTableOffset = readUInt64BE(trailer, 24);
+  if (debug) {
+    console.log("offsetTableOffset: " + offsetTableOffset);
+  }
+
+  // Handle offset table
+  var offsetTable = [];
+
+  for (var i = 0; i < numObjects; i++) {
+    var offsetBytes = buffer.slice(offsetTableOffset + i * offsetSize, offsetTableOffset + (i + 1) * offsetSize);
+    offsetTable[i] = readUInt(offsetBytes, 0);
+    if (debug) {
+      console.log("Offset for Object #" + i + " is " + offsetTable[i] + " [" + offsetTable[i].toString(16) + "]");
+    }
+  }
+
+  // Parses an object inside the currently parsed binary property list.
+  // For the format specification check
+  // <a href="http://www.opensource.apple.com/source/CF/CF-635/CFBinaryPList.c">
+  // Apple's binary property list parser implementation</a>.
+  function parseObject(tableOffset) {
+    var offset = offsetTable[tableOffset];
+    var type = buffer[offset];
+    var objType = (type & 0xF0) >> 4; //First  4 bits
+    var objInfo = (type & 0x0F);      //Second 4 bits
+    switch (objType) {
+    case 0x0:
+      return parseSimple();
+    case 0x1:
+    case 0x8: // UID (really just an integer)
+      return parseInteger();
+    case 0x2:
+      return parseReal();
+    case 0x3:
+      return parseDate();
+    case 0x4:
+      return parseData();
+    case 0x5: // ASCII
+      return parsePlistString();
+    case 0x6: // UTF-16
+      return parsePlistString(true);
+    case 0xA:
+      return parseArray();
+    case 0xD:
+      return parseDictionary();
+    default:
+      throw new Error("Unhandled type 0x" + objType.toString(16));
+    }
+
+    function parseSimple() {
+      //Simple
+      switch (objInfo) {
+      case 0x0: // null
+        return null;
+      case 0x8: // false
+        return false;
+      case 0x9: // true
+        return true;
+      case 0xF: // filler byte
+        return null;
+      default:
+        throw new Error("Unhandled simple type 0x" + objType.toString(16));
+      }
+    }
+
+    function parseInteger() {
+      var length = Math.pow(2, objInfo);
+      if (length < exports.maxObjectSize) {
+        return readUInt(buffer.slice(offset + 1, offset + 1 + length));
+      } else {
+        throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
+      }
+    }
+
+    function parseReal() {
+      var length = Math.pow(2, objInfo);
+      if (length < exports.maxObjectSize) {
+        var realBuffer = buffer.slice(offset + 1, offset + 1 + length);
+        if (length === 4) {
+          return realBuffer.readFloatBE(0);
+        }
+        else if (length === 8) {
+          return realBuffer.readDoubleBE(0);
+        }
+      } else {
+        throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
+      }
+    }
+
+    function parseDate() {
+      if (objInfo != 0x3) {
+        console.error("Unknown date type :" + objInfo + ". Parsing anyway...");
+      }
+      var dateBuffer = buffer.slice(offset + 1, offset + 9);
+      return new Date(EPOCH + (1000 * dateBuffer.readDoubleBE(0)));
+    }
+
+    function parseData() {
+      var dataoffset = 1;
+      var length = objInfo;
+      if (objInfo == 0xF) {
+        var int_type = buffer[offset + 1];
+        var intType = (int_type & 0xF0) / 0x10;
+        if (intType != 0x1) {
+          console.error("0x4: UNEXPECTED LENGTH-INT TYPE! " + intType);
+        }
+        var intInfo = int_type & 0x0F;
+        var intLength = Math.pow(2, intInfo);
+        dataoffset = 2 + intLength;
+        if (intLength < 3) {
+          length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+        } else {
+          length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+        }
+      }
+      if (length < exports.maxObjectSize) {
+        return buffer.slice(offset + dataoffset, offset + dataoffset + length);
+      } else {
+        throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
+      }
+    }
+
+    function parsePlistString (isUtf16) {
+      isUtf16 = isUtf16 || 0;
+      var enc = "utf8";
+      var length = objInfo;
+      var stroffset = 1;
+      if (objInfo == 0xF) {
+        var int_type = buffer[offset + 1];
+        var intType = (int_type & 0xF0) / 0x10;
+        if (intType != 0x1) {
+          console.err("UNEXPECTED LENGTH-INT TYPE! " + intType);
+        }
+        var intInfo = int_type & 0x0F;
+        var intLength = Math.pow(2, intInfo);
+        var stroffset = 2 + intLength;
+        if (intLength < 3) {
+          length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+        } else {
+          length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+        }
+      }
+      // length is String length -> to get byte length multiply by 2, as 1 character takes 2 bytes in UTF-16
+      length *= (isUtf16 + 1);
+      if (length < exports.maxObjectSize) {
+        var plistString = buffer.slice(offset + stroffset, offset + stroffset + length);
+        if (isUtf16) {
+          plistString = swapBytes(plistString); 
+          enc = "ucs2";
+        }
+        return plistString.toString(enc);
+      } else {
+        throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
+      }
+    }
+
+    function parseArray() {
+      var length = objInfo;
+      var arrayoffset = 1;
+      if (objInfo == 0xF) {
+        var int_type = buffer[offset + 1];
+        var intType = (int_type & 0xF0) / 0x10;
+        if (intType != 0x1) {
+          console.error("0xa: UNEXPECTED LENGTH-INT TYPE! " + intType);
+        }
+        var intInfo = int_type & 0x0F;
+        var intLength = Math.pow(2, intInfo);
+        arrayoffset = 2 + intLength;
+        if (intLength < 3) {
+          length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+        } else {
+          length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+        }
+      }
+      if (length * objectRefSize > exports.maxObjectSize) {
+        throw new Error("To little heap space available!");
+      }
+      var array = [];
+      for (var i = 0; i < length; i++) {
+        var objRef = readUInt(buffer.slice(offset + arrayoffset + i * objectRefSize, offset + arrayoffset + (i + 1) * objectRefSize));
+        array[i] = parseObject(objRef);
+      }
+      return array;
+    }
+
+    function parseDictionary() {
+      var length = objInfo;
+      var dictoffset = 1;
+      if (objInfo == 0xF) {
+        var int_type = buffer[offset + 1];
+        var intType = (int_type & 0xF0) / 0x10;
+        if (intType != 0x1) {
+          console.error("0xD: UNEXPECTED LENGTH-INT TYPE! " + intType);
+        }
+        var intInfo = int_type & 0x0F;
+        var intLength = Math.pow(2, intInfo);
+        dictoffset = 2 + intLength;
+        if (intLength < 3) {
+          length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+        } else {
+          length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+        }
+      }
+      if (length * 2 * objectRefSize > exports.maxObjectSize) {
+        throw new Error("To little heap space available!");
+      }
+      if (debug) {
+        console.log("Parsing dictionary #" + tableOffset);
+      }
+      var dict = {};
+      for (var i = 0; i < length; i++) {
+        var keyRef = readUInt(buffer.slice(offset + dictoffset + i * objectRefSize, offset + dictoffset + (i + 1) * objectRefSize));
+        var valRef = readUInt(buffer.slice(offset + dictoffset + (length * objectRefSize) + i * objectRefSize, offset + dictoffset + (length * objectRefSize) + (i + 1) * objectRefSize));
+        var key = parseObject(keyRef);
+        var val = parseObject(valRef);
+        if (debug) {
+          console.log("  DICT #" + tableOffset + ": Mapped " + key + " to " + val);
+        }
+        dict[key] = val;
+      }
+      return dict;
+    }
+  }
+
+  return [ parseObject(topObject) ];
+};
+
+function readUInt(buffer, start) {
+  start = start || 0;
+
+  var l = 0;
+  for (var i = start; i < buffer.length; i++) {
+    l <<= 8;
+    l |= buffer[i] & 0xFF;
+  }
+  return l;
+}
+
+// we're just going to toss the high order bits because javascript doesn't have 64-bit ints
+function readUInt64BE(buffer, start) {
+  var data = buffer.slice(start, start + 8);
+  return data.readUInt32BE(4, 8);
+}
+
+function swapBytes(buffer) {
+  var len = buffer.length;
+  for (var i = 0; i < len; i += 2) {
+    var a = buffer[i];
+    buffer[i] = buffer[i+1];
+    buffer[i+1] = a;
+  }
+  return buffer;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/package.json
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/package.json b/blackberry10/node_modules/plugman/node_modules/bplist-parser/package.json
new file mode 100644
index 0000000..8a33a97
--- /dev/null
+++ b/blackberry10/node_modules/plugman/node_modules/bplist-parser/package.json
@@ -0,0 +1,33 @@
+{
+  "name": "bplist-parser",
+  "version": "0.0.4",
+  "description": "Binary plist parser.",
+  "main": "bplistParser.js",
+  "scripts": {
+    "test": "./node_modules/nodeunit/bin/nodeunit test"
+  },
+  "keywords": [
+    "bplist",
+    "plist",
+    "parser"
+  ],
+  "author": {
+    "name": "Joe Ferner",
+    "email": "joe.ferner@nearinfinity.com"
+  },
+  "license": "MIT",
+  "devDependencies": {
+    "nodeunit": "~0.7.4"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/nearinfinity/node-bplist-parser.git"
+  },
+  "readme": "bplist-parser\n=============\n\nBinary Mac OS X Plist (property list) parser.\n\n## Installation\n\n```bash\n$ npm install bplist-parser\n```\n\n## Quick Examples\n\n```javascript\nvar bplist = require('bplist-parser');\n\nbplist.parseFile('myPlist.bplist', function(err, obj) {\n  if (err) throw err;\n\n  console.log(JSON.stringify(obj));\n});\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 Near Infinity Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial p
 ortions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
+  "readmeFilename": "README.md",
+  "bugs": {
+    "url": "https://github.com/nearinfinity/node-bplist-parser/issues"
+  },
+  "_id": "bplist-parser@0.0.4",
+  "_from": "bplist-parser@0.0.x"
+}

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/airplay.bplist
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/airplay.bplist b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/airplay.bplist
new file mode 100644
index 0000000..931adea
Binary files /dev/null and b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/airplay.bplist differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/iTunes-small.bplist
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/iTunes-small.bplist b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/iTunes-small.bplist
new file mode 100644
index 0000000..b7edb14
Binary files /dev/null and b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/iTunes-small.bplist differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/parseTest.js
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/parseTest.js b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/parseTest.js
new file mode 100644
index 0000000..dcb6dd0
--- /dev/null
+++ b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/parseTest.js
@@ -0,0 +1,120 @@
+'use strict';
+
+// tests are adapted from https://github.com/TooTallNate/node-plist
+
+var path = require('path');
+var nodeunit = require('nodeunit');
+var bplist = require('../');
+
+module.exports = {
+  'iTunes Small': function (test) {
+    var file = path.join(__dirname, "iTunes-small.bplist");
+    var startTime1 = new Date();
+
+    bplist.parseFile(file, function (err, dicts) {
+      if (err) {
+        throw err;
+      }
+
+      var endTime = new Date();
+      console.log('Parsed "' + file + '" in ' + (endTime - startTime1) + 'ms');
+      var dict = dicts[0];
+      test.equal(dict['Application Version'], "9.0.3");
+      test.equal(dict['Library Persistent ID'], "6F81D37F95101437");
+      test.done();
+    });
+  },
+
+  'sample1': function (test) {
+    var file = path.join(__dirname, "sample1.bplist");
+    var startTime = new Date();
+
+    bplist.parseFile(file, function (err, dicts) {
+      if (err) {
+        throw err;
+      }
+
+      var endTime = new Date();
+      console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms');
+      var dict = dicts[0];
+      test.equal(dict['CFBundleIdentifier'], 'com.apple.dictionary.MySample');
+      test.done();
+    });
+  },
+
+  'sample2': function (test) {
+    var file = path.join(__dirname, "sample2.bplist");
+    var startTime = new Date();
+
+    bplist.parseFile(file, function (err, dicts) {
+      if (err) {
+        throw err;
+      }
+
+      var endTime = new Date();
+      console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms');
+      var dict = dicts[0];
+      test.equal(dict['PopupMenu'][2]['Key'], "\n        #import <Cocoa/Cocoa.h>\n\n#import <MacRuby/MacRuby.h>\n\nint main(int argc, char *argv[])\n{\n  return macruby_main(\"rb_main.rb\", argc, argv);\n}\n");
+      test.done();
+    });
+  },
+
+  'airplay': function (test) {
+    var file = path.join(__dirname, "airplay.bplist");
+    var startTime = new Date();
+
+    bplist.parseFile(file, function (err, dicts) {
+      if (err) {
+        throw err;
+      }
+
+      var endTime = new Date();
+      console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms');
+
+      var dict = dicts[0];
+      test.equal(dict['duration'], 5555.0495000000001);
+      test.equal(dict['position'], 4.6269989039999997);
+      test.done();
+    });
+  },
+
+  'utf16': function (test) {
+    var file = path.join(__dirname, "utf16.bplist");
+    var startTime = new Date();
+
+    bplist.parseFile(file, function (err, dicts) {
+      if (err) {
+        throw err;
+      }
+
+      var endTime = new Date();
+      console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms');
+
+      var dict = dicts[0];
+      test.equal(dict['CFBundleName'], 'sellStuff');
+      test.equal(dict['CFBundleShortVersionString'], '2.6.1');
+      test.equal(dict['NSHumanReadableCopyright'], '©2008-2012, sellStuff, Inc.');
+      test.done();
+    });
+  },
+
+  'uid': function (test) {
+    var file = path.join(__dirname, "uid.bplist");
+    var startTime = new Date();
+
+    bplist.parseFile(file, function (err, dicts) {
+      if (err) {
+        throw err;
+      }
+
+      var endTime = new Date();
+      console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms');
+
+      var dict = dicts[0]; 
+      test.deepEqual(dict['$objects'][1]['NS.keys'], [2, 3, 4]);
+      test.deepEqual(dict['$objects'][1]['NS.objects'], [5, 6, 7]);
+      test.equal(dict['$top']['root'], 1);      
+      test.done();
+    });
+  }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/sample1.bplist
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/sample1.bplist b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/sample1.bplist
new file mode 100644
index 0000000..5b808ff
Binary files /dev/null and b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/sample1.bplist differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/sample2.bplist
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/sample2.bplist b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/sample2.bplist
new file mode 100644
index 0000000..fc42979
Binary files /dev/null and b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/sample2.bplist differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/uid.bplist
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/uid.bplist b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/uid.bplist
new file mode 100644
index 0000000..59f341e
Binary files /dev/null and b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/uid.bplist differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/utf16.bplist
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/utf16.bplist b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/utf16.bplist
new file mode 100644
index 0000000..ba4bcfa
Binary files /dev/null and b/blackberry10/node_modules/plugman/node_modules/bplist-parser/test/utf16.bplist differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1139813c/blackberry10/node_modules/plugman/node_modules/dep-graph/.npmignore
----------------------------------------------------------------------
diff --git a/blackberry10/node_modules/plugman/node_modules/dep-graph/.npmignore b/blackberry10/node_modules/plugman/node_modules/dep-graph/.npmignore
new file mode 100644
index 0000000..b512c09
--- /dev/null
+++ b/blackberry10/node_modules/plugman/node_modules/dep-graph/.npmignore
@@ -0,0 +1 @@
+node_modules
\ No newline at end of file


Mime
View raw message