19 return c1 ==
' ' && (c1 == c2);
31 bool retval =
ReadKeys(key_file_name, &
id, &secret);
37 bool ReadKeys(
const std::string& key_file_name, std::string* key_id,
38 std::string* secret) {
39 if (!(key_id && secret)) {
43 int key_file_fd = open(key_file_name.c_str(), O_RDONLY);
56 return ParseKey(body, key_id, secret);
59 bool ParseKey(
const std::string& body, std::string* key_id,
60 std::string* secret) {
61 std::string line =
GetLineMem(body.data(), body.size());
63 l.erase(std::unique(l.begin(), l.end(),
BothAreSpaces), l.end());
64 std::vector<std::string> tokens =
SplitString(l,
' ');
66 if (tokens.size() < 2 || tokens.size() > 3) {
70 if (tokens[0] ==
"plain_text") {
string GetLineMem(const char *text, const int text_size)
bool BothAreSpaces(const char &c1, const char &c2)
bool ParseKey(const std::string &body, std::string *key_id, std::string *secret)
string Trim(const string &raw, bool trim_newline)
string ReplaceAll(const string &haystack, const string &needle, const string &replace_by)
vector< string > SplitString(const string &str, char delim)
bool ReadKeys(const std::string &key_file_name, std::string *key_id, std::string *secret)
bool SafeReadToString(int fd, std::string *final_result)
GatewayKey ReadGatewayKey(const std::string &key_file_name)