diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-09-30 19:40:20 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-09-30 19:40:20 (EDT) |
commit | bc3add50886602f1cc1ea248305d4cc49c3619c8 (patch) | |
tree | f7c648eaa862d454e4a67bdf7316dd14d88ece3c /src | |
parent | 89f9769dd414de3ae090b30dda04cb01cb9034b0 (diff) | |
download | marquee-bc3add50886602f1cc1ea248305d4cc49c3619c8.zip marquee-bc3add50886602f1cc1ea248305d4cc49c3619c8.tar.gz marquee-bc3add50886602f1cc1ea248305d4cc49c3619c8.tar.bz2 |
mq_html_container(): New function
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 * |