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:
hoffmann
2013-02-17 17:01:31 +00:00
parent 205c7ec919
commit 2c6a4c2d6e
7 changed files with 3033 additions and 75 deletions

View 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__

File diff suppressed because it is too large Load Diff

View 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__