Wow, you nailed it. I forgot to declare that function static. This is why
everyone needs a second set of eyes. =)

I also added the second NULL argument for the option.

Thanks for the prompt response.

.


On Wed, May 28, 2014 at 2:02 AM, Christian Grothoff <[email protected]>wrote:

> On 05/28/2014 03:20 AM, Nader Zeid wrote:
> > I can't think of any reason why this won't work. I have the following
> > function:
> >
> >
> >
> > void * MicroHttpdServer::log(void * cls, const char * uri) {
> >   Request *request(new Request());
> >   printf("\nURI: %s\n", uri);
> >   return request;
> > }
> >
> >
> >
> > Given as the value of the MHD_OPTION_URI_LOG_CALLBACK option:
> >
> >
> >
> > MHD_Daemon *daemon;
> > daemon = MHD_start_daemon(
> >   MHD_USE_SELECT_INTERNALLY | MHD_USE_IPv6,
> >   MicroHttpdServer::port,
> >   NULL, // &MicroHttpdServer::authorize
> >   NULL,
> >   &MicroHttpdServer::handle,
> >   NULL,
> >   MHD_OPTION_THREAD_POOL_SIZE,
> >   MicroHttpdServer::amount,
> >   MHD_OPTION_URI_LOG_CALLBACK,
> >   &MicroHttpdServer::log,
> >   MHD_OPTION_END
> > );
>
> A first bug here is that you need to add an extra 'NULL' argument
> after &MicroHttpdServer::log for the 'cls'.  Right now, the behavior
> is undefined.
>
> Next, you might need to avoid the C++-ism of "MicroHttpdServer::log"
> as there is no "self" pointer passed from C, which might effectively
> shift your arguments by one.  So try with a plain old C function ;-)
>
> Happy hacking!
>
> Christian
>
>

Reply via email to