diff options
Diffstat (limited to 'src/Server.c')
-rw-r--r-- | src/Server.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/src/Server.c b/src/Server.c index 9af9c55..dee7f10 100644 --- a/src/Server.c +++ b/src/Server.c @@ -25,8 +25,8 @@ #include "httpd.h" -#include "http_Steer.h" -#include "http_Expression.h" +#include "Steer.h" +#include "Expression.h" #include "SString_Namespace.h" @@ -49,7 +49,7 @@ typedef struct ********************************************************************/ static httpPage *CreatePageData(int (*function)(const cGH *,httpRequest *, void *), void *data); -static httpPage *FindPage(char *path, char **residual); +static httpPage *FindPage(const char *path, const char **residual); static int StatusUntilIt (const cGH *cctkGH); static int StatusUntilTime (const cGH *cctkGH); @@ -100,20 +100,22 @@ static const char *notimplemented_page = int HTTP_RequestGET(cGH *cctkGH, httpRequest *request) { int retval = -1; - httpPage *pagedata; + const char *residual = NULL; + httpPage *pagedata = FindPage(HTTP_URI( request ), &residual ); + HTTP_SetResidual( request, residual ); - if((pagedata = FindPage(request->uri, &(request->residual)))) + if( pagedata ) { retval = pagedata->function(cctkGH, request, pagedata->data); } if(retval < 0) { - Send_HTTP(request,"HTTP/1.0 404 Not Found\r\n"); + HTTP_Send(request,"HTTP/1.0 404 Not Found\r\n"); - Send_HTTP(request,"Content-Type: text/html\r\n\r\n"); + HTTP_Send(request,"Content-Type: text/html\r\n\r\n"); - Send_HTTP(request, notfound_page); + HTTP_Send(request, notfound_page); } return retval; @@ -137,11 +139,11 @@ int HTTP_RequestUnsupported(cGH *cctkGH, httpRequest *request) { cctkGH = cctkGH; /* avoid compiler warning about unused parameter */ - Send_HTTP(request,"HTTP/1.0 501 Not Implemented\r\n"); + HTTP_Send(request,"HTTP/1.0 501 Not Implemented\r\n"); - Send_HTTP(request,"Content-Type: text/html\r\n\r\n"); + HTTP_Send(request,"Content-Type: text/html\r\n\r\n"); - Send_HTTP(request, notimplemented_page ); + HTTP_Send(request, notimplemented_page ); return 0; } @@ -164,8 +166,6 @@ int HTTP_RegisterPage(const char *path, int (*function)(const cGH *, httpRequest { int retval = -1; - httpPage *pagedata; - /* Create the hash table if it's not already been created */ if(! pages) { @@ -178,7 +178,7 @@ int HTTP_RegisterPage(const char *path, int (*function)(const cGH *, httpRequest } else { - pagedata = CreatePageData(function, data); + httpPage *pagedata = CreatePageData(function, data); if(pagedata) { @@ -339,7 +339,7 @@ static httpPage *CreatePageData(int (*function)(const cGH *, httpRequest *, void @endhistory @@*/ -static httpPage *FindPage(char *path, char **residual) +static httpPage *FindPage(const char *path, const char **residual) { httpPage *pagedata = NULL; @@ -360,13 +360,10 @@ static httpPage *FindPage(char *path, char **residual) ConcatCString( temp,"index.html"); pagedata = Util_HashData(pages, Length(temp), GetBuffer(temp), 0); - - *residual = NULL; } else if((pagedata = Util_HashData(pages, strlen(path), path, 0))) { /* Or exact path */ - *residual = NULL; } else { @@ -378,12 +375,12 @@ static httpPage *FindPage(char *path, char **residual) pagedata = Util_HashData(pages, Length(temp), GetBuffer(temp), 0); - *residual = NULL; } + *residual = NULL; if(!pagedata && strlen( path ) > 0) { - char *position; + const char *position; /* Ok, now cycle through. Know it doesn't end with a slash */ for(position = path+strlen(path)-1; position >= path; position--) { @@ -473,8 +470,6 @@ static int StatusUntilExpression (cGH *cctkGH) static char *parsed_expression = NULL; static int times_set = -1; int retval = 0; - char *copy; - /* See if we need to parse the expression again. */ int new_times_set = CCTK_ParameterQueryTimesSet("until_expression", @@ -493,7 +488,7 @@ static int StatusUntilExpression (cGH *cctkGH) if(parsed_expression && strlen(parsed_expression) > 0 && cctkGH) { /* Make a copy */ - copy = Util_Strdup(parsed_expression); + char *copy = Util_Strdup(parsed_expression); /* Evaluate the expression */ retval = HTTP_ExpressionEvaluate(copy, evaluator, cctkGH); @@ -524,15 +519,12 @@ static double evaluator(const char *expression, void *data) { double retval = 0.0; cGH *cctkGH = (cGH *)data; - void *pointer; - int vartype; int varindex = CCTK_VarIndex(expression); if(varindex > -1) { - vartype = CCTK_VarTypeI(varindex); - - pointer = CCTK_VarDataPtrI(cctkGH, 0, varindex); + int vartype = CCTK_VarTypeI(varindex); + int *pointer = CCTK_VarDataPtrI(cctkGH, 0, varindex); switch(vartype) { |