static int plugin_command_dispatch(struct command_base* cbase, struct hub_user* user, struct hub_command* cmd) { struct plugin_handle* plugin = (struct plugin_handle*) cmd->ptr; struct plugin_callback_data* data = get_callback_data(plugin); struct plugin_command_handle* cmdh; struct plugin_user* puser = (struct plugin_user*) user; // FIXME: Use a proper conversion function instead. struct plugin_command* pcommand = (struct plugin_command*) cmd; // FIXME: Use a proper conversion function instead. LOG_PLUGIN("plugin_command_dispatch: cmd=%s", cmd->prefix); LIST_FOREACH(struct plugin_command_handle*, cmdh, data->commands, { if (strcmp(cmdh->prefix, cmd->prefix) == 0) return cmdh->handler(plugin, puser, pcommand); });
void RESTRequestState::set_callback_response(RESTContentReaderCallback rsp_writer, const char* content_type) { const char* accept_enc = MHD_lookup_connection_value(get_conn(), MHD_HEADER_KIND, "Accept-Encoding"); bool use_gzip = accept_enc && strstr(accept_enc, "gzip"); set_response(MHD_create_response_from_callback( -1, RESPONSE_BLOCK_SIZE, callback_write, new ContentReaderState(rsp_writer, get_free_callback(), get_callback_data(), use_gzip), callback_free)); MHD_add_response_header(get_response(), "Content-Type", content_type); if (use_gzip) MHD_add_response_header(get_response(), "Content-Encoding", "gzip"); /* libmicrohttpd will call the appropriate callback to free the data instead of us */ set_free_callback(NULL); }