pcaprub : make it compilable under mingw on windows , need some more testing but it looks like it is running too, see issue #4554 for comment

git-svn-id: file:///home/svn/framework3/trunk@12770 4d416f70-5f16-0410-b530-b9f4589650da
unstable
amaloteaux 2011-05-30 18:26:20 +00:00
parent f33cc502f0
commit c022ac447e
2 changed files with 10 additions and 11 deletions

View File

@ -1,16 +1,10 @@
require 'mkmf'
if /i386-mswin32/ =~ RUBY_PLATFORM
pcap_dir = with_config("pcap-dir", "C:\WpdPack")
pcap_includedir = with_config("pcap-includedir", pcap_dir + "\\include")
pcap_libdir = with_config("pcap-libdir", pcap_dir + "\\lib")
$CFLAGS = "-DWIN32 -I#{pcap_includedir}"
$LDFLAGS = "/link /LIBPATH:#{pcap_libdir}"
have_library("wpcap", "pcap_open_live")
if /i386-mingw32/ =~ RUBY_PLATFORM
dir_config("pcap","C:/WpdPack/include","C:/WpdPack/lib")
have_library("wpcap", "pcap_open_live")
have_library("wpcap", "pcap_setnonblock")
else
have_library("pcap", "pcap_open_live")
have_library("pcap", "pcap_open_live")
have_library("pcap", "pcap_setnonblock")
end

View File

@ -10,9 +10,10 @@
#if !defined(WIN32)
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#endif
#include <sys/time.h>
static VALUE rb_cPcap;
@ -459,7 +460,11 @@ rbpcap_capture(VALUE self)
if(! rbpcap_ready(rbp)) return self;
#if !defined(WIN32)
fno = pcap_get_selectable_fd(rbp->pd);
#else
fno = pcap_fileno(rbp->pd);
#endif
for(;;) {
VALUE packet = rbpcap_next(self);