| 43 | return gpgbin; |
| 44 | } |
| 45 | static std::string gpg_nth_column (const std::string& line, unsigned int col) |
| 46 | { |
| 47 | std::string::size_type pos = 0; |
| 48 | |
| 49 | for (unsigned int i = 0; i < col; ++i) { |
| 50 | pos = line.find_first_of(':', pos); |
| 51 | if (pos == std::string::npos) { |
| 52 | throw Gpg_error("Malformed output from gpg"); |
| 53 | } |
| 54 | pos = pos + 1; |
| 55 | } |
| 56 | |
| 57 | const std::string::size_type end_pos = line.find_first_of(':', pos); |
| 58 | |
| 59 | return end_pos != std::string::npos ? |
| 60 | line.substr(pos, end_pos - pos) : |
| 61 | line.substr(pos); |
| 62 | } |
| 63 | |
| 64 | // given a key fingerprint, return the key's UID (e.g. "John Smith <jsmith@example.com>") |
| 65 | std::string gpg_get_uid (const std::string& fingerprint) |
no test coverage detected