#include "stringtools.h" #include <unistd.h> #include <iostream> #include <cstdio> std::string& trim(std::string& str) { std::string::size_type pos = str.find_last_not_of(" \t"); if(pos != std::string::npos) { str.erase(pos + 1); pos = str.find_first_not_of(" \t"); if(pos != std::string::npos) str.erase(0, pos); } else str.erase(str.begin(), str.end()); return str; } void removeComments(std::string& str) { std::string::size_type pos; if ((pos = str.find('#')) != std::string::npos) { str.erase(pos); } } void setSafeEuid() { if (getuid() != 0) { if (seteuid(getuid())) { perror("setSafeEuid"); } } } void setEuidRoot() { if (getuid() != 0) { if (seteuid(0)) { perror("setEuidRoot"); } } } void tokenize(std::string& str, std::vector<std::string>& tokens, const std::string& delimiters) { // Skip delimiters at the beginning std::string::size_type lastPos = str.find_first_not_of(delimiters, 0); // Find first delimiter std::string::size_type pos = str.find_first_of(delimiters, lastPos); while (std::string::npos != pos || std::string::npos != lastPos) { // Found a token, add it tokens.push_back(str.substr(lastPos, pos - lastPos)); // Skip delimiters lastPos = str.find_first_not_of(delimiters, pos); // Find the next "non-delimiter" pos = str.find_first_of(delimiters, lastPos); } }
# | 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 |