Split reply line in the form 'AUTH METHODS=...' into a type * 'AUTH' and arguments 'METHODS=...'. * Grammar is implicitly defined in https://spec.torproject.org/control-spec by * the server reply formats for PROTOCOLINFO (S3.21) and AUTHCHALLENGE (S3.24). */
| 251 | * the server reply formats for PROTOCOLINFO (S3.21) and AUTHCHALLENGE (S3.24). |
| 252 | */ |
| 253 | std::pair<std::string,std::string> SplitTorReplyLine(const std::string &s) |
| 254 | { |
| 255 | size_t ptr=0; |
| 256 | std::string type; |
| 257 | while (ptr < s.size() && s[ptr] != ' ') { |
| 258 | type.push_back(s[ptr]); |
| 259 | ++ptr; |
| 260 | } |
| 261 | if (ptr < s.size()) |
| 262 | ++ptr; // skip ' ' |
| 263 | return make_pair(type, s.substr(ptr)); |
| 264 | } |
| 265 | |
| 266 | /** Parse reply arguments in the form 'METHODS=COOKIE,SAFECOOKIE COOKIEFILE=".../control_auth_cookie"'. |
| 267 | * Returns a map of keys to values, or an empty map if there was an error. |