Hi Gavin.

I'm not sure if I understood properly, but, if you are trying to share your
config instance to your request handle function, you can send it
via MHD_start_daemon(), for example, supposing code at
https://github.com/SentryPeer/SentryPeer/blob/99a5b5be48c788d9e5f4177725babc5a97e8f37e/src/http_daemon.c#L127,
it would looks like this:

...
  daemon = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION,
        HTTP_DAEMON_PORT, NULL, NULL, &ahc_get, *your_config_instance*,
        MHD_OPTION_END);
...

so you would be able to access it as:

...
static enum MHD_Result ahc_get(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 **ptr)
{
  *your_config_instance* = cls;
...

Let me know if this is what you are looking for.

The "ptr" in general is used to share something between requests. I have
been using both in my project
<https://github.com/risoflora/libsagui/blob/master/src/sg_httpsrv.c>.

A good reference:
https://www.gnu.org/software/libmicrohttpd/manual/libmicrohttpd.html#index-MHD_005fstart_005fdaemon

On Fri, Dec 17, 2021 at 1:47 PM Gavin Henry <ghe...@sentrypeer.org> wrote:

> Hi all,
>
> At
> https://github.com/SentryPeer/SentryPeer/blob/99a5b5be48c788d9e5f4177725babc5a97e8f37e/src/http_daemon.c#L135
>
> I'm looking to pass in sentrypeer_config const *config, and am using
> dh_cls to pick off cls in:
>
>
> https://github.com/SentryPeer/SentryPeer/blob/99a5b5be48c788d9e5f4177725babc5a97e8f37e/src/http_daemon.c#L56
>
> Is that the correct way? It looks like I should be using **ptr at:
>
>
> https://github.com/SentryPeer/SentryPeer/blob/99a5b5be48c788d9e5f4177725babc5a97e8f37e/src/http_daemon.c#L59
>
> But how do I set that in MHD_start_daemon()
>
> Thanks.
>
> --
> Kind Regards,
>
> Gavin Henry.
> https://sentrypeer.org
>

-- 
Silvio Clécio

Reply via email to