aboutsummaryrefslogtreecommitdiff
path: root/src/Content.c
diff options
context:
space:
mode:
authorgoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-09-16 14:23:37 +0000
committergoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-09-16 14:23:37 +0000
commit645206e8e1e76a4206ab2d421f1d8345a41ddb1d (patch)
tree9a5ef8777a4e712c6405506ea1a969ad3e9932d5 /src/Content.c
parent3ab68329120dcbc0a6ceff2dabdd1c6318ae17ab (diff)
Parameter steering stuff.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@26 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'src/Content.c')
-rw-r--r--src/Content.c250
1 files changed, 166 insertions, 84 deletions
diff --git a/src/Content.c b/src/Content.c
index 080a13c..e7d1541 100644
--- a/src/Content.c
+++ b/src/Content.c
@@ -24,6 +24,9 @@
#include "http_Request.h"
#include "http_Auth.h"
+#include "http_Steer.h"
+
+#include "cctk_Arguments.h"
static char *rcsid = "$Header$";
@@ -72,6 +75,25 @@ static int CompareStrings(const void *string1, const void *string2);
********************************************************************/
/*@@
+ @routine HTTP_ContentWork
+ @date Sat Sep 16 15:22:59 2000
+ @author Tom Goodale
+ @desc
+ Does any work which needs to be done by the content pages.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+void HTTP_ContentWork(CCTK_ARGUMENTS)
+{
+ HTTP_SteerDispatch();
+}
+
+ /*@@
@routine HTTP_RegisterPages
@date Wed Sep 13 23:47:43 2000
@author Tom Goodale
@@ -377,9 +399,12 @@ static int RegisterParameterPages(void)
@calls
@calledby
@history
-
+ @hdate Sat Sep 16 15:13:16 2000 @hauthor Tom Goodale
+ @hdesc Copied content format from original http thorn
+ developed by Werner Benger, with the aesthetic
+ enhancements of Gabrielle Allen, John Shalf and
+ Ed Seidel.
@endhistory
-
@@*/
static int MainParameterPage(cGH *cctkGH, httpRequest *request, void *data)
{
@@ -450,6 +475,28 @@ static int MainParameterPage(cGH *cctkGH, httpRequest *request, void *data)
return retval;
}
+ /*@@
+ @routine ThornParameterPage
+ @date Sat Sep 16 15:13:55 2000
+ @author Tom Goodale
+ @desc
+ Parameter page for a thorn.
+ Checks to see if it is a setting request or
+ an info request and behaves accordingly.
+
+ Copied content format from original http thorn
+ developed by Werner Benger, with the aesthetic
+ enhancements of Gabrielle Allen, John Shalf and
+ Ed Seidel.
+
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
static int ThornParameterPage(cGH *cctkGH, httpRequest *request, void *data)
{
int retval;
@@ -460,115 +507,150 @@ static int ThornParameterPage(cGH *cctkGH, httpRequest *request, void *data)
const cParamData *pData;
char *value;
const char *prefix;
+ const httpArg *argument;
thorn = (const char *)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));
+ if(request->n_arguments > 0)
+ {
+ /* This is a parameter set request */
- /* Start the page */
- sprintf(message,
- "<HTML><HEAD><TITLE>Cactus Parameters Request : %s</TITLE></HEAD>\n", thorn);
+ /* Queue parameters for steering */
+ first = 1;
+ while(argument = HTTP_ArgumentWalk(request, first))
+ {
+ first = 0;
+ fprintf(stderr, "Setting %s::%s to %s\n", thorn, argument->arg, argument->value);
+ HTTP_SteerQueue(thorn, argument->arg, argument->value);
+ }
- strcat(message, cactus_header);
- strcat(message,"<BODY>");
- HTTP_Write(request, message, strlen(message));
+ /* 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");
+ }
- strcpy(message, "<center>");
- HTTP_Write(request, message, strlen(message));
+ sprintf(message, "%sLocation: /Parameters/%s/\r\n\r\n", message, thorn);
- if (!CCTK_IsThornActive(thorn))
- {
- sprintf(message,"<BLOCKQUOTE><P><B> Thorn %s is not active !!!</B><BR></BLOCKQUOTE>\n",thorn);
HTTP_Write(request, message, strlen(message));
- }
+
+ }
else
- {
- strcpy(message,"<BLOCKQUOTE>");
+ {
+ /* Display the page. */
+ /* Status message */
+ strcpy(message,"HTTP/1.0 200 OK\r\n");
+
HTTP_Write(request, message, strlen(message));
- /* Send table of available parameters for given thorn */
- /* Steerable parameters can be edited in a FORM. */
- sprintf(message,
- "<center><H2>Check/Modify Parameters for Thorn <FONT COLOR=RED> %s</FONT></H2></center>\n",
- thorn);
- strcat(message,
- "<center>[<A HREF=\"/\">This Simulation Homepage</A>]</center>\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"
- "<p>Return to <a href=\"../\">active thorn list</a></p>\n"
- "<TABLE BORDER= 0 CELLSPACING=5 CELLPADDING=5>\n");
+ /* Content-Type */
+ strcpy(message,"Content-Type: text/html\r\n\r\n");
HTTP_Write(request, message, strlen(message));
- sprintf(message,"<FORM ACTION=\"/Parameters/%s/\"><TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT VALUE=\"Update all parameters\"></TD></TR>\n", thorn);
+ /* Start the page */
+ sprintf(message,
+ "<HTML><HEAD><TITLE>Cactus Parameters Request : %s</TITLE></HEAD>\n", thorn);
+
+ strcat(message, cactus_header);
+ strcat(message,"<BODY>");
HTTP_Write(request, message, strlen(message));
- /* Walk through all parameters of given implementation. */
- first = 1;
+ strcpy(message, "<center>");
+ HTTP_Write(request, message, strlen(message));
- while(CCTK_ParameterWalk(first, thorn, NULL, &pData) == 0)
+ if (!CCTK_IsThornActive(thorn))
{
- first = 0;
- //strcpy(message,"<FORM ACTION=\"\">");
- strcpy(message,"");
+ sprintf(message,"<BLOCKQUOTE><P><B> Thorn %s is not active !!!</B><BR></BLOCKQUOTE>\n",thorn);
+ HTTP_Write(request, message, strlen(message));
+ }
+ else
+ {
+ strcpy(message,"<BLOCKQUOTE>");
+ HTTP_Write(request, message, strlen(message));
+
+ /* Send table of available parameters for given thorn */
+ /* Steerable parameters can be edited in a FORM. */
+ sprintf(message,
+ "<center><H2>Check/Modify Parameters for Thorn <FONT COLOR=RED> %s</FONT></H2></center>\n",
+ thorn);
+ strcat(message,
+ "<center>[<A HREF=\"/\">This Simulation Homepage</A>]</center>\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"
+ "<p>Return to <a href=\"../\">active thorn list</a></p>\n"
+ "<TABLE BORDER= 0 CELLSPACING=5 CELLPADDING=5>\n");
- value = CCTK_ParameterValString (pData->name, pData->thorn);
- if(value)
+ HTTP_Write(request, message, strlen(message));
+
+ sprintf(message,"<FORM ACTION=\"/Parameters/%s/\"><TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT VALUE=\"Update all parameters\"></TD></TR>\n", thorn);
+ HTTP_Write(request, message, strlen(message));
+
+ /* Walk through all parameters of given implementation. */
+ first = 1;
+
+ while(CCTK_ParameterWalk(first, thorn, NULL, &pData) == 0)
{
- if (pData->scope == SCOPE_PRIVATE)
- {
- prefix = pData->thorn;
- }
- else
+ first = 0;
+ //strcpy(message,"<FORM ACTION=\"\">");
+ strcpy(message,"");
+
+ value = CCTK_ParameterValString (pData->name, pData->thorn);
+ if(value)
{
- prefix = CCTK_ThornImplementation (pData->thorn);
+ if (pData->scope == SCOPE_PRIVATE)
+ {
+ prefix = pData->thorn;
+ }
+ else
+ {
+ prefix = CCTK_ThornImplementation (pData->thorn);
+ }
+
+ if (pData->steerable == CCTK_STEERABLE_ALWAYS)
+ {
+ sprintf(message,
+ "%s<TR><TD align=left valign=center><font color=red>%s::%s</font></TD>"
+ "<TD align=left valign=center><INPUT TYPE=TEXT NAME=\"%s\" VALUE=\"%s\">"
+ "</TD></TR>\n",
+ message,prefix, pData->name, pData->name, value);
+ }
+ else
+ {
+ sprintf(message,
+ "%s<TR><TD align=left valign=center>%s::%s</TD>"
+ "<TD>%s</TD></TR>\n",
+ message, prefix,pData->name, value);
+ }
+ free (value);
}
+ HTTP_Write(request, message, strlen(message));
- if (pData->steerable == CCTK_STEERABLE_ALWAYS)
- {
- sprintf(message,
- "%s<TR><TD align=left valign=center><font color=red>%s::%s</font></TD>"
- "<TD align=left valign=center><INPUT TYPE=TEXT NAME=\"%s\" VALUE=\"%s\">"
- "</TD></TR>\n",
- message,prefix, pData->name, pData->name, value);
- }
- else
- {
- sprintf(message,
- "%s<TR><TD align=left valign=center>%s::%s</TD>"
- "<TD>%s</TD></TR>\n",
- message, prefix,pData->name, value);
- }
- free (value);
- }
- HTTP_Write(request, message, strlen(message));
+ }
- }
+ strcpy(message,
+ "<TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT VALUE=\"Update all parameters\"></TD></TR>\n"
+ "</TABLE><P></BLOCKQUOTE>\n"
+ "</FORM>\n");
+ HTTP_Write(request, message, strlen(message));
+ }
- strcpy(message,
- "<TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT VALUE=\"Update all parameters\"></TD></TR>\n"
- "</TABLE><P></BLOCKQUOTE>\n"
- "</FORM>\n");
+ strcpy(message,"</center>");
+
HTTP_Write(request, message, strlen(message));
- }
-
- strcpy(message,"</center>");
-
- HTTP_Write(request, message, strlen(message));
-
- /* Write out the footer part. */
-
- retval = HTTP_Write(request, cactus_footer, strlen(cactus_footer));
+ /* Write out the footer part. */
+
+ retval = HTTP_Write(request, cactus_footer, strlen(cactus_footer));
+ } /* n_arguments > 0 */
return retval;
}