diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/html.c | 41 | ||||
-rw-r--r-- | src/html.h | 3 |
2 files changed, 44 insertions, 0 deletions
@@ -27,6 +27,47 @@ #include "html.h" gchar * +mq_html_container(const gchar *element, ...) +{ + gsize len; + va_list ap; + gchar *child; + gchar *container; + gchar *ptr; + + /* Calculate length. */ + len = strlen("<"); + len += strlen(element); + len += strlen(">\n"); + va_start(ap, element); + while ((child = va_arg(ap, gchar *))) { + len += strlen(child); + } + va_end(ap); + len += strlen("</"); + len += strlen(element); + len += strlen(">\n"); + ++len; /* NUL byte */ + + /* Build string. */ + container = g_new(gchar, len); + ptr = g_stpcpy(container, "<"); + ptr = g_stpcpy(ptr, element); + ptr = g_stpcpy(ptr, ">\n"); + va_start(ap, element); + while ((child = va_arg(ap, gchar *))) { + ptr = g_stpcpy(ptr, child); + g_free(child); + } + va_end(ap); + ptr = g_stpcpy(ptr, "</"); + ptr = g_stpcpy(ptr, element); + ptr = g_stpcpy(ptr, ">\n"); /* g_stpcpy() adds the NUL. */ + + return container; +} + +gchar * mq_html_notebook(gboolean vertical, const gchar *name, ...) { gsize name_len; @@ -25,6 +25,9 @@ #include <glib.h> gchar * +mq_html_container(const gchar *element, ...); + +gchar * mq_html_notebook(gboolean vertical, const gchar *name, ...); gchar * |