From b898dbd864e764cdb173e8d8548d31efdb485ac0 Mon Sep 17 00:00:00 2001 From: allen Date: Thu, 29 Jun 2000 21:04:28 +0000 Subject: (Nasty) little hack to add the old Cactus 3 nameofparfile functionality ... anywhere that $PARAMETER_FILE appears it will be replaced by the name of the parameter file that was used, without the last 4 characters. This is so you can say IO::outdir = $PARAMETER_FILE so that ./cactus_exe mypar.par will put output in a directory mypar (using the standard IO thorns). This feature won't be documented until it is added properly, and the notation may change slightly. git-svn-id: http://svn.cactuscode.org/flesh/trunk@1707 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/util/ParseFile.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/util') diff --git a/src/util/ParseFile.c b/src/util/ParseFile.c index b18432af..40be9a83 100644 --- a/src/util/ParseFile.c +++ b/src/util/ParseFile.c @@ -69,7 +69,8 @@ static int lineno = 1; int ParseFile(FILE *ifp, - int (*set_function)(const char *, const char *)) + int (*set_function)(const char *, const char *), + tFleshConfig *ConfigData) { /* Buffers for parsing from the file */ char tokens[BUF_SZ], value[BUF_SZ]; @@ -212,11 +213,26 @@ int ParseFile(FILE *ifp, tokens,value); #endif set_function(tokens,value); - - } - else + else if (c == '$') + { + /* We got a define */ + /* FIXME: Assume it is a parameter file for now */ + int lpar=(strlen(ConfigData->parameter_file_name)-4)*sizeof(char); + + while (!(c==' ' || c=='\t' || c == '\n' || c == EOF)) + { + c = fgetc(ifp); +#ifdef DEBUG + printf("%c",c); +#endif + } + strncpy(value,ConfigData->parameter_file_name,lpar); + set_function(tokens,value); + } + else { + int p = 0; value[p++] = c; if (ntokens == 1) -- cgit v1.2.3