I need to use Mongoose 3.0 for some reason. But, I am facing a problem 
related to passing user_data. Looks like this Mongoose version provides the 
facility to set user_data in main() when calling mg_start() but not when 
event handler fn callback() gets called. Is there a separate field for that 
or is there a separate way to do that? Am I missing something here?

    typedef void * (*mg_callback_t)(enum mg_event event, struct 
mg_connection *conn, const struct mg_request_info *request_info);
    (gdb) p *conn->ctx->user_callback
    $6 = {void *(enum mg_event, struct mg_connection *, const struct 
mg_request_info *)} 0x406b18 <callback>

My requirement is to allocate user_data depending upon request data, which 
is available only when event handler fn callback() gets called. Please let 
me know how can I create and pass user data in event handler fn callback()? 

*Program snippet*

static void *callback(enum mg_event event, struct mg_connection *conn, 
const struct mg_request_info *request_info)
{
    //since request_info is declared as const, I cannot do following
    //    request_info->user_data = "NEW_REQUEST_DATA";
}

int
main(void)
{
    int cfd;
    struct mg_context *ctx;
    char *user_data = "MY_DATA";

    ctx = mg_start(callback, user_data, options);

    pause();
    return 0;
}


*Mongoose 3.0 source code*

    
https://code.google.com/p/mongoose/downloads/detail?name=mongoose-3.0.tgz&can=4&q=

Regards,
~Puneet

-- 
You received this message because you are subscribed to the Google Groups 
"mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to