T32: Parsing cli options for T32 fail-client
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@2108 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
21
debuggers/t32/include/T32Connector.hpp
Normal file
21
debuggers/t32/include/T32Connector.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __T32CONNECTOR_HPP__
|
||||
#define __T32CONNECTOR_HPP__
|
||||
|
||||
namespace fail {
|
||||
|
||||
class T32Connector {
|
||||
char* m_hostname;
|
||||
unsigned m_port;
|
||||
unsigned m_packetlength;
|
||||
|
||||
public:
|
||||
T32Connector() { };
|
||||
T32Connector(char* hostname, unsigned port, unsigned packlen);
|
||||
~T32Connector();
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // end-of-namespace fail
|
||||
#endif // __T32CONNECTOR_HPP__
|
||||
|
||||
2815
debuggers/t32/include/optionparser.h
Normal file
2815
debuggers/t32/include/optionparser.h
Normal file
File diff suppressed because it is too large
Load Diff
53
debuggers/t32/include/optionparser_ext.hpp
Normal file
53
debuggers/t32/include/optionparser_ext.hpp
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef __OPTIONSPARSER_EXT_HPP__
|
||||
#define __OPTIONSPARSER_EXT_HPP__
|
||||
|
||||
|
||||
struct Arg: public option::Arg
|
||||
{
|
||||
static void printError(const char* msg1, const option::Option& opt, const char* msg2)
|
||||
{
|
||||
fprintf(stderr, "%s", msg1);
|
||||
fwrite(opt.name, opt.namelen, 1, stderr);
|
||||
fprintf(stderr, "%s", msg2);
|
||||
}
|
||||
|
||||
static option::ArgStatus Unknown(const option::Option& option, bool msg)
|
||||
{
|
||||
if (msg) printError("Unknown option '", option, "'\n");
|
||||
return option::ARG_ILLEGAL;
|
||||
}
|
||||
|
||||
static option::ArgStatus Required(const option::Option& option, bool msg)
|
||||
{
|
||||
if (option.arg != 0)
|
||||
return option::ARG_OK;
|
||||
|
||||
if (msg) printError("Option '", option, "' requires an argument\n");
|
||||
return option::ARG_ILLEGAL;
|
||||
}
|
||||
|
||||
static option::ArgStatus NonEmpty(const option::Option& option, bool msg)
|
||||
{
|
||||
if (option.arg != 0 && option.arg[0] != 0)
|
||||
return option::ARG_OK;
|
||||
|
||||
if (msg) printError("Option '", option, "' requires a non-empty argument\n");
|
||||
return option::ARG_ILLEGAL;
|
||||
}
|
||||
|
||||
static option::ArgStatus Numeric(const option::Option& option, bool msg)
|
||||
{
|
||||
char* endptr = 0;
|
||||
if (option.arg != 0 && strtol(option.arg, &endptr, 10)){};
|
||||
if (endptr != option.arg && *endptr == 0)
|
||||
return option::ARG_OK;
|
||||
|
||||
if (msg) printError("Option '", option, "' requires a numeric argument\n");
|
||||
return option::ARG_ILLEGAL;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __OPTIONSPARSER_EXT_HPP__
|
||||
Reference in New Issue
Block a user