aboutsummaryrefslogtreecommitdiff
path: root/src/Parameters.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Parameters.c')
-rw-r--r--src/Parameters.c798
1 files changed, 400 insertions, 398 deletions
diff --git a/src/Parameters.c b/src/Parameters.c
index f9e2c5a..17cc3d5 100644
--- a/src/Parameters.c
+++ b/src/Parameters.c
@@ -34,6 +34,9 @@
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
+#define STRING_NAMESPACE 1
+#include "SStringHTML.h"
+
static const char *rcsid = "$Header$";
CCTK_FILEVERSION(CactusConnect_HTTPD_Parameters_c)
@@ -144,6 +147,34 @@ int HTTPi_RegisterParameterPages(void)
********************************************************************/
+static void
+SendHTTP_Redirect_Header( httpRequest *request )
+{
+ /* Now redirect the browser to the normal page */
+ /* Status message */
+ if(request->http_major_version < 1 ||
+ (request->http_major_version == 1 && request->http_minor_version < 1))
+ {
+ /* Older browsers don't understand 303 */
+ Send_HTTP(request,"HTTP/1.0 302 Found\r\n");
+ }
+ else
+ {
+ Send_HTTP(request,"HTTP/1.0 303 See Other\r\n");
+ }
+}
+
+static void
+SendHTTP_Uauthorized_Header( httpRequest *request )
+{
+ Send_HTTP(request,"HTTP/1.0 401 Unauthorized\r\n");
+
+ Send_HTTP(request,"WWW-Authenticate: Basic realm=\"foo\"\r\n");
+
+ Send_HTTP(request,"Content-Type: text/html\r\n\r\n");
+
+}
+
/******************************************************************************
***************************** Parameter Pages ********************************
******************************************************************************/
@@ -168,53 +199,46 @@ int HTTPi_RegisterParameterPages(void)
@@*/
static int MainParameterPage(const cGH *cctkGH, httpRequest *request, void *data)
{
- int retval;
- char message[4098];
+ int retval = -1;
+ String *message = String_New();
int i;
- const char *thorn;
+ const char *thorn = NULL;
/* avoid compiler warning about unused parameter */
data = data;
- /* Status message */
- strcpy(message,"HTTP/1.0 200 OK\r\n");
-
- HTTP_Write(request, message, strlen(message));
-
- /* Content-Type */
- strcpy(message,"Content-Type: text/html\r\n\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ SendHTTP_OK_Header( request );
+ SetHTML_Doctype( message );
+ Send_HTTP_String(request, message);
/* Start the page */
- strcpy(message, "<HTML><HEAD><TITLE>Cactus Parameters Request</TITLE>\n");
- HTTP_Write(request, message, strlen(message));
-
- strcpy(message,"<HTML>\n");
- HTTP_Write(request, message, strlen(message));
-
- HTTP_ContentHeader(cctkGH,0,4098,message,NULL);
- HTTP_Write(request, message, strlen(message));
-
- strcpy(message, "<center>");
- HTTP_Write(request, message, strlen(message));
-
- strcpy(message,
- "<center><H1>Check/Modify Parameters</H1></center>\n"
- "</center><p>From this page you can check the values \n"
- "of all parameters for the \n"
- "simulation, and modify any parameters which have been designated as <i>steerable</i></p>\n"
- "<p>Parameters can be viewed for all <i>Active Thorns</i>, that is, for thorns which \n"
- "have been activated in the parameter file for the simulation. \n"
- "Select one of the active thorns for this simulation from the list below to \n"
- "view all of its parameters</p>\n"
- "<p>Steerable parameters can be identified by the presence of a form input box, \n"
- "to change the value of a parameter, simply edit the value in the box and press \n"
- " the submit button to register the new values.</p><center>\n"
- "<table cellspacing=5 cellpadding=5 border=0\n>"
- "<tr><th>Thorn Name</th><th>Implementation</th></TR>\n");
-
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "<html><head><title>Cactus Parameters Request</title>\n");
+ SetHTML_HeadHeader( message);
+ Send_HTTP_String(request, message );
+ Truncate( message, 0 );
+
+ Send_HTTP(request, "\n</head>\n<body>\n");
+
+ SetHTML_ContentHeader(cctkGH,0,message,NULL);
+ Send_HTTP_String(request, message);
+
+ Send_HTTP(request,
+ "<h1>Check/Modify Parameters</h1>\n"
+ "<p>From this page you can check the values of all parameters for \n"
+ "the simulation, and modify any parameters which have been \n"
+ "designated as <i>steerable</i></p>\n"
+ "<p>Parameters can be viewed for all <i>Active Thorns</i>, that is,\n"
+ "for thorns which have been activated in the parameter file for the\n"
+ " simulation. \n"
+ "Select one of the active thorns for this simulation from the list \n"
+ "below to view all of its parameters</p>\n"
+ "<p>Steerable parameters can be identified by the presence of a \n"
+ "form input box, to change the value of a parameter, simply edit \n"
+ "the value in the box and press the submit button to register the \n"
+ "new values.</p>\n"
+ "<div class=\"centered\">\n"
+ "<table cellspacing=\"5\" cellpadding=\"5\">\n"
+ "<tr><th>Thorn Name</th><th>Implementation</th></tr>\n");
for (i = 0; i < CCTK_NumCompiledThorns (); i++)
{
@@ -222,25 +246,26 @@ static int MainParameterPage(const cGH *cctkGH, httpRequest *request, void *data
if (CCTK_IsThornActive (thorn))
{
- sprintf(message,
- "<TR>\n"
- "<TD VALIGN=TOP ALIGN=CENTER><A HREF=\"/Parameters/%s/\">%s</A></td>\n"
- "<TD VALIGN=TOP ALIGN=CENTER>%s</TD>\n"
- "</TR>\n",
- thorn, thorn,CCTK_ThornImplementation(thorn));
- HTTP_Write(request, message, strlen(message));
+ SetToCString(message, "<tr>\n<td><a href=\"/Parameters/");
+ ConcatCString(message, thorn);
+ ConcatCString(message, "/\">");
+ ConcatCString(message, thorn);
+ ConcatCString(message, "</a></td>\n<td>");
+ ConcatCString(message, CCTK_ThornImplementation(thorn));
+ ConcatCString(message, "</td>\n</tr>\n");
+ Send_HTTP_String(request, message);
}
}
- strcpy(message,"</table></center>");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request,"</table></div>");
/* Write out the footer part. */
- HTTP_ContentFooter(cctkGH, 0, 4098, message);
- retval = HTTP_Write(request, message, strlen(message));
+ SetHTML_ContentFooter(cctkGH, 0, message);
+ retval = Send_HTTP_String(request, message);
+ String_Delete( message );
return retval;
}
@@ -270,15 +295,16 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
{
int retval=0;
int i;
- char message[4098];
- char menu[4098];
+ String * message = String_New();
+ String * menu = String_New();
+ String * temp = String_New();
const char *thorn, *menuthorn;
int first;
const cParamData *pData;
t_range *range;
char *value;
const httpArg *argument;
- char user[USER_LENGTH+1];
+ char user[USER_LENGTH+1] = EMPTYSTRING;
int notauthorised;
int readonly;
@@ -307,62 +333,24 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
while((argument = HTTP_ArgumentWalk(request, first)) != NULL)
{
first = 0;
- fprintf(stderr, "Setting %s::%s to %s\n", thorn, argument->arg, argument->value);
+ fprintf(stderr, "Setting %s::%s to %s\n", thorn, argument->arg,
+ argument->value);
HTTP_SteerQueue(thorn, argument->arg, argument->value);
}
-
- /* Now redirect the browser to the normal page */
- /* Status message */
- if(request->http_major_version < 1 ||
- (request->http_major_version == 1 && request->http_minor_version < 1))
- {
- /* Older browsers don't understand 303 */
- strcpy(message,"HTTP/1.0 302 Found\r\n");
- }
- else
- {
- strcpy(message,"HTTP/1.0 303 See Other\r\n");
- }
-
- sprintf(message, "%sLocation: /Parameters/%s/\r\n\r\n", message, thorn);
-
- HTTP_Write(request, message, strlen(message));
}
- else
- {
- /* Redirect the browser to the normal page */
- /* Status message */
- if(request->http_major_version < 1 ||
- (request->http_major_version == 1 && request->http_minor_version < 1))
- {
- /* Older browsers don't understand 303 */
- strcpy(message,"HTTP/1.0 302 Found\r\n");
- }
- else
- {
- strcpy(message,"HTTP/1.0 303 See Other\r\n");
- }
+ SendHTTP_Redirect_Header( request );
- sprintf(message, "%sLocation: /Parameters/%s/\r\n\r\n", message, thorn);
+ ConcatCString(message, "Location: /Parameters/");
+ ConcatCString(message, thorn);
+ ConcatCString(message, "/\r\n\r\n");
- HTTP_Write(request, message, strlen(message));
- }
+ Send_HTTP_String(request, message);
}
else
{
- strcpy(message,"HTTP/1.0 401 Unauthorized\r\n");
-
- HTTP_Write(request, message, strlen(message));
-
- strcpy(message,"WWW-Authenticate: Basic realm=\"foo\"\r\n");
-
- HTTP_Write(request, message, strlen(message));
-
- strcpy(message,"Content-Type: text/html\r\n\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ SendHTTP_Uauthorized_Header( request );
- HTTP_Write(request, notauthorized_page, strlen(notauthorized_page));
+ Send_HTTP(request, notauthorized_page);
}
}
@@ -370,24 +358,27 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
{
/* Display the page. */
/* Status message */
- strcpy(message,"HTTP/1.0 200 OK\r\n");
-
- HTTP_Write(request, message, strlen(message));
-
- /* Content-Type */
- strcpy(message,"Content-Type: text/html\r\n\r\n");
+ SendHTTP_OK_Header( request );
- HTTP_Write(request, message, strlen(message));
+ SetHTML_Doctype( message );
+ Send_HTTP_String(request, message);
/* Start the page */
- sprintf(message,
- "<HTML><HEAD><TITLE>Cactus Parameters Request : %s</TITLE></HEAD>\n", thorn);
+ SetToCString(message, "<html><head>\n<title>Cactus Parameters Request : ");
+ ConcatCString(message, thorn);
+ ConcatCString(message, "</title>\n");
+ Send_HTTP_String(request, message );
+
+ SetHTML_HeadHeader( message);
+ Send_HTTP_String(request, message );
+ Truncate( message, 0 );
+
+ Send_HTTP(request, "</head>\n<body>\n");
- HTTP_Write(request, message, strlen(message));
if (CCTK_NumCompiledThorns()>0)
{
- strcpy(menu,"<DT><B>Parameters:</B>\n");
+ SetToCString(menu, "<h3>Parameters:</h3>\n");
}
/* Menu for this page */
for (i = 0; i < CCTK_NumCompiledThorns (); i++)
@@ -395,47 +386,54 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
menuthorn = CCTK_CompiledThorn (i);
if (CCTK_IsThornActive (menuthorn))
{
- sprintf(menu,
- "%s<DT> <A HREF=\"/Parameters/%s/\">%s</A>\n",
- menu,menuthorn, menuthorn);
+ ConcatCString(menu, " <a href=\"/Parameters/");
+ ConcatCString(menu, menuthorn);
+ ConcatCString(menu, "/\">");
+ ConcatCString(menu, menuthorn);
+ ConcatCString(menu, "</a><br />\n");
}
}
- HTTP_ContentHeader(cctkGH,0,4098,message,menu);
- strcat(message,"<BODY>");
- HTTP_Write(request, message, strlen(message));
+ SetHTML_ContentHeader(cctkGH,0,message,menu);
+ Send_HTTP_String(request, message);
if (!CCTK_IsThornActive(thorn))
{
- sprintf(message,"<B> Thorn %s is not active !!!</B><BR>\n",thorn);
- HTTP_Write(request, message, strlen(message));
+ SetToCString(message, "<strong> Thorn ");
+ ConcatCString(message, thorn);
+ ConcatCString(message, " is not active !!!</strong><br />\n");
+ Send_HTTP_String(request, message);
}
else
{
/* Send table of available parameters for given thorn */
/* Steerable parameters can be edited in a FORM. */
- sprintf(message,
- "<center><H1>Check/Modify Parameters</H1>"
- "<H2>Thorn %s</H2></center>\n",
- thorn);
- strcat(message,
- "<p>Parameters in Cactus can be either <i>fixed</i> or <i>steerable</i>. "
- "Steerable parameters are those which can be modified during a "
- "simulation"
- "To change steerable parameters, edit the values and press \n"
- " the submit button."
- "Before applying the new parameter value, Cactus will check that"
- " the parameter lies in the allowed range. Note that there"
- " is currently no log of parameters which have been modified.</p>\n"
- "<p>The tables below show the parameter name, current value and description."
- "The default value of each parameter is shown in brackets at the end of the description.</p>"
- "<center>\n");
-
- HTTP_Write(request, message, strlen(message));
+ SetToCString(message,
+ "<h1>Check/Modify Parameters</h1>\n"
+ "<h2>Thorn ");
+ ConcatCString(message, thorn);
+ ConcatCString(message,
+ "</h2>\n");
+ ConcatCString(message,
+ "<p>Parameters in Cactus can be either <dfn>fixed</dfn> or <dfn>steerable</dfn>. \n"
+ "Steerable parameters are those which can be modified during a simulation.\n"
+ "To change steerable parameters, edit the values and press "
+ " the submit button.\n"
+ "Before applying the new parameter value, Cactus will check that the\n"
+ "parameter lies in the allowed range. \nNote that there"
+ " is currently no log of parameters which have been modified.</p>\n"
+ "<p>The tables below show the parameter name, current value and description.\n"
+ "The default value of each parameter is shown in brackets at the end of the description.</p>"
+ "\n");
+
+ Send_HTTP_String(request, message);
+ Send_HTTP(request, "<div class=\"centered\">\n");
if(!readonly )
{
- sprintf(message,"<FORM ACTION=\"/Parameters/%s/\">",thorn);
- HTTP_Write(request, message, strlen(message));
+ SetToCString(message,"<form action=\"/Parameters/");
+ ConcatCString(message, thorn);
+ ConcatCString(message, "/\">\n");
+ Send_HTTP_String(request, message);
}
/* Walk through all steerable parameters of given implementation. */
@@ -444,7 +442,7 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
while(CCTK_ParameterWalk(first, thorn, NULL, &pData) == 0)
{
first = 0;
- strcpy(message,"");
+ Truncate(message,0);
value = CCTK_ParameterValString (pData->name, pData->thorn);
if(value)
@@ -454,16 +452,18 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
if (nsteerable == 0)
{
- strcat(message,"<h2>Steerable Parameters</h2>");
+ ConcatCString(message,"<h2>Steerable Parameters</h2>\n");
if (readonly)
{
- strcat(message,"<p><i>The following parameters are steerable, "
- "but you do not have authorisation to change them. "
+ ConcatCString(message,
+ "<p><em>The following parameters are steerable, "
+ "but you do not have authorisation to change them. \n"
"To change parameters you must first register on the "
"<a href=\"/control.html\">Simulation Control Page</a>."
- "</i></p>");
+ "</em></p>\n");
}
- strcat(message,"<table cellpadding=5 cellspacing=5>");
+ ConcatCString(message,
+ "<table class=\"paramtable\" cellpadding=\"5\" cellspacing=\"5\">\n");
}
nsteerable++;
@@ -474,102 +474,137 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
/* Steerable boolean */
param_bool =
*((const CCTK_INT *)CCTK_ParameterGet(pData->name,thorn,&param_type));
- sprintf(message,
- "%s<TR>\n"
- "<TD ALIGN=LEFT VALIGN=CENTER>"
- "<A HREF=\"/Parameters/%s/%s\">%s</A></TD>\n"
- "<TD ALIGN=LEFT VALIGN=CENTER>"
- "Yes <INPUT TYPE=\"RADIO\" NAME=\"%s\" %s VALUE=\"1\">"
+ ConcatCString(message, "<tr>\n<td><a href=\"/Parameters/");
+ ConcatCString(message, pData->thorn);
+ ConcatCString(message, "/");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "\">");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "</a></td>\n"
+ "<td>"
+ "Yes \n<input type=\"radio\" name=\"");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "\" ");
+ ConcatCString(message, param_bool ? "checked=\"checked\"" : "");
+ ConcatCString(message, " value=\"1\" />"
"&nbsp;"
- "No <INPUT type=\"RADIO\" name=\"%s\" %s VALUE=\"0\">"
- "</TD>\n"
- "<TD><SMALL>%s (%s)</SMALL></TD>\n"
- "</TR>\n",
- message,pData->thorn,pData->name,
- pData->name,pData->name,
- param_bool ? "checked" : "", pData->name,
- param_bool ? "" : "checked",pData->description,pData->defval);
+ "No \n<input type=\"radio\" name=\"");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "\" ");
+ ConcatCString(message, param_bool ? "" : "checked=\"checked\"");
+ ConcatCString(message, " value=\"0\" />"
+ "</td>\n"
+ "<td class=\"description\">");
+ SetToEncodedHTMLCString( temp, pData->description );
+ Concat(message, temp );
+ ConcatCString(message, " (");
+ ConcatCString(message, pData->defval);
+ ConcatCString(message, ")</td>\n"
+ "</tr>\n");
}
else if (pData->type == PARAMETER_KEYWORD)
{
/* Steerable keyword */
CCTK_ParameterGet(pData->name,thorn,&param_type);
- sprintf(message,"%s<TR>\n"
- "<TD ALIGN=LEFT VALIGN=CENTER>"
- "<A HREF=\"/Parameters/%s/%s\">%s</A></TD>\n"
- "<TD ALIGN=LEFT VALIGN=CENTER>\n",
- message,pData->thorn,pData->name,pData->name);
- sprintf(message,"%s <SELECT name=%s size=1>\n",
- message,pData->name);
+ ConcatCString(message,"<tr>\n<td><a href=\"/Parameters/");
+ ConcatCString(message, pData->thorn);
+ ConcatCString(message, "/");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "\">");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "</a></td>\n");
+ ConcatCString(message,"<td> <select name=\"");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "\" size=\"1\">\n");
for(range = pData->range; range ; range = range->next)
{
if (CCTK_Equals(value,range->range))
{
- sprintf(message,"%s<OPTION SELECTED>%s\n",
- message, range->range);
+ ConcatCString(message, "<option selected>");
+ ConcatCString(message, range->range);
+ ConcatCString(message, "\n");
}
else
{
- sprintf(message,"%s<OPTION>%s\n",
- message,range->range);
+ ConcatCString(message, "<option>");
+ ConcatCString(message, range->range);
+ ConcatCString(message, "\n");
}
}
- strcat(message,"</SELECT>\n");
- sprintf(message,"%s</TD>\n"
- "<TD><SMALL>%s (%s)</SMALL></TD>\n"
- "</TR>\n",
- message,pData->description,pData->defval);
+ ConcatCString(message,"</select>\n");
+ ConcatCString(message,"</td>\n<td class=\"description\">");
+ SetToEncodedHTMLCString( temp, pData->description );
+ Concat(message, temp);
+ ConcatCString(message, " (");
+ SetToEncodedHTMLCString( temp, pData->defval );
+ Concat(message, temp);
+ ConcatCString(message, ")</td>\n</tr>\n");
}
else
{
/* Steerable nonboolean */
- sprintf(message,
- "%s<TR>\n"
- "<TD align=left valign=center>"
- "<A HREF=\"/Parameters/%s/%s\">%s</A></TD>\n"
- "<TD align=left valign=center>"
- "<INPUT TYPE=TEXT NAME=\"%s\" VALUE=\"%s\"></TD>\n"
- "<TD><SMALL>%s (%s)</SMALL></TD>\n</TR>\n",
- message, pData->thorn, pData->name,
- pData->name, pData->name,
- value, pData->description,pData->defval);
+ ConcatCString(message, "<tr>\n<td><a href=\"/Parameters/");
+ ConcatCString(message, pData->thorn);
+ ConcatCString(message, "/");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "\">");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "</a></td>\n"
+ "<td><input type=\"text\" name=\"");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "\" value=\"");
+ ConcatCString(message, value);
+ ConcatCString(message, "\" /></td>\n"
+ "<td class=\"description\">");
+ SetToEncodedHTMLCString( temp, pData->description );
+ Concat(message, temp);
+ ConcatCString(message, " (");
+ SetToEncodedHTMLCString( temp, pData->defval );
+ Concat(message, temp);
+ ConcatCString(message, ")</td>\n</tr>\n");
}
}
else
{
/* Steerable but no authority */
- sprintf(message,
- "%s<TR><TD align=left valign=center>"
- "<A HREF=\"/Parameters/%s/%s\">%s</A></TD>\n"
- "<TD align=left valign=center>%s</TD><TD>"
- "<SMALL>%s (%s)</SMALL></TD></TR>\n",
- message, pData->thorn, pData->name,
- pData->name, value, pData->description,pData->defval);
+ ConcatCString(message, "<tr><td><a href=\"/Parameters/");
+ ConcatCString(message, pData->thorn);
+ ConcatCString(message, "/");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "\">");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "</a></td>\n<td>");
+ ConcatCString(message, value);
+ ConcatCString(message, "</td><td class=\"description\">");
+ SetToEncodedHTMLCString( temp, pData->description );
+ Concat(message, temp);
+ ConcatCString(message, " (");
+ SetToEncodedHTMLCString( temp, pData->defval );
+ Concat(message, temp);
+ ConcatCString(message, ")</td></tr>\n");
}
}
free (value);
}
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP_String(request, message);
}
if (nsteerable>0)
{
- strcpy(message, "</TABLE>\n");
+ Send_HTTP(request, "</table>\n");
}
else
{
- strcpy(message, "<P>This thorn has no steerable parameters.</P>\n");
+ Send_HTTP(request, "<p>This thorn has no steerable parameters.</p>\n");
}
- HTTP_Write(request, message, strlen(message));
if(!readonly && nsteerable>0)
{
- strcpy(message,
- "<INPUT TYPE=SUBMIT VALUE=\"Update all parameters\">\n"
- "</FORM>\n");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request,
+ "<input type=\"submit\" value=\"Update all parameters\" />\n"
+ "</form>\n");
}
@@ -579,7 +614,7 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
while(CCTK_ParameterWalk(first, thorn, NULL, &pData) == 0)
{
first = 0;
- strcpy(message,"");
+ Truncate(message,0);
value = CCTK_ParameterValString (pData->name, pData->thorn);
if(value)
@@ -589,8 +624,8 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
if (nfixed == 0)
{
- strcat(message,"<h2>Fixed Parameters</h2>"
- "<table cellpadding=5 cellspacing=5>");
+ ConcatCString(message,"<h2>Fixed Parameters</h2>\n"
+ "<table class=\"paramtable\" cellpadding=\"5\" cellspacing=\"5\">");
}
nfixed++;
@@ -601,51 +636,54 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
strcmp(pData->name,"encryption_scheme")))
{
- sprintf(message,
- "%s<TR>\n"
- "<TD align=left valign=center>"
- "<A HREF=\"/Parameters/%s/%s\">%s</A></TD>\n"
- "<TD>%s</TD>\n"
- "<TD><SMALL>%s (%s)</SMALL></TD>\n"
- "</TR>\n",
- message, pData->thorn, pData->name,
- pData->name, value, pData->description,pData->defval);
+ ConcatCString(message, "<tr>\n<td><a href=\"/Parameters/");
+ ConcatCString(message, pData->thorn);
+ ConcatCString(message, "/");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "\">");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "</a></td>\n"
+ "<td>");
+ ConcatCString(message, value);
+ ConcatCString(message, "</td>\n<td class=\"description\">");
+ SetToEncodedHTMLCString( temp, pData->description );
+ Concat(message, temp);
+ ConcatCString(message, " (");
+ SetToEncodedHTMLCString( temp, pData->defval );
+ Concat(message, temp);
+ ConcatCString(message, ")</td>\n</tr>\n");
}
}
free(value);
}
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP_String(request, message);
}
if (nfixed>0)
{
- strcpy(message, "</TABLE>\n");
+ Send_HTTP(request, "</table>\n");
}
else
{
- strcpy(message, "<p>This thorn has no fixed parameters.</p>\n");
+ Send_HTTP(request, "<p>This thorn has no fixed parameters.</p>\n");
}
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "</div>\n");
}
- strcpy(message,"</center>");
-
- HTTP_Write(request, message, strlen(message));
/* Write out the footer part. */
- HTTP_ContentFooter(cctkGH, 0, 4098, message);
- retval = HTTP_Write(request, message, strlen(message));
+ SetHTML_ContentFooter(cctkGH, 0, message);
+ retval = Send_HTTP_String(request, message);
} /* n_arguments > 0 */
-
+ String_Delete( message );
+ String_Delete( menu );
+ String_Delete( temp );
return retval;
}
-
-
-
/*@@
@routine ParameterPage
@date Thu Sep 21 15:13:55 2000
@@ -664,25 +702,19 @@ static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *dat
static int ParameterPage(const cGH *cctkGH, httpRequest *request, void *data)
{
int retval=0;
- char message[10000];
- char menu[10000];
+ String * message = String_New();
+ String * menu = String_New();
+ String * temp = String_New();
int first;
- const cParamData *pData;
+ const cParamData *pData = (cParamData *)data;
const cParamData *pDataWalk=NULL;
t_range *range;
char *value;
const httpArg *argument;
- char user[USER_LENGTH+1];
-
- int notauthorised;
- int readonly;
-
-
- pData = (cParamData *)data;
-
- notauthorised = HTTP_AuthenticateBasic(request, "user", user, USER_LENGTH);
-
- readonly = notauthorised;
+ char user[USER_LENGTH+1] = EMPTYSTRING;
+ int notauthorised = HTTP_AuthenticateBasic(request, "user", user,
+ USER_LENGTH);
+ int readonly = notauthorised;
if(request->n_arguments > 0)
{
@@ -697,84 +729,46 @@ static int ParameterPage(const cGH *cctkGH, httpRequest *request, void *data)
while((argument = HTTP_ArgumentWalk(request, first)) != NULL)
{
first = 0;
- fprintf(stderr, "Setting %s::%s to %s\n", pData->thorn, argument->arg, argument->value);
+ fprintf(stderr, "Setting %s::%s to %s\n", pData->thorn,
+ argument->arg, argument->value);
HTTP_SteerQueue(pData->thorn, argument->arg, argument->value);
}
-
- /* Now redirect the browser to the normal page */
- /* Status message */
- if(request->http_major_version < 1 ||
- (request->http_major_version == 1 && request->http_minor_version < 1))
- {
- /* Older browsers don't understand 303 */
- strcpy(message,"HTTP/1.0 302 Found\r\n");
- }
- else
- {
- strcpy(message,"HTTP/1.0 303 See Other\r\n");
- }
-
- sprintf(message, "%sLocation: /Parameters/%s/\r\n\r\n", message, pData->thorn);
-
- HTTP_Write(request, message, strlen(message));
}
- else
- {
- /* Redirect the browser to the normal page */
- /* Status message */
- if(request->http_major_version < 1 ||
- (request->http_major_version == 1 && request->http_minor_version < 1))
- {
- /* Older browsers don't understand 303 */
- strcpy(message,"HTTP/1.0 302 Found\r\n");
- }
- else
- {
- strcpy(message,"HTTP/1.0 303 See Other\r\n");
- }
-
- sprintf(message, "%sLocation: /Parameters/%s/\r\n\r\n", message, pData->thorn);
+ SendHTTP_Redirect_Header( request );
+ ConcatCString(message, "Location: /Parameters/");
+ ConcatCString(message, pData->thorn);
+ ConcatCString(message, "/\r\n\r\n");
- HTTP_Write(request, message, strlen(message));
- }
+ Send_HTTP_String(request, message);
}
else
{
- strcpy(message,"HTTP/1.0 401 Unauthorized\r\n");
-
- HTTP_Write(request, message, strlen(message));
-
- strcpy(message,"WWW-Authenticate: Basic realm=\"foo\"\r\n");
-
- HTTP_Write(request, message, strlen(message));
-
- strcpy(message,"Content-Type: text/html\r\n\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ SendHTTP_Uauthorized_Header( request );
- HTTP_Write(request, notauthorized_page, strlen(notauthorized_page));
+ Send_HTTP(request, notauthorized_page);
}
-
}
else
{
/* Display the page. */
- /* Status message */
- strcpy(message,"HTTP/1.0 200 OK\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ SendHTTP_OK_Header( request );
- /* Content-Type */
- strcpy(message,"Content-Type: text/html\r\n\r\n");
+ SetHTML_Doctype( message );
+ Send_HTTP_String(request, message);
+ /* Start the page */
+ Send_HTTP(request, "<html><head>\n");
- HTTP_Write(request, message, strlen(message));
+ SetToCString(message, "<title>Cactus Parameter Request : ");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "</title>\n");
- /* Start the page */
- sprintf(message,
- "<HTML><HEAD><TITLE>Cactus Parameter Request : %s</TITLE>"
- "</HEAD>\n", pData->name);
+ Send_HTTP_String(request, message);
- HTTP_Write(request, message, strlen(message));
+ SetHTML_HeadHeader( message);
+ Send_HTTP_String(request, message );
+ Truncate( message, 0 );
+
+ Send_HTTP(request,"</head>\n<body>\n");
/* Menu for this page */
@@ -783,26 +777,39 @@ static int ParameterPage(const cGH *cctkGH, httpRequest *request, void *data)
{
if (first==1)
{
- sprintf(menu,"<DT><B>%s:</B>\n",pDataWalk->thorn);
+ ConcatCString(menu,"<h3>");
+ ConcatCString(menu, pDataWalk->thorn);
+ ConcatCString(menu, ":</h3>\n");
}
first = 0;
- sprintf(menu,
- "%s <DT> <A HREF=\"/Parameters/%s/%s\">%s</A>\n",
- menu,pDataWalk->thorn,pDataWalk->name,pDataWalk->name);
+ ConcatCString(menu, " <a href=\"/Parameters/");
+ ConcatCString(menu, pDataWalk->thorn);
+ ConcatCString(menu, "/");
+ ConcatCString(menu, pDataWalk->name);
+ ConcatCString(menu, "\">");
+ ConcatCString(menu, pDataWalk->name);
+ ConcatCString(menu, "</a><br />\n");
}
- HTTP_ContentHeader(cctkGH,0,4098,message,menu);
- HTTP_Write(request, message, strlen(message));
-
- sprintf(message,"<CENTER><H1>%s: %s</H1></CENTER>\n",pData->thorn,pData->name);
- HTTP_Write(request, message, strlen(message));
-
- sprintf(message,
- "<CENTER><P>Return to all parameters for this "
- "<A HREF=\"Parameters/%s\">thorn</A>.</P></CENTER> ",
- CCTK_ThornImplementation(pData->thorn));
-
- HTTP_Write(request, message, strlen(message));
+ SetHTML_ContentHeader(cctkGH,0,message,menu);
+ Send_HTTP_String(request, message);
+
+ SetToCString(message,"<h1>");
+ ConcatCString(message, pData->thorn);
+ ConcatCString(message, ": ");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "</h1>\n");
+ Send_HTTP_String(request, message);
+
+ SetToCString(message,
+ "<div class=\"centered\">Return to all parameters for this \n"
+ "<a href=\"Parameters/");
+ ConcatCString(message,
+ CCTK_ThornImplementation(pData->thorn));
+ ConcatCString(message,
+ "\">thorn</a>.</div> ");
+
+ Send_HTTP_String(request, message);
value = CCTK_ParameterValString (pData->name, pData->thorn);
@@ -813,155 +820,150 @@ static int ParameterPage(const cGH *cctkGH, httpRequest *request, void *data)
strcmp(pData->name,"encryption_scheme")))
{
- sprintf(message,"<CENTER><TABLE CELLPADDING=5 CELLSPACING=5 "
- " BORDER=1 NOSHADE>\n"
- "<TR>\n"
- "<TD ALIGN=RIGHT VALIGN=TOP><B>Name:</B></TD>\n"
- "<TD>%s</TD>\n"
- "</TR>\n"
- "<TR>\n"
- "<TD ALIGN=RIGHT VALIGN=TOP><B>Thorn:</B></TD>\n"
- "<TD>%s</TD>\n"
- "</TR>\n"
- "<TR>\n"
- "<TD ALIGN=RIGHT VALIGN=TOP><B>Implementation:</B></TD>\n"
- "<TD>%s</TD>\n"
- "</TR>\n"
- "<TR>\n"
- "<TD ALIGN=RIGHT VALIGN=TOP><B>Current value:</B></TD>\n"
- "<TD>%s</TD>\n"
- "</TR>"
- "<TR>\n"
- "<TD ALIGN=RIGHT VALIGN=TOP><B>Description:</B></TD>\n"
- "<TD>%s</TD>\n"
- "</TR>"
- "<TR>"
- "<TD ALIGN=RIGHT VALIGN=TOP><B>Default:</B></TD>\n"
- "<TD>%s</TD>\n"
- "</TR>",
- pData->name,pData->thorn,CCTK_ThornImplementation(pData->thorn),
- value,pData->description,pData->defval);
- HTTP_Write(request, message, strlen(message));
-
- strcpy(message,"<TR>\n<TD ALIGN=RIGHT VALIGN=TOP>\n"
- "<B>Steerable:</B></TD>\n<TD>");
+ SetToCString(message,"<div class=\"centered\">\n"
+ "<table class=\"thornparams\" cellpadding=\"5\" cellspacing=\"5\" "
+ " border=\"1\">\n" );
+ ConcatCString(message, "<tr>\n<th>Name:</th>\n<td>");
+ ConcatCString(message, pData->name);
+ ConcatCString(message, "</td>\n</tr>\n" );
+ ConcatCString(message, "<tr>\n<th>Thorn:</th>\n<td>");
+ ConcatCString(message, pData->thorn);
+ ConcatCString(message, "</td>\n</tr>\n" );
+ ConcatCString(message, "<tr>\n<th>Implementation:</th>\n<td>");
+ ConcatCString(message, CCTK_ThornImplementation(pData->thorn));
+ ConcatCString(message, "</td>\n</tr>\n" );
+ ConcatCString(message, "<tr>\n<th>Current value:</th>\n<td>");
+ ConcatCString(message, value);
+ ConcatCString(message, "</td>\n</tr>\n" );
+ ConcatCString(message, "<tr>\n<th>Description::</th>\n<td>");
+ SetToEncodedHTMLCString( temp, pData->description );
+ Concat(message, temp);
+ ConcatCString(message, "</td>\n</tr>\n" );
+ ConcatCString(message, "<tr>\n<th>Default:::</th>\n<td>");
+ SetToEncodedHTMLCString( temp, pData->defval );
+ Concat(message, temp);
+ ConcatCString(message, "</td>\n</tr>");
+ Send_HTTP_String(request, message);
+ SetToCString(message,"<tr>\n<th>Steerable:</th>\n<td>");
switch(pData->steerable)
{
case CCTK_STEERABLE_ALWAYS :
- strcat(message,"Always");
+ ConcatCString(message,"Always");
break;
case CCTK_STEERABLE_NEVER :
- strcat(message,"Never");
+ ConcatCString(message,"Never");
break;
case CCTK_STEERABLE_RECOVER :
- strcat(message,"Recovery");
+ ConcatCString(message,"Recovery");
break;
default :
- strcat(message,"Not matched");
+ ConcatCString(message,"Not matched");
}
- strcat(message,"</TD>\n</TR>\n");
- HTTP_Write(request, message, strlen(message));
+ ConcatCString(message,"</td>\n</tr>\n");
+ Send_HTTP_String(request, message);
- strcpy(message,"<TR>\n"
- "<TD ALIGN=RIGHT VALIGN=TOP><B>Type:</B></TD>\n<TD>\n");
+ SetToCString(message,"<tr>\n"
+ "<th>Type:</th>\n<td>");
switch(pData->type)
{
case PARAMETER_BOOLEAN :
- strcat(message,"Boolean");
+ ConcatCString(message,"Boolean");
break;
case PARAMETER_REAL :
- strcat(message,"Real");
+ ConcatCString(message,"Real");
break;
case PARAMETER_INTEGER :
- strcat(message,"Integer");
+ ConcatCString(message,"Integer");
break;
case PARAMETER_SENTENCE :
- strcat(message,"Sentence");
+ ConcatCString(message,"Sentence");
break;
case PARAMETER_STRING :
- strcat(message,"String");
+ ConcatCString(message,"String");
break;
case PARAMETER_KEYWORD :
- strcat(message,"Keyword");
+ ConcatCString(message,"Keyword");
break;
default :
- strcat(message,"Not matched");
+ ConcatCString(message,"Not matched");
}
- strcat(message,"</TD>\n</TR>\n");
+ ConcatCString(message,"</td>\n</tr>\n");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP_String(request, message);
- strcpy(message,"<TR><TD ALIGN=RIGHT VALIGN=TOP><B>Scope:</B></TD><TD>");
+ SetToCString(message,"<tr><th>Scope:</th><td>");
switch(pData->scope)
{
case SCOPE_GLOBAL :
- strcat(message,"Global</TD></TR>");
+ ConcatCString(message,"Global</td></tr>\n");
break;
case SCOPE_RESTRICTED :
- strcat(message,"Restricted</TD></TR>");
+ ConcatCString(message,"Restricted</td></tr>\n");
break;
case SCOPE_PRIVATE :
- strcat(message,"Private</TD></TR>");
+ ConcatCString(message,"Private</td></tr>\n");
break;
default :
- strcat(message,"Not matched</TD></TR>");
+ ConcatCString(message,"Not matched</td></tr>\n");
}
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP_String(request, message);
- strcpy(message,"");
+ Truncate(message,0);
first = 1;
for(range = pData->range; range ; range = range->next)
{
if (first==1)
{
- sprintf(message,
- "%s<TR>\n"
- "<TD ALIGN=RIGHT VALIGN=TOP>\n"
- "<B>Range:</B>"
- "</TD>\n<TD><DL>\n",
- message);
+ ConcatCString(message,
+ "<tr>\n"
+ "<th>\n"
+ "Range:"
+ "</th>\n<td><dl>\n"
+ );
}
first = 0;
- sprintf(message,"%s<DT>%s\n<DD>%s\n",
- message,range->range,range->description);
+ ConcatCString(message, "<dt>");
+ ConcatCString(message, range->range);
+ ConcatCString(message, "</dt>\n<dd>");
+ SetToEncodedHTMLCString( temp, range->description );
+ Concat(message, temp);
+ ConcatCString(message, "</dd>\n");
if (!CCTK_Equals(range->origin,pData->thorn))
{
- sprintf(message,"%s<BR>[Extended by thorn %s]\n",
- message,range->origin);
+ ConcatCString(message, "<br />[Extended by thorn ");
+ ConcatCString(message, range->origin);
+ ConcatCString(message, "]\n");
}
}
if(first==0)
{
- strcat(message,"</DL></TD>\n</TR>\n");
+ ConcatCString(message, "</dl></td>\n</tr>\n");
}
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP_String(request, message);
- sprintf(message,
- "<TR>\n"
- "<TD ALIGN=RIGHT VALIGN=TOP><B>Times Set:</B></TD>\n"
- "<TD>%d</TD>\n"
- "</TR>\n"
- "</TABLE></CENTER>\n",
- pData->n_set);
- HTTP_Write(request, message, strlen(message));
+ SetToCString(message, "<tr>\n<th>Times Set:</th>\n<td>");
+ ConcatDecimal(message, pData->n_set);
+ ConcatCString(message, "</td>\n</tr>\n</table>\n</div>\n");
+ Send_HTTP_String(request, message);
}
else
{
- strcpy(message,"<p>Hidden parameter, information is not available</p>");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request,"<p>Hidden parameter, information is not available</p>\n");
}
/* Write out the footer part. */
- HTTP_ContentFooter(cctkGH, 0, 4098, message);
- retval = HTTP_Write(request, message, strlen(message));
+ SetHTML_ContentFooter(cctkGH, 0, message);
+ retval = Send_HTTP_String(request, message);
}
-
+ String_Delete( message );
+ String_Delete( menu );
+ String_Delete( temp );
return retval;
}