summaryrefslogtreecommitdiff
path: root/src/main/SetParams.c
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-08-26 15:34:20 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-08-26 15:34:20 +0000
commit5e90d4682484a0b9cbc232d0005bcda3895f6c9f (patch)
treed14c7ec57f48fd431663326f9c7b55900846aa47 /src/main/SetParams.c
parent9a643dc37c6334abd06d70688d2e1494c435bbf2 (diff)
New parameter stuff.
Now a non-active thorn's extensions to parameters shouldn't be valid, range checking is now done, even for strings, which must conform to a regular expression. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@859 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/SetParams.c')
-rw-r--r--src/main/SetParams.c103
1 files changed, 87 insertions, 16 deletions
diff --git a/src/main/SetParams.c b/src/main/SetParams.c
index 074e638d..2a32c775 100644
--- a/src/main/SetParams.c
+++ b/src/main/SetParams.c
@@ -11,7 +11,14 @@
#include "cctk.h"
+/* FIXME - remove this when ActiveThorns doesn't need it */
+#include "SKBinTree.h"
+
+#include "cctk_ActiveThorns.h"
+#include "ParameterBindings.h"
+
#include "cctk_WarnLevel.h"
+#include "cctk_Misc.h"
static char *rcsid = "$Id$";
@@ -36,9 +43,9 @@ int CCTKi_SetParameter(const char *parameter, const char *value)
const char *position;
int length;
int n_errors;
-
+
retval = 0;
-
+
if(CCTK_Equals(parameter, "ActiveThorns"))
{
n_errors = 0;
@@ -47,18 +54,18 @@ int CCTKi_SetParameter(const char *parameter, const char *value)
while(*position)
{
length=0;
-
+
for(;*position && *position != ' ';position++)
{
thornname[length] = *position;
if(length < 100) length++;
}
-
+
thornname[length] = '\0';
n_errors += CCTKi_ActivateThorn(thornname) != 0;
if(*position) position++;
}
-
+
if(n_errors)
{
CCTK_WARN(0, "Errors while activating thorns\n");
@@ -66,25 +73,89 @@ int CCTKi_SetParameter(const char *parameter, const char *value)
}
else
{
- retval = CCTKi_BindingsParameterSet(parameter, value);
+ /* retval = CCTKi_BindingsParameterSet(parameter, value);*/
+ retval = CCTKi_ReallySetParameter(parameter, value);
}
-
+
if(retval)
{
-#if 0
if(retval == -1)
{
-#endif
- char *msg = (char *) malloc (strlen (parameter) + 30);
-
- sprintf(msg, "Unknown parameter %s", parameter);
- CCTK_PARAMWARN (msg);
- free (msg);
-#if 0
+ fprintf(stderr, "Unknown parameter %s\n", parameter);
+ }
+ else
+ {
+ fprintf(stderr, "Error setting parameter %s to %s\n", parameter, value);
}
-#endif
}
return retval;
}
+int CCTKi_ReallySetParameter(const char *parameter, const char *value)
+{
+ int retval;
+ const char *thorn;
+ char *param;
+ char *imp;
+
+ int retval_imp;
+ int retval_thorn;
+
+
+ /*
+ CCTKi_BindingsParameterHelp(optarg,"%s",stdout);
+ */
+
+ Util_SplitString(&imp, &param, parameter, "::");
+
+ retval = -1;
+ /* If param is null, there were no colons in the input */
+
+ if(!param)
+ {
+ retval = ParameterSet(parameter, imp, value);
+ }
+ else
+ {
+ /* Set if this is an implementation one */
+ if(CCTK_IsImplementationActive(imp))
+ {
+ thorn = CCTK_ActivatingThorn(imp);
+ retval_imp = ParameterSet(param, thorn, value);
+ }
+ else
+ {
+ thorn = NULL;
+ retval_imp = -1;
+ }
+
+
+ /* Set if this is a thorn one. */
+ if(!thorn || !CCTK_Equals(thorn,imp))
+ {
+ retval_thorn = ParameterSet(param, imp, value);
+ }
+ else
+ {
+ /* Don't need to set it twice if the name of the imp is the same as the thorn providing it */
+ retval_thorn = retval_imp;
+ }
+
+ if(!retval_imp || !retval_thorn)
+ {
+ retval = 0;
+ }
+ else
+ {
+ retval = retval_imp ? retval_imp : retval_thorn;
+ }
+ }
+
+ /* Free any allocated memory. */
+ free(imp);
+ free(param);
+
+ return retval;
+
+}