1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

vhost: lws_get_vhost_by_name

This commit is contained in:
Andy Green 2019-07-30 06:02:23 +01:00
parent 077ecf042a
commit fa8356f882
2 changed files with 25 additions and 0 deletions

View file

@ -894,6 +894,16 @@ lws_get_vhost(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN const char *
lws_get_vhost_name(struct lws_vhost *vhost);
/**
* lws_get_vhost_by_name() - returns the vhost with the requested name, or NULL
*
* \param name: vhost name we are looking for
*
* Returns NULL, or the vhost with the name \p name
*/
LWS_VISIBLE LWS_EXTERN struct lws_vhost *
lws_get_vhost_by_name(struct lws_context *context, const char *name);
/**
* lws_get_vhost_port() - returns the port a vhost listens on, or -1
*

View file

@ -1301,3 +1301,18 @@ lws_context_deprecate(struct lws_context *context, lws_reload_func cb)
context->deprecated = 1;
context->deprecation_cb = cb;
}
#if defined(LWS_WITH_NETWORK)
struct lws_vhost *
lws_get_vhost_by_name(struct lws_context *context, const char *name)
{
lws_start_foreach_ll(struct lws_vhost *, v,
context->vhost_list) {
if (!strcmp(v->name, name))
return v;
} lws_end_foreach_ll(v, vhost_next);
return NULL;
}
#endif