aboutsummaryrefslogtreecommitdiff
path: root/src/Content.c
diff options
context:
space:
mode:
authorgoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-09-16 00:09:56 +0000
committergoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-09-16 00:09:56 +0000
commitb0b2c2fab4f256a500334af161adc87babf30d76 (patch)
tree3ed89963497d0e103249905bbb54c3961586a7e2 /src/Content.c
parentb2e36a5dddbc887f7eb786c4770834f224643d5f (diff)
Adding stuff to parameter page.
Tom git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@19 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'src/Content.c')
-rw-r--r--src/Content.c289
1 files changed, 236 insertions, 53 deletions
diff --git a/src/Content.c b/src/Content.c
index 9681a0d..cdcc1e0 100644
--- a/src/Content.c
+++ b/src/Content.c
@@ -16,6 +16,9 @@
#include "cctk.h"
+#include "cctk_Parameter.h"
+#include "cctk_ActiveThorns.h"
+
#include "util_String.h"
#include "http_Request.h"
@@ -43,8 +46,10 @@ struct httpStaticPage
static int RegisterImages(void);
+static int RegisterParameterPages(void);
static int MainPage(cGH *cctkGH, httpRequest *request, void *data);
-static int ParameterPage(cGH *cctkGH, httpRequest *request, void *data);
+static int MainParameterPage(cGH *cctkGH, httpRequest *request, void *data);
+static int ThornParameterPage(cGH *cctkGH, httpRequest *request, void *data);
static int ShowStaticPage(cGH *cctkGH, httpRequest *request, void *data);
@@ -89,9 +94,9 @@ int HTTP_RegisterPages(void)
/* Register the master page. */
HTTP_RegisterPage("/index.html", MainPage, NULL);
- /* Register a duff parameters page */
-
- HTTP_RegisterPage("/parameters", ParameterPage, NULL);
+ /* Register parameter stuff */
+
+ RegisterParameterPages();
/* Register a test page */
HTTP_RegisterPage("/test_page", TestPage, NULL);
@@ -132,45 +137,36 @@ static int CompareStrings(const void *string1, const void *string2)
******************************************************************************/
-static const char *cactus_mainheader = " \
-</HEAD>\n \
-<BODY BGCOLOR=\"#FFFFFF\" \
- link=\"#1B831D\" vlink=\"#768000\" alink=\"#00FF00\">\n \
-<center><A HREF=\"http://www.cactuscode.org/\"> \
-<img src=\"/Images/wwwcactuscodeorg.jpg\" \
- alt=\"Cactus\" BORDER=0></A> \
-</A> \
-<table width=70% border=0><tr><td> \
-\n";
-
-static const char *cactus_header = " \
-</HEAD>\n \
-<BODY BGCOLOR=\"#FFFFFF\" \
- link=\"#1B831D\" vlink=\"#768000\" alink=\"#00FF00\">\n \
-<center> \
-</A> \
-<table width=70% border=0><tr><td> \
-\n";
-
-static const char *cactus_footer = \
-"</table>" \
-"\n \
-<HR size=1>\n \
-<ADDRESS><DIV ALIGN=left>\n \
-<SMALL>\n \
-<A HREF=\"http://www.cactuscode.org/\">Cactus Home Page</A><BR>\n\
-Cactus Web Interface by <A HREF=\"mailto:cactusmaint@cactuscode.org\">The Cactus Team</A><BR>\n\
-</SMALL></DIV></ADDRESS></BODY></HTML>\n";
-
-static const char base_page[] =
-"<HTML>\n<HEAD><TITLE>Test Page for Tom's trivial web server</TITLE></HEAD>\
-<BODY BGCOLOR=\"#FFFFFF\" \
- link=\"#1B831D\" vlink=\"#768000\" alink=\"#00FF00\">\n \
-<center><A HREF=\"http://www.cactuscode.org/\"> \
-<img src=\"/Images/wwwcactuscodeorg.jpg\" \
- alt=\"Cactus\" BORDER=0></A> \
-</A> \
-</BODY></HTML>";
+static const char *cactus_mainheader =
+"</HEAD>\n"
+"<BODY BGCOLOR=\"#FFFFFF\""
+" link=\"#1B831D\" vlink=\"#768000\" alink=\"#00FF00\">\n"
+"<center><A HREF=\"http://www.cactuscode.org/\">"
+"<img src=\"/Images/wwwcactuscodeorg.jpg\""
+" alt=\"Cactus\" BORDER=0></A>"
+"</A>"
+"<table width=70% border=0><tr><td>"
+"\n";
+
+static const char *cactus_header =
+"</HEAD>\n"
+"<BODY BGCOLOR=\"#FFFFFF\""
+" link=\"#1B831D\" vlink=\"#768000\" alink=\"#00FF00\">\n"
+"<center>"
+"</A>"
+"<table width=70% border=0><tr><td>"
+"\n";
+
+static const char *cactus_footer =
+"</table>"
+"\n"
+"<HR size=1>\n"
+"<ADDRESS><DIV ALIGN=left>\n"
+"<SMALL>\n"
+"<A HREF=\"http://www.cactuscode.org/\">Cactus Home Page</A><BR>\n"
+"Cactus Web Interface by <A HREF=\"mailto:cactusmaint@cactuscode.org\">The Cactus Team</A><BR>\n"
+"</SMALL></DIV></ADDRESS></BODY></HTML>\n";
+
/*@@
@routine MainPage
@@ -334,11 +330,45 @@ static int MainPage(cGH *cctkGH, httpRequest *request, void *data)
/******************************************************************************
- ***************************** Parameter Page *********************************
+ ***************************** Parameter Pages ********************************
******************************************************************************/
+
+static int RegisterParameterPages(void)
+{
+ int i;
+ const char *thorn;
+ char pagename[27+20]; /* Thorns have maximum length */
+ char *namecopy;
+
+ /* Two ways to do this - can either just have one function
+ * registered as /Parameters which then checks request->residual,
+ * to see what the actual accessed page is, or can register a
+ * main page and one for each thorn.
+ * Choose the latter for the mo to keep functions smaller, and also
+ * since the compiled thorn list is static at the moment.
+ */
+
+ HTTP_RegisterPage("/Parameters/index.html", MainParameterPage, NULL);
+
+ for (i = 0; i < CCTK_NumCompiledThorns (); i++)
+ {
+ thorn = CCTK_CompiledThorn(i);
+
+ sprintf(pagename,"/Parameters/%s", thorn);
+
+ namecopy = Util_Strdup(thorn);
+
+ HTTP_RegisterPage(pagename, ThornParameterPage, namecopy);
+ }
+
+ return 0;
+}
+
+
+
/*@@
- @routine ParameterPage
+ @routine MainParameterPage
@date Wed Sep 13 23:47:43 2000
@author Tom Goodale
@desc
@@ -351,10 +381,12 @@ static int MainPage(cGH *cctkGH, httpRequest *request, void *data)
@endhistory
@@*/
-static int ParameterPage(cGH *cctkGH, httpRequest *request, void *data)
+static int MainParameterPage(cGH *cctkGH, httpRequest *request, void *data)
{
int retval;
char message[4098];
+ int i;
+ const char *thorn;
/* Status message */
strcpy(message,"HTTP/1.0 200 OK\r\n");
@@ -367,23 +399,174 @@ static int ParameterPage(cGH *cctkGH, httpRequest *request, void *data)
HTTP_Write(request, message, strlen(message));
/* Start the page */
- strcpy(message,"<HTML><HEAD><TITLE>Running CACTUS Status Information</TITLE>\n");
-
+ strcpy(message, "<HTML><HEAD><TITLE>Cactus Parameters Request</TITLE></HEAD>\n");
+ strcat(message, cactus_header);
+ strcat(message,"<BODY>");
HTTP_Write(request, message, strlen(message));
- /* Write out the main header part */
- HTTP_Write(request, cactus_header, strlen(cactus_header));
+ strcpy(message, "<center>");
+ HTTP_Write(request, message, strlen(message));
- /* This is just a test to see what the actual page requested was. */
- sprintf(message, "Residual is '%s'\n", request->residual);
+ strcpy(message,
+ "<center><H2>Check/Modify Parameters</H2></center>\n"
+ "<center>[<A HREF=\"/\">This Simulation Homepage</A>]</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 border=0\n>"
+ "<tr><td><b>Thorn Name</b></td><td><b>Implementation</b></td></tr>\n");
HTTP_Write(request, message, strlen(message));
+ for (i = 0; i < CCTK_NumCompiledThorns (); i++)
+ {
+ thorn = CCTK_CompiledThorn (i);
+
+ if (CCTK_IsThornActive (thorn))
+ {
+ sprintf(message,
+ "<tr><td valign=top><A HREF=\"/Parameters/%s\">%s</A></td>\n"
+ "<td valign=top>%s</td></tr>",
+ thorn, thorn,CCTK_ThornImplementation(thorn));
+ HTTP_Write(request, message, strlen(message));
+
+ }
+ }
+
+ strcpy(message,"</table></BLOCKQUOTE></center>");
+ HTTP_Write(request, message, strlen(message));
+
/* Write out the footer part. */
retval = HTTP_Write(request, cactus_footer, strlen(cactus_footer));
- /* retval = HTTP_Write(request, base_page, strlen(base_page)); */
+ return retval;
+}
+
+static int ThornParameterPage(cGH *cctkGH, httpRequest *request, void *data)
+{
+ int retval;
+ char message[4098];
+ int i;
+ const char *thorn;
+ int first;
+ const cParamData *pData;
+ char *value;
+ const char *prefix;
+
+ 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));
+
+ /* 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));
+
+ strcpy(message, "<center>");
+ HTTP_Write(request, message, strlen(message));
+
+ 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>");
+ 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");
+
+ 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)
+ {
+ first = 0;
+ //strcpy(message,"<FORM ACTION=\"\">");
+ strcpy(message,"");
+
+ value = CCTK_ParameterValString (pData->name, pData->thorn);
+ if(value)
+ {
+ 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));
+
+ }
+
+ 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,"</center>");
+
+ HTTP_Write(request, message, strlen(message));
+
+ /* Write out the footer part. */
+
+ retval = HTTP_Write(request, cactus_footer, strlen(cactus_footer));
return retval;
}