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). */
| 238 | * the server reply formats for PROTOCOLINFO (S3.21) and AUTHCHALLENGE (S3.24). |
| 239 | */ |
| 240 | std::pair<std::string,std::string> SplitTorReplyLine(const std::string &s) |
| 241 | { |
| 242 | size_t ptr=0; |
| 243 | std::string type; |
| 244 | while (ptr < s.size() && s[ptr] != ' ') { |
| 245 | type.push_back(s[ptr]); |
| 246 | ++ptr; |
| 247 | } |
| 248 | if (ptr < s.size()) |
| 249 | ++ptr; // skip ' ' |
| 250 | return make_pair(type, s.substr(ptr)); |
| 251 | } |
| 252 | |
| 253 | /** Parse reply arguments in the form 'METHODS=COOKIE,SAFECOOKIE COOKIEFILE=".../control_auth_cookie"'. |
| 254 | * Returns a map of keys to values, or an empty map if there was an error. |