core/util: Added CommandLine interface (for bochs)

This commit is contained in:
Christian Dietrich
2013-03-11 15:27:45 +01:00
parent c1f32f5a98
commit ad3c185b61
7 changed files with 177 additions and 7 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +0,0 @@
#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__

View File

@ -18,8 +18,8 @@
#include <vector>
#include "config/VariantConfig.hpp"
#include "sal/SALInst.hpp"
#include "optionparser.h"
#include "optionparser_ext.hpp"
#include "optionparser/optionparser.h"
#include "optionparser/optionparser_ext.hpp"
#include "T32Connector.hpp"
#include "t32config.hpp"