From 454b204000d870c9fa74a13e997964fe3f01edfa Mon Sep 17 00:00:00 2001 Message-Id: <454b204000d870c9fa74a13e997964fe3f01edfa.1713547955.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 31 Jan 2009 12:45:22 +0000 Subject: [PATCH] Kill off cgi_attr(), cgi_opentag() and cgi_closetag() which aren't actually used (?any more). Organization: Straylight/Edgeware From: Richard Kettlewell http://code.google.com/p/disorder/issues/detail?id=24 --- lib/cgi.c | 48 ------------------------------------------------ lib/cgi.h | 3 --- libtests/t-cgi.c | 22 ---------------------- 3 files changed, 73 deletions(-) diff --git a/lib/cgi.c b/lib/cgi.c index 7758b38..42d599f 100644 --- a/lib/cgi.c +++ b/lib/cgi.c @@ -256,54 +256,6 @@ char *cgi_sgmlquote(const char *src) { return d->vec; } -/** @brief Write a CGI attribute - * @param output Where to send output - * @param name Attribute name - * @param value Attribute value - */ -void cgi_attr(struct sink *output, const char *name, const char *value) { - /* Try to avoid needless quoting */ - if(!value[strspn(value, "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789")]) - sink_printf(output, "%s=%s", name, value); - else - sink_printf(output, "%s=\"%s\"", name, cgi_sgmlquote(value)); -} - -/** @brief Write an open tag - * @param output Where to send output - * @param name Element name - * @param ... Attribute name/value pairs - * - * The name/value pair list is terminated by a single (char *)0. - */ -void cgi_opentag(struct sink *output, const char *name, ...) { - va_list ap; - const char *n, *v; - - sink_printf(output, "<%s", name); - va_start(ap, name); - while((n = va_arg(ap, const char *))) { - sink_printf(output, " "); - v = va_arg(ap, const char *); - if(v) - cgi_attr(output, n, v); - else - sink_printf(output, n); - } - va_end(ap); - sink_printf(output, ">"); -} - -/** @brief Write a close tag - * @param output Where to send output - * @param name Element name - */ -void cgi_closetag(struct sink *output, const char *name) { - sink_printf(output, "", name); -} - /** @brief Construct a URL * @param url Base URL * @param ... Name/value pairs for constructed query string diff --git a/lib/cgi.h b/lib/cgi.h index 8f85e5c..dd27fa2 100644 --- a/lib/cgi.h +++ b/lib/cgi.h @@ -28,9 +28,6 @@ void cgi_init(void); const char *cgi_get(const char *name); void cgi_set(const char *name, const char *value); char *cgi_sgmlquote(const char *src); -void cgi_attr(struct sink *output, const char *name, const char *value); -void cgi_opentag(struct sink *output, const char *name, ...); -void cgi_closetag(struct sink *output, const char *name); char *cgi_makeurl(const char *url, ...); char *cgi_thisurl(const char *url); void cgi_clear(void); diff --git a/libtests/t-cgi.c b/libtests/t-cgi.c index 44b7c29..109a38a 100644 --- a/libtests/t-cgi.c +++ b/libtests/t-cgi.c @@ -35,7 +35,6 @@ static void input_from(const char *s) { } static void test_cgi(void) { - struct dynstr d[1]; setenv("REQUEST_METHOD", "GET", 1); setenv("QUERY_STRING", "foo=bar&a=b+c&c=x%7ey", 1); @@ -112,27 +111,6 @@ static void test_cgi(void) { check_string(cgi_sgmlquote("\"&\""), ""&""); check_string(cgi_sgmlquote("\xC2\xA3"), "£"); - dynstr_init(d); - cgi_opentag(sink_dynstr(d), "element", - "foo", "bar", - "foo", "has space", - "foo", "has \"quotes\"", - (char *)NULL); - dynstr_terminate(d); - check_string(d->vec, ""); - - dynstr_init(d); - cgi_opentag(sink_dynstr(d), "element", - "foo", (char *)NULL, - (char *)NULL); - dynstr_terminate(d); - check_string(d->vec, ""); - - dynstr_init(d); - cgi_closetag(sink_dynstr(d), "element"); - dynstr_terminate(d); - check_string(d->vec, ""); - check_string(cgi_makeurl("http://example.com/", (char *)NULL), "http://example.com/"); check_string(cgi_makeurl("http://example.com/", -- [mdw]