/*@@ @file Groups.c @date Wed Sep 24 23:47:43 2000 @author Gabrielle Allen @desc Pages about thorns @enddesc @version $Header$ @@*/ #include #include #include "cctk.h" #include "util_String.h" #include "http_Request.h" #include "http_Content.h" static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusConnect_HTTPD_Thorns_c) /******************************************************************** ********************* Local Data Types *********************** ********************************************************************/ /******************************************************************** ********************* Local Routine Prototypes ********************* ********************************************************************/ static int ThornMainPage(const cGH *cctkGH, httpRequest *request, void *data); static int ThornPage(const cGH *cctkGH, httpRequest *request, void *data); /******************************************************************** ********************* Other Routine Prototypes ********************* ********************************************************************/ int HTTPi_RegisterThornPages(void); /******************************************************************** ********************* 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(const cGH *cctkGH, httpRequest *request, void *data) { int i; int retval; int foundone; const char *thorn; char message[4098]; /* 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)); /* Start the page */ strcpy(message,"Cactus Thorns\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, "

Thorns

" "

These pages describe the thorns used in this simulation.

"); retval = HTTP_Write(request, message, strlen(message)); strcpy(message,"\n\n
"); 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, "

Active Thorns

\n" "
\n" "" "\n" "\n" "\n" "\n"); HTTP_Write(request, message, strlen(message)); foundone++; } sprintf(message, "\n" "\n" "\n" "\n", thorn, thorn,CCTK_ThornImplementation(thorn)); HTTP_Write(request, message, strlen(message)); } } if (foundone) { strcpy(message,"
Thorn NameImplementation
%s%s
"); HTTP_Write(request, message, strlen(message)); } strcpy(message,"
"); 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, "

Dormant Thorns

\n" "
" "\n" "\n" "\n" "\n"); HTTP_Write(request, message, strlen(message)); foundone++; } sprintf(message, "\n" "\n" "\n" "\n", thorn, CCTK_ThornImplementation(thorn)); HTTP_Write(request, message, strlen(message)); } } if (foundone) { strcpy(message,"
Thorn NameImplementation
\n" "%s%s
\n
\n"); HTTP_Write(request, message, strlen(message)); } strcpy(message,"
\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(const 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, "Thorn Page : %s\n", thorn); HTTP_Write(request, message, strlen(message)); HTTP_ContentHeader(cctkGH,0,4098,message,NULL); strcat(message,""); HTTP_Write(request, message, strlen(message)); sprintf(message,"

Thorn %s

\n",thorn); HTTP_Write(request, message, strlen(message)); sprintf(message,"

This page will include all the information about thorn" "%s. For now, only information about the parameters is given.

", thorn); sprintf(message,"%s\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; }