#include "Proxy.h" #include <errno.h> #include <iostream> #include <cstdlib> Proxy::Proxy(const std::string& name, const std::string& type, Configuration * config) : Executable(name, type, config), _compress(true), _size("1") { } Proxy::~Proxy() { } Proxy::var_map Proxy::VariableMap; // Warning: // Optional Variables are defined directly in verifyVariables() bool Proxy::initializeVariableMap() { VariableMap["Proxy"] = &Proxy::setExecutable; VariableMap["Owner"] = &Proxy::setUser; VariableMap["P4PCACHE"] = &Proxy::setCache; VariableMap["P4TARGET"] = &Proxy::setTarget; VariableMap["P4PORT"] = &Proxy::setPort; return true; } void Proxy::verifyVariables() throw(VerificationException) { static bool initialized = initializeVariableMap(); env_map::iterator pos; var_map::const_iterator iter; for (iter = VariableMap.begin(); iter != VariableMap.end(); ++iter) { pos = _variables.find(iter->first); if (pos != _variables.end()) { (this->*iter->second)(pos->second); _variables.erase(pos); } else { std::string err = _type + " " + _name + ". No " + iter->first + " defined"; throw VerificationException(err); } } // extra verification // if the following variables exist, check their consistency, then assign them // - compress // - size pos = _variables.find("P4PFSIZE"); if (pos != _variables.end()) { int value = atoi(pos->second.c_str()); if (!value) { std::string err = "P4PFSIZE: only positive integers allowed."; err += " Illegal value : "; err += pos->second; throw VerificationException(err); } setSize(pos->second); } pos = _variables.find("Proxy_compress"); if (pos != _variables.end()) { if (pos->second == "true") { setCompress(true); } else if (pos->second == "false") { setCompress(false); } else { std::string err = "Proxy_compress only {true|false} allowed."; err += " Illegal value : "; err += pos->second; throw VerificationException(err); } } } void Proxy::prepareArgs(arg_vec& args) { std::string procname = _executable + " [" + _port + "]"; args.push_back(procname); args.push_back("-q"); addOption("P4LOG", "-L", args); addOption("P4PFSIZE", "-e", args); addOption("Options", NULL, args); args.push_back("-p"); args.push_back(_port); args.push_back("-t"); args.push_back(_target); args.push_back("-r"); args.push_back(_cache); if (!_compress) { args.push_back("-c"); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 8038 | Sven Erik Knop | Updated imports and link libraries for Linux to deal with new compiler. | ||
#2 | 5987 | Sven Erik Knop |
Few minor changes: All commands now accept variable called "Options". This can be used to collect all options for which Perforce has not defined an environment variable - for example the undocumented "-C1" for p4d to start a case insensitive server. p4d also accepts the variables P4USER and P4PASSWD. These are only used for stopping the service, which is done first via "p4 admin stop". Note that if the stop via the admin command fails, p4dcfg will stop the service via a kill |
||
#1 | 5882 | Sven Erik Knop | initial publish |