diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/html.c | 40 | ||||
-rw-r--r-- | src/html.h | 3 |
2 files changed, 43 insertions, 0 deletions
@@ -536,6 +536,46 @@ mq_html_form(const gchar *submit_label, const gchar *reset_label, ...) } gchar * +mq_html_fieldset(gchar *first_child, ...) +{ + gsize len; + va_list ap; + gchar *child; + gchar *fieldset; + gchar *ptr; + + /* Calculate length. */ + len = strlen("<fieldset>\n"); + len += strlen("<table>\n"); + len += strlen(first_child); + va_start(ap, first_child); + while ((child = va_arg(ap, gchar *))) { + len += strlen(child); + } + va_end(ap); + len += strlen("</table>\n"); + len += strlen("</fieldset>\n"); + ++len; /* NUL byte */ + + /* Build string. */ + fieldset = g_new(gchar, len); + ptr = g_stpcpy(fieldset, "<fieldset>\n"); + ptr = g_stpcpy(ptr, "<table>\n"); + ptr = g_stpcpy(ptr, first_child); + g_free(first_child); + va_start(ap, first_child); + while ((child = va_arg(ap, gchar *))) { + ptr = g_stpcpy(ptr, child); + g_free(child); + } + va_end(ap); + ptr = g_stpcpy(ptr, "</table>\n"); + ptr = g_stpcpy(ptr, "</fieldset>\n"); /* g_stpcpy() adds the NUL. */ + + return fieldset; +} + +gchar * mq_html_input_text(const gchar *name, const gchar *label, const gchar *value) { return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n" @@ -58,6 +58,9 @@ mq_html_form(const gchar *submit_label, const gchar *reset_label, ...) G_GNUC_NULL_TERMINATED; gchar * +mq_html_fieldset(gchar *first_child, ...); + +gchar * mq_html_input_text(const gchar *name, const gchar *label, const gchar *value); gchar * |