callback parameter order question

gedaiu szabobogdan at yahoo.com
Sat May 11 02:32:40 PDT 2013


Hi,

I try to create a D interface to GNU Libmicrohttpd because i 
could not find any, and while i was implementing a demo webserver 
i've noticed that the     MHD_AccessHandlerCallback in D is 
triggered with the parameters in the reverse order.

This is in c:

struct MHD_Daemon *
MHD_start_daemon (unsigned int flags,
		  uint16_t port,
		  MHD_AcceptPolicyCallback apc, void *apc_cls,
		  MHD_AccessHandlerCallback dh, void *dh_cls,
		  ...);

typedef int
   (*MHD_AccessHandlerCallback) (void *cls,
                                 struct MHD_Connection * 
connection,
                                 const char *url,
                                 const char *method,
                                 const char *version,
                                 const char *upload_data,
                                 size_t *upload_data_size,
                                 void **con_cls);



and to work in D I had to this:

alias int function(void **con_cls,
size_t *upload_data_size,
const char *upload_data,
const char *ver,
const char *method,
const char *url,
MHD_Connection* connection,
void* cls) MHD_AccessHandlerCallback;

extern (C) {
     .....
MHD_Daemon *MHD_start_daemon(uint flags, uint port, 
MHD_AcceptPolicyCallback apc, void *apc_cls, 
MHD_AccessHandlerCallback dh, void *dh_cls,...);

....
}
	
Can anyone help me to understand this?

Thanks,
Bogdan


More information about the Digitalmars-d-learn mailing list