lws_context_init_extensions(struct lws_context_creation_info *info,
struct lws_context *context)
{
- context->extensions = info->extensions;
lwsl_info(" LWS_MAX_EXTENSIONS_ACTIVE: %u\n", LWS_MAX_EXTENSIONS_ACTIVE);
}
pending_close_quote = 0;
struct lws_ext_option_arg oa;
+ oa.option_name = NULL;
+
while (opts[count_options].name)
count_options++;
while (len) {
oa.option_index = n;
lwsl_ext("hit %d\n", oa.option_index);
leap = LEAPS_SEEK_VAL;
- if (len ==1)
+ if (len == 1)
goto set_arg;
break;
}
wsi->active_extensions[n]->name, reason);
return -1;
}
+ /* valgrind... */
+ if (reason == LWS_EXT_CB_DESTROY)
+ wsi->act_ext_user[n] = NULL;
if (m > handled)
handled = m;
}
int reason, void *arg, int len)
{
int n = 0, m, handled = 0;
- const struct lws_extension *ext = context->extensions;
+ const struct lws_extension *ext;
+
+ if (!wsi || !wsi->vhost)
+ return 0;
+
+ ext = wsi->vhost->extensions;
while (ext && ext->callback && !handled) {
m = ext->callback(context, ext, wsi, reason,
- (void *)(long)n, arg, len);
+ (void *)(lws_intptr_t)n, arg, len);
if (m < 0) {
lwsl_ext("Ext '%s' failed to handle callback %d!\n",
wsi->active_extensions[n]->name, reason);
return handled;
}
+
+int
+lws_set_extension_option(struct lws *wsi, const char *ext_name,
+ const char *opt_name, const char *opt_val)
+{
+ struct lws_ext_option_arg oa;
+ int idx = 0;
+
+ /* first identify if the ext is active on this wsi */
+ while (idx < wsi->count_act_ext &&
+ strcmp(wsi->active_extensions[idx]->name, ext_name))
+ idx++;
+
+ if (idx == wsi->count_act_ext)
+ return -1; /* request ext not active on this wsi */
+
+ oa.option_name = opt_name;
+ oa.option_index = 0;
+ oa.start = opt_val;
+ oa.len = 0;
+
+ return wsi->active_extensions[idx]->callback(
+ wsi->context, wsi->active_extensions[idx], wsi,
+ LWS_EXT_CB_NAMED_OPTION_SET, wsi->act_ext_user[idx], &oa, 0);
+}