From 819a8ce31288c065be0160d23dd804ec3ea188d7 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 01 Oct 2017 02:39:56 -0400 Subject: mq_html_p(), mq_html_p_free(): New functions --- (limited to 'src/html.c') diff --git a/src/html.c b/src/html.c index 0a0bd40..0425dfe 100644 --- a/src/html.c +++ b/src/html.c @@ -70,6 +70,40 @@ mq_html_document(const gchar *title, ...) } gchar * +mq_html_p(gchar *text) +{ + gsize len; + gchar *p; + gchar *ptr; + + /* Calculate length. */ + len = strlen("

"); + len += strlen(text); + len += strlen("

\n"); + ++len; /* NUL byte */ + + /* Build string. */ + p = g_new(gchar, len); + ptr = g_stpcpy(p, "

"); + ptr = g_stpcpy(ptr, text); + ptr = g_stpcpy(ptr, "

\n"); /* g_stpcpy() adds the NUL. */ + + return p; +} + +gchar * +mq_html_p_free(gchar *text) +{ + gchar *p; + + p = mq_html_p(text); + + g_free(text); + + return p; +} + +gchar * mq_html_container(const gchar *element, ...) { gsize len; -- cgit v0.9.1