From 8a4d88a3ce54ecd6692d66733540fe3dfa957147 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 07 Oct 2017 13:16:50 -0400 Subject: mq_html_input_select(): New function --- (limited to 'src') diff --git a/src/html.c b/src/html.c index fae9dca..e8f8e4c 100644 --- a/src/html.c +++ b/src/html.c @@ -604,3 +604,78 @@ mq_html_input_checkbox(const gchar *name, const gchar *label, gboolean checked) name, label, name, name, name, checked ? " checked=\"checked\"" : ""); } + +gchar * +mq_html_input_select(const gchar *name, const gchar *label, + const gchar *selected, + GDestroyNotify destroy_value, GDestroyNotify destroy_label, ...) +{ + gsize len; + va_list ap; + gchar *option_value; + gchar *option_label; + gchar *select; + gchar *ptr; + + g_assert(selected && selected[0]); /* Would cause buffer overflow */ + + /* Calculate length. */ + len = strlen("\n"); + ++len; /* NUL byte */ + + /* Build string. */ + select = g_new(gchar, len); + ptr = g_stpcpy(select, "\n"); /* g_stpcpy() adds NUL */ + + return select; +} diff --git a/src/html.h b/src/html.h index 24deb8a..6fe35a8 100644 --- a/src/html.h +++ b/src/html.h @@ -71,4 +71,9 @@ mq_html_input_radio(const gchar *name, const gchar *label, gboolean checked); gchar * mq_html_input_checkbox(const gchar *name, const gchar *label, gboolean checked); +gchar * +mq_html_input_select(const gchar *name, const gchar *label, + const gchar *selected, + GDestroyNotify destroy_value, GDestroyNotify destroy_label, ...); + #endif -- cgit v0.9.1