aboutsummaryrefslogtreecommitdiff
path: root/src/Thorns.c
diff options
context:
space:
mode:
authorallen <allen@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-09-28 04:36:02 +0000
committerallen <allen@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-09-28 04:36:02 +0000
commit672cdf715e314fec2df6ba3b6eb8248d1112db44 (patch)
treefdb44d8e49be065d373157ad5ca7d2b4bb43e6ef /src/Thorns.c
parentaa69bad8e6317c8192c5e89bd88188c2fe511b51 (diff)
New headers for all pages.
Added new Thorns pages, for now these just have the parameters, but there will be an easy way for thorns to add their own stuff git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@89 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'src/Thorns.c')
-rw-r--r--src/Thorns.c302
1 files changed, 302 insertions, 0 deletions
diff --git a/src/Thorns.c b/src/Thorns.c
new file mode 100644
index 0000000..e84150a
--- /dev/null
+++ b/src/Thorns.c
@@ -0,0 +1,302 @@
+ /*@@
+ @file Groups.c
+ @date Wed Sep 24 23:47:43 2000
+ @author Gabrielle Allen
+ @desc
+ Pages about thorns
+ @enddesc
+ @version $Header$
+ @@*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include "cctk.h"
+
+#include "util_String.h"
+
+#include "http_Request.h"
+#include "http_Content.h"
+
+static char *rcsid = "$Header$";
+
+CCTK_FILEVERSION(DevThorns_httpd_Thorns_c)
+
+/********************************************************************
+ ********************* Local Data Types ***********************
+ ********************************************************************/
+
+/********************************************************************
+ ********************* Local Routine Prototypes *********************
+ ********************************************************************/
+
+static int ThornMainPage(cGH *cctkGH, httpRequest *request, void *data);
+static int ThornPage(cGH *cctkGH, httpRequest *request, void *data);
+
+
+/********************************************************************
+ ********************* Other Routine Prototypes *********************
+ ********************************************************************/
+
+/********************************************************************
+ ********************* Local Data *****************************
+ ********************************************************************/
+
+/********************************************************************
+ ********************* External Routines **********************
+ ********************************************************************/
+
+ /*@@
+ @routine HTTPi_RegisterThornsPages
+ @date Wed Sep 14 11:29:43 2000
+ @author Gabrielle Allen
+ @desc
+ Httpd utils registration routine.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+int HTTPi_RegisterThornPages(void)
+{
+ int i;
+ char pagename[27+20]; /* Thorns have maximum length */
+ char *namecopy;
+ const char *thorn;
+
+ /* Register the group info page. */
+ HTTP_RegisterPage("/Thorns", ThornMainPage, NULL);
+
+ HTTP_ContentLink("/Thorns/index.html", "Thorns",
+ "Information from Flesh and individual thorns",
+ HTTP_QUICKLINK);
+
+ for (i = 0; i < CCTK_NumCompiledThorns (); i++)
+ {
+ thorn = CCTK_CompiledThorn(i);
+
+ sprintf(pagename,"/Thorns/%s", thorn);
+
+ namecopy = Util_Strdup(thorn);
+
+ HTTP_RegisterPage(pagename, ThornPage, namecopy);
+ }
+
+ return 0;
+}
+
+/********************************************************************
+ ********************* Local Routines *************************
+ ********************************************************************/
+
+
+/******************************************************************************
+ *************************** Thorn Page **************************************
+ ******************************************************************************/
+
+ /*@@
+ @routine ThornMainPage
+ @date Thu Sep 14 23:47:43 2000
+ @author Gabrielle Allen
+ @desc
+ Displays the thorn main page.
+ @enddesc
+ @calls
+ @calledby
+@@*/
+static int ThornMainPage(cGH *cctkGH, httpRequest *request, void *data)
+{
+ int i;
+ int retval;
+ int foundone;
+ const char *thorn;
+ char message[4098];
+
+ /* 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 */
+ strcpy(message,"<HTML><HEAD><TITLE>Cactus Thorns</TITLE>\n");
+
+ HTTP_Write(request, message, strlen(message));
+
+ /* HTTP_Write out the header part. */
+
+ HTTP_ContentHeader(cctkGH,0,strlen(message),message,NULL);
+
+ retval = HTTP_Write(request, message, strlen(message));
+
+ strcpy(message, "<center><h1>Thorns</h1></center>"
+ "<p>These pages describe the thorns used in this simulation.</p>");
+ retval = HTTP_Write(request, message, strlen(message));
+
+
+ strcpy(message,"<TABLE><TR><TD VALIGN=TOP ALIGN=LEFT>");
+ retval = HTTP_Write(request, message, strlen(message));
+
+ foundone = 0;
+ for (i = 0; i < CCTK_NumCompiledThorns (); i++)
+ {
+ thorn = CCTK_CompiledThorn (i);
+ if (CCTK_IsThornActive (thorn))
+ {
+ if (!foundone)
+ {
+ strcpy(message,
+ "<H2>Active Thorns</H2>\n"
+ "<CENTER>\n"
+ "<TABLE ALIGN=TOP cellspacing=0 cellpadding=5 border=0\n>"
+ "<TR>\n"
+ "<TH ALIGN=LEFT>Thorn Name</TH>\n"
+ "<TH ALIGN=LEFT>Implementation</TH>\n"
+ "</TR>\n");
+ HTTP_Write(request, message, strlen(message));
+ foundone++;
+ }
+ sprintf(message,
+ "<TR>\n"
+ "<TD VALIGN=TOP ALIGN=LEFT><A HREF=\"/Thorns/%s/\">%s</A></td>\n"
+ "<TD VALIGN=TOP ALIGN=LEFT>%s</TD>\n"
+ "</TR>\n",
+ thorn, thorn,CCTK_ThornImplementation(thorn));
+ HTTP_Write(request, message, strlen(message));
+ }
+ }
+
+ if (foundone)
+ {
+ strcpy(message,"</TABLE></CENTER>");
+ HTTP_Write(request, message, strlen(message));
+ }
+
+
+ strcpy(message,"</TD><TD ALIGN=LEFT VALIGN=TOP>");
+ retval = HTTP_Write(request, message, strlen(message));
+
+
+ foundone = 0;
+ for (i = 0; i < CCTK_NumCompiledThorns (); i++)
+ {
+ thorn = CCTK_CompiledThorn (i);
+ if (!CCTK_IsThornActive (thorn))
+ {
+
+ if (!foundone)
+ {
+ strcpy(message,
+ "<H2>Dormant Thorns</H2>\n"
+ "<CENTER><TABLE CELL SPACING=0 cellpadding=5 border=0\n>"
+ "<TR>\n"
+ "<TH ALIGN=LEFT>Thorn Name</TH>\n"
+ "<TH ALIGN=LEFT>Implementation</TH>\n"
+ "</TR>\n");
+ HTTP_Write(request, message, strlen(message));
+ foundone++;
+ }
+
+ sprintf(message,
+ "<TR>\n"
+ "<TD VALIGN=TOP ALIGN=LEFT>\n"
+ "%s</td>\n"
+ "<TD VALIGN=TOP ALIGN=LEFT>%s</TD>\n"
+ "</TR>\n",
+ thorn, thorn,CCTK_ThornImplementation(thorn));
+ HTTP_Write(request, message, strlen(message));
+
+ }
+ }
+
+ if (foundone)
+ {
+ strcpy(message,"</TABLE>\n</CENTER>\n");
+ HTTP_Write(request, message, strlen(message));
+ }
+
+ strcpy(message,"</TD>\n</TR>\n</TABLE>\n");
+
+ retval = HTTP_Write(request, message, strlen(message));
+
+ /* Write out the footer part. */
+
+ HTTP_ContentFooter(cctkGH,0,strlen(message),message);
+ retval = HTTP_Write(request, message, strlen(message));
+
+ return retval;
+}
+
+
+
+ /*@@
+ @routine ThornPage
+ @date Sun Sep 24 15:13:55 2000
+ @author Gabrielle Allen
+ @desc
+ Individual thorn information
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+static int ThornPage(cGH *cctkGH, httpRequest *request, void *data)
+{
+ int retval=0;
+ char message[4098];
+ const char *thorn;
+
+ thorn = (const char *)data;
+
+ 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>Thorn Page : %s</TITLE></HEAD>\n", thorn);
+
+ HTTP_Write(request, message, strlen(message));
+
+ HTTP_ContentHeader(cctkGH,0,4098,message,NULL);
+
+ strcat(message,"<BODY>");
+ HTTP_Write(request, message, strlen(message));
+
+ sprintf(message,"<CENTER><H1>Thorn %s</H1></CENTER>\n",thorn);
+ HTTP_Write(request, message, strlen(message));
+
+ sprintf(message,"<P>This page will include all the information about thorn"
+ "%s. For now, only information about the parameters is given.</p>",
+ thorn);
+
+ sprintf(message,"%s<UL>\n"
+ "<LI> <A HREF=\"/Parameters/%s\">Parameters</A>\n"
+ "</UL>\n",
+ message,thorn);
+ HTTP_Write(request, message, strlen(message));
+
+ /* Write out the footer part. */
+
+ HTTP_ContentFooter(cctkGH, 0, 4098, message);
+ retval = HTTP_Write(request, message, strlen(message));
+
+ return retval;
+}
+