mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-14 05:20:50 -05:00
KWSys 2017-05-16 (fe1f22ce)
Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit fe1f22ceefdae18df33e5bab8483fec7a82d4cee (master).
Upstream Shortlog
-----------------
Adam Weisi (3):
8a799e36 Process: Improve definition ordering in header file
7d56ef24 Process: Save results from all children internally
b7eba998 Process: Add APIs to get results of individual processes
Ben Boeckel (2):
cea71543 style: remove separator comments
874dc559 style: help clang-format near macros
This commit is contained in:
committed by
Brad King
parent
2dec4695b7
commit
7be70ca6cc
10
Base64.c
10
Base64.c
@@ -9,13 +9,11 @@
|
|||||||
#include "Base64.h.in"
|
#include "Base64.h.in"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static const unsigned char kwsysBase64EncodeTable[65] =
|
static const unsigned char kwsysBase64EncodeTable[65] =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
"0123456789+/";
|
"0123456789+/";
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static const unsigned char kwsysBase64DecodeTable[256] = {
|
static const unsigned char kwsysBase64DecodeTable[256] = {
|
||||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
@@ -40,19 +38,16 @@ static const unsigned char kwsysBase64DecodeTable[256] = {
|
|||||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static unsigned char kwsysBase64EncodeChar(int c)
|
static unsigned char kwsysBase64EncodeChar(int c)
|
||||||
{
|
{
|
||||||
return kwsysBase64EncodeTable[(unsigned char)c];
|
return kwsysBase64EncodeTable[(unsigned char)c];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static unsigned char kwsysBase64DecodeChar(unsigned char c)
|
static unsigned char kwsysBase64DecodeChar(unsigned char c)
|
||||||
{
|
{
|
||||||
return kwsysBase64DecodeTable[c];
|
return kwsysBase64DecodeTable[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Encode 3 bytes into a 4 byte string. */
|
/* Encode 3 bytes into a 4 byte string. */
|
||||||
void kwsysBase64_Encode3(const unsigned char* src, unsigned char* dest)
|
void kwsysBase64_Encode3(const unsigned char* src, unsigned char* dest)
|
||||||
{
|
{
|
||||||
@@ -64,7 +59,6 @@ void kwsysBase64_Encode3(const unsigned char* src, unsigned char* dest)
|
|||||||
dest[3] = kwsysBase64EncodeChar(src[2] & 0x3F);
|
dest[3] = kwsysBase64EncodeChar(src[2] & 0x3F);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Encode 2 bytes into a 4 byte string. */
|
/* Encode 2 bytes into a 4 byte string. */
|
||||||
void kwsysBase64_Encode2(const unsigned char* src, unsigned char* dest)
|
void kwsysBase64_Encode2(const unsigned char* src, unsigned char* dest)
|
||||||
{
|
{
|
||||||
@@ -75,7 +69,6 @@ void kwsysBase64_Encode2(const unsigned char* src, unsigned char* dest)
|
|||||||
dest[3] = '=';
|
dest[3] = '=';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Encode 1 bytes into a 4 byte string. */
|
/* Encode 1 bytes into a 4 byte string. */
|
||||||
void kwsysBase64_Encode1(const unsigned char* src, unsigned char* dest)
|
void kwsysBase64_Encode1(const unsigned char* src, unsigned char* dest)
|
||||||
{
|
{
|
||||||
@@ -85,7 +78,6 @@ void kwsysBase64_Encode1(const unsigned char* src, unsigned char* dest)
|
|||||||
dest[3] = '=';
|
dest[3] = '=';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Encode 'length' bytes from the input buffer and store the
|
/* Encode 'length' bytes from the input buffer and store the
|
||||||
encoded stream into the output buffer. Return the length of the encoded
|
encoded stream into the output buffer. Return the length of the encoded
|
||||||
buffer (output). Note that the output buffer must be allocated by the caller
|
buffer (output). Note that the output buffer must be allocated by the caller
|
||||||
@@ -135,7 +127,6 @@ size_t kwsysBase64_Encode(const unsigned char* input, size_t length,
|
|||||||
return (size_t)(optr - output);
|
return (size_t)(optr - output);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Decode 4 bytes into a 3 byte string. */
|
/* Decode 4 bytes into a 3 byte string. */
|
||||||
int kwsysBase64_Decode3(const unsigned char* src, unsigned char* dest)
|
int kwsysBase64_Decode3(const unsigned char* src, unsigned char* dest)
|
||||||
{
|
{
|
||||||
@@ -169,7 +160,6 @@ int kwsysBase64_Decode3(const unsigned char* src, unsigned char* dest)
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Decode bytes from the input buffer and store the decoded stream
|
/* Decode bytes from the input buffer and store the decoded stream
|
||||||
into the output buffer until 'length' bytes have been decoded. Return the
|
into the output buffer until 'length' bytes have been decoded. Return the
|
||||||
real length of the decoded stream (which should be equal to 'length'). Note
|
real length of the decoded stream (which should be equal to 'length'). Note
|
||||||
|
|||||||
@@ -41,8 +41,6 @@
|
|||||||
|
|
||||||
namespace KWSYS_NAMESPACE {
|
namespace KWSYS_NAMESPACE {
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//============================================================================
|
|
||||||
struct CommandLineArgumentsCallbackStructure
|
struct CommandLineArgumentsCallbackStructure
|
||||||
{
|
{
|
||||||
const char* Argument;
|
const char* Argument;
|
||||||
@@ -91,10 +89,7 @@ public:
|
|||||||
|
|
||||||
VectorOfStrings UnusedArguments;
|
VectorOfStrings UnusedArguments;
|
||||||
};
|
};
|
||||||
//============================================================================
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
CommandLineArguments::CommandLineArguments()
|
CommandLineArguments::CommandLineArguments()
|
||||||
{
|
{
|
||||||
this->Internals = new CommandLineArguments::Internal;
|
this->Internals = new CommandLineArguments::Internal;
|
||||||
@@ -103,13 +98,11 @@ CommandLineArguments::CommandLineArguments()
|
|||||||
this->StoreUnusedArgumentsFlag = false;
|
this->StoreUnusedArgumentsFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
CommandLineArguments::~CommandLineArguments()
|
CommandLineArguments::~CommandLineArguments()
|
||||||
{
|
{
|
||||||
delete this->Internals;
|
delete this->Internals;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::Initialize(int argc, const char* const argv[])
|
void CommandLineArguments::Initialize(int argc, const char* const argv[])
|
||||||
{
|
{
|
||||||
int cc;
|
int cc;
|
||||||
@@ -121,26 +114,22 @@ void CommandLineArguments::Initialize(int argc, const char* const argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::Initialize(int argc, char* argv[])
|
void CommandLineArguments::Initialize(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
this->Initialize(argc, static_cast<const char* const*>(argv));
|
this->Initialize(argc, static_cast<const char* const*>(argv));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::Initialize()
|
void CommandLineArguments::Initialize()
|
||||||
{
|
{
|
||||||
this->Internals->Argv.clear();
|
this->Internals->Argv.clear();
|
||||||
this->Internals->LastArgument = 0;
|
this->Internals->LastArgument = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::ProcessArgument(const char* arg)
|
void CommandLineArguments::ProcessArgument(const char* arg)
|
||||||
{
|
{
|
||||||
this->Internals->Argv.push_back(arg);
|
this->Internals->Argv.push_back(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool CommandLineArguments::GetMatchedArguments(
|
bool CommandLineArguments::GetMatchedArguments(
|
||||||
std::vector<std::string>* matches, const std::string& arg)
|
std::vector<std::string>* matches, const std::string& arg)
|
||||||
{
|
{
|
||||||
@@ -164,7 +153,6 @@ bool CommandLineArguments::GetMatchedArguments(
|
|||||||
return !matches->empty();
|
return !matches->empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int CommandLineArguments::Parse()
|
int CommandLineArguments::Parse()
|
||||||
{
|
{
|
||||||
std::vector<std::string>::size_type cc;
|
std::vector<std::string>::size_type cc;
|
||||||
@@ -286,7 +274,6 @@ int CommandLineArguments::Parse()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::GetRemainingArguments(int* argc, char*** argv)
|
void CommandLineArguments::GetRemainingArguments(int* argc, char*** argv)
|
||||||
{
|
{
|
||||||
CommandLineArguments::Internal::VectorOfStrings::size_type size =
|
CommandLineArguments::Internal::VectorOfStrings::size_type size =
|
||||||
@@ -310,7 +297,6 @@ void CommandLineArguments::GetRemainingArguments(int* argc, char*** argv)
|
|||||||
*argv = args;
|
*argv = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::GetUnusedArguments(int* argc, char*** argv)
|
void CommandLineArguments::GetUnusedArguments(int* argc, char*** argv)
|
||||||
{
|
{
|
||||||
CommandLineArguments::Internal::VectorOfStrings::size_type size =
|
CommandLineArguments::Internal::VectorOfStrings::size_type size =
|
||||||
@@ -334,7 +320,6 @@ void CommandLineArguments::GetUnusedArguments(int* argc, char*** argv)
|
|||||||
*argv = args;
|
*argv = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::DeleteRemainingArguments(int argc, char*** argv)
|
void CommandLineArguments::DeleteRemainingArguments(int argc, char*** argv)
|
||||||
{
|
{
|
||||||
int cc;
|
int cc;
|
||||||
@@ -344,7 +329,6 @@ void CommandLineArguments::DeleteRemainingArguments(int argc, char*** argv)
|
|||||||
delete[] * argv;
|
delete[] * argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::AddCallback(const char* argument,
|
void CommandLineArguments::AddCallback(const char* argument,
|
||||||
ArgumentTypeEnum type,
|
ArgumentTypeEnum type,
|
||||||
CallbackType callback, void* call_data,
|
CallbackType callback, void* call_data,
|
||||||
@@ -363,7 +347,6 @@ void CommandLineArguments::AddCallback(const char* argument,
|
|||||||
this->GenerateHelp();
|
this->GenerateHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::AddArgument(const char* argument,
|
void CommandLineArguments::AddArgument(const char* argument,
|
||||||
ArgumentTypeEnum type,
|
ArgumentTypeEnum type,
|
||||||
VariableTypeEnum vtype, void* variable,
|
VariableTypeEnum vtype, void* variable,
|
||||||
@@ -382,7 +365,6 @@ void CommandLineArguments::AddArgument(const char* argument,
|
|||||||
this->GenerateHelp();
|
this->GenerateHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
#define CommandLineArgumentsAddArgumentMacro(type, ctype) \
|
#define CommandLineArgumentsAddArgumentMacro(type, ctype) \
|
||||||
void CommandLineArguments::AddArgument(const char* argument, \
|
void CommandLineArguments::AddArgument(const char* argument, \
|
||||||
ArgumentTypeEnum type, \
|
ArgumentTypeEnum type, \
|
||||||
@@ -392,22 +374,24 @@ void CommandLineArguments::AddArgument(const char* argument,
|
|||||||
variable, help); \
|
variable, help); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
CommandLineArgumentsAddArgumentMacro(BOOL, bool)
|
CommandLineArgumentsAddArgumentMacro(BOOL, bool)
|
||||||
CommandLineArgumentsAddArgumentMacro(INT, int)
|
CommandLineArgumentsAddArgumentMacro(INT, int)
|
||||||
CommandLineArgumentsAddArgumentMacro(DOUBLE, double)
|
CommandLineArgumentsAddArgumentMacro(DOUBLE, double)
|
||||||
CommandLineArgumentsAddArgumentMacro(STRING, char*)
|
CommandLineArgumentsAddArgumentMacro(STRING, char*)
|
||||||
CommandLineArgumentsAddArgumentMacro(STL_STRING, std::string)
|
CommandLineArgumentsAddArgumentMacro(STL_STRING, std::string)
|
||||||
|
|
||||||
CommandLineArgumentsAddArgumentMacro(VECTOR_BOOL, std::vector<bool>)
|
CommandLineArgumentsAddArgumentMacro(VECTOR_BOOL, std::vector<bool>)
|
||||||
CommandLineArgumentsAddArgumentMacro(VECTOR_INT, std::vector<int>)
|
CommandLineArgumentsAddArgumentMacro(VECTOR_INT, std::vector<int>)
|
||||||
CommandLineArgumentsAddArgumentMacro(VECTOR_DOUBLE,
|
CommandLineArgumentsAddArgumentMacro(VECTOR_DOUBLE, std::vector<double>)
|
||||||
std::vector<double>)
|
CommandLineArgumentsAddArgumentMacro(VECTOR_STRING, std::vector<char*>)
|
||||||
CommandLineArgumentsAddArgumentMacro(VECTOR_STRING,
|
CommandLineArgumentsAddArgumentMacro(VECTOR_STL_STRING,
|
||||||
std::vector<char*>)
|
std::vector<std::string>)
|
||||||
CommandLineArgumentsAddArgumentMacro(
|
#ifdef HELP_CLANG_FORMAT
|
||||||
VECTOR_STL_STRING, std::vector<std::string>)
|
;
|
||||||
|
#endif
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
#define CommandLineArgumentsAddBooleanArgumentMacro(type, ctype) \
|
#define CommandLineArgumentsAddBooleanArgumentMacro(type, ctype) \
|
||||||
void CommandLineArguments::AddBooleanArgument( \
|
void CommandLineArguments::AddBooleanArgument( \
|
||||||
const char* argument, ctype* variable, const char* help) \
|
const char* argument, ctype* variable, const char* help) \
|
||||||
@@ -416,29 +400,28 @@ CommandLineArgumentsAddArgumentMacro(BOOL, bool)
|
|||||||
CommandLineArguments::type##_TYPE, variable, help); \
|
CommandLineArguments::type##_TYPE, variable, help); \
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandLineArgumentsAddBooleanArgumentMacro(BOOL, bool)
|
/* clang-format off */
|
||||||
CommandLineArgumentsAddBooleanArgumentMacro(INT, int)
|
CommandLineArgumentsAddBooleanArgumentMacro(BOOL, bool)
|
||||||
CommandLineArgumentsAddBooleanArgumentMacro(DOUBLE,
|
CommandLineArgumentsAddBooleanArgumentMacro(INT, int)
|
||||||
double)
|
CommandLineArgumentsAddBooleanArgumentMacro(DOUBLE, double)
|
||||||
CommandLineArgumentsAddBooleanArgumentMacro(STRING,
|
CommandLineArgumentsAddBooleanArgumentMacro(STRING, char*)
|
||||||
char*)
|
CommandLineArgumentsAddBooleanArgumentMacro(STL_STRING, std::string)
|
||||||
CommandLineArgumentsAddBooleanArgumentMacro(
|
#ifdef HELP_CLANG_FORMAT
|
||||||
STL_STRING, std::string)
|
;
|
||||||
|
#endif
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
void CommandLineArguments::SetClientData(void* client_data)
|
||||||
void CommandLineArguments::SetClientData(void* client_data)
|
|
||||||
{
|
{
|
||||||
this->Internals->ClientData = client_data;
|
this->Internals->ClientData = client_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::SetUnknownArgumentCallback(
|
void CommandLineArguments::SetUnknownArgumentCallback(
|
||||||
CommandLineArguments::ErrorCallbackType callback)
|
CommandLineArguments::ErrorCallbackType callback)
|
||||||
{
|
{
|
||||||
this->Internals->UnknownArgumentCallback = callback;
|
this->Internals->UnknownArgumentCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* CommandLineArguments::GetHelp(const char* arg)
|
const char* CommandLineArguments::GetHelp(const char* arg)
|
||||||
{
|
{
|
||||||
CommandLineArguments::Internal::CallbacksMap::iterator it =
|
CommandLineArguments::Internal::CallbacksMap::iterator it =
|
||||||
@@ -461,7 +444,6 @@ const char* CommandLineArguments::GetHelp(const char* arg)
|
|||||||
return cs->Help;
|
return cs->Help;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::SetLineLength(unsigned int ll)
|
void CommandLineArguments::SetLineLength(unsigned int ll)
|
||||||
{
|
{
|
||||||
if (ll < 9 || ll > 1000) {
|
if (ll < 9 || ll > 1000) {
|
||||||
@@ -471,19 +453,16 @@ void CommandLineArguments::SetLineLength(unsigned int ll)
|
|||||||
this->GenerateHelp();
|
this->GenerateHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* CommandLineArguments::GetArgv0()
|
const char* CommandLineArguments::GetArgv0()
|
||||||
{
|
{
|
||||||
return this->Internals->Argv0.c_str();
|
return this->Internals->Argv0.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
unsigned int CommandLineArguments::GetLastArgument()
|
unsigned int CommandLineArguments::GetLastArgument()
|
||||||
{
|
{
|
||||||
return static_cast<unsigned int>(this->Internals->LastArgument + 1);
|
return static_cast<unsigned int>(this->Internals->LastArgument + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::GenerateHelp()
|
void CommandLineArguments::GenerateHelp()
|
||||||
{
|
{
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
@@ -633,7 +612,6 @@ void CommandLineArguments::GenerateHelp()
|
|||||||
this->Help = str.str();
|
this->Help = str.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::PopulateVariable(bool* variable,
|
void CommandLineArguments::PopulateVariable(bool* variable,
|
||||||
const std::string& value)
|
const std::string& value)
|
||||||
{
|
{
|
||||||
@@ -646,7 +624,6 @@ void CommandLineArguments::PopulateVariable(bool* variable,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::PopulateVariable(int* variable,
|
void CommandLineArguments::PopulateVariable(int* variable,
|
||||||
const std::string& value)
|
const std::string& value)
|
||||||
{
|
{
|
||||||
@@ -658,7 +635,6 @@ void CommandLineArguments::PopulateVariable(int* variable,
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::PopulateVariable(double* variable,
|
void CommandLineArguments::PopulateVariable(double* variable,
|
||||||
const std::string& value)
|
const std::string& value)
|
||||||
{
|
{
|
||||||
@@ -670,7 +646,6 @@ void CommandLineArguments::PopulateVariable(double* variable,
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::PopulateVariable(char** variable,
|
void CommandLineArguments::PopulateVariable(char** variable,
|
||||||
const std::string& value)
|
const std::string& value)
|
||||||
{
|
{
|
||||||
@@ -682,14 +657,12 @@ void CommandLineArguments::PopulateVariable(char** variable,
|
|||||||
strcpy(*variable, value.c_str());
|
strcpy(*variable, value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::PopulateVariable(std::string* variable,
|
void CommandLineArguments::PopulateVariable(std::string* variable,
|
||||||
const std::string& value)
|
const std::string& value)
|
||||||
{
|
{
|
||||||
*variable = value;
|
*variable = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::PopulateVariable(std::vector<bool>* variable,
|
void CommandLineArguments::PopulateVariable(std::vector<bool>* variable,
|
||||||
const std::string& value)
|
const std::string& value)
|
||||||
{
|
{
|
||||||
@@ -702,7 +675,6 @@ void CommandLineArguments::PopulateVariable(std::vector<bool>* variable,
|
|||||||
variable->push_back(val);
|
variable->push_back(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::PopulateVariable(std::vector<int>* variable,
|
void CommandLineArguments::PopulateVariable(std::vector<int>* variable,
|
||||||
const std::string& value)
|
const std::string& value)
|
||||||
{
|
{
|
||||||
@@ -714,7 +686,6 @@ void CommandLineArguments::PopulateVariable(std::vector<int>* variable,
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::PopulateVariable(std::vector<double>* variable,
|
void CommandLineArguments::PopulateVariable(std::vector<double>* variable,
|
||||||
const std::string& value)
|
const std::string& value)
|
||||||
{
|
{
|
||||||
@@ -726,7 +697,6 @@ void CommandLineArguments::PopulateVariable(std::vector<double>* variable,
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::PopulateVariable(std::vector<char*>* variable,
|
void CommandLineArguments::PopulateVariable(std::vector<char*>* variable,
|
||||||
const std::string& value)
|
const std::string& value)
|
||||||
{
|
{
|
||||||
@@ -735,14 +705,12 @@ void CommandLineArguments::PopulateVariable(std::vector<char*>* variable,
|
|||||||
variable->push_back(var);
|
variable->push_back(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void CommandLineArguments::PopulateVariable(std::vector<std::string>* variable,
|
void CommandLineArguments::PopulateVariable(std::vector<std::string>* variable,
|
||||||
const std::string& value)
|
const std::string& value)
|
||||||
{
|
{
|
||||||
variable->push_back(value);
|
variable->push_back(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool CommandLineArguments::PopulateVariable(
|
bool CommandLineArguments::PopulateVariable(
|
||||||
CommandLineArgumentsCallbackStructure* cs, const char* value)
|
CommandLineArgumentsCallbackStructure* cs, const char* value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
namespace KWSYS_NAMESPACE {
|
namespace KWSYS_NAMESPACE {
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
class DirectoryInternals
|
class DirectoryInternals
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -31,25 +30,21 @@ public:
|
|||||||
std::string Path;
|
std::string Path;
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
Directory::Directory()
|
Directory::Directory()
|
||||||
{
|
{
|
||||||
this->Internal = new DirectoryInternals;
|
this->Internal = new DirectoryInternals;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
Directory::~Directory()
|
Directory::~Directory()
|
||||||
{
|
{
|
||||||
delete this->Internal;
|
delete this->Internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
unsigned long Directory::GetNumberOfFiles() const
|
unsigned long Directory::GetNumberOfFiles() const
|
||||||
{
|
{
|
||||||
return static_cast<unsigned long>(this->Internal->Files.size());
|
return static_cast<unsigned long>(this->Internal->Files.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* Directory::GetFile(unsigned long dindex) const
|
const char* Directory::GetFile(unsigned long dindex) const
|
||||||
{
|
{
|
||||||
if (dindex >= this->Internal->Files.size()) {
|
if (dindex >= this->Internal->Files.size()) {
|
||||||
@@ -58,13 +53,11 @@ const char* Directory::GetFile(unsigned long dindex) const
|
|||||||
return this->Internal->Files[dindex].c_str();
|
return this->Internal->Files[dindex].c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* Directory::GetPath() const
|
const char* Directory::GetPath() const
|
||||||
{
|
{
|
||||||
return this->Internal->Path.c_str();
|
return this->Internal->Path.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void Directory::Clear()
|
void Directory::Clear()
|
||||||
{
|
{
|
||||||
this->Internal->Path.resize(0);
|
this->Internal->Path.resize(0);
|
||||||
|
|||||||
@@ -26,20 +26,17 @@
|
|||||||
// the static methods of DynamicLoader.
|
// the static methods of DynamicLoader.
|
||||||
|
|
||||||
#if !KWSYS_SUPPORTS_SHARED_LIBS
|
#if !KWSYS_SUPPORTS_SHARED_LIBS
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Implementation for environments without dynamic libs
|
// Implementation for environments without dynamic libs
|
||||||
#include <string.h> // for strerror()
|
#include <string.h> // for strerror()
|
||||||
|
|
||||||
namespace KWSYS_NAMESPACE {
|
namespace KWSYS_NAMESPACE {
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
||||||
const std::string& libname)
|
const std::string& libname)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
||||||
{
|
{
|
||||||
if (!lib) {
|
if (!lib) {
|
||||||
@@ -49,14 +46,12 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
return "General error";
|
return "General error";
|
||||||
@@ -65,21 +60,18 @@ const char* DynamicLoader::LastError()
|
|||||||
} // namespace KWSYS_NAMESPACE
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|
||||||
#elif defined(__hpux)
|
#elif defined(__hpux)
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Implementation for HPUX machines
|
// Implementation for HPUX machines
|
||||||
#include <dl.h>
|
#include <dl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
namespace KWSYS_NAMESPACE {
|
namespace KWSYS_NAMESPACE {
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
||||||
const std::string& libname)
|
const std::string& libname)
|
||||||
{
|
{
|
||||||
return shl_load(libname.c_str(), BIND_DEFERRED | DYNAMIC_PATH, 0L);
|
return shl_load(libname.c_str(), BIND_DEFERRED | DYNAMIC_PATH, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
||||||
{
|
{
|
||||||
if (!lib) {
|
if (!lib) {
|
||||||
@@ -88,7 +80,6 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
|||||||
return !shl_unload(lib);
|
return !shl_unload(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
||||||
{
|
{
|
||||||
@@ -132,14 +123,12 @@ const char* DynamicLoader::LastError()
|
|||||||
} // namespace KWSYS_NAMESPACE
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|
||||||
#elif defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED < 1030)
|
#elif defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED < 1030)
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Implementation for Mac OS X 10.2.x and earlier
|
// Implementation for Mac OS X 10.2.x and earlier
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
#include <string.h> // for strlen
|
#include <string.h> // for strlen
|
||||||
|
|
||||||
namespace KWSYS_NAMESPACE {
|
namespace KWSYS_NAMESPACE {
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
||||||
const std::string& libname)
|
const std::string& libname)
|
||||||
{
|
{
|
||||||
@@ -158,7 +147,6 @@ DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
||||||
{
|
{
|
||||||
// NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED
|
// NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED
|
||||||
@@ -170,7 +158,6 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
||||||
{
|
{
|
||||||
@@ -191,7 +178,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
|||||||
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
|
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@@ -200,13 +186,11 @@ const char* DynamicLoader::LastError()
|
|||||||
} // namespace KWSYS_NAMESPACE
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|
||||||
#elif defined(_WIN32) && !defined(__CYGWIN__)
|
#elif defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Implementation for Windows win32 code but not cygwin
|
// Implementation for Windows win32 code but not cygwin
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
namespace KWSYS_NAMESPACE {
|
namespace KWSYS_NAMESPACE {
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
||||||
const std::string& libname)
|
const std::string& libname)
|
||||||
{
|
{
|
||||||
@@ -220,13 +204,11 @@ DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
|||||||
return lh;
|
return lh;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
||||||
{
|
{
|
||||||
return (int)FreeLibrary(lib);
|
return (int)FreeLibrary(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
||||||
{
|
{
|
||||||
@@ -274,7 +256,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
LPVOID lpMsgBuf = NULL;
|
LPVOID lpMsgBuf = NULL;
|
||||||
@@ -299,7 +280,6 @@ const char* DynamicLoader::LastError()
|
|||||||
} // namespace KWSYS_NAMESPACE
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|
||||||
#elif defined(__BEOS__)
|
#elif defined(__BEOS__)
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Implementation for BeOS / Haiku
|
// Implementation for BeOS / Haiku
|
||||||
#include <string.h> // for strerror()
|
#include <string.h> // for strerror()
|
||||||
|
|
||||||
@@ -310,7 +290,6 @@ namespace KWSYS_NAMESPACE {
|
|||||||
|
|
||||||
static image_id last_dynamic_err = B_OK;
|
static image_id last_dynamic_err = B_OK;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
||||||
const std::string& libname)
|
const std::string& libname)
|
||||||
{
|
{
|
||||||
@@ -325,7 +304,6 @@ DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
|||||||
return rc + 1;
|
return rc + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
||||||
{
|
{
|
||||||
if (!lib) {
|
if (!lib) {
|
||||||
@@ -343,7 +321,6 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
||||||
{
|
{
|
||||||
@@ -372,7 +349,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
|||||||
return result.psym;
|
return result.psym;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
const char* retval = strerror(last_dynamic_err);
|
const char* retval = strerror(last_dynamic_err);
|
||||||
@@ -383,7 +359,6 @@ const char* DynamicLoader::LastError()
|
|||||||
} // namespace KWSYS_NAMESPACE
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|
||||||
#elif defined(__MINT__)
|
#elif defined(__MINT__)
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Implementation for FreeMiNT on Atari
|
// Implementation for FreeMiNT on Atari
|
||||||
#define _GNU_SOURCE /* for program_invocation_name */
|
#define _GNU_SOURCE /* for program_invocation_name */
|
||||||
#include <dld.h>
|
#include <dld.h>
|
||||||
@@ -393,7 +368,6 @@ const char* DynamicLoader::LastError()
|
|||||||
|
|
||||||
namespace KWSYS_NAMESPACE {
|
namespace KWSYS_NAMESPACE {
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
||||||
const std::string& libname)
|
const std::string& libname)
|
||||||
{
|
{
|
||||||
@@ -404,7 +378,6 @@ DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
|||||||
return (void*)name;
|
return (void*)name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
||||||
{
|
{
|
||||||
dld_unlink_by_file((char*)lib, 0);
|
dld_unlink_by_file((char*)lib, 0);
|
||||||
@@ -412,7 +385,6 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
||||||
{
|
{
|
||||||
@@ -426,7 +398,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
|||||||
return result.psym;
|
return result.psym;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
return dld_strerror(dld_errno);
|
return dld_strerror(dld_errno);
|
||||||
@@ -435,21 +406,18 @@ const char* DynamicLoader::LastError()
|
|||||||
} // namespace KWSYS_NAMESPACE
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|
||||||
#else
|
#else
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Default implementation for *NIX systems (including Mac OS X 10.3 and
|
// Default implementation for *NIX systems (including Mac OS X 10.3 and
|
||||||
// later) which use dlopen
|
// later) which use dlopen
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
namespace KWSYS_NAMESPACE {
|
namespace KWSYS_NAMESPACE {
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
|
||||||
const std::string& libname)
|
const std::string& libname)
|
||||||
{
|
{
|
||||||
return dlopen(libname.c_str(), RTLD_LAZY);
|
return dlopen(libname.c_str(), RTLD_LAZY);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
||||||
{
|
{
|
||||||
if (lib) {
|
if (lib) {
|
||||||
@@ -460,7 +428,6 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
DynamicLoader::LibraryHandle lib, const std::string& sym)
|
||||||
{
|
{
|
||||||
@@ -474,7 +441,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
|||||||
return result.psym;
|
return result.psym;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
return dlerror();
|
return dlerror();
|
||||||
|
|||||||
12
Glob.cxx
12
Glob.cxx
@@ -37,7 +37,6 @@ namespace KWSYS_NAMESPACE {
|
|||||||
#define KWSYS_GLOB_SUPPORT_NETWORK_PATHS
|
#define KWSYS_GLOB_SUPPORT_NETWORK_PATHS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
class GlobInternals
|
class GlobInternals
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -45,7 +44,6 @@ public:
|
|||||||
std::vector<kwsys::RegularExpression> Expressions;
|
std::vector<kwsys::RegularExpression> Expressions;
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
Glob::Glob()
|
Glob::Glob()
|
||||||
{
|
{
|
||||||
this->Internals = new GlobInternals;
|
this->Internals = new GlobInternals;
|
||||||
@@ -62,19 +60,16 @@ Glob::Glob()
|
|||||||
this->RecurseListDirs = false;
|
this->RecurseListDirs = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
Glob::~Glob()
|
Glob::~Glob()
|
||||||
{
|
{
|
||||||
delete this->Internals;
|
delete this->Internals;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
std::vector<std::string>& Glob::GetFiles()
|
std::vector<std::string>& Glob::GetFiles()
|
||||||
{
|
{
|
||||||
return this->Internals->Files;
|
return this->Internals->Files;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
std::string Glob::PatternToRegex(const std::string& pattern,
|
std::string Glob::PatternToRegex(const std::string& pattern,
|
||||||
bool require_whole_string, bool preserve_case)
|
bool require_whole_string, bool preserve_case)
|
||||||
{
|
{
|
||||||
@@ -183,7 +178,6 @@ std::string Glob::PatternToRegex(const std::string& pattern,
|
|||||||
return regex;
|
return regex;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool Glob::RecurseDirectory(std::string::size_type start,
|
bool Glob::RecurseDirectory(std::string::size_type start,
|
||||||
const std::string& dir, GlobMessages* messages)
|
const std::string& dir, GlobMessages* messages)
|
||||||
{
|
{
|
||||||
@@ -277,7 +271,6 @@ bool Glob::RecurseDirectory(std::string::size_type start,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void Glob::ProcessDirectory(std::string::size_type start,
|
void Glob::ProcessDirectory(std::string::size_type start,
|
||||||
const std::string& dir, GlobMessages* messages)
|
const std::string& dir, GlobMessages* messages)
|
||||||
{
|
{
|
||||||
@@ -337,7 +330,6 @@ void Glob::ProcessDirectory(std::string::size_type start,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool Glob::FindFiles(const std::string& inexpr, GlobMessages* messages)
|
bool Glob::FindFiles(const std::string& inexpr, GlobMessages* messages)
|
||||||
{
|
{
|
||||||
std::string cexpr;
|
std::string cexpr;
|
||||||
@@ -420,14 +412,12 @@ bool Glob::FindFiles(const std::string& inexpr, GlobMessages* messages)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void Glob::AddExpression(const std::string& expr)
|
void Glob::AddExpression(const std::string& expr)
|
||||||
{
|
{
|
||||||
this->Internals->Expressions.push_back(
|
this->Internals->Expressions.push_back(
|
||||||
kwsys::RegularExpression(this->PatternToRegex(expr)));
|
kwsys::RegularExpression(this->PatternToRegex(expr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void Glob::SetRelative(const char* dir)
|
void Glob::SetRelative(const char* dir)
|
||||||
{
|
{
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
@@ -437,7 +427,6 @@ void Glob::SetRelative(const char* dir)
|
|||||||
this->Relative = dir;
|
this->Relative = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* Glob::GetRelative()
|
const char* Glob::GetRelative()
|
||||||
{
|
{
|
||||||
if (this->Relative.empty()) {
|
if (this->Relative.empty()) {
|
||||||
@@ -446,7 +435,6 @@ const char* Glob::GetRelative()
|
|||||||
return this->Relative.c_str();
|
return this->Relative.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void Glob::AddFile(std::vector<std::string>& files, const std::string& file)
|
void Glob::AddFile(std::vector<std::string>& files, const std::string& file)
|
||||||
{
|
{
|
||||||
if (!this->Relative.empty()) {
|
if (!this->Relative.empty()) {
|
||||||
|
|||||||
10
MD5.c
10
MD5.c
@@ -13,8 +13,6 @@
|
|||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> /* memcpy, strlen */
|
#include <string.h> /* memcpy, strlen */
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* This MD5 implementation has been taken from a third party. Slight
|
/* This MD5 implementation has been taken from a third party. Slight
|
||||||
modifications to the arrangement of the code have been made to put
|
modifications to the arrangement of the code have been made to put
|
||||||
it in a single source file instead of a separate header and
|
it in a single source file instead of a separate header and
|
||||||
@@ -425,14 +423,12 @@ static void md5_finish(md5_state_t* pms, md5_byte_t digest[16])
|
|||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Wrap up the MD5 state in our opaque structure. */
|
/* Wrap up the MD5 state in our opaque structure. */
|
||||||
struct kwsysMD5_s
|
struct kwsysMD5_s
|
||||||
{
|
{
|
||||||
md5_state_t md5_state;
|
md5_state_t md5_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
kwsysMD5* kwsysMD5_New(void)
|
kwsysMD5* kwsysMD5_New(void)
|
||||||
{
|
{
|
||||||
/* Allocate a process control structure. */
|
/* Allocate a process control structure. */
|
||||||
@@ -443,7 +439,6 @@ kwsysMD5* kwsysMD5_New(void)
|
|||||||
return md5;
|
return md5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysMD5_Delete(kwsysMD5* md5)
|
void kwsysMD5_Delete(kwsysMD5* md5)
|
||||||
{
|
{
|
||||||
/* Make sure we have an instance. */
|
/* Make sure we have an instance. */
|
||||||
@@ -455,13 +450,11 @@ void kwsysMD5_Delete(kwsysMD5* md5)
|
|||||||
free(md5);
|
free(md5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysMD5_Initialize(kwsysMD5* md5)
|
void kwsysMD5_Initialize(kwsysMD5* md5)
|
||||||
{
|
{
|
||||||
md5_init(&md5->md5_state);
|
md5_init(&md5->md5_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysMD5_Append(kwsysMD5* md5, unsigned char const* data, int length)
|
void kwsysMD5_Append(kwsysMD5* md5, unsigned char const* data, int length)
|
||||||
{
|
{
|
||||||
size_t dlen;
|
size_t dlen;
|
||||||
@@ -473,13 +466,11 @@ void kwsysMD5_Append(kwsysMD5* md5, unsigned char const* data, int length)
|
|||||||
md5_append(&md5->md5_state, (md5_byte_t const*)data, dlen);
|
md5_append(&md5->md5_state, (md5_byte_t const*)data, dlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysMD5_Finalize(kwsysMD5* md5, unsigned char digest[16])
|
void kwsysMD5_Finalize(kwsysMD5* md5, unsigned char digest[16])
|
||||||
{
|
{
|
||||||
md5_finish(&md5->md5_state, (md5_byte_t*)digest);
|
md5_finish(&md5->md5_state, (md5_byte_t*)digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysMD5_FinalizeHex(kwsysMD5* md5, char buffer[32])
|
void kwsysMD5_FinalizeHex(kwsysMD5* md5, char buffer[32])
|
||||||
{
|
{
|
||||||
unsigned char digest[16];
|
unsigned char digest[16];
|
||||||
@@ -487,7 +478,6 @@ void kwsysMD5_FinalizeHex(kwsysMD5* md5, char buffer[32])
|
|||||||
kwsysMD5_DigestToHex(digest, buffer);
|
kwsysMD5_DigestToHex(digest, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysMD5_DigestToHex(unsigned char const digest[16], char buffer[32])
|
void kwsysMD5_DigestToHex(unsigned char const digest[16], char buffer[32])
|
||||||
{
|
{
|
||||||
/* Map from 4-bit index to hexadecimal representation. */
|
/* Map from 4-bit index to hexadecimal representation. */
|
||||||
|
|||||||
73
Process.h.in
73
Process.h.in
@@ -42,7 +42,6 @@
|
|||||||
#define kwsysProcess_State_Expired kwsys_ns(Process_State_Expired)
|
#define kwsysProcess_State_Expired kwsys_ns(Process_State_Expired)
|
||||||
#define kwsysProcess_State_Killed kwsys_ns(Process_State_Killed)
|
#define kwsysProcess_State_Killed kwsys_ns(Process_State_Killed)
|
||||||
#define kwsysProcess_State_Disowned kwsys_ns(Process_State_Disowned)
|
#define kwsysProcess_State_Disowned kwsys_ns(Process_State_Disowned)
|
||||||
#define kwsysProcess_GetState kwsys_ns(Process_GetState)
|
|
||||||
#define kwsysProcess_State_e kwsys_ns(Process_State_e)
|
#define kwsysProcess_State_e kwsys_ns(Process_State_e)
|
||||||
#define kwsysProcess_Exception_None kwsys_ns(Process_Exception_None)
|
#define kwsysProcess_Exception_None kwsys_ns(Process_Exception_None)
|
||||||
#define kwsysProcess_Exception_Fault kwsys_ns(Process_Exception_Fault)
|
#define kwsysProcess_Exception_Fault kwsys_ns(Process_Exception_Fault)
|
||||||
@@ -50,12 +49,21 @@
|
|||||||
#define kwsysProcess_Exception_Interrupt kwsys_ns(Process_Exception_Interrupt)
|
#define kwsysProcess_Exception_Interrupt kwsys_ns(Process_Exception_Interrupt)
|
||||||
#define kwsysProcess_Exception_Numerical kwsys_ns(Process_Exception_Numerical)
|
#define kwsysProcess_Exception_Numerical kwsys_ns(Process_Exception_Numerical)
|
||||||
#define kwsysProcess_Exception_Other kwsys_ns(Process_Exception_Other)
|
#define kwsysProcess_Exception_Other kwsys_ns(Process_Exception_Other)
|
||||||
#define kwsysProcess_GetExitException kwsys_ns(Process_GetExitException)
|
|
||||||
#define kwsysProcess_Exception_e kwsys_ns(Process_Exception_e)
|
#define kwsysProcess_Exception_e kwsys_ns(Process_Exception_e)
|
||||||
|
#define kwsysProcess_GetState kwsys_ns(Process_GetState)
|
||||||
|
#define kwsysProcess_GetExitException kwsys_ns(Process_GetExitException)
|
||||||
#define kwsysProcess_GetExitCode kwsys_ns(Process_GetExitCode)
|
#define kwsysProcess_GetExitCode kwsys_ns(Process_GetExitCode)
|
||||||
#define kwsysProcess_GetExitValue kwsys_ns(Process_GetExitValue)
|
#define kwsysProcess_GetExitValue kwsys_ns(Process_GetExitValue)
|
||||||
#define kwsysProcess_GetErrorString kwsys_ns(Process_GetErrorString)
|
#define kwsysProcess_GetErrorString kwsys_ns(Process_GetErrorString)
|
||||||
#define kwsysProcess_GetExceptionString kwsys_ns(Process_GetExceptionString)
|
#define kwsysProcess_GetExceptionString kwsys_ns(Process_GetExceptionString)
|
||||||
|
#define kwsysProcess_GetStateByIndex kwsys_ns(Process_GetStateByIndex)
|
||||||
|
#define kwsysProcess_GetExitExceptionByIndex \
|
||||||
|
kwsys_ns(Process_GetExitExceptionByIndex)
|
||||||
|
#define kwsysProcess_GetExitCodeByIndex kwsys_ns(Process_GetExitCodeByIndex)
|
||||||
|
#define kwsysProcess_GetExitValueByIndex kwsys_ns(Process_GetExitValueByIndex)
|
||||||
|
#define kwsysProcess_GetExceptionStringByIndex \
|
||||||
|
kwsys_ns(Process_GetExceptionStringByIndex)
|
||||||
|
#define kwsysProcess_GetExitCodeByIndex kwsys_ns(Process_GetExitCodeByIndex)
|
||||||
#define kwsysProcess_Execute kwsys_ns(Process_Execute)
|
#define kwsysProcess_Execute kwsys_ns(Process_Execute)
|
||||||
#define kwsysProcess_Disown kwsys_ns(Process_Disown)
|
#define kwsysProcess_Disown kwsys_ns(Process_Disown)
|
||||||
#define kwsysProcess_WaitForData kwsys_ns(Process_WaitForData)
|
#define kwsysProcess_WaitForData kwsys_ns(Process_WaitForData)
|
||||||
@@ -297,6 +305,67 @@ kwsysEXPORT const char* kwsysProcess_GetErrorString(kwsysProcess* cp);
|
|||||||
*/
|
*/
|
||||||
kwsysEXPORT const char* kwsysProcess_GetExceptionString(kwsysProcess* cp);
|
kwsysEXPORT const char* kwsysProcess_GetExceptionString(kwsysProcess* cp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current state of the Process instance. Possible states are:
|
||||||
|
*
|
||||||
|
* kwsysProcess_StateByIndex_Starting = Execute has not yet been called.
|
||||||
|
* kwsysProcess_StateByIndex_Exception = Child process exited abnormally.
|
||||||
|
* kwsysProcess_StateByIndex_Exited = Child process exited normally.
|
||||||
|
* kwsysProcess_StateByIndex_Error = Error getting the child return code.
|
||||||
|
*/
|
||||||
|
kwsysEXPORT int kwsysProcess_GetStateByIndex(kwsysProcess* cp, int idx);
|
||||||
|
enum kwsysProcess_StateByIndex_e
|
||||||
|
{
|
||||||
|
kwsysProcess_StateByIndex_Starting = kwsysProcess_State_Starting,
|
||||||
|
kwsysProcess_StateByIndex_Exception = kwsysProcess_State_Exception,
|
||||||
|
kwsysProcess_StateByIndex_Exited = kwsysProcess_State_Exited,
|
||||||
|
kwsysProcess_StateByIndex_Error = kwsysProcess_State_Error
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When GetState returns "Exception", this method returns a
|
||||||
|
* platform-independent description of the exceptional behavior that
|
||||||
|
* caused the child to terminate abnormally. Possible exceptions are:
|
||||||
|
*
|
||||||
|
* kwsysProcess_Exception_None = No exceptional behavior occurred.
|
||||||
|
* kwsysProcess_Exception_Fault = Child crashed with a memory fault.
|
||||||
|
* kwsysProcess_Exception_Illegal = Child crashed with an illegal
|
||||||
|
* instruction.
|
||||||
|
* kwsysProcess_Exception_Interrupt = Child was interrupted by user
|
||||||
|
* (Cntl-C/Break).
|
||||||
|
* kwsysProcess_Exception_Numerical = Child crashed with a numerical
|
||||||
|
* exception.
|
||||||
|
* kwsysProcess_Exception_Other = Child terminated for another reason.
|
||||||
|
*/
|
||||||
|
kwsysEXPORT int kwsysProcess_GetExitExceptionByIndex(kwsysProcess* cp,
|
||||||
|
int idx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When GetState returns "Exited" or "Exception", this method returns
|
||||||
|
* the platform-specific raw exit code of the process. UNIX platforms
|
||||||
|
* should use WIFEXITED/WEXITSTATUS and WIFSIGNALED/WTERMSIG to access
|
||||||
|
* this value. Windows users should compare the value to the various
|
||||||
|
* EXCEPTION_* values.
|
||||||
|
*
|
||||||
|
* If GetState returns "Exited", use GetExitValue to get the
|
||||||
|
* platform-independent child return value.
|
||||||
|
*/
|
||||||
|
kwsysEXPORT int kwsysProcess_GetExitCodeByIndex(kwsysProcess* cp, int idx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When GetState returns "Exited", this method returns the child's
|
||||||
|
* platform-independent exit code (such as the value returned by the
|
||||||
|
* child's main).
|
||||||
|
*/
|
||||||
|
kwsysEXPORT int kwsysProcess_GetExitValueByIndex(kwsysProcess* cp, int idx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When GetState returns "Exception", this method returns a string
|
||||||
|
* describing the problem. Otherwise, it returns NULL.
|
||||||
|
*/
|
||||||
|
kwsysEXPORT const char* kwsysProcess_GetExceptionStringByIndex(
|
||||||
|
kwsysProcess* cp, int idx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start executing the child process.
|
* Start executing the child process.
|
||||||
*/
|
*/
|
||||||
|
|||||||
233
ProcessUNIX.c
233
ProcessUNIX.c
@@ -140,7 +140,6 @@ typedef struct kwsysProcessCreateInformation_s
|
|||||||
int ErrorPipe[2];
|
int ErrorPipe[2];
|
||||||
} kwsysProcessCreateInformation;
|
} kwsysProcessCreateInformation;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessVolatileFree(volatile void* p);
|
static void kwsysProcessVolatileFree(volatile void* p);
|
||||||
static int kwsysProcessInitialize(kwsysProcess* cp);
|
static int kwsysProcessInitialize(kwsysProcess* cp);
|
||||||
static void kwsysProcessCleanup(kwsysProcess* cp, int error);
|
static void kwsysProcessCleanup(kwsysProcess* cp, int error);
|
||||||
@@ -166,7 +165,8 @@ static kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1,
|
|||||||
kwsysProcessTime in2);
|
kwsysProcessTime in2);
|
||||||
static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
|
static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
|
||||||
kwsysProcessTime in2);
|
kwsysProcessTime in2);
|
||||||
static void kwsysProcessSetExitException(kwsysProcess* cp, int sig);
|
static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int sig,
|
||||||
|
int idx);
|
||||||
static void kwsysProcessChildErrorExit(int errorPipe);
|
static void kwsysProcessChildErrorExit(int errorPipe);
|
||||||
static void kwsysProcessRestoreDefaultSignalHandlers(void);
|
static void kwsysProcessRestoreDefaultSignalHandlers(void);
|
||||||
static pid_t kwsysProcessFork(kwsysProcess* cp,
|
static pid_t kwsysProcessFork(kwsysProcess* cp,
|
||||||
@@ -184,7 +184,26 @@ static void kwsysProcessesSignalHandler(int signum, siginfo_t* info,
|
|||||||
static void kwsysProcessesSignalHandler(int signum);
|
static void kwsysProcessesSignalHandler(int signum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/* A structure containing results data for each process. */
|
||||||
|
typedef struct kwsysProcessResults_s kwsysProcessResults;
|
||||||
|
struct kwsysProcessResults_s
|
||||||
|
{
|
||||||
|
/* The status of the child process. */
|
||||||
|
int State;
|
||||||
|
|
||||||
|
/* The exceptional behavior that terminated the process, if any. */
|
||||||
|
int ExitException;
|
||||||
|
|
||||||
|
/* The process exit code. */
|
||||||
|
int ExitCode;
|
||||||
|
|
||||||
|
/* The process return code, if any. */
|
||||||
|
int ExitValue;
|
||||||
|
|
||||||
|
/* Description for the ExitException. */
|
||||||
|
char ExitExceptionString[KWSYSPE_PIPE_BUFFER_SIZE + 1];
|
||||||
|
};
|
||||||
|
|
||||||
/* Structure containing data used to implement the child's execution. */
|
/* Structure containing data used to implement the child's execution. */
|
||||||
struct kwsysProcess_s
|
struct kwsysProcess_s
|
||||||
{
|
{
|
||||||
@@ -255,28 +274,18 @@ struct kwsysProcess_s
|
|||||||
/* The number of children still executing. */
|
/* The number of children still executing. */
|
||||||
int CommandsLeft;
|
int CommandsLeft;
|
||||||
|
|
||||||
/* The current status of the child process. Must be atomic because
|
/* The status of the process structure. Must be atomic because
|
||||||
the signal handler checks this to avoid a race. */
|
the signal handler checks this to avoid a race. */
|
||||||
volatile sig_atomic_t State;
|
volatile sig_atomic_t State;
|
||||||
|
|
||||||
/* The exceptional behavior that terminated the child process, if
|
|
||||||
* any. */
|
|
||||||
int ExitException;
|
|
||||||
|
|
||||||
/* The exit code of the child process. */
|
|
||||||
int ExitCode;
|
|
||||||
|
|
||||||
/* The exit value of the child process, if any. */
|
|
||||||
int ExitValue;
|
|
||||||
|
|
||||||
/* Whether the process was killed. */
|
/* Whether the process was killed. */
|
||||||
volatile sig_atomic_t Killed;
|
volatile sig_atomic_t Killed;
|
||||||
|
|
||||||
/* Buffer for error message in case of failure. */
|
/* Buffer for error message in case of failure. */
|
||||||
char ErrorMessage[KWSYSPE_PIPE_BUFFER_SIZE + 1];
|
char ErrorMessage[KWSYSPE_PIPE_BUFFER_SIZE + 1];
|
||||||
|
|
||||||
/* Description for the ExitException. */
|
/* process results. */
|
||||||
char ExitExceptionString[KWSYSPE_PIPE_BUFFER_SIZE + 1];
|
kwsysProcessResults* ProcessResults;
|
||||||
|
|
||||||
/* The exit codes of each child process in the pipeline. */
|
/* The exit codes of each child process in the pipeline. */
|
||||||
int* CommandExitCodes;
|
int* CommandExitCodes;
|
||||||
@@ -301,7 +310,6 @@ struct kwsysProcess_s
|
|||||||
char* RealWorkingDirectory;
|
char* RealWorkingDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
kwsysProcess* kwsysProcess_New(void)
|
kwsysProcess* kwsysProcess_New(void)
|
||||||
{
|
{
|
||||||
/* Allocate a process control structure. */
|
/* Allocate a process control structure. */
|
||||||
@@ -328,7 +336,6 @@ kwsysProcess* kwsysProcess_New(void)
|
|||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_Delete(kwsysProcess* cp)
|
void kwsysProcess_Delete(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
/* Make sure we have an instance. */
|
/* Make sure we have an instance. */
|
||||||
@@ -354,10 +361,10 @@ void kwsysProcess_Delete(kwsysProcess* cp)
|
|||||||
if (cp->CommandExitCodes) {
|
if (cp->CommandExitCodes) {
|
||||||
free(cp->CommandExitCodes);
|
free(cp->CommandExitCodes);
|
||||||
}
|
}
|
||||||
|
free(cp->ProcessResults);
|
||||||
free(cp);
|
free(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_SetCommand(kwsysProcess* cp, char const* const* command)
|
int kwsysProcess_SetCommand(kwsysProcess* cp, char const* const* command)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -382,7 +389,6 @@ int kwsysProcess_SetCommand(kwsysProcess* cp, char const* const* command)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
|
int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
|
||||||
{
|
{
|
||||||
int newNumberOfCommands;
|
int newNumberOfCommands;
|
||||||
@@ -462,7 +468,6 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
|
void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -476,7 +481,6 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
|
|||||||
cp->TimeoutTime.tv_sec = -1;
|
cp->TimeoutTime.tv_sec = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
|
int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -502,7 +506,6 @@ int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_SetPipeFile(kwsysProcess* cp, int prPipe, const char* file)
|
int kwsysProcess_SetPipeFile(kwsysProcess* cp, int prPipe, const char* file)
|
||||||
{
|
{
|
||||||
char** pfile;
|
char** pfile;
|
||||||
@@ -543,7 +546,6 @@ int kwsysProcess_SetPipeFile(kwsysProcess* cp, int prPipe, const char* file)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_SetPipeShared(kwsysProcess* cp, int prPipe, int shared)
|
void kwsysProcess_SetPipeShared(kwsysProcess* cp, int prPipe, int shared)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -572,7 +574,6 @@ void kwsysProcess_SetPipeShared(kwsysProcess* cp, int prPipe, int shared)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, int p[2])
|
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, int p[2])
|
||||||
{
|
{
|
||||||
int* pPipeNative = 0;
|
int* pPipeNative = 0;
|
||||||
@@ -612,7 +613,6 @@ void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, int p[2])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_GetOption(kwsysProcess* cp, int optionId)
|
int kwsysProcess_GetOption(kwsysProcess* cp, int optionId)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -633,7 +633,6 @@ int kwsysProcess_GetOption(kwsysProcess* cp, int optionId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_SetOption(kwsysProcess* cp, int optionId, int value)
|
void kwsysProcess_SetOption(kwsysProcess* cp, int optionId, int value)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -658,31 +657,32 @@ void kwsysProcess_SetOption(kwsysProcess* cp, int optionId, int value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_GetState(kwsysProcess* cp)
|
int kwsysProcess_GetState(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
return cp ? cp->State : kwsysProcess_State_Error;
|
return cp ? cp->State : kwsysProcess_State_Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_GetExitException(kwsysProcess* cp)
|
int kwsysProcess_GetExitException(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
return cp ? cp->ExitException : kwsysProcess_Exception_Other;
|
return (cp && cp->ProcessResults && (cp->NumberOfCommands > 0))
|
||||||
|
? cp->ProcessResults[cp->NumberOfCommands - 1].ExitException
|
||||||
|
: kwsysProcess_Exception_Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_GetExitCode(kwsysProcess* cp)
|
int kwsysProcess_GetExitCode(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
return cp ? cp->ExitCode : 0;
|
return (cp && cp->ProcessResults && (cp->NumberOfCommands > 0))
|
||||||
|
? cp->ProcessResults[cp->NumberOfCommands - 1].ExitCode
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_GetExitValue(kwsysProcess* cp)
|
int kwsysProcess_GetExitValue(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
return cp ? cp->ExitValue : -1;
|
return (cp && cp->ProcessResults && (cp->NumberOfCommands > 0))
|
||||||
|
? cp->ProcessResults[cp->NumberOfCommands - 1].ExitValue
|
||||||
|
: -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
const char* kwsysProcess_GetErrorString(kwsysProcess* cp)
|
const char* kwsysProcess_GetErrorString(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -693,18 +693,58 @@ const char* kwsysProcess_GetErrorString(kwsysProcess* cp)
|
|||||||
return "Success";
|
return "Success";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
const char* kwsysProcess_GetExceptionString(kwsysProcess* cp)
|
const char* kwsysProcess_GetExceptionString(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!(cp && cp->ProcessResults && (cp->NumberOfCommands > 0))) {
|
||||||
return "GetExceptionString called with NULL process management structure";
|
return "GetExceptionString called with NULL process management structure";
|
||||||
} else if (cp->State == kwsysProcess_State_Exception) {
|
} else if (cp->State == kwsysProcess_State_Exception) {
|
||||||
return cp->ExitExceptionString;
|
return cp->ProcessResults[cp->NumberOfCommands - 1].ExitExceptionString;
|
||||||
}
|
}
|
||||||
return "No exception";
|
return "No exception";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/* the index should be in array bound. */
|
||||||
|
#define KWSYSPE_IDX_CHK(RET) \
|
||||||
|
if (!cp || idx >= cp->NumberOfCommands || idx < 0) { \
|
||||||
|
return RET; \
|
||||||
|
}
|
||||||
|
|
||||||
|
int kwsysProcess_GetStateByIndex(kwsysProcess* cp, int idx)
|
||||||
|
{
|
||||||
|
KWSYSPE_IDX_CHK(kwsysProcess_State_Error)
|
||||||
|
return cp->ProcessResults[idx].State;
|
||||||
|
}
|
||||||
|
|
||||||
|
int kwsysProcess_GetExitExceptionByIndex(kwsysProcess* cp, int idx)
|
||||||
|
{
|
||||||
|
KWSYSPE_IDX_CHK(kwsysProcess_Exception_Other)
|
||||||
|
return cp->ProcessResults[idx].ExitException;
|
||||||
|
}
|
||||||
|
|
||||||
|
int kwsysProcess_GetExitValueByIndex(kwsysProcess* cp, int idx)
|
||||||
|
{
|
||||||
|
KWSYSPE_IDX_CHK(-1)
|
||||||
|
return cp->ProcessResults[idx].ExitValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int kwsysProcess_GetExitCodeByIndex(kwsysProcess* cp, int idx)
|
||||||
|
{
|
||||||
|
KWSYSPE_IDX_CHK(-1)
|
||||||
|
return cp->CommandExitCodes[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* kwsysProcess_GetExceptionStringByIndex(kwsysProcess* cp, int idx)
|
||||||
|
{
|
||||||
|
KWSYSPE_IDX_CHK("GetExceptionString called with NULL process management "
|
||||||
|
"structure or index out of bound")
|
||||||
|
if (cp->ProcessResults[idx].State == kwsysProcess_StateByIndex_Exception) {
|
||||||
|
return cp->ProcessResults[idx].ExitExceptionString;
|
||||||
|
}
|
||||||
|
return "No exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef KWSYSPE_IDX_CHK
|
||||||
|
|
||||||
void kwsysProcess_Execute(kwsysProcess* cp)
|
void kwsysProcess_Execute(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -990,7 +1030,6 @@ void kwsysProcess_Execute(kwsysProcess* cp)
|
|||||||
cp->Detached = cp->OptionDetach;
|
cp->Detached = cp->OptionDetach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
kwsysEXPORT void kwsysProcess_Disown(kwsysProcess* cp)
|
kwsysEXPORT void kwsysProcess_Disown(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
/* Make sure a detached child process is running. */
|
/* Make sure a detached child process is running. */
|
||||||
@@ -1009,7 +1048,6 @@ kwsysEXPORT void kwsysProcess_Disown(kwsysProcess* cp)
|
|||||||
cp->State = kwsysProcess_State_Disowned;
|
cp->State = kwsysProcess_State_Disowned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
typedef struct kwsysProcessWaitData_s
|
typedef struct kwsysProcessWaitData_s
|
||||||
{
|
{
|
||||||
int Expired;
|
int Expired;
|
||||||
@@ -1021,7 +1059,6 @@ typedef struct kwsysProcessWaitData_s
|
|||||||
static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
|
static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
|
||||||
kwsysProcessWaitData* wd);
|
kwsysProcessWaitData* wd);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
|
int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
|
||||||
double* userTimeout)
|
double* userTimeout)
|
||||||
{
|
{
|
||||||
@@ -1083,7 +1120,6 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
|
static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
|
||||||
kwsysProcessWaitData* wd)
|
kwsysProcessWaitData* wd)
|
||||||
{
|
{
|
||||||
@@ -1285,10 +1321,8 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
|
int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
|
||||||
{
|
{
|
||||||
int status = 0;
|
|
||||||
int prPipe = 0;
|
int prPipe = 0;
|
||||||
|
|
||||||
/* Make sure we are executing a process. */
|
/* Make sure we are executing a process. */
|
||||||
@@ -1319,10 +1353,6 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
|
|||||||
cp->State = kwsysProcess_State_Error;
|
cp->State = kwsysProcess_State_Error;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use the status of the last process in the pipeline. */
|
|
||||||
status = cp->CommandExitCodes[cp->NumberOfCommands - 1];
|
|
||||||
|
|
||||||
/* Determine the outcome. */
|
/* Determine the outcome. */
|
||||||
if (cp->Killed) {
|
if (cp->Killed) {
|
||||||
/* We killed the child. */
|
/* We killed the child. */
|
||||||
@@ -1330,29 +1360,36 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
|
|||||||
} else if (cp->TimeoutExpired) {
|
} else if (cp->TimeoutExpired) {
|
||||||
/* The timeout expired. */
|
/* The timeout expired. */
|
||||||
cp->State = kwsysProcess_State_Expired;
|
cp->State = kwsysProcess_State_Expired;
|
||||||
} else if (WIFEXITED(status)) {
|
|
||||||
/* The child exited normally. */
|
|
||||||
cp->State = kwsysProcess_State_Exited;
|
|
||||||
cp->ExitException = kwsysProcess_Exception_None;
|
|
||||||
cp->ExitCode = status;
|
|
||||||
cp->ExitValue = (int)WEXITSTATUS(status);
|
|
||||||
} else if (WIFSIGNALED(status)) {
|
|
||||||
/* The child received an unhandled signal. */
|
|
||||||
cp->State = kwsysProcess_State_Exception;
|
|
||||||
cp->ExitCode = status;
|
|
||||||
kwsysProcessSetExitException(cp, (int)WTERMSIG(status));
|
|
||||||
} else {
|
} else {
|
||||||
/* Error getting the child return code. */
|
/* The children exited. Report the outcome of the child processes. */
|
||||||
strcpy(cp->ErrorMessage, "Error getting child return code.");
|
for (prPipe = 0; prPipe < cp->NumberOfCommands; ++prPipe) {
|
||||||
cp->State = kwsysProcess_State_Error;
|
cp->ProcessResults[prPipe].ExitCode = cp->CommandExitCodes[prPipe];
|
||||||
|
if (WIFEXITED(cp->ProcessResults[prPipe].ExitCode)) {
|
||||||
|
/* The child exited normally. */
|
||||||
|
cp->ProcessResults[prPipe].State = kwsysProcess_StateByIndex_Exited;
|
||||||
|
cp->ProcessResults[prPipe].ExitException = kwsysProcess_Exception_None;
|
||||||
|
cp->ProcessResults[prPipe].ExitValue =
|
||||||
|
(int)WEXITSTATUS(cp->ProcessResults[prPipe].ExitCode);
|
||||||
|
} else if (WIFSIGNALED(cp->ProcessResults[prPipe].ExitCode)) {
|
||||||
|
/* The child received an unhandled signal. */
|
||||||
|
cp->ProcessResults[prPipe].State = kwsysProcess_State_Exception;
|
||||||
|
kwsysProcessSetExitExceptionByIndex(
|
||||||
|
cp, (int)WTERMSIG(cp->ProcessResults[prPipe].ExitCode), prPipe);
|
||||||
|
} else {
|
||||||
|
/* Error getting the child return code. */
|
||||||
|
strcpy(cp->ProcessResults[prPipe].ExitExceptionString,
|
||||||
|
"Error getting child return code.");
|
||||||
|
cp->ProcessResults[prPipe].State = kwsysProcess_StateByIndex_Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* support legacy state status value */
|
||||||
|
cp->State = cp->ProcessResults[cp->NumberOfCommands - 1].State;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Normal cleanup. */
|
/* Normal cleanup. */
|
||||||
kwsysProcessCleanup(cp, 0);
|
kwsysProcessCleanup(cp, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_Interrupt(kwsysProcess* cp)
|
void kwsysProcess_Interrupt(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1384,7 +1421,6 @@ void kwsysProcess_Interrupt(kwsysProcess* cp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_Kill(kwsysProcess* cp)
|
void kwsysProcess_Kill(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1431,7 +1467,6 @@ void kwsysProcess_Kill(kwsysProcess* cp)
|
|||||||
cp->CommandsLeft = 0;
|
cp->CommandsLeft = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Call the free() function with a pointer to volatile without causing
|
/* Call the free() function with a pointer to volatile without causing
|
||||||
compiler warnings. */
|
compiler warnings. */
|
||||||
static void kwsysProcessVolatileFree(volatile void* p)
|
static void kwsysProcessVolatileFree(volatile void* p)
|
||||||
@@ -1448,7 +1483,6 @@ static void kwsysProcessVolatileFree(volatile void* p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Initialize a process control structure for kwsysProcess_Execute. */
|
/* Initialize a process control structure for kwsysProcess_Execute. */
|
||||||
static int kwsysProcessInitialize(kwsysProcess* cp)
|
static int kwsysProcessInitialize(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
@@ -1474,11 +1508,7 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
|
|||||||
#endif
|
#endif
|
||||||
cp->State = kwsysProcess_State_Starting;
|
cp->State = kwsysProcess_State_Starting;
|
||||||
cp->Killed = 0;
|
cp->Killed = 0;
|
||||||
cp->ExitException = kwsysProcess_Exception_None;
|
|
||||||
cp->ExitCode = 1;
|
|
||||||
cp->ExitValue = 1;
|
|
||||||
cp->ErrorMessage[0] = 0;
|
cp->ErrorMessage[0] = 0;
|
||||||
strcpy(cp->ExitExceptionString, "No exception");
|
|
||||||
|
|
||||||
oldForkPIDs = cp->ForkPIDs;
|
oldForkPIDs = cp->ForkPIDs;
|
||||||
cp->ForkPIDs = (volatile pid_t*)malloc(sizeof(volatile pid_t) *
|
cp->ForkPIDs = (volatile pid_t*)malloc(sizeof(volatile pid_t) *
|
||||||
@@ -1504,6 +1534,23 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
|
|||||||
memset(cp->CommandExitCodes, 0,
|
memset(cp->CommandExitCodes, 0,
|
||||||
sizeof(int) * (size_t)(cp->NumberOfCommands));
|
sizeof(int) * (size_t)(cp->NumberOfCommands));
|
||||||
|
|
||||||
|
/* Allocate process result information for each process. */
|
||||||
|
free(cp->ProcessResults);
|
||||||
|
cp->ProcessResults = (kwsysProcessResults*)malloc(
|
||||||
|
sizeof(kwsysProcessResults) * (size_t)(cp->NumberOfCommands));
|
||||||
|
if (!cp->ProcessResults) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memset(cp->ProcessResults, 0,
|
||||||
|
sizeof(kwsysProcessResults) * (size_t)(cp->NumberOfCommands));
|
||||||
|
for (i = 0; i < cp->NumberOfCommands; i++) {
|
||||||
|
cp->ProcessResults[i].ExitException = kwsysProcess_Exception_None;
|
||||||
|
cp->ProcessResults[i].State = kwsysProcess_StateByIndex_Starting;
|
||||||
|
cp->ProcessResults[i].ExitCode = 1;
|
||||||
|
cp->ProcessResults[i].ExitValue = 1;
|
||||||
|
strcpy(cp->ProcessResults[i].ExitExceptionString, "No exception");
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate memory to save the real working directory. */
|
/* Allocate memory to save the real working directory. */
|
||||||
if (cp->WorkingDirectory) {
|
if (cp->WorkingDirectory) {
|
||||||
#if defined(MAXPATHLEN)
|
#if defined(MAXPATHLEN)
|
||||||
@@ -1523,7 +1570,6 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Free all resources used by the given kwsysProcess instance that were
|
/* Free all resources used by the given kwsysProcess instance that were
|
||||||
allocated by kwsysProcess_Execute. */
|
allocated by kwsysProcess_Execute. */
|
||||||
static void kwsysProcessCleanup(kwsysProcess* cp, int error)
|
static void kwsysProcessCleanup(kwsysProcess* cp, int error)
|
||||||
@@ -1590,7 +1636,6 @@ static void kwsysProcessCleanup(kwsysProcess* cp, int error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Close the given file descriptor if it is open. Reset its value to -1. */
|
/* Close the given file descriptor if it is open. Reset its value to -1. */
|
||||||
static void kwsysProcessCleanupDescriptor(int* pfd)
|
static void kwsysProcessCleanupDescriptor(int* pfd)
|
||||||
{
|
{
|
||||||
@@ -1603,7 +1648,6 @@ static void kwsysProcessCleanupDescriptor(int* pfd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessClosePipes(kwsysProcess* cp)
|
static void kwsysProcessClosePipes(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1636,7 +1680,6 @@ static void kwsysProcessClosePipes(kwsysProcess* cp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcessSetNonBlocking(int fd)
|
static int kwsysProcessSetNonBlocking(int fd)
|
||||||
{
|
{
|
||||||
int flags = fcntl(fd, F_GETFL);
|
int flags = fcntl(fd, F_GETFL);
|
||||||
@@ -1646,12 +1689,10 @@ static int kwsysProcessSetNonBlocking(int fd)
|
|||||||
return flags >= 0;
|
return flags >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#if defined(__VMS)
|
#if defined(__VMS)
|
||||||
int decc$set_child_standard_streams(int fd1, int fd2, int fd3);
|
int decc$set_child_standard_streams(int fd1, int fd2, int fd3);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
|
static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
|
||||||
kwsysProcessCreateInformation* si)
|
kwsysProcessCreateInformation* si)
|
||||||
{
|
{
|
||||||
@@ -1831,7 +1872,6 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessDestroy(kwsysProcess* cp)
|
static void kwsysProcessDestroy(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
/* A child process has terminated. Reap it if it is one handled by
|
/* A child process has terminated. Reap it if it is one handled by
|
||||||
@@ -1880,7 +1920,6 @@ static void kwsysProcessDestroy(kwsysProcess* cp)
|
|||||||
sigprocmask(SIG_SETMASK, &old_mask, 0);
|
sigprocmask(SIG_SETMASK, &old_mask, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcessSetupOutputPipeFile(int* p, const char* name)
|
static int kwsysProcessSetupOutputPipeFile(int* p, const char* name)
|
||||||
{
|
{
|
||||||
int fout;
|
int fout;
|
||||||
@@ -1906,7 +1945,6 @@ static int kwsysProcessSetupOutputPipeFile(int* p, const char* name)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcessSetupOutputPipeNative(int* p, int des[2])
|
static int kwsysProcessSetupOutputPipeNative(int* p, int des[2])
|
||||||
{
|
{
|
||||||
/* Close the existing descriptor. */
|
/* Close the existing descriptor. */
|
||||||
@@ -1925,7 +1963,6 @@ static int kwsysProcessSetupOutputPipeNative(int* p, int des[2])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Get the time at which either the process or user timeout will
|
/* Get the time at which either the process or user timeout will
|
||||||
expire. Returns 1 if the user timeout is first, and 0 otherwise. */
|
expire. Returns 1 if the user timeout is first, and 0 otherwise. */
|
||||||
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
||||||
@@ -1957,7 +1994,6 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Get the length of time before the given timeout time arrives.
|
/* Get the length of time before the given timeout time arrives.
|
||||||
Returns 1 if the time has already arrived, and 0 otherwise. */
|
Returns 1 if the time has already arrived, and 0 otherwise. */
|
||||||
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
||||||
@@ -1992,7 +2028,6 @@ static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static kwsysProcessTime kwsysProcessTimeGetCurrent(void)
|
static kwsysProcessTime kwsysProcessTimeGetCurrent(void)
|
||||||
{
|
{
|
||||||
kwsysProcessTime current;
|
kwsysProcessTime current;
|
||||||
@@ -2003,13 +2038,11 @@ static kwsysProcessTime kwsysProcessTimeGetCurrent(void)
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static double kwsysProcessTimeToDouble(kwsysProcessTime t)
|
static double kwsysProcessTimeToDouble(kwsysProcessTime t)
|
||||||
{
|
{
|
||||||
return (double)t.tv_sec + (double)(t.tv_usec) * 0.000001;
|
return (double)t.tv_sec + (double)(t.tv_usec) * 0.000001;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static kwsysProcessTime kwsysProcessTimeFromDouble(double d)
|
static kwsysProcessTime kwsysProcessTimeFromDouble(double d)
|
||||||
{
|
{
|
||||||
kwsysProcessTime t;
|
kwsysProcessTime t;
|
||||||
@@ -2018,14 +2051,12 @@ static kwsysProcessTime kwsysProcessTimeFromDouble(double d)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcessTimeLess(kwsysProcessTime in1, kwsysProcessTime in2)
|
static int kwsysProcessTimeLess(kwsysProcessTime in1, kwsysProcessTime in2)
|
||||||
{
|
{
|
||||||
return ((in1.tv_sec < in2.tv_sec) ||
|
return ((in1.tv_sec < in2.tv_sec) ||
|
||||||
((in1.tv_sec == in2.tv_sec) && (in1.tv_usec < in2.tv_usec)));
|
((in1.tv_sec == in2.tv_sec) && (in1.tv_usec < in2.tv_usec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1,
|
static kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1,
|
||||||
kwsysProcessTime in2)
|
kwsysProcessTime in2)
|
||||||
{
|
{
|
||||||
@@ -2039,7 +2070,6 @@ static kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1,
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
|
static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
|
||||||
kwsysProcessTime in2)
|
kwsysProcessTime in2)
|
||||||
{
|
{
|
||||||
@@ -2053,11 +2083,11 @@ static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#define KWSYSPE_CASE(type, str) \
|
#define KWSYSPE_CASE(type, str) \
|
||||||
cp->ExitException = kwsysProcess_Exception_##type; \
|
cp->ProcessResults[idx].ExitException = kwsysProcess_Exception_##type; \
|
||||||
strcpy(cp->ExitExceptionString, str)
|
strcpy(cp->ProcessResults[idx].ExitExceptionString, str)
|
||||||
static void kwsysProcessSetExitException(kwsysProcess* cp, int sig)
|
static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int sig,
|
||||||
|
int idx)
|
||||||
{
|
{
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
#ifdef SIGSEGV
|
#ifdef SIGSEGV
|
||||||
@@ -2243,14 +2273,13 @@ static void kwsysProcessSetExitException(kwsysProcess* cp, int sig)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
cp->ExitException = kwsysProcess_Exception_Other;
|
cp->ProcessResults[idx].ExitException = kwsysProcess_Exception_Other;
|
||||||
sprintf(cp->ExitExceptionString, "Signal %d", sig);
|
sprintf(cp->ProcessResults[idx].ExitExceptionString, "Signal %d", sig);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#undef KWSYSPE_CASE
|
#undef KWSYSPE_CASE
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* When the child process encounters an error before its program is
|
/* When the child process encounters an error before its program is
|
||||||
invoked, this is called to report the error to the parent and
|
invoked, this is called to report the error to the parent and
|
||||||
exit. */
|
exit. */
|
||||||
@@ -2269,7 +2298,6 @@ static void kwsysProcessChildErrorExit(int errorPipe)
|
|||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Restores all signal handlers to their default values. */
|
/* Restores all signal handlers to their default values. */
|
||||||
static void kwsysProcessRestoreDefaultSignalHandlers(void)
|
static void kwsysProcessRestoreDefaultSignalHandlers(void)
|
||||||
{
|
{
|
||||||
@@ -2377,13 +2405,11 @@ static void kwsysProcessRestoreDefaultSignalHandlers(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessExit(void)
|
static void kwsysProcessExit(void)
|
||||||
{
|
{
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#if !defined(__VMS)
|
#if !defined(__VMS)
|
||||||
static pid_t kwsysProcessFork(kwsysProcess* cp,
|
static pid_t kwsysProcessFork(kwsysProcess* cp,
|
||||||
kwsysProcessCreateInformation* si)
|
kwsysProcessCreateInformation* si)
|
||||||
@@ -2433,7 +2459,6 @@ static pid_t kwsysProcessFork(kwsysProcess* cp,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* We try to obtain process information by invoking the ps command.
|
/* We try to obtain process information by invoking the ps command.
|
||||||
Here we define the command to call on each platform and the
|
Here we define the command to call on each platform and the
|
||||||
corresponding parsing format string. The parsing format should
|
corresponding parsing format string. The parsing format should
|
||||||
@@ -2457,7 +2482,6 @@ static pid_t kwsysProcessFork(kwsysProcess* cp,
|
|||||||
#define KWSYSPE_PS_FORMAT "%d %d %*[^\n]\n"
|
#define KWSYSPE_PS_FORMAT "%d %d %*[^\n]\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessKill(pid_t process_id)
|
static void kwsysProcessKill(pid_t process_id)
|
||||||
{
|
{
|
||||||
#if defined(__linux__) || defined(__CYGWIN__)
|
#if defined(__linux__) || defined(__CYGWIN__)
|
||||||
@@ -2561,7 +2585,6 @@ static void kwsysProcessKill(pid_t process_id)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#if defined(__VMS)
|
#if defined(__VMS)
|
||||||
int decc$feature_get_index(const char* name);
|
int decc$feature_get_index(const char* name);
|
||||||
int decc$feature_set_value(int index, int mode, int value);
|
int decc$feature_set_value(int index, int mode, int value);
|
||||||
@@ -2574,7 +2597,6 @@ static int kwsysProcessSetVMSFeature(const char* name, int value)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Global set of executing processes for use by the signal handler.
|
/* Global set of executing processes for use by the signal handler.
|
||||||
This global instance will be zero-initialized by the compiler. */
|
This global instance will be zero-initialized by the compiler. */
|
||||||
typedef struct kwsysProcessInstances_s
|
typedef struct kwsysProcessInstances_s
|
||||||
@@ -2590,7 +2612,6 @@ static struct sigaction kwsysProcessesOldSigChldAction;
|
|||||||
static struct sigaction kwsysProcessesOldSigIntAction;
|
static struct sigaction kwsysProcessesOldSigIntAction;
|
||||||
static struct sigaction kwsysProcessesOldSigTermAction;
|
static struct sigaction kwsysProcessesOldSigTermAction;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessesUpdate(kwsysProcessInstances* newProcesses)
|
static void kwsysProcessesUpdate(kwsysProcessInstances* newProcesses)
|
||||||
{
|
{
|
||||||
/* Block signals while we update the set of pipes to check.
|
/* Block signals while we update the set of pipes to check.
|
||||||
@@ -2611,7 +2632,6 @@ static void kwsysProcessesUpdate(kwsysProcessInstances* newProcesses)
|
|||||||
sigprocmask(SIG_SETMASK, &oldset, 0);
|
sigprocmask(SIG_SETMASK, &oldset, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcessesAdd(kwsysProcess* cp)
|
static int kwsysProcessesAdd(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
/* Create a pipe through which the signal handler can notify the
|
/* Create a pipe through which the signal handler can notify the
|
||||||
@@ -2721,7 +2741,6 @@ static int kwsysProcessesAdd(kwsysProcess* cp)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessesRemove(kwsysProcess* cp)
|
static void kwsysProcessesRemove(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
/* Attempt to remove the given signal pipe from the signal handler set. */
|
/* Attempt to remove the given signal pipe from the signal handler set. */
|
||||||
@@ -2772,7 +2791,6 @@ static void kwsysProcessesRemove(kwsysProcess* cp)
|
|||||||
kwsysProcessCleanupDescriptor(&cp->SignalPipe);
|
kwsysProcessCleanupDescriptor(&cp->SignalPipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessesSignalHandler(int signum
|
static void kwsysProcessesSignalHandler(int signum
|
||||||
#if KWSYSPE_USE_SIGINFO
|
#if KWSYSPE_USE_SIGINFO
|
||||||
,
|
,
|
||||||
@@ -2884,7 +2902,6 @@ static void kwsysProcessesSignalHandler(int signum
|
|||||||
errno = old_errno;
|
errno = old_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_ResetStartTime(kwsysProcess* cp)
|
void kwsysProcess_ResetStartTime(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
|
|||||||
253
ProcessWin32.c
253
ProcessWin32.c
@@ -86,7 +86,6 @@ typedef struct kwsysProcessCreateInformation_s
|
|||||||
HANDLE hStdError;
|
HANDLE hStdError;
|
||||||
} kwsysProcessCreateInformation;
|
} kwsysProcessCreateInformation;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
typedef struct kwsysProcessPipeData_s kwsysProcessPipeData;
|
typedef struct kwsysProcessPipeData_s kwsysProcessPipeData;
|
||||||
static DWORD WINAPI kwsysProcessPipeThreadRead(LPVOID ptd);
|
static DWORD WINAPI kwsysProcessPipeThreadRead(LPVOID ptd);
|
||||||
static void kwsysProcessPipeThreadReadPipe(kwsysProcess* cp,
|
static void kwsysProcessPipeThreadReadPipe(kwsysProcess* cp,
|
||||||
@@ -119,6 +118,8 @@ static kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1,
|
|||||||
static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
|
static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
|
||||||
kwsysProcessTime in2);
|
kwsysProcessTime in2);
|
||||||
static void kwsysProcessSetExitException(kwsysProcess* cp, int code);
|
static void kwsysProcessSetExitException(kwsysProcess* cp, int code);
|
||||||
|
static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int code,
|
||||||
|
int idx);
|
||||||
static void kwsysProcessKillTree(int pid);
|
static void kwsysProcessKillTree(int pid);
|
||||||
static void kwsysProcessDisablePipeThreads(kwsysProcess* cp);
|
static void kwsysProcessDisablePipeThreads(kwsysProcess* cp);
|
||||||
static int kwsysProcessesInitialize(void);
|
static int kwsysProcessesInitialize(void);
|
||||||
@@ -129,7 +130,6 @@ static int kwsysProcessesAdd(HANDLE hProcess, DWORD dwProcessId,
|
|||||||
static void kwsysProcessesRemove(HANDLE hProcess);
|
static void kwsysProcessesRemove(HANDLE hProcess);
|
||||||
static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType);
|
static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* A structure containing synchronization data for each thread. */
|
/* A structure containing synchronization data for each thread. */
|
||||||
typedef struct kwsysProcessPipeSync_s kwsysProcessPipeSync;
|
typedef struct kwsysProcessPipeSync_s kwsysProcessPipeSync;
|
||||||
struct kwsysProcessPipeSync_s
|
struct kwsysProcessPipeSync_s
|
||||||
@@ -147,7 +147,6 @@ struct kwsysProcessPipeSync_s
|
|||||||
HANDLE Reset;
|
HANDLE Reset;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* A structure containing data for each pipe's threads. */
|
/* A structure containing data for each pipe's threads. */
|
||||||
struct kwsysProcessPipeData_s
|
struct kwsysProcessPipeData_s
|
||||||
{
|
{
|
||||||
@@ -183,7 +182,26 @@ struct kwsysProcessPipeData_s
|
|||||||
HANDLE Write;
|
HANDLE Write;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/* A structure containing results data for each process. */
|
||||||
|
typedef struct kwsysProcessResults_s kwsysProcessResults;
|
||||||
|
struct kwsysProcessResults_s
|
||||||
|
{
|
||||||
|
/* The status of the process. */
|
||||||
|
int State;
|
||||||
|
|
||||||
|
/* The exceptional behavior that terminated the process, if any. */
|
||||||
|
int ExitException;
|
||||||
|
|
||||||
|
/* The process exit code. */
|
||||||
|
DWORD ExitCode;
|
||||||
|
|
||||||
|
/* The process return code, if any. */
|
||||||
|
int ExitValue;
|
||||||
|
|
||||||
|
/* Description for the ExitException. */
|
||||||
|
char ExitExceptionString[KWSYSPE_PIPE_BUFFER_SIZE + 1];
|
||||||
|
};
|
||||||
|
|
||||||
/* Structure containing data used to implement the child's execution. */
|
/* Structure containing data used to implement the child's execution. */
|
||||||
struct kwsysProcess_s
|
struct kwsysProcess_s
|
||||||
{
|
{
|
||||||
@@ -249,15 +267,6 @@ struct kwsysProcess_s
|
|||||||
|
|
||||||
/* ------------- Data managed per call to Execute ------------- */
|
/* ------------- Data managed per call to Execute ------------- */
|
||||||
|
|
||||||
/* The exceptional behavior that terminated the process, if any. */
|
|
||||||
int ExitException;
|
|
||||||
|
|
||||||
/* The process exit code. */
|
|
||||||
DWORD ExitCode;
|
|
||||||
|
|
||||||
/* The process return code, if any. */
|
|
||||||
int ExitValue;
|
|
||||||
|
|
||||||
/* Index of last pipe to report data, if any. */
|
/* Index of last pipe to report data, if any. */
|
||||||
int CurrentIndex;
|
int CurrentIndex;
|
||||||
|
|
||||||
@@ -289,8 +298,8 @@ struct kwsysProcess_s
|
|||||||
/* Buffer for error messages. */
|
/* Buffer for error messages. */
|
||||||
char ErrorMessage[KWSYSPE_PIPE_BUFFER_SIZE + 1];
|
char ErrorMessage[KWSYSPE_PIPE_BUFFER_SIZE + 1];
|
||||||
|
|
||||||
/* Description for the ExitException. */
|
/* process results. */
|
||||||
char ExitExceptionString[KWSYSPE_PIPE_BUFFER_SIZE + 1];
|
kwsysProcessResults* ProcessResults;
|
||||||
|
|
||||||
/* Windows process information data. */
|
/* Windows process information data. */
|
||||||
PROCESS_INFORMATION* ProcessInformation;
|
PROCESS_INFORMATION* ProcessInformation;
|
||||||
@@ -308,7 +317,6 @@ struct kwsysProcess_s
|
|||||||
HANDLE PipeChildStd[3];
|
HANDLE PipeChildStd[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
kwsysProcess* kwsysProcess_New(void)
|
kwsysProcess* kwsysProcess_New(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -447,7 +455,6 @@ kwsysProcess* kwsysProcess_New(void)
|
|||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_Delete(kwsysProcess* cp)
|
void kwsysProcess_Delete(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -519,10 +526,10 @@ void kwsysProcess_Delete(kwsysProcess* cp)
|
|||||||
if (cp->CommandExitCodes) {
|
if (cp->CommandExitCodes) {
|
||||||
free(cp->CommandExitCodes);
|
free(cp->CommandExitCodes);
|
||||||
}
|
}
|
||||||
|
free(cp->ProcessResults);
|
||||||
free(cp);
|
free(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_SetCommand(kwsysProcess* cp, char const* const* command)
|
int kwsysProcess_SetCommand(kwsysProcess* cp, char const* const* command)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -543,7 +550,6 @@ int kwsysProcess_SetCommand(kwsysProcess* cp, char const* const* command)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
|
int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
|
||||||
{
|
{
|
||||||
int newNumberOfCommands;
|
int newNumberOfCommands;
|
||||||
@@ -639,7 +645,6 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
|
void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -653,7 +658,6 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
|
|||||||
cp->TimeoutTime.QuadPart = -1;
|
cp->TimeoutTime.QuadPart = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
|
int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -685,7 +689,6 @@ int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_SetPipeFile(kwsysProcess* cp, int pipe, const char* file)
|
int kwsysProcess_SetPipeFile(kwsysProcess* cp, int pipe, const char* file)
|
||||||
{
|
{
|
||||||
char** pfile;
|
char** pfile;
|
||||||
@@ -727,7 +730,6 @@ int kwsysProcess_SetPipeFile(kwsysProcess* cp, int pipe, const char* file)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe, int shared)
|
void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe, int shared)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -756,7 +758,6 @@ void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe, int shared)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, HANDLE p[2])
|
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, HANDLE p[2])
|
||||||
{
|
{
|
||||||
HANDLE* pPipeNative = 0;
|
HANDLE* pPipeNative = 0;
|
||||||
@@ -796,7 +797,6 @@ void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, HANDLE p[2])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_GetOption(kwsysProcess* cp, int optionId)
|
int kwsysProcess_GetOption(kwsysProcess* cp, int optionId)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -819,7 +819,6 @@ int kwsysProcess_GetOption(kwsysProcess* cp, int optionId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_SetOption(kwsysProcess* cp, int optionId, int value)
|
void kwsysProcess_SetOption(kwsysProcess* cp, int optionId, int value)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -847,31 +846,32 @@ void kwsysProcess_SetOption(kwsysProcess* cp, int optionId, int value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_GetState(kwsysProcess* cp)
|
int kwsysProcess_GetState(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
return cp ? cp->State : kwsysProcess_State_Error;
|
return cp ? cp->State : kwsysProcess_State_Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_GetExitException(kwsysProcess* cp)
|
int kwsysProcess_GetExitException(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
return cp ? cp->ExitException : kwsysProcess_Exception_Other;
|
return (cp && cp->ProcessResults && (cp->NumberOfCommands > 0))
|
||||||
|
? cp->ProcessResults[cp->NumberOfCommands - 1].ExitException
|
||||||
|
: kwsysProcess_Exception_Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_GetExitValue(kwsysProcess* cp)
|
int kwsysProcess_GetExitValue(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
return cp ? cp->ExitValue : -1;
|
return (cp && cp->ProcessResults && (cp->NumberOfCommands > 0))
|
||||||
|
? cp->ProcessResults[cp->NumberOfCommands - 1].ExitValue
|
||||||
|
: -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_GetExitCode(kwsysProcess* cp)
|
int kwsysProcess_GetExitCode(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
return cp ? cp->ExitCode : 0;
|
return (cp && cp->ProcessResults && (cp->NumberOfCommands > 0))
|
||||||
|
? cp->ProcessResults[cp->NumberOfCommands - 1].ExitCode
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
const char* kwsysProcess_GetErrorString(kwsysProcess* cp)
|
const char* kwsysProcess_GetErrorString(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@@ -882,18 +882,59 @@ const char* kwsysProcess_GetErrorString(kwsysProcess* cp)
|
|||||||
return "Success";
|
return "Success";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
const char* kwsysProcess_GetExceptionString(kwsysProcess* cp)
|
const char* kwsysProcess_GetExceptionString(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!(cp && cp->ProcessResults && (cp->NumberOfCommands > 0))) {
|
||||||
return "GetExceptionString called with NULL process management structure";
|
return "GetExceptionString called with NULL process management structure";
|
||||||
} else if (cp->State == kwsysProcess_State_Exception) {
|
} else if (cp->State == kwsysProcess_State_Exception) {
|
||||||
return cp->ExitExceptionString;
|
return cp->ProcessResults[cp->NumberOfCommands - 1].ExitExceptionString;
|
||||||
}
|
}
|
||||||
return "No exception";
|
return "No exception";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/* the index should be in array bound. */
|
||||||
|
#define KWSYSPE_IDX_CHK(RET) \
|
||||||
|
if (!cp || idx >= cp->NumberOfCommands || idx < 0) { \
|
||||||
|
KWSYSPE_DEBUG((stderr, "array index out of bound\n")); \
|
||||||
|
return RET; \
|
||||||
|
}
|
||||||
|
|
||||||
|
int kwsysProcess_GetStateByIndex(kwsysProcess* cp, int idx)
|
||||||
|
{
|
||||||
|
KWSYSPE_IDX_CHK(kwsysProcess_State_Error)
|
||||||
|
return cp->ProcessResults[idx].State;
|
||||||
|
}
|
||||||
|
|
||||||
|
int kwsysProcess_GetExitExceptionByIndex(kwsysProcess* cp, int idx)
|
||||||
|
{
|
||||||
|
KWSYSPE_IDX_CHK(kwsysProcess_Exception_Other)
|
||||||
|
return cp->ProcessResults[idx].ExitException;
|
||||||
|
}
|
||||||
|
|
||||||
|
int kwsysProcess_GetExitValueByIndex(kwsysProcess* cp, int idx)
|
||||||
|
{
|
||||||
|
KWSYSPE_IDX_CHK(-1)
|
||||||
|
return cp->ProcessResults[idx].ExitValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int kwsysProcess_GetExitCodeByIndex(kwsysProcess* cp, int idx)
|
||||||
|
{
|
||||||
|
KWSYSPE_IDX_CHK(-1)
|
||||||
|
return cp->CommandExitCodes[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* kwsysProcess_GetExceptionStringByIndex(kwsysProcess* cp, int idx)
|
||||||
|
{
|
||||||
|
KWSYSPE_IDX_CHK("GetExceptionString called with NULL process management "
|
||||||
|
"structure or index out of bound")
|
||||||
|
if (cp->ProcessResults[idx].State == kwsysProcess_StateByIndex_Exception) {
|
||||||
|
return cp->ProcessResults[idx].ExitExceptionString;
|
||||||
|
}
|
||||||
|
return "No exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef KWSYSPE_IDX_CHK
|
||||||
|
|
||||||
void kwsysProcess_Execute(kwsysProcess* cp)
|
void kwsysProcess_Execute(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1135,7 +1176,6 @@ void kwsysProcess_Execute(kwsysProcess* cp)
|
|||||||
cp->Detached = cp->OptionDetach;
|
cp->Detached = cp->OptionDetach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_Disown(kwsysProcess* cp)
|
void kwsysProcess_Disown(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1162,8 +1202,6 @@ void kwsysProcess_Disown(kwsysProcess* cp)
|
|||||||
cp->State = kwsysProcess_State_Disowned;
|
cp->State = kwsysProcess_State_Disowned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
|
int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
|
||||||
double* userTimeout)
|
double* userTimeout)
|
||||||
{
|
{
|
||||||
@@ -1289,7 +1327,6 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
|
int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1338,25 +1375,29 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
|
|||||||
/* The timeout expired. */
|
/* The timeout expired. */
|
||||||
cp->State = kwsysProcess_State_Expired;
|
cp->State = kwsysProcess_State_Expired;
|
||||||
} else {
|
} else {
|
||||||
/* The children exited. Report the outcome of the last process. */
|
/* The children exited. Report the outcome of the child processes. */
|
||||||
cp->ExitCode = cp->CommandExitCodes[cp->NumberOfCommands - 1];
|
for (i = 0; i < cp->NumberOfCommands; ++i) {
|
||||||
if ((cp->ExitCode & 0xF0000000) == 0xC0000000) {
|
cp->ProcessResults[i].ExitCode = cp->CommandExitCodes[i];
|
||||||
/* Child terminated due to exceptional behavior. */
|
if ((cp->ProcessResults[i].ExitCode & 0xF0000000) == 0xC0000000) {
|
||||||
cp->State = kwsysProcess_State_Exception;
|
/* Child terminated due to exceptional behavior. */
|
||||||
cp->ExitValue = 1;
|
cp->ProcessResults[i].State = kwsysProcess_StateByIndex_Exception;
|
||||||
kwsysProcessSetExitException(cp, cp->ExitCode);
|
cp->ProcessResults[i].ExitValue = 1;
|
||||||
} else {
|
kwsysProcessSetExitExceptionByIndex(cp, cp->ProcessResults[i].ExitCode,
|
||||||
/* Child exited without exception. */
|
i);
|
||||||
cp->State = kwsysProcess_State_Exited;
|
} else {
|
||||||
cp->ExitException = kwsysProcess_Exception_None;
|
/* Child exited without exception. */
|
||||||
cp->ExitValue = cp->ExitCode;
|
cp->ProcessResults[i].State = kwsysProcess_StateByIndex_Exited;
|
||||||
|
cp->ProcessResults[i].ExitException = kwsysProcess_Exception_None;
|
||||||
|
cp->ProcessResults[i].ExitValue = cp->ProcessResults[i].ExitCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
/* support legacy state status value */
|
||||||
|
cp->State = cp->ProcessResults[cp->NumberOfCommands - 1].State;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_Interrupt(kwsysProcess* cp)
|
void kwsysProcess_Interrupt(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1394,7 +1435,6 @@ void kwsysProcess_Interrupt(kwsysProcess* cp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_Kill(kwsysProcess* cp)
|
void kwsysProcess_Kill(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1429,8 +1469,6 @@ void kwsysProcess_Kill(kwsysProcess* cp)
|
|||||||
for them to exit. */
|
for them to exit. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function executed for each pipe's thread. Argument is a pointer to
|
Function executed for each pipe's thread. Argument is a pointer to
|
||||||
the kwsysProcessPipeData instance for this thread.
|
the kwsysProcessPipeData instance for this thread.
|
||||||
@@ -1451,8 +1489,6 @@ DWORD WINAPI kwsysProcessPipeThreadRead(LPVOID ptd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function called in each pipe's thread to handle data for one
|
Function called in each pipe's thread to handle data for one
|
||||||
execution of a subprocess.
|
execution of a subprocess.
|
||||||
@@ -1494,8 +1530,6 @@ void kwsysProcessPipeThreadReadPipe(kwsysProcess* cp, kwsysProcessPipeData* td)
|
|||||||
ReleaseSemaphore(td->Reader.Go, 1, 0);
|
ReleaseSemaphore(td->Reader.Go, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function executed for each pipe's thread. Argument is a pointer to
|
Function executed for each pipe's thread. Argument is a pointer to
|
||||||
the kwsysProcessPipeData instance for this thread.
|
the kwsysProcessPipeData instance for this thread.
|
||||||
@@ -1516,8 +1550,6 @@ DWORD WINAPI kwsysProcessPipeThreadWake(LPVOID ptd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function called in each pipe's thread to handle reading thread
|
Function called in each pipe's thread to handle reading thread
|
||||||
wakeup for one execution of a subprocess.
|
wakeup for one execution of a subprocess.
|
||||||
@@ -1540,23 +1572,34 @@ void kwsysProcessPipeThreadWakePipe(kwsysProcess* cp, kwsysProcessPipeData* td)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Initialize a process control structure for kwsysProcess_Execute. */
|
/* Initialize a process control structure for kwsysProcess_Execute. */
|
||||||
int kwsysProcessInitialize(kwsysProcess* cp)
|
int kwsysProcessInitialize(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
/* Reset internal status flags. */
|
/* Reset internal status flags. */
|
||||||
cp->TimeoutExpired = 0;
|
cp->TimeoutExpired = 0;
|
||||||
cp->Terminated = 0;
|
cp->Terminated = 0;
|
||||||
cp->Killed = 0;
|
cp->Killed = 0;
|
||||||
cp->ExitException = kwsysProcess_Exception_None;
|
|
||||||
cp->ExitCode = 1;
|
|
||||||
cp->ExitValue = 1;
|
|
||||||
|
|
||||||
/* Reset error data. */
|
free(cp->ProcessResults);
|
||||||
cp->ErrorMessage[0] = 0;
|
/* Allocate process result information for each process. */
|
||||||
strcpy(cp->ExitExceptionString, "No exception");
|
cp->ProcessResults = (kwsysProcessResults*)malloc(
|
||||||
|
sizeof(kwsysProcessResults) * (cp->NumberOfCommands));
|
||||||
|
if (!cp->ProcessResults) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ZeroMemory(cp->ProcessResults,
|
||||||
|
sizeof(kwsysProcessResults) * cp->NumberOfCommands);
|
||||||
|
for (i = 0; i < cp->NumberOfCommands; i++) {
|
||||||
|
cp->ProcessResults[i].ExitException = kwsysProcess_Exception_None;
|
||||||
|
cp->ProcessResults[i].State = kwsysProcess_StateByIndex_Starting;
|
||||||
|
cp->ProcessResults[i].ExitCode = 1;
|
||||||
|
cp->ProcessResults[i].ExitValue = 1;
|
||||||
|
strcpy(cp->ProcessResults[i].ExitExceptionString, "No exception");
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate process information for each process. */
|
/* Allocate process information for each process. */
|
||||||
|
free(cp->ProcessInformation);
|
||||||
cp->ProcessInformation = (PROCESS_INFORMATION*)malloc(
|
cp->ProcessInformation = (PROCESS_INFORMATION*)malloc(
|
||||||
sizeof(PROCESS_INFORMATION) * cp->NumberOfCommands);
|
sizeof(PROCESS_INFORMATION) * cp->NumberOfCommands);
|
||||||
if (!cp->ProcessInformation) {
|
if (!cp->ProcessInformation) {
|
||||||
@@ -1596,7 +1639,6 @@ int kwsysProcessInitialize(kwsysProcess* cp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
cp->PipeChildStd[i] = INVALID_HANDLE_VALUE;
|
cp->PipeChildStd[i] = INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
@@ -1605,7 +1647,6 @@ int kwsysProcessInitialize(kwsysProcess* cp)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static DWORD kwsysProcessCreateChildHandle(PHANDLE out, HANDLE in, int isStdIn)
|
static DWORD kwsysProcessCreateChildHandle(PHANDLE out, HANDLE in, int isStdIn)
|
||||||
{
|
{
|
||||||
DWORD flags;
|
DWORD flags;
|
||||||
@@ -1641,7 +1682,6 @@ static DWORD kwsysProcessCreateChildHandle(PHANDLE out, HANDLE in, int isStdIn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
DWORD kwsysProcessCreate(kwsysProcess* cp, int index,
|
DWORD kwsysProcessCreate(kwsysProcess* cp, int index,
|
||||||
kwsysProcessCreateInformation* si)
|
kwsysProcessCreateInformation* si)
|
||||||
{
|
{
|
||||||
@@ -1706,7 +1746,6 @@ DWORD kwsysProcessCreate(kwsysProcess* cp, int index,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcessDestroy(kwsysProcess* cp, int event)
|
void kwsysProcessDestroy(kwsysProcess* cp, int event)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1756,7 +1795,6 @@ void kwsysProcessDestroy(kwsysProcess* cp, int event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
DWORD kwsysProcessSetupOutputPipeFile(PHANDLE phandle, const char* name)
|
DWORD kwsysProcessSetupOutputPipeFile(PHANDLE phandle, const char* name)
|
||||||
{
|
{
|
||||||
HANDLE fout;
|
HANDLE fout;
|
||||||
@@ -1784,7 +1822,6 @@ DWORD kwsysProcessSetupOutputPipeFile(PHANDLE phandle, const char* name)
|
|||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcessSetupSharedPipe(DWORD nStdHandle, PHANDLE handle)
|
void kwsysProcessSetupSharedPipe(DWORD nStdHandle, PHANDLE handle)
|
||||||
{
|
{
|
||||||
/* Close the existing handle. */
|
/* Close the existing handle. */
|
||||||
@@ -1793,7 +1830,6 @@ void kwsysProcessSetupSharedPipe(DWORD nStdHandle, PHANDLE handle)
|
|||||||
*handle = GetStdHandle(nStdHandle);
|
*handle = GetStdHandle(nStdHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcessSetupPipeNative(HANDLE native, PHANDLE handle)
|
void kwsysProcessSetupPipeNative(HANDLE native, PHANDLE handle)
|
||||||
{
|
{
|
||||||
/* Close the existing handle. */
|
/* Close the existing handle. */
|
||||||
@@ -1802,8 +1838,6 @@ void kwsysProcessSetupPipeNative(HANDLE native, PHANDLE handle)
|
|||||||
*handle = native;
|
*handle = native;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Close the given handle if it is open. Reset its value to 0. */
|
/* Close the given handle if it is open. Reset its value to 0. */
|
||||||
void kwsysProcessCleanupHandle(PHANDLE h)
|
void kwsysProcessCleanupHandle(PHANDLE h)
|
||||||
{
|
{
|
||||||
@@ -1816,8 +1850,6 @@ void kwsysProcessCleanupHandle(PHANDLE h)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Close all handles created by kwsysProcess_Execute. */
|
/* Close all handles created by kwsysProcess_Execute. */
|
||||||
void kwsysProcessCleanup(kwsysProcess* cp, DWORD error)
|
void kwsysProcessCleanup(kwsysProcess* cp, DWORD error)
|
||||||
{
|
{
|
||||||
@@ -1902,7 +1934,6 @@ void kwsysProcessCleanup(kwsysProcess* cp, DWORD error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcessCleanErrorMessage(kwsysProcess* cp)
|
void kwsysProcessCleanErrorMessage(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
/* Remove trailing period and newline, if any. */
|
/* Remove trailing period and newline, if any. */
|
||||||
@@ -1920,7 +1951,6 @@ void kwsysProcessCleanErrorMessage(kwsysProcess* cp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Get the time at which either the process or user timeout will
|
/* Get the time at which either the process or user timeout will
|
||||||
expire. Returns 1 if the user timeout is first, and 0 otherwise. */
|
expire. Returns 1 if the user timeout is first, and 0 otherwise. */
|
||||||
int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
||||||
@@ -1952,7 +1982,6 @@ int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Get the length of time before the given timeout time arrives.
|
/* Get the length of time before the given timeout time arrives.
|
||||||
Returns 1 if the time has already arrived, and 0 otherwise. */
|
Returns 1 if the time has already arrived, and 0 otherwise. */
|
||||||
int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
||||||
@@ -1982,7 +2011,6 @@ int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
kwsysProcessTime kwsysProcessTimeGetCurrent()
|
kwsysProcessTime kwsysProcessTimeGetCurrent()
|
||||||
{
|
{
|
||||||
kwsysProcessTime current;
|
kwsysProcessTime current;
|
||||||
@@ -1993,19 +2021,16 @@ kwsysProcessTime kwsysProcessTimeGetCurrent()
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
DWORD kwsysProcessTimeToDWORD(kwsysProcessTime t)
|
DWORD kwsysProcessTimeToDWORD(kwsysProcessTime t)
|
||||||
{
|
{
|
||||||
return (DWORD)(t.QuadPart * 0.0001);
|
return (DWORD)(t.QuadPart * 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
double kwsysProcessTimeToDouble(kwsysProcessTime t)
|
double kwsysProcessTimeToDouble(kwsysProcessTime t)
|
||||||
{
|
{
|
||||||
return t.QuadPart * 0.0000001;
|
return t.QuadPart * 0.0000001;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
kwsysProcessTime kwsysProcessTimeFromDouble(double d)
|
kwsysProcessTime kwsysProcessTimeFromDouble(double d)
|
||||||
{
|
{
|
||||||
kwsysProcessTime t;
|
kwsysProcessTime t;
|
||||||
@@ -2013,13 +2038,11 @@ kwsysProcessTime kwsysProcessTimeFromDouble(double d)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
int kwsysProcessTimeLess(kwsysProcessTime in1, kwsysProcessTime in2)
|
int kwsysProcessTimeLess(kwsysProcessTime in1, kwsysProcessTime in2)
|
||||||
{
|
{
|
||||||
return in1.QuadPart < in2.QuadPart;
|
return in1.QuadPart < in2.QuadPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1,
|
kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1,
|
||||||
kwsysProcessTime in2)
|
kwsysProcessTime in2)
|
||||||
{
|
{
|
||||||
@@ -2028,7 +2051,6 @@ kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1,
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
|
kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
|
||||||
kwsysProcessTime in2)
|
kwsysProcessTime in2)
|
||||||
{
|
{
|
||||||
@@ -2037,11 +2059,11 @@ kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#define KWSYSPE_CASE(type, str) \
|
#define KWSYSPE_CASE(type, str) \
|
||||||
cp->ExitException = kwsysProcess_Exception_##type; \
|
cp->ProcessResults[idx].ExitException = kwsysProcess_Exception_##type; \
|
||||||
strcpy(cp->ExitExceptionString, str)
|
strcpy(cp->ProcessResults[idx].ExitExceptionString, str)
|
||||||
static void kwsysProcessSetExitException(kwsysProcess* cp, int code)
|
static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int code,
|
||||||
|
int idx)
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case STATUS_CONTROL_C_EXIT:
|
case STATUS_CONTROL_C_EXIT:
|
||||||
@@ -2120,9 +2142,9 @@ static void kwsysProcessSetExitException(kwsysProcess* cp, int code)
|
|||||||
|
|
||||||
case STATUS_NO_MEMORY:
|
case STATUS_NO_MEMORY:
|
||||||
default:
|
default:
|
||||||
cp->ExitException = kwsysProcess_Exception_Other;
|
cp->ProcessResults[idx].ExitException = kwsysProcess_Exception_Other;
|
||||||
_snprintf(cp->ExitExceptionString, KWSYSPE_PIPE_BUFFER_SIZE,
|
_snprintf(cp->ProcessResults[idx].ExitExceptionString,
|
||||||
"Exit code 0x%x\n", code);
|
KWSYSPE_PIPE_BUFFER_SIZE, "Exit code 0x%x\n", code);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2136,7 +2158,6 @@ static int kwsysProcess_List_NextProcess(kwsysProcess_List* self);
|
|||||||
static int kwsysProcess_List_GetCurrentProcessId(kwsysProcess_List* self);
|
static int kwsysProcess_List_GetCurrentProcessId(kwsysProcess_List* self);
|
||||||
static int kwsysProcess_List_GetCurrentParentId(kwsysProcess_List* self);
|
static int kwsysProcess_List_GetCurrentParentId(kwsysProcess_List* self);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Windows NT 4 API definitions. */
|
/* Windows NT 4 API definitions. */
|
||||||
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
|
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
|
||||||
typedef LONG NTSTATUS;
|
typedef LONG NTSTATUS;
|
||||||
@@ -2168,7 +2189,6 @@ struct _SYSTEM_PROCESS_INFORMATION
|
|||||||
ULONG InheritedFromProcessId;
|
ULONG InheritedFromProcessId;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Toolhelp32 API definitions. */
|
/* Toolhelp32 API definitions. */
|
||||||
#define TH32CS_SNAPPROCESS 0x00000002
|
#define TH32CS_SNAPPROCESS 0x00000002
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
@@ -2192,7 +2212,6 @@ struct tagPROCESSENTRY32
|
|||||||
char szExeFile[MAX_PATH];
|
char szExeFile[MAX_PATH];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Windows API function types. */
|
/* Windows API function types. */
|
||||||
typedef HANDLE(WINAPI* CreateToolhelp32SnapshotType)(DWORD, DWORD);
|
typedef HANDLE(WINAPI* CreateToolhelp32SnapshotType)(DWORD, DWORD);
|
||||||
typedef BOOL(WINAPI* Process32FirstType)(HANDLE, LPPROCESSENTRY32);
|
typedef BOOL(WINAPI* Process32FirstType)(HANDLE, LPPROCESSENTRY32);
|
||||||
@@ -2200,7 +2219,6 @@ typedef BOOL(WINAPI* Process32NextType)(HANDLE, LPPROCESSENTRY32);
|
|||||||
typedef NTSTATUS(WINAPI* ZwQuerySystemInformationType)(ULONG, PVOID, ULONG,
|
typedef NTSTATUS(WINAPI* ZwQuerySystemInformationType)(ULONG, PVOID, ULONG,
|
||||||
PULONG);
|
PULONG);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__New_NT4(kwsysProcess_List* self);
|
static int kwsysProcess_List__New_NT4(kwsysProcess_List* self);
|
||||||
static int kwsysProcess_List__New_Snapshot(kwsysProcess_List* self);
|
static int kwsysProcess_List__New_Snapshot(kwsysProcess_List* self);
|
||||||
static void kwsysProcess_List__Delete_NT4(kwsysProcess_List* self);
|
static void kwsysProcess_List__Delete_NT4(kwsysProcess_List* self);
|
||||||
@@ -2233,7 +2251,6 @@ struct kwsysProcess_List_s
|
|||||||
PROCESSENTRY32 CurrentEntry;
|
PROCESSENTRY32 CurrentEntry;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static kwsysProcess_List* kwsysProcess_List_New(void)
|
static kwsysProcess_List* kwsysProcess_List_New(void)
|
||||||
{
|
{
|
||||||
OSVERSIONINFO osv;
|
OSVERSIONINFO osv;
|
||||||
@@ -2279,7 +2296,6 @@ static kwsysProcess_List* kwsysProcess_List_New(void)
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcess_List_Delete(kwsysProcess_List* self)
|
static void kwsysProcess_List_Delete(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
if (self) {
|
if (self) {
|
||||||
@@ -2292,7 +2308,6 @@ static void kwsysProcess_List_Delete(kwsysProcess_List* self)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List_Update(kwsysProcess_List* self)
|
static int kwsysProcess_List_Update(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
return self ? (self->NT4 ? kwsysProcess_List__Update_NT4(self)
|
return self ? (self->NT4 ? kwsysProcess_List__Update_NT4(self)
|
||||||
@@ -2300,7 +2315,6 @@ static int kwsysProcess_List_Update(kwsysProcess_List* self)
|
|||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List_GetCurrentProcessId(kwsysProcess_List* self)
|
static int kwsysProcess_List_GetCurrentProcessId(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
return self ? (self->NT4 ? kwsysProcess_List__GetProcessId_NT4(self)
|
return self ? (self->NT4 ? kwsysProcess_List__GetProcessId_NT4(self)
|
||||||
@@ -2308,7 +2322,6 @@ static int kwsysProcess_List_GetCurrentProcessId(kwsysProcess_List* self)
|
|||||||
: -1;
|
: -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List_GetCurrentParentId(kwsysProcess_List* self)
|
static int kwsysProcess_List_GetCurrentParentId(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
return self ? (self->NT4 ? kwsysProcess_List__GetParentId_NT4(self)
|
return self ? (self->NT4 ? kwsysProcess_List__GetParentId_NT4(self)
|
||||||
@@ -2316,7 +2329,6 @@ static int kwsysProcess_List_GetCurrentParentId(kwsysProcess_List* self)
|
|||||||
: -1;
|
: -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List_NextProcess(kwsysProcess_List* self)
|
static int kwsysProcess_List_NextProcess(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
return (self ? (self->NT4 ? kwsysProcess_List__Next_NT4(self)
|
return (self ? (self->NT4 ? kwsysProcess_List__Next_NT4(self)
|
||||||
@@ -2324,7 +2336,6 @@ static int kwsysProcess_List_NextProcess(kwsysProcess_List* self)
|
|||||||
: 0);
|
: 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__New_NT4(kwsysProcess_List* self)
|
static int kwsysProcess_List__New_NT4(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
/* Get a handle to the NT runtime module that should already be
|
/* Get a handle to the NT runtime module that should already be
|
||||||
@@ -2348,7 +2359,6 @@ static int kwsysProcess_List__New_NT4(kwsysProcess_List* self)
|
|||||||
return self->Buffer ? 1 : 0;
|
return self->Buffer ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcess_List__Delete_NT4(kwsysProcess_List* self)
|
static void kwsysProcess_List__Delete_NT4(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
/* Free the process information buffer. */
|
/* Free the process information buffer. */
|
||||||
@@ -2357,7 +2367,6 @@ static void kwsysProcess_List__Delete_NT4(kwsysProcess_List* self)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__Update_NT4(kwsysProcess_List* self)
|
static int kwsysProcess_List__Update_NT4(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
self->CurrentInfo = 0;
|
self->CurrentInfo = 0;
|
||||||
@@ -2387,7 +2396,6 @@ static int kwsysProcess_List__Update_NT4(kwsysProcess_List* self)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__Next_NT4(kwsysProcess_List* self)
|
static int kwsysProcess_List__Next_NT4(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
if (self->CurrentInfo) {
|
if (self->CurrentInfo) {
|
||||||
@@ -2401,19 +2409,16 @@ static int kwsysProcess_List__Next_NT4(kwsysProcess_List* self)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__GetProcessId_NT4(kwsysProcess_List* self)
|
static int kwsysProcess_List__GetProcessId_NT4(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
return self->CurrentInfo ? self->CurrentInfo->ProcessId : -1;
|
return self->CurrentInfo ? self->CurrentInfo->ProcessId : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__GetParentId_NT4(kwsysProcess_List* self)
|
static int kwsysProcess_List__GetParentId_NT4(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
return self->CurrentInfo ? self->CurrentInfo->InheritedFromProcessId : -1;
|
return self->CurrentInfo ? self->CurrentInfo->InheritedFromProcessId : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__New_Snapshot(kwsysProcess_List* self)
|
static int kwsysProcess_List__New_Snapshot(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
/* Get a handle to the Windows runtime module that should already be
|
/* Get a handle to the Windows runtime module that should already be
|
||||||
@@ -2436,7 +2441,6 @@ static int kwsysProcess_List__New_Snapshot(kwsysProcess_List* self)
|
|||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcess_List__Delete_Snapshot(kwsysProcess_List* self)
|
static void kwsysProcess_List__Delete_Snapshot(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
if (self->Snapshot) {
|
if (self->Snapshot) {
|
||||||
@@ -2444,7 +2448,6 @@ static void kwsysProcess_List__Delete_Snapshot(kwsysProcess_List* self)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__Update_Snapshot(kwsysProcess_List* self)
|
static int kwsysProcess_List__Update_Snapshot(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
if (self->Snapshot) {
|
if (self->Snapshot) {
|
||||||
@@ -2464,7 +2467,6 @@ static int kwsysProcess_List__Update_Snapshot(kwsysProcess_List* self)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__Next_Snapshot(kwsysProcess_List* self)
|
static int kwsysProcess_List__Next_Snapshot(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
if (self->Snapshot) {
|
if (self->Snapshot) {
|
||||||
@@ -2477,19 +2479,16 @@ static int kwsysProcess_List__Next_Snapshot(kwsysProcess_List* self)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__GetProcessId_Snapshot(kwsysProcess_List* self)
|
static int kwsysProcess_List__GetProcessId_Snapshot(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
return self->Snapshot ? self->CurrentEntry.th32ProcessID : -1;
|
return self->Snapshot ? self->CurrentEntry.th32ProcessID : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysProcess_List__GetParentId_Snapshot(kwsysProcess_List* self)
|
static int kwsysProcess_List__GetParentId_Snapshot(kwsysProcess_List* self)
|
||||||
{
|
{
|
||||||
return self->Snapshot ? self->CurrentEntry.th32ParentProcessID : -1;
|
return self->Snapshot ? self->CurrentEntry.th32ParentProcessID : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessKill(DWORD pid)
|
static void kwsysProcessKill(DWORD pid)
|
||||||
{
|
{
|
||||||
HANDLE h = OpenProcess(PROCESS_TERMINATE, 0, pid);
|
HANDLE h = OpenProcess(PROCESS_TERMINATE, 0, pid);
|
||||||
@@ -2500,7 +2499,6 @@ static void kwsysProcessKill(DWORD pid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessKillTree(int pid)
|
static void kwsysProcessKillTree(int pid)
|
||||||
{
|
{
|
||||||
kwsysProcess_List* plist = kwsysProcess_List_New();
|
kwsysProcess_List* plist = kwsysProcess_List_New();
|
||||||
@@ -2516,7 +2514,6 @@ static void kwsysProcessKillTree(int pid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static void kwsysProcessDisablePipeThreads(kwsysProcess* cp)
|
static void kwsysProcessDisablePipeThreads(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -2568,7 +2565,6 @@ static void kwsysProcessDisablePipeThreads(kwsysProcess* cp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Global set of executing processes for use by the Ctrl handler.
|
/* Global set of executing processes for use by the Ctrl handler.
|
||||||
This global instance will be zero-initialized by the compiler.
|
This global instance will be zero-initialized by the compiler.
|
||||||
|
|
||||||
@@ -2598,7 +2594,6 @@ typedef struct kwsysProcessInstances_s
|
|||||||
} kwsysProcessInstances;
|
} kwsysProcessInstances;
|
||||||
static kwsysProcessInstances kwsysProcesses;
|
static kwsysProcessInstances kwsysProcesses;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Initialize critial section and set up console Ctrl handler. You MUST call
|
/* Initialize critial section and set up console Ctrl handler. You MUST call
|
||||||
this before using any other kwsysProcesses* functions below. */
|
this before using any other kwsysProcesses* functions below. */
|
||||||
static int kwsysProcessesInitialize(void)
|
static int kwsysProcessesInitialize(void)
|
||||||
@@ -2617,7 +2612,6 @@ static int kwsysProcessesInitialize(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* The Ctrl handler waits on the global list of processes. To prevent an
|
/* The Ctrl handler waits on the global list of processes. To prevent an
|
||||||
orphaned process, do not create a new process if the Ctrl handler is
|
orphaned process, do not create a new process if the Ctrl handler is
|
||||||
already running. Do so by using this function to check if it is ok to
|
already running. Do so by using this function to check if it is ok to
|
||||||
@@ -2636,7 +2630,6 @@ static int kwsysTryEnterCreateProcessSection(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Matching function on successful kwsysTryEnterCreateProcessSection return.
|
/* Matching function on successful kwsysTryEnterCreateProcessSection return.
|
||||||
Make sure you called kwsysProcessesAdd if applicable before calling this.*/
|
Make sure you called kwsysProcessesAdd if applicable before calling this.*/
|
||||||
static void kwsysLeaveCreateProcessSection(void)
|
static void kwsysLeaveCreateProcessSection(void)
|
||||||
@@ -2644,7 +2637,6 @@ static void kwsysLeaveCreateProcessSection(void)
|
|||||||
LeaveCriticalSection(&kwsysProcesses.Lock);
|
LeaveCriticalSection(&kwsysProcesses.Lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Add new process to global process list. The Ctrl handler will wait for
|
/* Add new process to global process list. The Ctrl handler will wait for
|
||||||
the process to exit before it returns. Do not close the process handle
|
the process to exit before it returns. Do not close the process handle
|
||||||
until after calling kwsysProcessesRemove. The newProcessGroup parameter
|
until after calling kwsysProcessesRemove. The newProcessGroup parameter
|
||||||
@@ -2702,7 +2694,6 @@ static int kwsysProcessesAdd(HANDLE hProcess, DWORD dwProcessid,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Removes process to global process list. */
|
/* Removes process to global process list. */
|
||||||
static void kwsysProcessesRemove(HANDLE hProcess)
|
static void kwsysProcessesRemove(HANDLE hProcess)
|
||||||
{
|
{
|
||||||
@@ -2738,7 +2729,6 @@ static void kwsysProcessesRemove(HANDLE hProcess)
|
|||||||
LeaveCriticalSection(&kwsysProcesses.Lock);
|
LeaveCriticalSection(&kwsysProcesses.Lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType)
|
static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@@ -2774,7 +2764,6 @@ static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysProcess_ResetStartTime(kwsysProcess* cp)
|
void kwsysProcess_ResetStartTime(kwsysProcess* cp)
|
||||||
{
|
{
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
|
|||||||
@@ -72,8 +72,6 @@
|
|||||||
#pragma warn - 8019
|
#pragma warn - 8019
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Full path to the directory in which this executable is built. Do
|
/* Full path to the directory in which this executable is built. Do
|
||||||
not include a trailing slash. */
|
not include a trailing slash. */
|
||||||
#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD)
|
#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD)
|
||||||
@@ -159,7 +157,6 @@
|
|||||||
#undef KWSYS_SHARED_FORWARD_OPTION_LDD
|
#undef KWSYS_SHARED_FORWARD_OPTION_LDD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Include needed system headers. */
|
/* Include needed system headers. */
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -180,7 +177,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Configuration for this platform. */
|
/* Configuration for this platform. */
|
||||||
|
|
||||||
/* The path separator for this platform. */
|
/* The path separator for this platform. */
|
||||||
@@ -292,7 +288,6 @@ static const char kwsys_shared_forward_path_slash[2] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV
|
#ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
typedef struct kwsys_sf_arg_info_s
|
typedef struct kwsys_sf_arg_info_s
|
||||||
{
|
{
|
||||||
const char* arg;
|
const char* arg;
|
||||||
@@ -300,7 +295,6 @@ typedef struct kwsys_sf_arg_info_s
|
|||||||
int quote;
|
int quote;
|
||||||
} kwsys_sf_arg_info;
|
} kwsys_sf_arg_info;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static kwsys_sf_arg_info kwsys_sf_get_arg_info(const char* in)
|
static kwsys_sf_arg_info kwsys_sf_get_arg_info(const char* in)
|
||||||
{
|
{
|
||||||
/* Initialize information. */
|
/* Initialize information. */
|
||||||
@@ -354,7 +348,6 @@ static kwsys_sf_arg_info kwsys_sf_get_arg_info(const char* in)
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static char* kwsys_sf_get_arg(kwsys_sf_arg_info info, char* out)
|
static char* kwsys_sf_get_arg(kwsys_sf_arg_info info, char* out)
|
||||||
{
|
{
|
||||||
/* String iterator. */
|
/* String iterator. */
|
||||||
@@ -413,7 +406,6 @@ static char* kwsys_sf_get_arg(kwsys_sf_arg_info info, char* out)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Function to convert a logical or relative path to a physical full path. */
|
/* Function to convert a logical or relative path to a physical full path. */
|
||||||
static int kwsys_shared_forward_realpath(const char* in_path, char* out_path)
|
static int kwsys_shared_forward_realpath(const char* in_path, char* out_path)
|
||||||
{
|
{
|
||||||
@@ -428,7 +420,6 @@ static int kwsys_shared_forward_realpath(const char* in_path, char* out_path)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsys_shared_forward_samepath(const char* file1, const char* file2)
|
static int kwsys_shared_forward_samepath(const char* file1, const char* file2)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@@ -458,7 +449,6 @@ static int kwsys_shared_forward_samepath(const char* file1, const char* file2)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Function to report a system error message. */
|
/* Function to report a system error message. */
|
||||||
static void kwsys_shared_forward_strerror(char* message)
|
static void kwsys_shared_forward_strerror(char* message)
|
||||||
{
|
{
|
||||||
@@ -481,7 +471,6 @@ static void kwsys_shared_forward_strerror(char* message)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Functions to execute a child process. */
|
/* Functions to execute a child process. */
|
||||||
static void kwsys_shared_forward_execvp(const char* cmd,
|
static void kwsys_shared_forward_execvp(const char* cmd,
|
||||||
char const* const* argv)
|
char const* const* argv)
|
||||||
@@ -521,7 +510,6 @@ static void kwsys_shared_forward_execvp(const char* cmd,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Function to get the directory containing the given file or directory. */
|
/* Function to get the directory containing the given file or directory. */
|
||||||
static void kwsys_shared_forward_dirname(const char* begin, char* result)
|
static void kwsys_shared_forward_dirname(const char* begin, char* result)
|
||||||
{
|
{
|
||||||
@@ -557,7 +545,6 @@ static void kwsys_shared_forward_dirname(const char* begin, char* result)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Function to check if a file exists and is executable. */
|
/* Function to check if a file exists and is executable. */
|
||||||
static int kwsys_shared_forward_is_executable(const char* f)
|
static int kwsys_shared_forward_is_executable(const char* f)
|
||||||
{
|
{
|
||||||
@@ -578,7 +565,6 @@ static int kwsys_shared_forward_is_executable(const char* f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Function to locate the executable currently running. */
|
/* Function to locate the executable currently running. */
|
||||||
static int kwsys_shared_forward_self_path(const char* argv0, char* result)
|
static int kwsys_shared_forward_self_path(const char* argv0, char* result)
|
||||||
{
|
{
|
||||||
@@ -644,7 +630,6 @@ static int kwsys_shared_forward_self_path(const char* argv0, char* result)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Function to convert a specified path to a full path. If it is not
|
/* Function to convert a specified path to a full path. If it is not
|
||||||
already full, it is taken relative to the self path. */
|
already full, it is taken relative to the self path. */
|
||||||
static int kwsys_shared_forward_fullpath(const char* self_path,
|
static int kwsys_shared_forward_fullpath(const char* self_path,
|
||||||
@@ -681,7 +666,6 @@ static int kwsys_shared_forward_fullpath(const char* self_path,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Function to compute the library search path and executable name
|
/* Function to compute the library search path and executable name
|
||||||
based on the self path. */
|
based on the self path. */
|
||||||
static int kwsys_shared_forward_get_settings(const char* self_path,
|
static int kwsys_shared_forward_get_settings(const char* self_path,
|
||||||
@@ -773,7 +757,6 @@ static int kwsys_shared_forward_get_settings(const char* self_path,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Function to print why execution of a command line failed. */
|
/* Function to print why execution of a command line failed. */
|
||||||
static void kwsys_shared_forward_print_failure(char const* const* argv)
|
static void kwsys_shared_forward_print_failure(char const* const* argv)
|
||||||
{
|
{
|
||||||
@@ -791,7 +774,6 @@ static void kwsys_shared_forward_print_failure(char const* const* argv)
|
|||||||
static char kwsys_shared_forward_ldpath[65535] =
|
static char kwsys_shared_forward_ldpath[65535] =
|
||||||
KWSYS_SHARED_FORWARD_LDPATH "=";
|
KWSYS_SHARED_FORWARD_LDPATH "=";
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Main driver function to be called from main. */
|
/* Main driver function to be called from main. */
|
||||||
static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in)
|
static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in)
|
||||||
{
|
{
|
||||||
|
|||||||
4
System.c
4
System.c
@@ -22,7 +22,6 @@ typedef ptrdiff_t kwsysSystem_ptrdiff_t;
|
|||||||
typedef int kwsysSystem_ptrdiff_t;
|
typedef int kwsysSystem_ptrdiff_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysSystem__AppendByte(char* local, char** begin, char** end,
|
static int kwsysSystem__AppendByte(char* local, char** begin, char** end,
|
||||||
int* size, char c)
|
int* size, char c)
|
||||||
{
|
{
|
||||||
@@ -47,7 +46,6 @@ static int kwsysSystem__AppendByte(char* local, char** begin, char** end,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysSystem__AppendArgument(char** local, char*** begin,
|
static int kwsysSystem__AppendArgument(char** local, char*** begin,
|
||||||
char*** end, int* size, char* arg_local,
|
char*** end, int* size, char* arg_local,
|
||||||
char** arg_begin, char** arg_end,
|
char** arg_begin, char** arg_end,
|
||||||
@@ -91,7 +89,6 @@ static int kwsysSystem__AppendArgument(char** local, char*** begin,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#define KWSYSPE_LOCAL_BYTE_COUNT 1024
|
#define KWSYSPE_LOCAL_BYTE_COUNT 1024
|
||||||
#define KWSYSPE_LOCAL_ARGS_COUNT 32
|
#define KWSYSPE_LOCAL_ARGS_COUNT 32
|
||||||
static char** kwsysSystem__ParseUnixCommand(const char* command, int flags)
|
static char** kwsysSystem__ParseUnixCommand(const char* command, int flags)
|
||||||
@@ -227,7 +224,6 @@ static char** kwsysSystem__ParseUnixCommand(const char* command, int flags)
|
|||||||
return newCommand;
|
return newCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
char** kwsysSystem_Parse_CommandForUnix(const char* command, int flags)
|
char** kwsysSystem_Parse_CommandForUnix(const char* command, int flags)
|
||||||
{
|
{
|
||||||
/* Validate the flags. */
|
/* Validate the flags. */
|
||||||
|
|||||||
@@ -838,7 +838,6 @@ void SystemInformation::RunMemoryCheck()
|
|||||||
this->Implementation->RunMemoryCheck();
|
this->Implementation->RunMemoryCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
// SystemInformationImplementation starts here
|
// SystemInformationImplementation starts here
|
||||||
|
|
||||||
#define STORE_TLBCACHE_INFO(x, y) x = (x < (y)) ? (y) : x
|
#define STORE_TLBCACHE_INFO(x, y) x = (x < (y)) ? (y) : x
|
||||||
@@ -1314,7 +1313,6 @@ private:
|
|||||||
int ReportPath;
|
int ReportPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
std::ostream& operator<<(std::ostream& os, const SymbolProperties& sp)
|
std::ostream& operator<<(std::ostream& os, const SymbolProperties& sp)
|
||||||
{
|
{
|
||||||
#if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP)
|
#if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP)
|
||||||
@@ -1333,7 +1331,6 @@ std::ostream& operator<<(std::ostream& os, const SymbolProperties& sp)
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
SymbolProperties::SymbolProperties()
|
SymbolProperties::SymbolProperties()
|
||||||
{
|
{
|
||||||
// not using an initializer list
|
// not using an initializer list
|
||||||
@@ -1352,7 +1349,6 @@ SymbolProperties::SymbolProperties()
|
|||||||
this->GetLineNumber();
|
this->GetLineNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
std::string SymbolProperties::GetFileName(const std::string& path) const
|
std::string SymbolProperties::GetFileName(const std::string& path) const
|
||||||
{
|
{
|
||||||
std::string file(path);
|
std::string file(path);
|
||||||
@@ -1365,7 +1361,6 @@ std::string SymbolProperties::GetFileName(const std::string& path) const
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
std::string SymbolProperties::GetBinary() const
|
std::string SymbolProperties::GetBinary() const
|
||||||
{
|
{
|
||||||
// only linux has proc fs
|
// only linux has proc fs
|
||||||
@@ -1386,7 +1381,6 @@ std::string SymbolProperties::GetBinary() const
|
|||||||
return this->GetFileName(this->Binary);
|
return this->GetFileName(this->Binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
std::string SymbolProperties::Demangle(const char* symbol) const
|
std::string SymbolProperties::Demangle(const char* symbol) const
|
||||||
{
|
{
|
||||||
std::string result = safes(symbol);
|
std::string result = safes(symbol);
|
||||||
@@ -1406,7 +1400,6 @@ std::string SymbolProperties::Demangle(const char* symbol) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
void SymbolProperties::Initialize(void* address)
|
void SymbolProperties::Initialize(void* address)
|
||||||
{
|
{
|
||||||
this->Address = address;
|
this->Address = address;
|
||||||
@@ -1425,7 +1418,6 @@ void SymbolProperties::Initialize(void* address)
|
|||||||
}
|
}
|
||||||
#endif // don't define this class if we're not using it
|
#endif // don't define this class if we're not using it
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
#define KWSYS_SYSTEMINFORMATION_USE_GetSystemTimes
|
#define KWSYS_SYSTEMINFORMATION_USE_GetSystemTimes
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -547,8 +547,6 @@ bool SystemTools::HasEnv(const std::string& key)
|
|||||||
return SystemTools::HasEnv(key.c_str());
|
return SystemTools::HasEnv(key.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#if KWSYS_CXX_HAS_UNSETENV
|
#if KWSYS_CXX_HAS_UNSETENV
|
||||||
/* unsetenv("A") removes A from the environment.
|
/* unsetenv("A") removes A from the environment.
|
||||||
On older platforms it returns void instead of int. */
|
On older platforms it returns void instead of int. */
|
||||||
@@ -639,8 +637,6 @@ static int kwsysUnPutEnv(const std::string& env)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#if KWSYS_CXX_HAS_SETENV
|
#if KWSYS_CXX_HAS_SETENV
|
||||||
|
|
||||||
/* setenv("A", "B", 1) will set A=B in the environment and makes its
|
/* setenv("A", "B", 1) will set A=B in the environment and makes its
|
||||||
@@ -731,8 +727,6 @@ bool SystemTools::UnPutEnv(const std::string& env)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const char* SystemTools::GetExecutableExtension()
|
const char* SystemTools::GetExecutableExtension()
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__VMS)
|
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__VMS)
|
||||||
@@ -1144,7 +1138,6 @@ bool SystemTools::SameFile(const std::string& file1, const std::string& file2)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::PathExists(const std::string& path)
|
bool SystemTools::PathExists(const std::string& path)
|
||||||
{
|
{
|
||||||
if (path.empty()) {
|
if (path.empty()) {
|
||||||
@@ -1167,7 +1160,6 @@ bool SystemTools::PathExists(const std::string& path)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::FileExists(const char* filename)
|
bool SystemTools::FileExists(const char* filename)
|
||||||
{
|
{
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
@@ -1176,7 +1168,6 @@ bool SystemTools::FileExists(const char* filename)
|
|||||||
return SystemTools::FileExists(std::string(filename));
|
return SystemTools::FileExists(std::string(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::FileExists(const std::string& filename)
|
bool SystemTools::FileExists(const std::string& filename)
|
||||||
{
|
{
|
||||||
if (filename.empty()) {
|
if (filename.empty()) {
|
||||||
@@ -1203,7 +1194,6 @@ bool SystemTools::FileExists(const std::string& filename)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::FileExists(const char* filename, bool isFile)
|
bool SystemTools::FileExists(const char* filename, bool isFile)
|
||||||
{
|
{
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
@@ -1212,7 +1202,6 @@ bool SystemTools::FileExists(const char* filename, bool isFile)
|
|||||||
return SystemTools::FileExists(std::string(filename), isFile);
|
return SystemTools::FileExists(std::string(filename), isFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::FileExists(const std::string& filename, bool isFile)
|
bool SystemTools::FileExists(const std::string& filename, bool isFile)
|
||||||
{
|
{
|
||||||
if (SystemTools::FileExists(filename)) {
|
if (SystemTools::FileExists(filename)) {
|
||||||
@@ -1223,7 +1212,6 @@ bool SystemTools::FileExists(const std::string& filename, bool isFile)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::TestFileAccess(const char* filename,
|
bool SystemTools::TestFileAccess(const char* filename,
|
||||||
TestFilePermissions permissions)
|
TestFilePermissions permissions)
|
||||||
{
|
{
|
||||||
@@ -1233,7 +1221,6 @@ bool SystemTools::TestFileAccess(const char* filename,
|
|||||||
return SystemTools::TestFileAccess(std::string(filename), permissions);
|
return SystemTools::TestFileAccess(std::string(filename), permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::TestFileAccess(const std::string& filename,
|
bool SystemTools::TestFileAccess(const std::string& filename,
|
||||||
TestFilePermissions permissions)
|
TestFilePermissions permissions)
|
||||||
{
|
{
|
||||||
@@ -1255,7 +1242,6 @@ bool SystemTools::TestFileAccess(const std::string& filename,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int SystemTools::Stat(const char* path, SystemTools::Stat_t* buf)
|
int SystemTools::Stat(const char* path, SystemTools::Stat_t* buf)
|
||||||
{
|
{
|
||||||
if (!path) {
|
if (!path) {
|
||||||
@@ -1265,7 +1251,6 @@ int SystemTools::Stat(const char* path, SystemTools::Stat_t* buf)
|
|||||||
return SystemTools::Stat(std::string(path), buf);
|
return SystemTools::Stat(std::string(path), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf)
|
int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf)
|
||||||
{
|
{
|
||||||
if (path.empty()) {
|
if (path.empty()) {
|
||||||
@@ -1287,7 +1272,6 @@ int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path)
|
bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path)
|
||||||
{
|
{
|
||||||
@@ -1752,7 +1736,6 @@ std::string SystemTools::CropString(const std::string& s, size_t max_len)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
std::vector<kwsys::String> SystemTools::SplitString(const std::string& p,
|
std::vector<kwsys::String> SystemTools::SplitString(const std::string& p,
|
||||||
char sep, bool isPath)
|
char sep, bool isPath)
|
||||||
{
|
{
|
||||||
@@ -1777,7 +1760,6 @@ std::vector<kwsys::String> SystemTools::SplitString(const std::string& p,
|
|||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int SystemTools::EstimateFormatLength(const char* format, va_list ap)
|
int SystemTools::EstimateFormatLength(const char* format, va_list ap)
|
||||||
{
|
{
|
||||||
if (!format) {
|
if (!format) {
|
||||||
@@ -2165,7 +2147,6 @@ bool SystemTools::FilesDiffer(const std::string& source,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
/**
|
/**
|
||||||
* Copy a file named by "source" to the file named by "destination".
|
* Copy a file named by "source" to the file named by "destination".
|
||||||
*/
|
*/
|
||||||
@@ -2269,7 +2250,6 @@ bool SystemTools::CopyFileAlways(const std::string& source,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::CopyAFile(const std::string& source,
|
bool SystemTools::CopyAFile(const std::string& source,
|
||||||
const std::string& destination, bool always)
|
const std::string& destination, bool always)
|
||||||
{
|
{
|
||||||
@@ -3550,7 +3530,6 @@ static std::string GetCasePathName(std::string const& pathIn)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
std::string SystemTools::GetActualCaseForPath(const std::string& p)
|
std::string SystemTools::GetActualCaseForPath(const std::string& p)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@@ -3571,7 +3550,6 @@ std::string SystemTools::GetActualCaseForPath(const std::string& p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* SystemTools::SplitPathRootComponent(const std::string& p,
|
const char* SystemTools::SplitPathRootComponent(const std::string& p,
|
||||||
std::string* root)
|
std::string* root)
|
||||||
{
|
{
|
||||||
@@ -3638,7 +3616,6 @@ const char* SystemTools::SplitPathRootComponent(const std::string& p,
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void SystemTools::SplitPath(const std::string& p,
|
void SystemTools::SplitPath(const std::string& p,
|
||||||
std::vector<std::string>& components,
|
std::vector<std::string>& components,
|
||||||
bool expand_home_dir)
|
bool expand_home_dir)
|
||||||
@@ -3695,13 +3672,11 @@ void SystemTools::SplitPath(const std::string& p,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
std::string SystemTools::JoinPath(const std::vector<std::string>& components)
|
std::string SystemTools::JoinPath(const std::vector<std::string>& components)
|
||||||
{
|
{
|
||||||
return SystemTools::JoinPath(components.begin(), components.end());
|
return SystemTools::JoinPath(components.begin(), components.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
std::string SystemTools::JoinPath(
|
std::string SystemTools::JoinPath(
|
||||||
std::vector<std::string>::const_iterator first,
|
std::vector<std::string>::const_iterator first,
|
||||||
std::vector<std::string>::const_iterator last)
|
std::vector<std::string>::const_iterator last)
|
||||||
@@ -3733,7 +3708,6 @@ std::string SystemTools::JoinPath(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::ComparePath(const std::string& c1, const std::string& c2)
|
bool SystemTools::ComparePath(const std::string& c1, const std::string& c2)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) || defined(__APPLE__)
|
#if defined(_WIN32) || defined(__APPLE__)
|
||||||
@@ -3749,7 +3723,6 @@ bool SystemTools::ComparePath(const std::string& c1, const std::string& c2)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::Split(const std::string& str,
|
bool SystemTools::Split(const std::string& str,
|
||||||
std::vector<std::string>& lines, char separator)
|
std::vector<std::string>& lines, char separator)
|
||||||
{
|
{
|
||||||
@@ -3770,7 +3743,6 @@ bool SystemTools::Split(const std::string& str,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool SystemTools::Split(const std::string& str,
|
bool SystemTools::Split(const std::string& str,
|
||||||
std::vector<std::string>& lines)
|
std::vector<std::string>& lines)
|
||||||
{
|
{
|
||||||
@@ -4707,7 +4679,6 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
bool SystemTools::ParseURLProtocol(const std::string& URL,
|
bool SystemTools::ParseURLProtocol(const std::string& URL,
|
||||||
std::string& protocol,
|
std::string& protocol,
|
||||||
std::string& dataglom)
|
std::string& dataglom)
|
||||||
@@ -4726,7 +4697,6 @@ bool SystemTools::ParseURLProtocol(const std::string& URL,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
bool SystemTools::ParseURL(const std::string& URL, std::string& protocol,
|
bool SystemTools::ParseURL(const std::string& URL, std::string& protocol,
|
||||||
std::string& username, std::string& password,
|
std::string& username, std::string& password,
|
||||||
std::string& hostname, std::string& dataport,
|
std::string& hostname, std::string& dataport,
|
||||||
@@ -4757,7 +4727,6 @@ bool SystemTools::ParseURL(const std::string& URL, std::string& protocol,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// These must NOT be initialized. Default initialization to zero is
|
// These must NOT be initialized. Default initialization to zero is
|
||||||
// necessary.
|
// necessary.
|
||||||
static unsigned int SystemToolsManagerCount;
|
static unsigned int SystemToolsManagerCount;
|
||||||
|
|||||||
10
Terminal.c
10
Terminal.c
@@ -9,7 +9,6 @@
|
|||||||
#include "Terminal.h.in"
|
#include "Terminal.h.in"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Configure support for this platform. */
|
/* Configure support for this platform. */
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
#define KWSYS_TERMINAL_SUPPORT_CONSOLE
|
#define KWSYS_TERMINAL_SUPPORT_CONSOLE
|
||||||
@@ -18,7 +17,6 @@
|
|||||||
#define KWSYS_TERMINAL_ISATTY_WORKS
|
#define KWSYS_TERMINAL_ISATTY_WORKS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Include needed system APIs. */
|
/* Include needed system APIs. */
|
||||||
|
|
||||||
#include <stdarg.h> /* va_list */
|
#include <stdarg.h> /* va_list */
|
||||||
@@ -36,7 +34,6 @@
|
|||||||
#include <sys/stat.h> /* fstat */
|
#include <sys/stat.h> /* fstat */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100,
|
static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100,
|
||||||
int default_tty);
|
int default_tty);
|
||||||
static void kwsysTerminalSetVT100Color(FILE* stream, int color);
|
static void kwsysTerminalSetVT100Color(FILE* stream, int color);
|
||||||
@@ -47,7 +44,6 @@ static void kwsysTerminalSetConsoleColor(HANDLE hOut,
|
|||||||
FILE* stream, int color);
|
FILE* stream, int color);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
void kwsysTerminal_cfprintf(int color, FILE* stream, const char* format, ...)
|
void kwsysTerminal_cfprintf(int color, FILE* stream, const char* format, ...)
|
||||||
{
|
{
|
||||||
/* Setup the stream with the given color if possible. */
|
/* Setup the stream with the given color if possible. */
|
||||||
@@ -89,7 +85,6 @@ void kwsysTerminal_cfprintf(int color, FILE* stream, const char* format, ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Detect cases when a stream is definitely not interactive. */
|
/* Detect cases when a stream is definitely not interactive. */
|
||||||
#if !defined(KWSYS_TERMINAL_ISATTY_WORKS)
|
#if !defined(KWSYS_TERMINAL_ISATTY_WORKS)
|
||||||
static int kwsysTerminalStreamIsNotInteractive(FILE* stream)
|
static int kwsysTerminalStreamIsNotInteractive(FILE* stream)
|
||||||
@@ -106,7 +101,6 @@ static int kwsysTerminalStreamIsNotInteractive(FILE* stream)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* List of terminal names known to support VT100 color escape sequences. */
|
/* List of terminal names known to support VT100 color escape sequences. */
|
||||||
static const char* kwsysTerminalVT100Names[] = { "Eterm",
|
static const char* kwsysTerminalVT100Names[] = { "Eterm",
|
||||||
"ansi",
|
"ansi",
|
||||||
@@ -162,7 +156,6 @@ static const char* kwsysTerminalVT100Names[] = { "Eterm",
|
|||||||
"xterm-termite",
|
"xterm-termite",
|
||||||
0 };
|
0 };
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Detect whether a stream is displayed in a VT100-compatible terminal. */
|
/* Detect whether a stream is displayed in a VT100-compatible terminal. */
|
||||||
static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100,
|
static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100,
|
||||||
int default_tty)
|
int default_tty)
|
||||||
@@ -214,7 +207,6 @@ static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* VT100 escape sequence strings. */
|
/* VT100 escape sequence strings. */
|
||||||
#define KWSYS_TERMINAL_VT100_NORMAL "\33[0m"
|
#define KWSYS_TERMINAL_VT100_NORMAL "\33[0m"
|
||||||
#define KWSYS_TERMINAL_VT100_BOLD "\33[1m"
|
#define KWSYS_TERMINAL_VT100_BOLD "\33[1m"
|
||||||
@@ -238,7 +230,6 @@ static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100,
|
|||||||
#define KWSYS_TERMINAL_VT100_BACKGROUND_CYAN "\33[46m"
|
#define KWSYS_TERMINAL_VT100_BACKGROUND_CYAN "\33[46m"
|
||||||
#define KWSYS_TERMINAL_VT100_BACKGROUND_WHITE "\33[47m"
|
#define KWSYS_TERMINAL_VT100_BACKGROUND_WHITE "\33[47m"
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
/* Write VT100 escape sequences to the stream for the given color. */
|
/* Write VT100 escape sequences to the stream for the given color. */
|
||||||
static void kwsysTerminalSetVT100Color(FILE* stream, int color)
|
static void kwsysTerminalSetVT100Color(FILE* stream, int color)
|
||||||
{
|
{
|
||||||
@@ -307,7 +298,6 @@ static void kwsysTerminalSetVT100Color(FILE* stream, int color)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#if defined(KWSYS_TERMINAL_SUPPORT_CONSOLE)
|
#if defined(KWSYS_TERMINAL_SUPPORT_CONSOLE)
|
||||||
|
|
||||||
#define KWSYS_TERMINAL_MASK_FOREGROUND \
|
#define KWSYS_TERMINAL_MASK_FOREGROUND \
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
main(int argc, char* argv[])
|
main(int argc, char* argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#ifdef TEST_KWSYS_C_HAS_PTRDIFF_T
|
#ifdef TEST_KWSYS_C_HAS_PTRDIFF_T
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
int f(ptrdiff_t n)
|
int f(ptrdiff_t n)
|
||||||
@@ -43,7 +42,6 @@ int KWSYS_PLATFORM_TEST_C_MAIN()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#ifdef TEST_KWSYS_C_HAS_SSIZE_T
|
#ifdef TEST_KWSYS_C_HAS_SSIZE_T
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
int f(ssize_t n)
|
int f(ssize_t n)
|
||||||
@@ -57,7 +55,6 @@ int KWSYS_PLATFORM_TEST_C_MAIN()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#ifdef TEST_KWSYS_C_TYPE_MACROS
|
#ifdef TEST_KWSYS_C_TYPE_MACROS
|
||||||
char* info_macros =
|
char* info_macros =
|
||||||
#if defined(__SIZEOF_SHORT__)
|
#if defined(__SIZEOF_SHORT__)
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ std::basic_streambuf<wchar_t>* errstream(const wchar_t* unused)
|
|||||||
return std::wcerr.rdbuf();
|
return std::wcerr.rdbuf();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void dumpBuffers(const T* expected, const T* received, size_t size)
|
static void dumpBuffers(const T* expected, const T* received, size_t size)
|
||||||
{
|
{
|
||||||
@@ -107,7 +106,6 @@ static void dumpBuffers(const T* expected, const T* received, size_t size)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
|
static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
|
||||||
{
|
{
|
||||||
BOOL bInheritHandles = FALSE;
|
BOOL bInheritHandles = FALSE;
|
||||||
@@ -158,7 +156,6 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static void finishProcess(bool success)
|
static void finishProcess(bool success)
|
||||||
{
|
{
|
||||||
if (success) {
|
if (success) {
|
||||||
@@ -172,7 +169,6 @@ static void finishProcess(bool success)
|
|||||||
CloseHandle(processInfo.hThread);
|
CloseHandle(processInfo.hThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static bool createPipe(PHANDLE readPipe, PHANDLE writePipe)
|
static bool createPipe(PHANDLE readPipe, PHANDLE writePipe)
|
||||||
{
|
{
|
||||||
SECURITY_ATTRIBUTES securityAttributes;
|
SECURITY_ATTRIBUTES securityAttributes;
|
||||||
@@ -183,7 +179,6 @@ static bool createPipe(PHANDLE readPipe, PHANDLE writePipe)
|
|||||||
: true;
|
: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static void finishPipe(HANDLE readPipe, HANDLE writePipe)
|
static void finishPipe(HANDLE readPipe, HANDLE writePipe)
|
||||||
{
|
{
|
||||||
if (readPipe != INVALID_HANDLE_VALUE) {
|
if (readPipe != INVALID_HANDLE_VALUE) {
|
||||||
@@ -194,7 +189,6 @@ static void finishPipe(HANDLE readPipe, HANDLE writePipe)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static HANDLE createFile(LPCWSTR fileName)
|
static HANDLE createFile(LPCWSTR fileName)
|
||||||
{
|
{
|
||||||
SECURITY_ATTRIBUTES securityAttributes;
|
SECURITY_ATTRIBUTES securityAttributes;
|
||||||
@@ -218,7 +212,6 @@ static HANDLE createFile(LPCWSTR fileName)
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static void finishFile(HANDLE file)
|
static void finishFile(HANDLE file)
|
||||||
{
|
{
|
||||||
if (file != INVALID_HANDLE_VALUE) {
|
if (file != INVALID_HANDLE_VALUE) {
|
||||||
@@ -226,8 +219,6 @@ static void finishFile(HANDLE file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef MAPVK_VK_TO_VSC
|
#ifndef MAPVK_VK_TO_VSC
|
||||||
#define MAPVK_VK_TO_VSC (0)
|
#define MAPVK_VK_TO_VSC (0)
|
||||||
#endif
|
#endif
|
||||||
@@ -269,7 +260,6 @@ static void writeInputKeyEvent(INPUT_RECORD inputBuffer[], WCHAR chr)
|
|||||||
inputBuffer[1].Event.KeyEvent.dwControlKeyState = 0;
|
inputBuffer[1].Event.KeyEvent.dwControlKeyState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static int testPipe()
|
static int testPipe()
|
||||||
{
|
{
|
||||||
int didFail = 1;
|
int didFail = 1;
|
||||||
@@ -377,7 +367,6 @@ static int testPipe()
|
|||||||
return didFail;
|
return didFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static int testFile()
|
static int testFile()
|
||||||
{
|
{
|
||||||
int didFail = 1;
|
int didFail = 1;
|
||||||
@@ -487,7 +476,6 @@ static int testFile()
|
|||||||
#define _WIN32_WINNT_VISTA 0x0600
|
#define _WIN32_WINNT_VISTA 0x0600
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static int testConsole()
|
static int testConsole()
|
||||||
{
|
{
|
||||||
int didFail = 1;
|
int didFail = 1;
|
||||||
@@ -748,7 +736,6 @@ static int testConsole()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int testConsoleBuf(int, char* [])
|
int testConsoleBuf(int, char* [])
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "testConsoleBuf.hxx"
|
#include "testConsoleBuf.hxx"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int main(int argc, const char* argv[])
|
int main(int argc, const char* argv[])
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "Encoding.hxx.in"
|
#include "Encoding.hxx.in"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static const unsigned char helloWorldStrings[][32] = {
|
static const unsigned char helloWorldStrings[][32] = {
|
||||||
// English
|
// English
|
||||||
{ 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', 0 },
|
{ 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', 0 },
|
||||||
@@ -50,7 +49,6 @@ static const unsigned char helloWorldStrings[][32] = {
|
|||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static int testHelloWorldEncoding()
|
static int testHelloWorldEncoding()
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@@ -262,7 +260,6 @@ static int testToWindowsExtendedPath()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int testEncoding(int, char* [])
|
int testEncoding(int, char* [])
|
||||||
{
|
{
|
||||||
const char* loc = setlocale(LC_ALL, "");
|
const char* loc = setlocale(LC_ALL, "");
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static int testNoFile()
|
static int testNoFile()
|
||||||
{
|
{
|
||||||
kwsys::ifstream in_file("NoSuchFile.txt");
|
kwsys::ifstream in_file("NoSuchFile.txt");
|
||||||
@@ -69,7 +68,6 @@ static unsigned char file_data[num_test_files][max_test_file_size] = {
|
|||||||
0x72, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x64 },
|
0x72, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x64 },
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static int testBOM()
|
static int testBOM()
|
||||||
{
|
{
|
||||||
// test various encodings in binary mode
|
// test various encodings in binary mode
|
||||||
@@ -104,7 +102,6 @@ static int testBOM()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int testFStream(int, char* [])
|
int testFStream(int, char* [])
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
typedef unsigned short mode_t;
|
typedef unsigned short mode_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static const char* toUnixPaths[][2] = {
|
static const char* toUnixPaths[][2] = {
|
||||||
{ "/usr/local/bin/passwd", "/usr/local/bin/passwd" },
|
{ "/usr/local/bin/passwd", "/usr/local/bin/passwd" },
|
||||||
{ "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" },
|
{ "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" },
|
||||||
@@ -67,7 +66,6 @@ static bool CheckConvertToUnixSlashes(std::string input, std::string output)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static const char* checkEscapeChars[][4] = { { "1 foo 2 bar 2", "12", "\\",
|
static const char* checkEscapeChars[][4] = { { "1 foo 2 bar 2", "12", "\\",
|
||||||
"\\1 foo \\2 bar \\2" },
|
"\\1 foo \\2 bar \\2" },
|
||||||
{ " {} ", "{}", "#", " #{#} " },
|
{ " {} ", "{}", "#", " #{#} " },
|
||||||
@@ -86,7 +84,6 @@ static bool CheckEscapeChars(std::string input, const char* chars_to_escape,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static bool CheckFileOperations()
|
static bool CheckFileOperations()
|
||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
@@ -469,7 +466,6 @@ static bool CheckFileOperations()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static bool CheckStringOperations()
|
static bool CheckStringOperations()
|
||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
@@ -613,8 +609,6 @@ static bool CheckStringOperations()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static bool CheckPutEnv(const std::string& env, const char* name,
|
static bool CheckPutEnv(const std::string& env, const char* name,
|
||||||
const char* value)
|
const char* value)
|
||||||
{
|
{
|
||||||
@@ -842,7 +836,6 @@ static bool CheckGetLineFromStream()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int testSystemTools(int, char* [])
|
int testSystemTools(int, char* [])
|
||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user