From 2276a1f342ce58d4d7f6111b169df0b0d562a7a4 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 01 Oct 2017 02:08:56 -0400 Subject: mq_html_document(): New function --- (limited to 'src/html.c') diff --git a/src/html.c b/src/html.c index bf4f18c..0a0bd40 100644 --- a/src/html.c +++ b/src/html.c @@ -23,10 +23,53 @@ #include #include +#include #include "html.h" gchar * +mq_html_document(const gchar *title, ...) +{ + gsize len; + va_list ap; + gchar *child; + gchar *document; + gchar *ptr; + + /* Calculate length. */ + len = strlen("\n\n\n\n"); + len += strlen(title); + len += strlen("\n\n\n"); + va_start(ap, title); + while ((child = va_arg(ap, gchar *))) { + len += strlen(child); + } + va_end(ap); + len += strlen("\n\n"); + ++len; /* NUL byte */ + + /* Build string. */ + document = g_new(gchar, len); + ptr = g_stpcpy(document, "\n\n\n\n"); + ptr = g_stpcpy(ptr, title); + ptr = g_stpcpy(ptr, "\n\n\n"); + va_start(ap, title); + while ((child = va_arg(ap, gchar *))) { + ptr = g_stpcpy(ptr, child); + g_free(child); + } + va_end(ap); + ptr = g_stpcpy(ptr, "\n\n"); /* g_stpcpy() adds NUL. */ + + return document; +} + +gchar * mq_html_container(const gchar *element, ...) { gsize len; -- cgit v0.9.1