www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - winpcap binding

reply maarten van damme <maartenvd1994 gmail.com> writes:
--000e0cd22fe6065c9004a9a8ac7c
Content-Type: text/plain; charset=ISO-8859-1

Hello everyone,
It's been a couple of days since I've started trying to use the pcap library
with d.
first I've started from scratch but I gave up partly because I don't know
enough of how sockets are implemented in d and how I was going to be able to
bridge those two, I ended up making one giant mess :p.
Then I've stumbled upon htod.exe but as of this moment it refuses to spit
something useful out. I was wondering if someone had ever used it before?
I do "htod.exe pcap.h ../pcap-stdinc.h *longpath*\winsock2.h
*longpath*\excpt.h"

Also I don't really know what I have to do with the bindings once I have
working d modules, simply place it with the shipped .lib files and wait for
magic to happen? (I've no experience whatsoever with c(++))

I'm also prety convinced d could gain a lot more users/libraries if binding
between header files and d files went way easier.

maarten

--000e0cd22fe6065c9004a9a8ac7c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello everyone,<div>It&#39;s been a couple of days since I&#39;ve started t=
rying to use the pcap library with d.</div><div>first I&#39;ve started from=
 scratch but I gave up partly because I don&#39;t know enough of how socket=
s are implemented in d and how I was going to be able to bridge those two, =
I ended up making one giant mess :p.</div>
<div>Then I&#39;ve stumbled upon htod.exe but as of this moment it refuses =
to spit something useful out. I was wondering if someone had ever used it b=
efore?</div><div>I do &quot;htod.exe pcap.h ../pcap-stdinc.h *longpath*\win=
sock2.h *longpath*\excpt.h&quot;</div>
<div><br></div><div>Also I don&#39;t really know what I have to do with the=
 bindings once I have working d modules, simply place it with the shipped .=
lib files and wait for magic to happen? (I&#39;ve no experience whatsoever =
with c(++))</div>
<div><br></div><div>I&#39;m also prety convinced d could gain a lot more us=
ers/libraries if binding between header files and d files went way easier.<=
/div><div><br></div><div>maarten</div>

--000e0cd22fe6065c9004a9a8ac7c--
Aug 04 2011
next sibling parent reply simendsjo <simendsjo gmail.com> writes:
On 04.08.2011 09:10, maarten van damme wrote:
 Hello everyone,
 It's been a couple of days since I've started trying to use the pcap
 library with d.
 first I've started from scratch but I gave up partly because I don't
 know enough of how sockets are implemented in d and how I was going to
 be able to bridge those two, I ended up making one giant mess :p.
 Then I've stumbled upon htod.exe but as of this moment it refuses to
 spit something useful out. I was wondering if someone had ever used it
 before?
 I do "htod.exe pcap.h ../pcap-stdinc.h *longpath*\winsock2.h
 *longpath*\excpt.h"

 Also I don't really know what I have to do with the bindings once I have
 working d modules, simply place it with the shipped .lib files and wait
 for magic to happen? (I've no experience whatsoever with c(++))

 I'm also prety convinced d could gain a lot more users/libraries if
 binding between header files and d files went way easier.

 maarten

The dsource bindings project have many bindings you can look at for examples: http://dsource.org/projects/bindings The win32 binding has some instructions on translating: http://dsource.org/projects/bindings/wiki/WindowsApi/Instructions dpl also has some instructions: http://www.d-programming-language.org/windows.html And some more: http://www.d-programming-language.org/htomodule.html I don't think htod is designed as a one-stop for converting header files. You'll probably have to manually change the file it spits out for all but the simplest cases.
Aug 04 2011
parent simendsjo <simendsjo gmail.com> writes:
On 05.08.2011 06:35, maarten van damme wrote:
 hehe, thank you, that was what I was looking for. I've created an import
 lib from the dll and now started to translate the header files following
 those guidelines.
 I'm assuming thats how I have to do it? :)

Starting with htod might give you a head start, but I have really only wrapped very small pieces of C code.
 the problem is that it's a lot of work and that I can never really test
 if what I have so far is really working...

That is always a problem :)
Aug 06 2011
prev sibling next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--00504502c61c69627204a9ba9f57
Content-Type: text/plain; charset=ISO-8859-1

hehe, thank you, that was what I was looking for. I've created an import lib
from the dll and now started to translate the header files following those
guidelines.
I'm assuming thats how I have to do it? :)

the problem is that it's a lot of work and that I can never really test if
what I have so far is really working...

2011/8/4 simendsjo <simendsjo gmail.com>

 On 04.08.2011 09:10, maarten van damme wrote:

 Hello everyone,
 It's been a couple of days since I've started trying to use the pcap
 library with d.
 first I've started from scratch but I gave up partly because I don't
 know enough of how sockets are implemented in d and how I was going to
 be able to bridge those two, I ended up making one giant mess :p.
 Then I've stumbled upon htod.exe but as of this moment it refuses to
 spit something useful out. I was wondering if someone had ever used it
 before?
 I do "htod.exe pcap.h ../pcap-stdinc.h *longpath*\winsock2.h
 *longpath*\excpt.h"

 Also I don't really know what I have to do with the bindings once I have
 working d modules, simply place it with the shipped .lib files and wait
 for magic to happen? (I've no experience whatsoever with c(++))

 I'm also prety convinced d could gain a lot more users/libraries if
 binding between header files and d files went way easier.

 maarten

The dsource bindings project have many bindings you can look at for examples: http://dsource.org/projects/**bindings<http://dsource.org/projects/bindings> The win32 binding has some instructions on translating: http://dsource.org/projects/**bindings/wiki/WindowsApi/**Instructions<http://dsource.org/projects/bindings/wiki/WindowsApi/Instructions> dpl also has some instructions: http://www.d-programming-** language.org/windows.html<http://www.d-programming-language.org/windows.html> And some more: http://www.d-programming-**language.org/htomodule.html<http://www.d-programming-language.org/htomodule.html> I don't think htod is designed as a one-stop for converting header files. You'll probably have to manually change the file it spits out for all but the simplest cases.

--00504502c61c69627204a9ba9f57 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable hehe, thank you, that was what I was looking for. I&#39;ve created an impor= t lib from the dll and now started to translate the header files following = those guidelines.<div>I&#39;m assuming thats how I have to do it? :)</div> <div><br></div><div>the problem is that it&#39;s a lot of work and that I c= an never really test if what I have so far is really working...<br><br><div= class=3D"gmail_quote">2011/8/4 simendsjo <span dir=3D"ltr">&lt;<a href=3D"= mailto:simendsjo gmail.com">simendsjo gmail.com</a>&gt;</span><br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex;"><div><div></div><div class=3D"h5">On 04.08.= 2011 09:10, maarten van damme wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> Hello everyone,<br> It&#39;s been a couple of days since I&#39;ve started trying to use the pca= p<br> library with d.<br> first I&#39;ve started from scratch but I gave up partly because I don&#39;= t<br> know enough of how sockets are implemented in d and how I was going to<br> be able to bridge those two, I ended up making one giant mess :p.<br> Then I&#39;ve stumbled upon htod.exe but as of this moment it refuses to<br=

before?<br> I do &quot;htod.exe pcap.h ../pcap-stdinc.h *longpath*\winsock2.h<br> *longpath*\excpt.h&quot;<br> <br> Also I don&#39;t really know what I have to do with the bindings once I hav= e<br> working d modules, simply place it with the shipped .lib files and wait<br> for magic to happen? (I&#39;ve no experience whatsoever with c(++))<br> <br> I&#39;m also prety convinced d could gain a lot more users/libraries if<br> binding between header files and d files went way easier.<br> <br> maarten<br> </blockquote> <br></div></div> The dsource bindings project have many bindings you can look at for example= s: <a href=3D"http://dsource.org/projects/bindings" target=3D"_blank">http:= //dsource.org/projects/<u></u>bindings</a><br> The win32 binding has some instructions on translating: <a href=3D"http://d= source.org/projects/bindings/wiki/WindowsApi/Instructions" target=3D"_blank= ">http://dsource.org/projects/<u></u>bindings/wiki/WindowsApi/<u></u>Instru= ctions</a><br> dpl also has some instructions: <a href=3D"http://www.d-programming-languag= e.org/windows.html" target=3D"_blank">http://www.d-programming-<u></u>langu= age.org/windows.html</a><br> And some more: <a href=3D"http://www.d-programming-language.org/htomodule.h= tml" target=3D"_blank">http://www.d-programming-<u></u>language.org/htomodu= le.html</a><br> <br> I don&#39;t think htod is designed as a one-stop for converting header file= s. You&#39;ll probably have to manually change the file it spits out for al= l but the simplest cases.<br> </blockquote></div><br></div> --00504502c61c69627204a9ba9f57--
Aug 04 2011
prev sibling next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--000e0cd1e00235e95e04a9e1bab0
Content-Type: text/plain; charset=ISO-8859-1

Sad news, I kinda gave up on it. at certain places I don't know enough c and
for my first c to d conversion I think that library is way out of my leage.
another problem was that I couldn't even compile to c header files with dmc
due to errors, let allone convert it correctly :p

I'll better start with something smaller. Too bad htod is not that advanced,
a good seamless conversion could give d more potential as it then can access
all c libraries without having to translate all those header files one by
one :)

Thanks for the links though, they'll become usefull in the feature.
2011/8/6 simendsjo <simendsjo gmail.com>

 On 05.08.2011 06:35, maarten van damme wrote:

 hehe, thank you, that was what I was looking for. I've created an import
 lib from the dll and now started to translate the header files following
 those guidelines.
 I'm assuming thats how I have to do it? :)

Starting with htod might give you a head start, but I have really only wrapped very small pieces of C code. the problem is that it's a lot of work and that I can never really test
 if what I have so far is really working...

That is always a problem :)

--000e0cd1e00235e95e04a9e1bab0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <br>Sad news, I kinda gave up on it. at certain places I don&#39;t know eno= ugh c and for my first c to d conversion I think that library is way out of= my leage. another problem was that I couldn&#39;t even compile to c header= files with dmc due to errors, let allone convert it correctly :p<div> <br></div><div>I&#39;ll better start with something smaller. Too bad htod i= s not that advanced, a good seamless conversion could give d more potential= as it then can access all c libraries without having to translate all thos= e header files one by one :)</div> <div><br></div><div>Thanks for the links though, they&#39;ll become usefull= in the feature.</div><div><div class=3D"gmail_quote">2011/8/6 simendsjo <s= pan dir=3D"ltr">&lt;<a href=3D"mailto:simendsjo gmail.com">simendsjo gmail.= com</a>&gt;</span><br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex;"><div class=3D"im">On 05.08.2011 06:35, maar= ten van damme wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> hehe, thank you, that was what I was looking for. I&#39;ve created an impor= t<br> lib from the dll and now started to translate the header files following<br=

I&#39;m assuming thats how I have to do it? :)<br> </blockquote> <br></div> Starting with htod might give you a head start, but I have really only wrap= ped very small pieces of C code.<div class=3D"im"><br> <br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> the problem is that it&#39;s a lot of work and that I can never really test= <br> if what I have so far is really working...<br> </blockquote> <br></div> That is always a problem :)<br> </blockquote></div><br></div> --000e0cd1e00235e95e04a9e1bab0--
Aug 06 2011
prev sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--001636e90eb54418fe04a9e241e6
Content-Type: text/plain; charset=ISO-8859-1

on a side note, where does the bcd http://www.dsource.org/projects/bcd project
stands?

2011/8/7 maarten van damme <maartenvd1994 gmail.com>

 Sad news, I kinda gave up on it. at certain places I don't know enough c
 and for my first c to d conversion I think that library is way out of my
 leage. another problem was that I couldn't even compile to c header files
 with dmc due to errors, let allone convert it correctly :p

 I'll better start with something smaller. Too bad htod is not that
 advanced, a good seamless conversion could give d more potential as it then
 can access all c libraries without having to translate all those header
 files one by one :)

 Thanks for the links though, they'll become usefull in the feature.
 2011/8/6 simendsjo <simendsjo gmail.com>

 On 05.08.2011 06:35, maarten van damme wrote:

 hehe, thank you, that was what I was looking for. I've created an import
 lib from the dll and now started to translate the header files following
 those guidelines.
 I'm assuming thats how I have to do it? :)

Starting with htod might give you a head start, but I have really only wrapped very small pieces of C code. the problem is that it's a lot of work and that I can never really test
 if what I have so far is really working...

That is always a problem :)


--001636e90eb54418fe04a9e241e6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable on a side note, where does the bcd=A0<a href=3D"http://www.dsource.org/proj= ects/bcd">http://www.dsource.org/projects/bcd</a>=A0project stands?<br><br>= <div class=3D"gmail_quote">2011/8/7 maarten van damme <span dir=3D"ltr">&lt= ;<a href=3D"mailto:maartenvd1994 gmail.com">maartenvd1994 gmail.com</a>&gt;= </span><br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex;"><br>Sad news, I kinda gave up on it. at cer= tain places I don&#39;t know enough c and for my first c to d conversion I = think that library is way out of my leage. another problem was that I could= n&#39;t even compile to c header files with dmc due to errors, let allone c= onvert it correctly :p<div> <br></div><div>I&#39;ll better start with something smaller. Too bad htod i= s not that advanced, a good seamless conversion could give d more potential= as it then can access all c libraries without having to translate all thos= e header files one by one :)</div> <div><br></div><div>Thanks for the links though, they&#39;ll become usefull= in the feature.</div><div><div></div><div class=3D"h5"><div><div class=3D"= gmail_quote">2011/8/6 simendsjo <span dir=3D"ltr">&lt;<a href=3D"mailto:sim= endsjo gmail.com" target=3D"_blank">simendsjo gmail.com</a>&gt;</span><br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div>On 05.08.2011 06:35, maarten van damme = wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> hehe, thank you, that was what I was looking for. I&#39;ve created an impor= t<br> lib from the dll and now started to translate the header files following<br=

I&#39;m assuming thats how I have to do it? :)<br> </blockquote> <br></div> Starting with htod might give you a head start, but I have really only wrap= ped very small pieces of C code.<div><br> <br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> the problem is that it&#39;s a lot of work and that I can never really test= <br> if what I have so far is really working...<br> </blockquote> <br></div> That is always a problem :)<br> </blockquote></div><br></div> </div></div></blockquote></div><br> --001636e90eb54418fe04a9e241e6--
Aug 06 2011