summaryrefslogtreecommitdiff
path: root/src/main/CommandLine.c
diff options
context:
space:
mode:
authorschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2006-06-23 04:16:13 +0000
committerschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2006-06-23 04:16:13 +0000
commita5554988d7b607ddb66ac499f3f9ceb74a35f31d (patch)
treec030a082c7512f973e8859911a2ec74f2a969c6e /src/main/CommandLine.c
parent4d5f9ed6fdc103aa509c79e14d1ec4680e643925 (diff)
Add a new command line option to select the buffering mode of stdout.
The option is "-b <mode>", or "-buffering=<mode>", where mode can be "no", "line", or "full". This option uses the ANSI C function call setvbuf() to select the corresponding buffering mode. The buffering mode can be selected only once in a portable programme, and it has to be selected before the first output occurs. This means that it has to be implemented in the flesh. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4329 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/CommandLine.c')
-rw-r--r--src/main/CommandLine.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/main/CommandLine.c b/src/main/CommandLine.c
index 4451949c..bfad972d 100644
--- a/src/main/CommandLine.c
+++ b/src/main/CommandLine.c
@@ -68,6 +68,7 @@ int cctki_onlyprintschedule = 0;
*/
#define CACTUS_COMMANDLINE_OPTIONS \
"[-h] [-O] [-o paramname] [-L n] [-W n] [-E n] [-r[o|e|oe|eo]] " \
+ "[-b [no|line|full]] " \
"[-S] [-T] [-t name] [-parameter-level <level>] [-v] " \
"<parameter_file_name>"
@@ -415,8 +416,8 @@ void CCTKi_CommandLineParameterLevel (const char *argument)
else
{
CCTK_VWarn (1, __LINE__, __FILE__, "Cactus",
- "CCTKi_CommandLineParameterLevel: Parameter checking level "
- "'%s' not recognized, defaulting to normal", argument);
+ "Parameter checking level '%s' not recognised, "
+ "defaulting to normal", argument);
parameterlevel = CCTK_PARAMETER_NORMAL;
}
@@ -425,7 +426,7 @@ void CCTKi_CommandLineParameterLevel (const char *argument)
/*@@
- @routine CCTKi_CommandLineRedirectStdout
+ @routine CCTKi_CommandLineRedirect
@date Fri Jul 23 11:32:46 1999
@author Tom Goodale
@desc
@@ -460,6 +461,44 @@ void CCTKi_CommandLineRedirect (const char *argument)
}
}
}
+ /*@@
+ @routine CCTKi_CommandLineSetBuffering
+ @date 2006-05-27
+ @author Erik Schnetter
+ @desc
+ Set stdout buffering. (stderr is always unbuffered.)
+ @enddesc
+
+ @var argument
+ @vdesc option argument
+ @vtype const char *
+ @vio in
+ @endvar
+@@*/
+void CCTKi_CommandLineSetBuffering (const char *argument)
+{
+ if (! strcmp (argument, "no"))
+ {
+ /* Switch to unbuffered mode (best for debugging) */
+ setvbuf (stdout, NULL, _IONBF, 0);
+ }
+ else if (! strcmp (argument, "line"))
+ {
+ /* Switch to line buffered mode (good for screen output) */
+ setvbuf (stdout, NULL, _IOLBF, 0);
+ }
+ else if (! strcmp (argument, "full"))
+ {
+ /* Switch to fully buffered mode (fastest) */
+ setvbuf (stdout, NULL, _IOFBF, 0);
+ }
+ else
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, "Cactus",
+ "Stdout buffering mode '%s' not recognised, "
+ "not changing the default setting", argument);
+ }
+}
/*@@
@@ -562,6 +601,7 @@ void CCTKi_CommandLineHelp (void)
"-E, -error-level <n> : Sets the error level to n.\n"
"-r, -redirect [o|e|oe|eo] : Redirects standard output and/or standard\n"
" error to files.\n"
+ "-b, -buffering [no|line|full] : Set stdout buffering mode.\n"
"-S, -print-schedule : Print the schedule tree, then exit.\n"
"-T, -list-thorns : Lists the compiled-in thorns.\n"
"-t, -test-thorn-compiled <name> : Tests for the presence of thorn <name>.\n"