From 17203a43ac8b327379260836d658319e505604a9 Mon Sep 17 00:00:00 2001 From: Andrew Tolbert Date: Sun, 23 Oct 2011 18:49:19 -0500 Subject: [PATCH] Node 0.5.x compatibility. If ./build/default require fails, try ./build/Release. Remove ev.h and node_events.h imports --- pcap.js | 12 +++++++++++- pcap_binding.cc | 2 -- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pcap.js b/pcap.js index 17c88e0..d586461 100644 --- a/pcap.js +++ b/pcap.js @@ -4,10 +4,20 @@ var util, IOWatcher, dns = require('dns'), Buffer = require('buffer').Buffer, events = require('events'), - binding = require('./build/default/pcap_binding'), HTTPParser = process.binding('http_parser').HTTPParser, url = require('url'); +/* + * Try catch here around multiple build paths to support + * `node@0.4.x` and >= `node@0.5.x`. + */ +try { + binding = require('./build/default/pcap_binding'); +} +catch (ex) { + binding = require('./build/Release/pcap_binding'); +} + if (process.versions && process.versions.node && process.versions.node.split('.')[1] >= 3) { util = require("util"); IOWatcher = process.binding('io_watcher').IOWatcher; diff --git a/pcap_binding.cc b/pcap_binding.cc index efb45d2..17fcf27 100644 --- a/pcap_binding.cc +++ b/pcap_binding.cc @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -9,7 +8,6 @@ #include #include #include -#include #include #include #include