www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - winpcap binding

reply maarten van damme <maartenvd1994 gmail.com> writes:
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
Aug 04 2011
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 reply maarten van damme <maartenvd1994 gmail.com> writes:
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.
Aug 04 2011
parent reply 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
next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
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 :)
Aug 06 2011
prev sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
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 :)
Aug 06 2011