aboutsummaryrefslogtreecommitdiff
path: root/src/Processors.c
blob: 737b350ae4cfabf952de2f852a7ab9ad53e1ec1d (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
 /*@@
   @file      Processors.c
   @date      Wed Nov 8 2000
   @author    Gabrielle Allen
   @desc 
   Pages about processors
   @enddesc
   @version $Header$
 @@*/

#include <stdio.h>

#include "cctk.h"

#include "util_String.h"

#include "CactusConnect/HTTPD/src/http_Request.h"
#include "CactusConnect/HTTPD/src/http_Content.h"
#include "httpextra_HostNames.h"

static const char *rcsid = "$Header$";

CCTK_FILEVERSION(CactusConnect_HTTPDExtra_Processors_c)

/********************************************************************
 *********************     Local Data Types   ***********************
 ********************************************************************/

/********************************************************************
 ********************* Local Routine Prototypes *********************
 ********************************************************************/

static int ProcessorsPage(const cGH *cctkGH, httpRequest *request, void *data);


/********************************************************************
 ********************* Other Routine Prototypes *********************
 ********************************************************************/

/********************************************************************
 *********************     Local Data   *****************************
 ********************************************************************/

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

 /*@@
   @routine    HTTPDExtra_RegisterProcessorsPages
   @date       Wed Sep 14 11:29:43 2000
   @author     Gabrielle Allen
   @desc 
   Httpd utils registration routine.
   @enddesc 
   @calls     
   @calledby   
   @history 
 
   @endhistory 

@@*/
int HTTPDExtra_RegisterProcessorsPages(void)
{
  /* Register the group info page. */
  HTTP_RegisterPage("/Processors", ProcessorsPage, NULL);

  HTTP_ContentLink("/Processors/index.html", "Processor Information",
                   "Processor layout and properties",
                   HTTP_QUICKLINK);
  return 0;
}

/********************************************************************
 *********************     Local Routines   *************************
 ********************************************************************/


/******************************************************************************
 ***************************** Groups Page **************************************
 ******************************************************************************/

 /*@@
   @routine    ProcessorsPage
   @date       Thu Sep 14 23:47:43 2000
   @author     Gabrielle Allen
   @desc 
   Displays the processor description page.
   @enddesc 
   @calls     
   @calledby   
@@*/
static int ProcessorsPage(const cGH *cctkGH, httpRequest *request, void *data)
{
  int retval;
  int nprocs,np;
  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 Simulation Processor Information</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>Processor Information</h1></center>\n");
  retval = HTTP_Write(request, message, strlen(message));

  strcpy(message,
	 "<center>\n<table>\n"
	 "<tr>"
	 "<th>Number</th>\n"
	 "<th>Machine Name</th>\n"
	 "</tr>");
  retval = HTTP_Write(request, message, strlen(message));
	 
  nprocs = CCTK_nProcs(cctkGH);
  for (np=0;np<nprocs;np++)
  {
    sprintf(message,
	    "<tr>"
	    "<td align=center>%d</td>"
	    "<td align=left>%s</td>"
	    "</tr>\n",
	    np,
	    HTTPDExtra_RemoteHostName(np)
	    );
    retval = HTTP_Write(request, message, strlen(message));
  }

  strcpy(message,
	 "</table>\n</center>\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;
}