aboutsummaryrefslogtreecommitdiff
path: root/src/Headers.c
blob: 82cdc98fb8043ac7fb2a4bef6ddfda3329bd32f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
 /*@@
   @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 <string.h>


static char *rcsid = "$Header$";

CCTK_FILEVERSION(DevThorns_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   *****************************
 ********************************************************************/

#define TITLE_ARRAY_SIZE 100

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_footer =
"</table>\n"
"<TABLE WIDTH=100%% BORDER=0>\n"
"<tr><td colspan=2><HR NOSHADE SIZE=1></td></tr>\n"
"<tr><td align=left valign=top>"
"<ADDRESS><DIV ALIGN=left>\n"
"<SMALL>\n"
"<A HREF=\"www.cactuscode.org\"><IMG SRC=\"/Images/www.gif\" BORDER=0></A><BR>\n"
"</SMALL></DIV></ADDRESS>"
"</TD><TD ALIGN=RIGHT VALIGN=TOP><SMALL>"
"Cactus Web Interface by <A HREF=\"mailto:cactusmaint@cactuscode.org\">The Cactus Team</A><BR>\n"
"<A HREF=\"/About.html\"><i>About this Server</i></A>"
"</SMALL></TD></TR></TABLE>"
"</BODY></HTML>\n";


/********************************************************************
 *********************     External Routines   **********************
 ********************************************************************/

 /*@@
   @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 

@@*/
int HTTP_ContentHeader(cGH *GH, int choice, int len, char *header, char *menu)
{
  char title[TITLE_ARRAY_SIZE];
  char currentdate[50];
  char currenttime[50];
  char quicklinks[524];
  struct httpLink *link;

  int titlelen,datelen,timelen;

  if(ContentLinks)
  {
    strcpy(quicklinks,"<dl><dt><b>Options:</b>");
    for(link = ContentLinks; link; link=link->next)
    {
      sprintf(quicklinks, 
              "%s<dt> <A HREF=\"%s\">%s</a></dt>\n",
              quicklinks, link->URL, link->name);

    }
    
    sprintf(quicklinks,"%s</dl>\n",quicklinks);
  }
 
  if (choice == 0)
  {
    /* Find strings needed for nonmain-page headers */
    titlelen = CCTK_RunTitle(TITLE_ARRAY_SIZE,title); 
    datelen  = Util_CurrentDate(50,currentdate);
    timelen  = Util_CurrentTime(50,currenttime);

    /* Build the header */
    sprintf( header, 
	     "</HEAD>\n<BODY BGCOLOR=\"#FFFFFF\" link=\"#1B831D\" "
	     "vlink=\"#768000\" alink=\"#00FF00\">\n"
	     "<center>\n<table cellpadding=10 width=100%% border=0>\n"
	     "<tr>\n<td bgcolor=#E5FFA2 valign=top align=left width=20%%>\n");
    strcat(header, "<A HREF=\"/\">Master Run Page</A>\n");
    sprintf(header,"%s\n"
	    "<small><dl>"
	    "<dt><b>Environment:</b>"
	    "<dt>Time: %s"
	    "<dt>Date: %s"
	    "</dl></small>",
	    header,currenttime,currentdate);
    sprintf(header,
	    "%s <small><dl>"
	    "<dt><b>Simulation:</b>"
	    "<dt><i>%s</i>"
	    "<dt>Iteration: %d"
	    "<dt>Physical time: %4.2f"
	    "</dl>"
	    ,header,title,GH ? GH->cctk_iteration : 0 , GH ? GH->cctk_time : 0);
    if (ContentLinks)
    {
      strcat(header,quicklinks);
    }
    strcat(header,"</small>");

    if (menu)
    {
      strcat(header,"<dl><small>");
      strcat(header,menu);
      strcat(header,"</dl></small>");
    }

    /* Online links */
    sprintf(header,"%s\n"
	    "<small><dl>"
	    "<dt><b>On-Line:</b>\n"
	    "<dt><A HREF=\"http://www.cactuscode.org\">Cactus Homepage</A>\n"
	    "<dt><A HREF=\"http://www.cactuscode.org/Documentation/UsersGuide_html/UsersGuide/\">Users Guide</A>\n"
	    "<dt><A HREF=\"mailto:cactusmaint@cactuscode.org\">Cactus Helpdesk</A>\n"
	    "</dl></small>\n",
	    header,currenttime,currentdate);

    strcat(header,"</td>\n<td valign=top>\n");
  }
  else
  {
      sprintf(header,"%s",cactus_mainheader);
  }

  return strlen(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_ContentFooter(cGH *GH, int choice, int len, char *footer)
{
  strcpy(footer,cactus_footer);
  return strlen(footer);
}