/*@@ @file Headers.c @date Wed Sep 17 23:47:43 2000 @author Gabrielle Allen @desc Functions to return standard headers and footers for HTML pages @enddesc @version $Header$ @@*/ #include "cctk.h" #include "util_String.h" #include "SString_Namespace.h" #define EMPTYSTRING { '\0' } static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusConnect_HTTPD_Headers_c) /******************************************************************** ********************* Local Data Types *********************** ********************************************************************/ extern struct httpLink *ContentLinks; struct httpLink { struct httpLink *next; char *URL; char *name; char *description; int flags; }; /******************************************************************** ********************* Local Routine Prototypes ********************* ********************************************************************/ /******************************************************************** ********************* Other Routine Prototypes ********************* ********************************************************************/ /******************************************************************** ********************* Local Data ***************************** ********************************************************************/ static const char *cactus_styles = "\n"; static const char *cactus_footer = "\n\n" "\n\n" "\n\n" "\n" "

\n" "" "\"www.CactusCode.org\"\n" "" "Cactus Web Interface by \n" "The Cactus Team
\n" "About this Server\n" "
\n" "\n" "\n"; static const char * cactus_doctype = "\n" "\n"; /******************************************************************** ********************* External Routines ********************** ********************************************************************/ void HTTP_SetHeadInfo( String *header) { SetToCString( header, cactus_styles ); ConcatCString( header, "\n"); } void HTTP_SetDoctype( String *header) { SetToCString( header, cactus_doctype ); } /*@@ @routine HTTP_ContentHeader @date Sat Sep 16 15:22:59 2000 @author Gabrielle Allen @desc Returns header for HTML pages @enddesc @calls @calledby @history @endhistory @@*/ extern void CCTK_GetRunTitleString( String *s ); int HTTP_SetContentHeaderString(const cGH *GH, int choice, String *header, const String *menu) { String *title = String_New(); String *quicklinks = String_New(); char parfile[200] = EMPTYSTRING; char currentdate[50] = EMPTYSTRING; char currenttime[50] = EMPTYSTRING; struct httpLink *link; char *file; char *dir; Truncate( header,0); if (choice == 0) { ConcatCString( header, "\n" "\n" "\n
\n" "

Master Run Page

\n"); } if(ContentLinks) { SetToCString( quicklinks,"

Options:

\n"); for(link = ContentLinks; link; link=link->next) { ConcatCString(quicklinks, "URL); ConcatCString(quicklinks, "\">"); ConcatCString(quicklinks, link->name); ConcatCString(quicklinks, "
\n"); } } if (choice == 0) { /* Find strings needed for nonmain-page headers */ CCTK_GetRunTitleString(title); CCTK_ParameterFilename(sizeof(parfile),parfile); Util_SplitFilename(&dir,&file,parfile); Util_CurrentDate(sizeof(currentdate),currentdate); Util_CurrentTime(sizeof(currenttime),currenttime); /* Build the header */ ConcatCString( header, "\n" "

Environment:

\n" "Time: "); ConcatCString( header, currenttime ); ConcatCString( header, "
\n" "Date: " ); ConcatCString( header, currentdate ); ConcatCString( header, "
\n" ); ConcatCString( header, "

Simulation:

\n" ""); Concat( header, title ); ConcatCString( header, "
\n" ""); ConcatCString( header, file ); ConcatCString( header, "
\n" "Iteration: "); ConcatDecimal( header, GH ? GH->cctk_iteration : 0 ); ConcatCString( header, "
\nPhysical time: "); ConcatFormattedDouble( header, GH ? GH->cctk_time : 0, 4, 2, SFMT_DEFAULT ); ConcatCString( header, "
\n"); if (ContentLinks) { Concat( header, quicklinks); } if (menu) { Concat( header, menu); } ConcatCString( header, "
\n\n"); } String_Delete( quicklinks ); String_Delete( title ); return Length(header); } /*@@ @routine HTTP_ContentFooter @date Sat Sep 16 15:22:59 2000 @author Tom Goodale @desc Returns footer for HTML pages @enddesc @calls @calledby @history @endhistory @@*/ int HTTP_SetContentFooterString(const cGH *GH, int choice, String *footer) { /* avoid compiler warnings about unused parameters */ GH = GH; choice = choice; Truncate( footer, 0 ); SetToCString(footer,cactus_footer); return Length(footer); } int HTTP_ContentHeader(const cGH *GH, int choice, int len, char *header, const char *menu) { String *menuString = NULL; String *headerString = String_New(); int retval = 0; if( menu ) menuString = String_Make( menu ); retval = HTTP_SetContentHeaderString( GH, choice, headerString, menuString ); /* SW: original didn't use len, although it was clearly meant * to indicate the length of the buffer, and all calls I saw to it * passed a buffer length */ if( len > 0 ) { SetToBuffer( headerString, header, len ); } String_Delete( menuString ); String_Delete( headerString ); return retval; } int HTTP_ContentFooter(const cGH *GH, int choice, int len, char *header) { String *headerString = String_New(); int retval = 0; retval = HTTP_SetContentFooterString( GH, choice, headerString ); /* note: original didn't use len, although it was clearly meant * to indicate the length of the buffer, and all calls I saw to it * passed a buffer length */ if( len > 0 ) { SetToBuffer( headerString, header, len ); } String_Delete( headerString ); return retval; }