chiark / gitweb /
Kill off cgi_attr(), cgi_opentag() and cgi_closetag() which aren't
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 31 Jan 2009 12:45:22 +0000 (12:45 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 31 Jan 2009 12:45:22 +0000 (12:45 +0000)
actually used (?any more).

http://code.google.com/p/disorder/issues/detail?id=24

lib/cgi.c
lib/cgi.h
libtests/t-cgi.c

index 7758b38a291d1d42d2dc991fca26fcfdf3c56058..42d599f2fa6a845809f3ae309d15a10636b0b39b 100644 (file)
--- 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, "</%s>", name);
-}
-
 /** @brief Construct a URL
  * @param url Base URL
  * @param ... Name/value pairs for constructed query string
index 8f85e5c3f2ae3f62bd7ae1cfc5059e8ace4c70fc..dd27fa218542f209e71be86a0ded1c552048fe7c 100644 (file)
--- 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);
index 44b7c2972088b855aa4a52ad5b41ade9a43b6bab..109a38afa1d62287d74c3ccf28465ee3ade1350c 100644 (file)
@@ -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("\"&\""), "&#34;&#38;&#34;");
   check_string(cgi_sgmlquote("\xC2\xA3"), "&#163;");
 
-  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, "<element foo=bar foo=\"has space\" foo=\"has &#34;quotes&#34;\">");
-  
-  dynstr_init(d);
-  cgi_opentag(sink_dynstr(d), "element",
-             "foo", (char *)NULL,
-             (char *)NULL);
-  dynstr_terminate(d);
-  check_string(d->vec, "<element foo>");
-  
-  dynstr_init(d);
-  cgi_closetag(sink_dynstr(d), "element");
-  dynstr_terminate(d);
-  check_string(d->vec, "</element>");
-
   check_string(cgi_makeurl("http://example.com/", (char *)NULL),
               "http://example.com/");
   check_string(cgi_makeurl("http://example.com/",