aboutsummaryrefslogtreecommitdiff
path: root/src/Groups.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Groups.c')
-rw-r--r--src/Groups.c93
1 files changed, 50 insertions, 43 deletions
diff --git a/src/Groups.c b/src/Groups.c
index cd4fa5c..eb3f248 100644
--- a/src/Groups.c
+++ b/src/Groups.c
@@ -14,10 +14,11 @@
#include "cctk.h"
#include "util_String.h"
-
-#include "CactusConnect/HTTPD/src/http_Request.h"
+#include "HTTPDUtils.h"
+/*
+ * #include "CactusConnect/HTTPD/src/http_Request.h"
#include "CactusConnect/HTTPD/src/http_Content.h"
-
+*/
static const char *rcsid = "$Header$";
CCTK_FILEVERSION(CactusConnect_HTTPDExtra_Groups_c)
@@ -76,10 +77,10 @@ int HTTPUTILS_RegisterPages (void)
@@*/
static int MessagesPage (const cGH *GH, httpRequest *request, void *data)
{
- int retval;
- size_t message_board_len;
- char message[1024], currtime[64], currdate[64];
- const char *const_string, *name, *memo;
+ int retval = 0;
+ char currtime[64], currdate[64];
+ String *message = String_New();
+ const char *temp, *name, *memo;
static char *message_board = NULL;
@@ -93,6 +94,7 @@ static int MessagesPage (const cGH *GH, httpRequest *request, void *data)
if (name && *name && memo && *memo)
{
+ size_t message_board_len = 0;
/* concatenate new message, labeled with current date/time, to the
message board */
Util_CurrentTime (sizeof (currtime), currtime);
@@ -115,7 +117,7 @@ static int MessagesPage (const cGH *GH, httpRequest *request, void *data)
if (message_board)
{
sprintf (message_board + message_board_len,
- "<P><STRONG>%s</STRONG> %s %s<BR>\n\n<I>%s</I></P>",
+ "<p><strong>%s</strong> %s %s<br />\n\n<em>%s</em></p>",
name, currtime, currdate, memo);
}
}
@@ -125,60 +127,65 @@ static int MessagesPage (const cGH *GH, httpRequest *request, void *data)
(request->http_major_version == 1 && request->http_minor_version < 1))
{
/* Older browsers don't understand 303 */
- const_string = "HTTP/1.0 302 Found\r\n"
+ temp = "HTTP/1.0 302 Found\r\n"
"Location: /Messages/index.html\r\n\r\n";
}
else
{
- const_string = "HTTP/1.0 303 See Other\r\n"
+ temp = "HTTP/1.0 303 See Other\r\n"
"Location: /Messages/index.html\r\n\r\n";
}
- HTTP_Write (request, const_string, strlen (const_string));
+ Send_HTTP (request, temp);
return (0);
}
/* Status message */
- const_string = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n";
- HTTP_Write (request, const_string, strlen (const_string));
+ SendHTTP_OK_Header( request );
+
+ SetHTML_Doctype( message );
+ Send_HTTP_String(request, message);
/* Start the page */
- const_string = "<HTML><HEAD><TITLE>CACTUS Messages</TITLE>\n";
- HTTP_Write (request, const_string, strlen (const_string));
+ Send_HTTP (request, "<html><head><title>CACTUS Messages</title>\n" );
+
+ SetHTML_HeadHeader( message);
+ Send_HTTP_String(request, message );
/* Write out the header part */
- HTTP_ContentHeader (GH, 0, sizeof (message), message, NULL);
- HTTP_Write (request, message, strlen (message));
-
- const_string = "<CENTER><H1>Message Board</H1></CENTER>\n"
- "<P>This page can be used to post messages during a "
- "simulation. At the moment the messages will disappear "
- "when the simulation finishes, but soon there will be an "
- "option to save them to a file.</P>\n"
- "<CENTER><TABLE><FORM ACTION=\"/Messages/\">\n"
- "<TR><TD>Name:</TD>"
- "<TD><INPUT TYPE=TEXT SIZE=40 MAXLENGTH=100 NAME=\"name\" "
- "VALUE=\"\"></TD></TR>\n"
- "<TR><TD VALIGN=TOP>Message:</TD><TD>"
- "<TEXTAREA NAME=\"memo\" ROWS=10 COLS=40></TEXTAREA>\n"
- "</TD></TR></TABLE>"
- "<INPUT TYPE=SUBMIT VALUE=\"Submit Message\"></FORM>\n"
- "<TABLE WIDTH=80%%><TR><TD><H2>Messages:</H2></TD></TR>"
- "<TR><TD><TABLE WIDTH=\"100%%\" CELLPADDING=5 CELLSPACING=5>"
- "<TR><TD BGCOLOR=\"#E9F4D3\">";
- HTTP_Write (request, const_string, strlen (const_string));
-
- const_string = message_board ? message_board :
+ SetHTML_ContentHeader(GH, 0, message, NULL);
+ Send_HTTP_String(request, message);
+
+ Send_HTTP (request,
+ "<h1>Message Board</h1>\n"
+ "<p>This page can be used to post messages during a \n"
+ "simulation. At the moment the messages will disappear \n"
+ "when the simulation finishes, but soon there will be an \n"
+ "option to save them to a file.</p>\n"
+ "<center><table><form action=\"/Messages/\">\n"
+ "<tr><td>Name:</td>"
+ "<td><input type=\"text\" size=\"40\" maxlength=\"100\" name=\"name\" "
+ "value=\"\"></td></tr>\n"
+ "<tr><td valign=\"top\">Message:</td><td>"
+ "<textarea name=\"memo\" rows=\"10\" cols=\"40\"></textarea>\n"
+ "</td></tr></table>\n"
+ "<input type=\"submit\" value=\"Submit Message\"></form>\n"
+ "<table width=\"80%\"><tr><td>\n"
+ "<h2>Messages:</h2></td></tr>\n"
+ "<tr><td><table width=\"100%\" cellpadding=\"5\" cellspacing=\"5\">"
+ "<tr><td bgcolor=\"#E9F4D3\">" );
+
+ temp = message_board ? message_board :
"No messages yet ... use the form above to add one";
- HTTP_Write (request, const_string, strlen (const_string));
+ Send_HTTP (request, temp );
- const_string = "</TD></TR></TABLE></TD></TR></TABLE></CENTER>";
- HTTP_Write (request, const_string, strlen (const_string));
+ Send_HTTP (request, "</td></tr></table></td></tr></table></center>" );
/* Write out the footer part. */
- HTTP_ContentFooter (GH, 0, sizeof (message), message);
- retval = HTTP_Write (request, message, strlen (message));
+ SetHTML_ContentFooter(GH, 0, message);
+ retval = Send_HTTP_String(request, message);
- return (retval);
+ String_Delete( message );
+ return retval;
}