5b6d828c2dfe2ec1d26b2bf33f7bde9d1d9850fb
larrym
  Thu Jun 14 09:59:02 2012 -0700
refactor BODY code; add class='cgi' so we can special case dynamic code
diff --git src/lib/htmshell.c src/lib/htmshell.c
index fd08ee8..2bd191f 100644
--- src/lib/htmshell.c
+++ src/lib/htmshell.c
@@ -426,30 +426,44 @@
 if(expires != NULL)
     printf("expires=%s; ", expires);
 
 if(path != NULL)
     printf("path=%s; ", encoded_path);
 
 if(domain != NULL)
     printf("domain=%s; ", domain);
 
 if(isSecure == TRUE)
     printf("secure");
 
 printf("\n");
 }
 
+void printBodyTag(FILE *f)
+{
+// print starting BODY tag, including any appropriate attributes (class, background and bgcolor). 
+fprintf(f, "<BODY");
+if (htmlFormClass == NULL )
+    fprintf(f, " CLASS=\"cgi\"");
+else
+    fprintf(f, " CLASS=\"cgi %s\"", htmlFormClass);
+if (htmlBackground != NULL )
+    fprintf(f, " BACKGROUND=\"%s\"", htmlBackground);
+if (gotBgColor)
+    fprintf(f, " BGCOLOR=\"#%X\"", htmlBgColor);
+fputs(">\n",f);
+}
 
 void _htmStartWithHead(FILE *f, char *head, char *title, boolean printDocType, int dirDepth)
 /* Write out bits of header that both stand-alone .htmls
  * and CGI returned .htmls need, including optional head info */
 {
 if (printDocType)
     {
 //#define TOO_TIMID_FOR_CURRENT_HTML_STANDARDS
 #ifdef TOO_TIMID_FOR_CURRENT_HTML_STANDARDS
     fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n", f);
 #else///ifndef TOO_TIMID_FOR_CURRENT_HTML_STANDARDS
     char *browserVersion;
     if (btIE == cgiClientBrowser(&browserVersion, NULL, NULL) && *browserVersion < '8')
         fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n", f);
     else
@@ -458,39 +472,31 @@
     //fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n",f);
 #endif///ndef TOO_TIMID_FOR_CURRENT_HTML_STANDARDS
     }
 fputs("<HTML>", f);
 fprintf(f,"<HEAD>\n%s<TITLE>%s</TITLE>\n", head, title);
 fprintf(f, "\t<META http-equiv=\"Content-Script-Type\" content=\"text/javascript\">\n");
 if (htmlStyle != NULL)
     fputs(htmlStyle, f);
 if (htmlStyleSheet != NULL)
     fprintf(f,"<link href=\"%s\" rel=\"stylesheet\" type=\"text/css\">\n"
         , htmlStyleSheet);  
 if (htmlStyleTheme != NULL)
     fputs(htmlStyleTheme, f);
 
 fputs("</HEAD>\n\n",f);
-fputs("<BODY",f);
-if (htmlFormClass != NULL )
-    fprintf(f, " CLASS=\"%s\"", htmlFormClass);
-if (htmlBackground != NULL )
-    fprintf(f, " BACKGROUND=\"%s\"", htmlBackground);
-if (gotBgColor)
-    fprintf(f, " BGCOLOR=\"#%X\"", htmlBgColor);
-fputs(">\n",f);
-
+printBodyTag(f);
 htmlWarnBoxSetup(f);
 }
 
 
 void htmlStart(char *title)
 /* Write the start of an html from CGI */
 {
 puts("Content-Type:text/html");
 puts("\n");
 _htmStartWithHead(stdout, "", title, TRUE, 1);
 }
 
 void htmStartWithHead(FILE *f, char *head, char *title)
 /* Write the start of a stand alone .html file, plus head info */
 {
@@ -596,34 +602,31 @@
 param title - The HTML page title
 param head - The head text: can be a refresh directive or javascript
 param method - The function pointer to execute in the middle
 param method - The browser request method to use
  */
 void htmShellWithHead( char *title, char *head, void (*doMiddle)(), char *method)
 {
 /* Preamble. */
 dnaUtilOpen();
 
 puts("Content-Type:text/html");
 puts("\n");
 
 puts("<HTML>");
 printf("<HEAD>%s<TITLE>%s</TITLE>\n</HEAD>\n\n", head, title);
-if (htmlBackground == NULL)
-    puts("<BODY>\n");
-else
-    printf("<BODY BACKGROUND=\"%s\">\n", htmlBackground);
+printBodyTag(stdout);
 
 htmlWarnBoxSetup(stdout);// Sets up a warning box which can be filled with errors as they occur
 
 /* Call wrapper for error handling. */
 htmEmptyShell(doMiddle, method);
 
 /* Post-script. */
 htmlEnd();
 }
 
 /* Include an HTML file in a CGI */
 void htmlIncludeFile(char *path)
 {
 char *str = NULL;
 size_t len = 0;