cscvs to tla changeset 4
[onak.git] / getcgi.c
index 47a94b294090c9a21da443247168aa706a72030a..26c3c50f5f52cf2b6bce08a0b962458640aa2f81 100644 (file)
--- a/getcgi.c
+++ b/getcgi.c
@@ -25,7 +25,7 @@ char *txt2html(const char *string)
        char *ptr = NULL;
        char *nextptr = NULL;
 
-       buf[0] = 0;
+       memset(buf, 0, 1024);
 
        ptr = strchr(string, '<');
        if (ptr != NULL) {
@@ -57,8 +57,42 @@ char *txt2html(const char *string)
        return buf;
 }
 
+/*
+ *     start_html - Start HTML output.
+ *     @title: The title for the HTML.
+ *
+ *     Takes a title string and starts HTML output, including the
+ *     Content-Type header all the way up to <BODY>.
+ */
+void start_html(const char *title)
+{
+       puts("Content-Type: text/html; charset=utf8\n");
+       puts("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2 Final//EN'>");
+       puts("<HTML>");
+       puts("<HEAD>");
+       printf("<TITLE>%s</TITLE>\n", title);
+       puts("</HEAD>");
+       puts("<BODY>");
+
+       return;
+}
+
+/*
+ *     end_html - End HTML output.
+ *
+ *     Ends HTML output - closes the BODY and HTML tags.
+ */
+void end_html(void)
+{
+       puts("</BODY>");
+       puts("</HTML>");
+
+       return;
+}
+
+
 /* Convert a two-char hex string into the char it represents */
-char x2c(char *what) 
+char x2c(const char *what) 
 {
        register char digit;