summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2003-12-05 16:53:17 (GMT)
committerBrad King <brad.king@kitware.com>2003-12-05 16:53:17 (GMT)
commited853b5d70649465370f161b774cf91735a822b3 (patch)
tree23a96d8eba86efd8aa124fd49ca3319689ba02ae /Source/kwsys
parent97b469537bffbedf2cfbc9c58f208b2641b1544a (diff)
downloadCMake-ed853b5d70649465370f161b774cf91735a822b3.zip
CMake-ed853b5d70649465370f161b774cf91735a822b3.tar.gz
CMake-ed853b5d70649465370f161b774cf91735a822b3.tar.bz2
ENH: Removed pipe selection argument from WaitForData method in kwsysProcess. This greatly simplifies its use.
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/Process.h.in13
-rw-r--r--Source/kwsys/ProcessUNIX.c10
-rw-r--r--Source/kwsys/ProcessWin32.c12
-rw-r--r--Source/kwsys/test1.cxx4
-rw-r--r--Source/kwsys/testProcess.c4
5 files changed, 15 insertions, 28 deletions
diff --git a/Source/kwsys/Process.h.in b/Source/kwsys/Process.h.in
index 16ccddd..0583c0c 100644
--- a/Source/kwsys/Process.h.in
+++ b/Source/kwsys/Process.h.in
@@ -213,13 +213,9 @@ kwsysEXPORT const char* kwsysProcess_GetErrorString(kwsysProcess* cp);
kwsysEXPORT void kwsysProcess_Execute(kwsysProcess* cp);
/**
- * Block until data are available on a requested pipe, a timeout
- * expires, or the child process terminates. Arguments are as
- * follows:
+ * Block until data are available on a pipe, a timeout expires, or the
+ * child process terminates. Arguments are as follows:
*
- * pipes = Flags for the child output pipes of interest to the caller.
- * Possible values are Pipe_STDOUT and Pipe_STDERR. Multiple
- * pipes may be specified by using the bitwise OR operator '|'.
* data = If data are read, the pointer to which this points is
* set to point to the data.
* length = If data are read, the integer to which this points is
@@ -241,9 +237,8 @@ kwsysEXPORT void kwsysProcess_Execute(kwsysProcess* cp);
* call. Time elapsed has been subtracted from timeout
* argument.
*/
-kwsysEXPORT int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes,
- char** data, int* length,
- double* timeout);
+kwsysEXPORT int kwsysProcess_WaitForData(kwsysProcess* cp, char** data,
+ int* length, double* timeout);
enum kwsysProcess_Pipes_e
{
kwsysProcess_Pipe_STDOUT=1,
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index 5efd0b9..7e8c617 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -486,8 +486,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
}
/*--------------------------------------------------------------------------*/
-int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data,
- int* length, double* userTimeout)
+int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
+ double* userTimeout)
{
int i;
int max = -1;
@@ -537,9 +537,9 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data,
{
/* This is data on the special termination pipe. Ignore it. */
}
- else if(pipes & (1 << i))
+ else if(data && length)
{
- /* Caller wants this data. Report it. */
+ /* Report this data. */
*data = cp->PipeBuffer;
*length = n;
pipeId = (1 << i);
@@ -687,7 +687,7 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
}
/* Wait for all the pipes to close. Ignore all data. */
- while((pipe = kwsysProcess_WaitForData(cp, 0, 0, 0, userTimeout)) > 0)
+ while((pipe = kwsysProcess_WaitForData(cp, 0, 0, userTimeout)) > 0)
{
if(pipe == kwsysProcess_Pipe_Timeout)
{
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c
index 7317cf7..fd4ddd0 100644
--- a/Source/kwsys/ProcessWin32.c
+++ b/Source/kwsys/ProcessWin32.c
@@ -921,7 +921,7 @@ void kwsysProcess_Execute(kwsysProcess* cp)
/*--------------------------------------------------------------------------*/
-int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data, int* length,
+int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
double* userTimeout)
{
kwsysProcessTime userStartTime;
@@ -997,18 +997,14 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data, int* leng
/* The pipe closed. */
--cp->PipesLeft;
}
- else if(pipes & (1 << cp->CurrentIndex))
+ else if(data && length)
{
- /* Caller wants this data. Report it. */
+ /* Report this data. */
*data = cp->Pipe[cp->CurrentIndex].DataBuffer;
*length = cp->Pipe[cp->CurrentIndex].DataLength;
pipeId = (1 << cp->CurrentIndex);
done = 1;
}
- else
- {
- /* Caller does not care about this pipe. Ignore the data. */
- }
}
else
{
@@ -1074,7 +1070,7 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
}
/* Wait for the process to terminate. Ignore all data. */
- while((pipe = kwsysProcess_WaitForData(cp, 0, 0, 0, userTimeout)) > 0)
+ while((pipe = kwsysProcess_WaitForData(cp, 0, 0, userTimeout)) > 0)
{
if(pipe == kwsysProcess_Pipe_Timeout)
{
diff --git a/Source/kwsys/test1.cxx b/Source/kwsys/test1.cxx
index 7dd61a4..84c3f8d 100644
--- a/Source/kwsys/test1.cxx
+++ b/Source/kwsys/test1.cxx
@@ -11,9 +11,7 @@ int main()
kwsysProcess_Execute(kp);
char* data = 0;
int length = 0;
- while(kwsysProcess_WaitForData(kp, (kwsysProcess_Pipe_STDOUT |
- kwsysProcess_Pipe_STDERR),
- &data, &length, 0))
+ while(kwsysProcess_WaitForData(kp, &data, &length, 0))
{
kwsys_std::cout.write(data, length);
}
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index c569528..1b4ea74 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -66,9 +66,7 @@ int runChild(const char* cmd[], int state, int exception, int value)
kwsysProcess_SetTimeout(kp, 3);
kwsysProcess_Execute(kp);
- while(kwsysProcess_WaitForData(kp, (kwsysProcess_Pipe_STDOUT |
- kwsysProcess_Pipe_STDERR),
- &data, &length, 0))
+ while(kwsysProcess_WaitForData(kp, &data, &length, 0))
{
fwrite(data, 1, length, stdout);
fflush(stdout);