aboutsummaryrefslogtreecommitdiff
path: root/src/Server.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Server.c')
-rw-r--r--src/Server.c120
1 files changed, 29 insertions, 91 deletions
diff --git a/src/Server.c b/src/Server.c
index cb6cf7e..53f170d 100644
--- a/src/Server.c
+++ b/src/Server.c
@@ -18,6 +18,7 @@
#include "cctk_Groups.h"
#include "cctk_GroupsOnGH.h"
#include "cctk_Parameter.h"
+#include "cctk_Parameters.h"
#include "util_Hash.h"
#include "util_String.h"
@@ -48,9 +49,9 @@ typedef struct
static httpPage *CreatePageData(int (*function)(cGH *,httpRequest *, void *), void *data);
static httpPage *FindPage(char *path, char **residual);
-static int StatusUntilIt(cGH *cctkGH);
-static int StatusUntilTime(cGH *cctkGH);
-static int StatusUntilExpression(cGH *cctkGH);
+static int StatusUntilIt (const cGH *cctkGH);
+static int StatusUntilTime (const cGH *cctkGH);
+static int StatusUntilExpression (cGH *cctkGH);
static double evaluator(const char *name, void *data);
@@ -227,42 +228,18 @@ int HTTP_RegisterPage(const char *path, int (*function)(cGH *, httpRequest *, vo
@@*/
int HTTP_UpdateState(cGH *cctkGH, httpState *state)
{
- int type;
- CCTK_INT *value;
- int pause_selected;
- int until_it_selected;
- int until_time_selected;
- int until_expression_selected;
+ DECLARE_CCTK_PARAMETERS
int stepping;
-
static int steering = 1;
static int last_steered = -1;
- value = (CCTK_INT *)CCTK_ParameterGet("single_step",CCTK_THORNSTRING, &type);
-
- stepping = *value;
-
- value = (CCTK_INT *)CCTK_ParameterGet("pause",CCTK_THORNSTRING, &type);
-
- pause_selected = *value;
-
- value = (CCTK_INT *)CCTK_ParameterGet("until_it_active",CCTK_THORNSTRING, &type);
-
- until_it_selected = *value;
-
- value = (CCTK_INT *)CCTK_ParameterGet("until_time_active",CCTK_THORNSTRING, &type);
-
- until_time_selected = *value;
-
- value = (CCTK_INT *)CCTK_ParameterGet("until_expression_active",CCTK_THORNSTRING, &type);
-
- until_expression_selected = *value;
+ stepping = single_step;
state->paused = (! stepping) &&
- (pause_selected || (cctkGH &&
- ((until_it_selected && StatusUntilIt(cctkGH)) ||
- (until_time_selected && StatusUntilTime(cctkGH)) ||
- (until_expression_selected && StatusUntilExpression(cctkGH)))));
+ (pause || (cctkGH &&
+ ((until_it_active && StatusUntilIt(cctkGH)) ||
+ (until_time_active && StatusUntilTime(cctkGH)) ||
+ (until_expression_active && StatusUntilExpression(cctkGH)))));
/* If single step is selected, need to reset the parameter to force a pause
* next time.
@@ -272,15 +249,12 @@ int HTTP_UpdateState(cGH *cctkGH, httpState *state)
HTTP_SteerQueue(CCTK_THORNSTRING, "single_step", "no");
}
-
if(cctkGH && ! state->paused)
{
if(steering)
{
- value = (CCTK_INT *)CCTK_ParameterGet("steering_frequency",CCTK_THORNSTRING, &type);
-
- if(*value > 0 &&
- *value+last_steered <= cctkGH->cctk_iteration)
+ if(steering_frequency > 0 &&
+ steering_frequency+last_steered <= cctkGH->cctk_iteration)
{
/* Time to steer */
state->steer = 1;
@@ -291,7 +265,7 @@ int HTTP_UpdateState(cGH *cctkGH, httpState *state)
state->steer = 0;
}
- if(*value <= 0)
+ if(steering_frequency <= 0)
{
/* Once steering is switched off, can't restart it ! */
steering = 0;
@@ -303,21 +277,11 @@ int HTTP_UpdateState(cGH *cctkGH, httpState *state)
state->steer = 1;
}
-
- value = (CCTK_INT *)CCTK_ParameterGet("terminate",CCTK_THORNSTRING, &type);
-
- state->terminate = *value;
-
+ state->terminate = terminate;
if(!state->paused)
{
-
- value = (CCTK_INT *)CCTK_ParameterGet("timeout_seconds",CCTK_THORNSTRING, &type);
-
- state->timeout_seconds = *value;
-
- value = (CCTK_INT *)CCTK_ParameterGet("timeout_useconds",CCTK_THORNSTRING, &type);
-
- state->timeout_useconds = *value;
+ state->timeout_seconds = timeout_seconds;
+ state->timeout_useconds = timeout_useconds;
}
else
{
@@ -483,26 +447,15 @@ static httpPage *FindPage(char *path, char **residual)
@endhistory
@@*/
-static int StatusUntilIt(cGH *cctkGH)
+static int StatusUntilIt (const cGH *cctkGH)
{
- int retval;
- CCTK_INT *value;
- int type;
+ DECLARE_CCTK_PARAMETERS
- value = (CCTK_INT *)CCTK_ParameterGet("until_it",CCTK_THORNSTRING, &type);
- if(cctkGH && *value <= cctkGH->cctk_iteration)
- {
- retval = 1;
- }
- else
- {
- retval = 0;
- }
-
- return retval;
+ return (cctkGH && until_it <= cctkGH->cctk_iteration);
}
+
/*@@
@routine StatusUntilTime
@date Tue Sep 19 23:00:16 2000
@@ -517,26 +470,15 @@ static int StatusUntilIt(cGH *cctkGH)
@endhistory
@@*/
-static int StatusUntilTime(cGH *cctkGH)
+static int StatusUntilTime (const cGH *cctkGH)
{
- int retval;
- CCTK_REAL *value;
- int type;
+ DECLARE_CCTK_PARAMETERS
- value = (CCTK_REAL *)CCTK_ParameterGet("until_time",CCTK_THORNSTRING, &type);
- if(cctkGH && *value <= cctkGH->cctk_time)
- {
- retval = 1;
- }
- else
- {
- retval = 0;
- }
-
- return retval;
+ return (cctkGH && until_time <= cctkGH->cctk_time);
}
+
/*@@
@routine StatusUntilExpression
@date Tue Sep 19 23:00:47 2000
@@ -551,18 +493,16 @@ static int StatusUntilTime(cGH *cctkGH)
@endhistory
@@*/
-static int StatusUntilExpression(cGH *cctkGH)
+static int StatusUntilExpression (cGH *cctkGH)
{
+ DECLARE_CCTK_PARAMETERS
static char *parsed_expression = NULL;
static int times_set = -1;
-
int new_times_set;
int retval;
-
- const char **value;
- int type;
char *copy;
+
/* See if we need to parse the expression again. */
new_times_set = CCTK_ParameterQueryTimesSet("until_expression",
CCTK_THORNSTRING);
@@ -570,13 +510,11 @@ static int StatusUntilExpression(cGH *cctkGH)
if(new_times_set > times_set)
{
times_set = new_times_set;
- value = (const char **)CCTK_ParameterGet("until_expression",CCTK_THORNSTRING, &type);
-
if(parsed_expression)
{
free(parsed_expression);
}
- parsed_expression = HTTP_ExpressionParse(*value);
+ parsed_expression = HTTP_ExpressionParse(until_expression);
}
if(parsed_expression && strlen(parsed_expression) > 0 && cctkGH)
@@ -585,7 +523,7 @@ static int StatusUntilExpression(cGH *cctkGH)
copy = Util_Strdup(parsed_expression);
/* Evaluate the expression */
- retval = HTTP_ExpressionEvaluate(copy, evaluator, (void *)cctkGH);
+ retval = HTTP_ExpressionEvaluate(copy, evaluator, cctkGH);
/* Free the copy */
free(copy);