diff options
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | src/Content.c | 45 | ||||
-rw-r--r-- | src/Groups.c | 4 | ||||
-rw-r--r-- | src/Headers.c | 8 | ||||
-rw-r--r-- | src/Parameters.c | 12 | ||||
-rw-r--r-- | src/Redirect.c | 9 | ||||
-rw-r--r-- | src/Server.c | 12 | ||||
-rw-r--r-- | src/Sockets.c | 31 | ||||
-rw-r--r-- | src/Thorns.c | 8 | ||||
-rw-r--r-- | src/http_Content.h | 4 | ||||
-rw-r--r-- | src/http_Request.h | 2 |
11 files changed, 56 insertions, 81 deletions
@@ -32,7 +32,7 @@ where 'path' is the URI you want to register, e.g. 'function' is a function of the form -int foo(cGH *cctkGH, httpRequest *request, void *data) +int foo(const cGH *cctkGH, httpRequest *request, void *data) which will be called when the page is accessed, with 'data' being the same data pointer that was passed into the registration routine. diff --git a/src/Content.c b/src/Content.c index 4f7526d..896c25e 100644 --- a/src/Content.c +++ b/src/Content.c @@ -69,24 +69,24 @@ struct httpLink static int RegisterImages(void); -static int MainPage(cGH *cctkGH, httpRequest *request, void *data); -static int AboutPage(cGH *cctkGH, httpRequest *request, void *data); +static int MainPage(const cGH *cctkGH, httpRequest *request, void *data); +static int AboutPage(const cGH *cctkGH, httpRequest *request, void *data); -static int ShowStaticPage(cGH *cctkGH, httpRequest *request, void *data); +static int ShowStaticPage(const cGH *cctkGH, httpRequest *request, void *data); static int CompareStrings(const void *string1, const void *string2); -static int ControlPage(cGH *cctkGH, httpRequest *request, void *data); -static int ControlSet(cGH *cctkGH, httpRequest *request); -static int ControlTerminationPage(cGH *cctkGH, httpRequest *request); +static int ControlPage(const cGH *cctkGH, httpRequest *request, void *data); +static int ControlSet(const cGH *cctkGH, httpRequest *request); +static int ControlTerminationPage(const cGH *cctkGH, httpRequest *request); -static int CookieTestPage(cGH *cctkGH, httpRequest *request, void *data); +static int CookieTestPage(const cGH *cctkGH, httpRequest *request, void *data); /******************************************************************** ********************* Other Routine Prototypes ********************* ********************************************************************/ -void HTTP_ContentWork(cGH *GH); +void HTTP_ContentWork(const cGH *GH); int HTTP_RegisterPages(void); int HTTPi_RegisterGroupsPages(void); int HTTPi_RegisterThornPages(void); @@ -123,7 +123,7 @@ static const char *notauthorized_page = @endhistory @@*/ -void HTTP_ContentWork(cGH *GH) +void HTTP_ContentWork(const cGH *GH) { /* avoid compiler warning about unused parameter */ GH = GH; @@ -294,7 +294,7 @@ static int CompareStrings(const void *string1, const void *string2) @endhistory @@*/ -static int MainPage(cGH *cctkGH, httpRequest *request, void *data) +static int MainPage(const cGH *cctkGH, httpRequest *request, void *data) { DECLARE_CCTK_PARAMETERS @@ -511,18 +511,15 @@ static int MainPage(cGH *cctkGH, httpRequest *request, void *data) strcpy(message,"<li>Estimated time to completion:<UL> "); - if (cctk_final_time < cctk_initial_time) + if (cctk_final_time<cctk_initial_time) { - seconds = cctk_itlast - cctkGH->cctk_iteration; + seconds = (cctk_itlast-cctkGH->cctk_iteration)*CCTK_RunTime()/ + cctkGH->cctk_iteration; } else { - seconds = (cctk_final_time - cctkGH->cctk_time) / cctkGH->cctk_delta_time; - } - seconds *= CCTK_RunTime(); - if (cctkGH->cctk_iteration) - { - seconds /= cctkGH->cctk_iteration; + seconds = (cctk_final_time-cctkGH->cctk_time)/cctkGH->cctk_delta_time* + CCTK_RunTime()/cctkGH->cctk_iteration; } minutes = seconds/60; @@ -693,7 +690,7 @@ static int RegisterImages(void) @endhistory @@*/ -static int ShowStaticPage(cGH *cctkGH, httpRequest *request, void *data) +static int ShowStaticPage(const cGH *cctkGH, httpRequest *request, void *data) { int retval; char message[1024]; @@ -740,7 +737,7 @@ static int ShowStaticPage(cGH *cctkGH, httpRequest *request, void *data) @endhistory @@*/ -static int ControlPage(cGH *cctkGH, httpRequest *request, void *data) +static int ControlPage(const cGH *cctkGH, httpRequest *request, void *data) { DECLARE_CCTK_PARAMETERS @@ -925,7 +922,7 @@ static int ControlPage(cGH *cctkGH, httpRequest *request, void *data) @endhistory @@*/ -static int ControlSet(cGH *cctkGH, httpRequest *request) +static int ControlSet(const cGH *cctkGH, httpRequest *request) { DECLARE_CCTK_PARAMETERS char message[4098]; @@ -1094,7 +1091,7 @@ static int ControlSet(cGH *cctkGH, httpRequest *request) @endhistory @@*/ -static int ControlTerminationPage(cGH *cctkGH, httpRequest *request) +static int ControlTerminationPage(const cGH *cctkGH, httpRequest *request) { int retval; char message[4098]; @@ -1306,7 +1303,7 @@ int HTTP_ContentSendFromFile(httpRequest *request, int filedes) @calls @calledby @@*/ -static int AboutPage(cGH *cctkGH, httpRequest *request, void *data) +static int AboutPage(const cGH *cctkGH, httpRequest *request, void *data) { int retval; char message[4098]; @@ -1381,7 +1378,7 @@ static int AboutPage(cGH *cctkGH, httpRequest *request, void *data) @endhistory @@*/ -static int CookieTestPage(cGH *cctkGH, httpRequest *request, void *data) +static int CookieTestPage(const cGH *cctkGH, httpRequest *request, void *data) { int retval; char message[4098]; diff --git a/src/Groups.c b/src/Groups.c index d1aab5a..de46bad 100644 --- a/src/Groups.c +++ b/src/Groups.c @@ -31,7 +31,7 @@ CCTK_FILEVERSION(CactusConnect_HTTPD_Groups_c) ********************* Local Routine Prototypes ********************* ********************************************************************/ -static int GroupsPage(cGH *cctkGH, httpRequest *request, void *data); +static int GroupsPage(const cGH *cctkGH, httpRequest *request, void *data); /*static int watch[1024];*/ @@ -93,7 +93,7 @@ int HTTPi_RegisterGroupsPages(void) @calls @calledby @@*/ -static int GroupsPage(cGH *cctkGH, httpRequest *request, void *data) +static int GroupsPage(const cGH *cctkGH, httpRequest *request, void *data) { int retval; char message[4098]; diff --git a/src/Headers.c b/src/Headers.c index b50c890..17cd140 100644 --- a/src/Headers.c +++ b/src/Headers.c @@ -42,8 +42,8 @@ struct httpLink ********************* Other Routine Prototypes ********************* ********************************************************************/ -int HTTP_ContentHeader(cGH *GH, int choice, int len, char *header, char *menu); -int HTTP_ContentFooter(cGH *GH, int choice, int len, char *footer); +int HTTP_ContentHeader(const cGH *GH, int choice, int len, char *header, char *menu); +int HTTP_ContentFooter(const cGH *GH, int choice, int len, char *footer); /******************************************************************** ********************* Local Data ***************************** @@ -96,7 +96,7 @@ static const char *cactus_footer = @endhistory @@*/ -int HTTP_ContentHeader(cGH *GH, int choice, int len, char *header, char *menu) +int HTTP_ContentHeader(const cGH *GH, int choice, int len, char *header, char *menu) { char title[TITLE_ARRAY_SIZE]; char parfile[200]; @@ -212,7 +212,7 @@ int HTTP_ContentHeader(cGH *GH, int choice, int len, char *header, char *menu) @endhistory @@*/ -int HTTP_ContentFooter(cGH *GH, int choice, int len, char *footer) +int HTTP_ContentFooter(const cGH *GH, int choice, int len, char *footer) { /* avoid compiler warnings about unused parameters */ GH = GH; diff --git a/src/Parameters.c b/src/Parameters.c index 6312e05..f9e2c5a 100644 --- a/src/Parameters.c +++ b/src/Parameters.c @@ -46,9 +46,9 @@ CCTK_FILEVERSION(CactusConnect_HTTPD_Parameters_c) ********************* Local Routine Prototypes ********************* ********************************************************************/ -static int MainParameterPage(cGH *cctkGH, httpRequest *request, void *data); -static int ThornParameterPage(cGH *cctkGH, httpRequest *request, void *data); -static int ParameterPage(cGH *cctkGH, httpRequest *request, void *data); +static int MainParameterPage(const cGH *cctkGH, httpRequest *request, void *data); +static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *data); +static int ParameterPage(const cGH *cctkGH, httpRequest *request, void *data); /******************************************************************** @@ -166,7 +166,7 @@ int HTTPi_RegisterParameterPages(void) Ed Seidel. @endhistory @@*/ -static int MainParameterPage(cGH *cctkGH, httpRequest *request, void *data) +static int MainParameterPage(const cGH *cctkGH, httpRequest *request, void *data) { int retval; char message[4098]; @@ -266,7 +266,7 @@ static int MainParameterPage(cGH *cctkGH, httpRequest *request, void *data) @endhistory @@*/ -static int ThornParameterPage(cGH *cctkGH, httpRequest *request, void *data) +static int ThornParameterPage(const cGH *cctkGH, httpRequest *request, void *data) { int retval=0; int i; @@ -661,7 +661,7 @@ static int ThornParameterPage(cGH *cctkGH, httpRequest *request, void *data) @endhistory @@*/ -static int ParameterPage(cGH *cctkGH, httpRequest *request, void *data) +static int ParameterPage(const cGH *cctkGH, httpRequest *request, void *data) { int retval=0; char message[10000]; diff --git a/src/Redirect.c b/src/Redirect.c index b7b7139..32cee44 100644 --- a/src/Redirect.c +++ b/src/Redirect.c @@ -40,7 +40,7 @@ CCTK_FILEVERSION(CactusConnect_HTTPD_Redirect_c) ********************************************************************/ static void RegisterRedirect(void); -static int RedirectPage(cGH *cctkGH, httpRequest *request, void *data); +static int RedirectPage(const cGH *cctkGH, httpRequest *request, void *data); /******************************************************************** ********************* Other Routine Prototypes ********************* @@ -96,8 +96,7 @@ int HTTP_SetupRedirect(int port, #endif memset(hostnm,0,addrlen); Util_GetHostName(hostnm, addrlen); - alladdr=(char*)malloc(addrlen * nprocs); - memset(alladdr,0,addrlen*nprocs); /* zero it */ + alladdr = (char *) calloc (addrlen, nprocs); #ifdef CCTK_MPI { /* push stack */ @@ -158,6 +157,8 @@ int HTTP_SetupRedirect(int port, httpredirect=0; } + free (alladdr); + return retval; } @@ -285,7 +286,7 @@ static void RegisterRedirect(void) @@*/ -static int RedirectPage(cGH *cctkGH, httpRequest *request, void *data) +static int RedirectPage(const cGH *cctkGH, httpRequest *request, void *data) { int retval; char message[1024]; diff --git a/src/Server.c b/src/Server.c index 53f170d..f014ebd 100644 --- a/src/Server.c +++ b/src/Server.c @@ -38,7 +38,7 @@ CCTK_FILEVERSION(CactusConnect_HTTPD_Server_c) typedef struct { - int (*function)(cGH *, httpRequest *, void *); + int (*function)(const cGH *, httpRequest *, void *); void *data; } httpPage; @@ -46,7 +46,7 @@ typedef struct ********************* Local Routine Prototypes ********************* ********************************************************************/ -static httpPage *CreatePageData(int (*function)(cGH *,httpRequest *, void *), void *data); +static httpPage *CreatePageData(int (*function)(const cGH *,httpRequest *, void *), void *data); static httpPage *FindPage(char *path, char **residual); static int StatusUntilIt (const cGH *cctkGH); @@ -68,7 +68,7 @@ static uHash *pages = NULL; static const char *notfound_page = "<HTML>\n<HEAD><TITLE>Error 404: Not Found</TITLE></HEAD>\ -<BODY>The URI you requested could not be found</BODY>\n<HTML>\n"; +<BODY>The URI you requested could not be found</BODY>\n</HTML>\n"; static const char *notimplemented_page = "<HTML>\n<HEAD><TITLE>Error 501: Not Implemented</TITLE></HEAD>\ @@ -177,7 +177,7 @@ int HTTP_RequestUnsupported(cGH *cctkGH, httpRequest *request) @endhistory @@*/ -int HTTP_RegisterPage(const char *path, int (*function)(cGH *, httpRequest *, void *), void *data) +int HTTP_RegisterPage(const char *path, int (*function)(const cGH *, httpRequest *, void *), void *data) { int retval; @@ -331,7 +331,7 @@ int HTTP_Terminate(cGH *cctkGH) @endhistory @@*/ -static httpPage *CreatePageData(int (*function)(cGH *, httpRequest *, void *), void *data) +static httpPage *CreatePageData(int (*function)(const cGH *, httpRequest *, void *), void *data) { httpPage *pagedata; @@ -368,11 +368,13 @@ static httpPage *FindPage(char *path, char **residual) pagedata = NULL; +printf ("Searching for '%s'\n", path); if(pages) { /* Check for index.html */ if(path[strlen(path)-1] == '/') { +#define HTTP_DEBUG 1 #ifdef HTTP_DEBUG printf("Looking for '%sindex.html'\n", path); #endif diff --git a/src/Sockets.c b/src/Sockets.c index 729e323..38a5ced 100644 --- a/src/Sockets.c +++ b/src/Sockets.c @@ -11,7 +11,6 @@ @@*/ #include "cctk.h" -#include "cctk_Parameters.h" #include "util_Network.h" #include <stdio.h> @@ -77,10 +76,6 @@ CCTK_FILEVERSION(CactusConnect_HTTPD_Sockets_c) #define MSG_NOSIGNAL 0 #endif -/* HTML filename to take the server URL */ -#define SERVER_URL_FILENAME "server_url.html" - - typedef enum {closed, open} httpSocketState; typedef struct HTTPSocket @@ -141,18 +136,16 @@ static unsigned long int httpport = 0; @endhistory @@*/ -int HTTP_SetupServer(int which_port, int queue_size, int which_hunt) +int HTTP_SetupServer(int port, int queue_size, int hunt) { char hostname[1025]; int realport; - DECLARE_CCTK_PARAMETERS - /* Some systems need special logic for starting up TCP. */ InitialiseTCP(); /* Create the socket and set it up to accept connections. */ - sock = HTTP_MakeSocket (which_port, which_hunt ? &realport : NULL); + sock = HTTP_MakeSocket (port, hunt ? &realport : NULL); if (ERROR_CHECK(listen (sock, queue_size))) { @@ -163,27 +156,9 @@ int HTTP_SetupServer(int which_port, int queue_size, int which_hunt) Util_GetHostName(hostname, 1024); - httpport = which_hunt ? realport : which_port; + httpport = hunt ? realport : port; printf("Server started on http://%s:%lu/\n", hostname, httpport); - if (announce_server_url) - { - char *filename; - FILE *file; - - - CCTK_CreateDirectory (0755, announce_server_url_outdir); - filename = (char *) malloc (strlen (announce_server_url_outdir) + 20); - sprintf (filename, "%s/%s", announce_server_url_outdir, SERVER_URL_FILENAME); - file = fopen (filename, "w"); - if (file) - { - fprintf (file, "HTTPD server started on <A HREF=\"http://%s:%lu\">http://%s:%lu</A>", - HTTP_Master (), (unsigned int) HTTP_Port (), HTTP_Master (), (unsigned int) HTTP_Port ()); - fclose (file); - } - free (filename); - } minsock = sock; maxsock = sock; diff --git a/src/Thorns.c b/src/Thorns.c index 6a6edfb..6f54b61 100644 --- a/src/Thorns.c +++ b/src/Thorns.c @@ -30,8 +30,8 @@ CCTK_FILEVERSION(CactusConnect_HTTPD_Thorns_c) ********************* Local Routine Prototypes ********************* ********************************************************************/ -static int ThornMainPage(cGH *cctkGH, httpRequest *request, void *data); -static int ThornPage(cGH *cctkGH, httpRequest *request, void *data); +static int ThornMainPage(const cGH *cctkGH, httpRequest *request, void *data); +static int ThornPage(const cGH *cctkGH, httpRequest *request, void *data); /******************************************************************** @@ -109,7 +109,7 @@ int HTTPi_RegisterThornPages(void) @calls @calledby @@*/ -static int ThornMainPage(cGH *cctkGH, httpRequest *request, void *data) +static int ThornMainPage(const cGH *cctkGH, httpRequest *request, void *data) { int i; int retval; @@ -256,7 +256,7 @@ static int ThornMainPage(cGH *cctkGH, httpRequest *request, void *data) @endhistory @@*/ -static int ThornPage(cGH *cctkGH, httpRequest *request, void *data) +static int ThornPage(const cGH *cctkGH, httpRequest *request, void *data) { int retval=0; char message[4098]; diff --git a/src/http_Content.h b/src/http_Content.h index c79b7a8..40c2777 100644 --- a/src/http_Content.h +++ b/src/http_Content.h @@ -26,8 +26,8 @@ int HTTP_ContentLink(const char *URL, int HTTP_ContentSendFromFile(httpRequest *request, int filedes); -int HTTP_ContentHeader(cGH *cctkGH, int choice, int len, char *mess, char *menu); -int HTTP_ContentFooter(cGH *cctkGH, int choice, int len, char *mess); +int HTTP_ContentHeader(const cGH *cctkGH, int choice, int len, char *mess, char *menu); +int HTTP_ContentFooter(const cGH *cctkGH, int choice, int len, char *mess); #ifdef __cplusplus } diff --git a/src/http_Request.h b/src/http_Request.h index cb2a4f5..02cb600 100644 --- a/src/http_Request.h +++ b/src/http_Request.h @@ -67,7 +67,7 @@ extern "C" { #endif -int HTTP_RegisterPage(const char *path, int (*function)(cGH *, httpRequest *, void *), void *data); +int HTTP_RegisterPage(const char *path, int (*function)(const cGH *, httpRequest *, void *), void *data); const char *HTTP_ArgumentValue(const httpRequest *request, const char *arg); |