diff --git a/lib/core/libwebsockets.c b/lib/core/libwebsockets.c index de9325177..4c095aec8 100644 --- a/lib/core/libwebsockets.c +++ b/lib/core/libwebsockets.c @@ -3019,6 +3019,21 @@ lws_pvo_search(const struct lws_protocol_vhost_options *pvo, const char *name) return pvo; } +int +lws_pvo_get_str(void *in, const char *name, const char **result) +{ + const struct lws_protocol_vhost_options *pv = + lws_pvo_search((const struct lws_protocol_vhost_options *)in, + name); + + if (!pv) + return 1; + + *result = (const char *)pv->value; + + return 0; +} + void lws_sum_stats(const struct lws_context *ctx, struct lws_conn_stats *cs) { diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index dffeb9d81..4857850ce 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -2456,6 +2456,18 @@ lws_finalize_startup(struct lws_context *context); LWS_VISIBLE LWS_EXTERN const struct lws_protocol_vhost_options * lws_pvo_search(const struct lws_protocol_vhost_options *pvo, const char *name); +/** + * lws_pvo_get_str() - retreive a string pvo value + * + * \param pvo: the first pvo in the linked-list + * \param name: the name of the pvo to return if found + * \param result: pointer to a const char * to get the result if any + * + * Returns 0 if found and *result set, or nonzero if not found + */ +LWS_VISIBLE LWS_EXTERN int +lws_pvo_get_str(void *in, const char *name, const char **result); + LWS_VISIBLE LWS_EXTERN int lws_protocol_init(struct lws_context *context);