16 #define CONNECTION_TIMEOUT 5.0
29 const char *at = txt.c_str();
34 result.
addString(std::string(at,len-slash_tweak));
40 slash_tweak = (ch==
slash && len>0)?1:0;
44 result.
addString(std::string(at,len-slash_tweak));
51 fp = fopen(fname,
"r");
61 bool ScriptLocalBroker::init(
const char* szcmd,
const char* szparam,
62 const char* szhost,
const char* szstdio,
63 const char* szworkdir,
const char* szenv )
71 for (
size_t i=0; i<possiblePaths.
size(); ++i)
73 std::string guessString=possiblePaths.
get(i).
asString() +
74 std::string{
slash} + szcmd;
75 const char* guess=guessString.c_str();
79 strCmd =
"\"" + std::string(guess) +
"\"";
94 strDevParam<<strCmd<<
" "<<strParam;
95 return LocalBroker::init(script.c_str(), strDevParam.str().c_str(),
96 szhost, szstdio, szworkdir, szenv);
100 bool ScriptYarprunBroker::whichFile(
const char* server,
const char* filename, std::string& filenameWithPath)
102 if (!strlen(server)) {
126 bool ret = port.
write(msg, filenameReader);
127 filenameWithPath=filenameReader.
asString();
138 bool ScriptYarprunBroker::init(
const char* szcmd,
const char* szparam,
139 const char* szhost,
const char* szstdio,
140 const char* szworkdir,
const char* szenv )
144 std::string strParam;
149 if (szhost[0] !=
'/') {
150 strHost = std::string(
"/") + std::string(szhost);
154 whichFile(strHost.c_str(), szcmd, strCmd);
159 strDevParam<<strCmd<<
" "<<strParam;
160 return YarpBroker::init(script.c_str(), strDevParam.str().c_str(),
161 szhost, szstdio, szworkdir, szenv);
A simple collection of objects that can be described and transmitted in a portable way.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void clear()
Empties the bottle of any objects it contains.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
static bool disconnect(const std::string &src, const std::string &dest, bool quiet)
Request that an output port disconnect from an input port.
A mini-server for network communication.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A single value (typically within a Bottle).
virtual std::string asString() const
Get string value.
static constexpr char path_separator
std::string get_string(const std::string &key, bool *found=nullptr)
Read a string from an environment variable.
static constexpr value_type preferred_separator
std::stringstream OSTRINGSTREAM
An interface to the operating system, including Port based communication.
#define CONNECTION_TIMEOUT
constexpr fs::value_type slash
static Bottle parsePaths(const std::string &txt)
static bool fileExists(const char *fname)