| | |
| | | #include <memory> |
| | | |
| | | using std::string; |
| | | using std::vector; |
| | | using std::unordered_map; |
| | | using std::shared_ptr; |
| | | using std::make_shared; |
| | |
| | | } |
| | | |
| | | /// @brief Считывает весь многострочный ответ SMTP (xyz- промежуточные строки, xyz<space> — последняя). |
| | | static vector<string> read_smtp_replies(int fd, string& rbuf, int timeout_sec) { |
| | | vector<string> lines; |
| | | static std::vector<string> read_smtp_replies(int fd, string& rbuf, int timeout_sec) { |
| | | std::vector<string> lines; |
| | | string line; |
| | | if (!recv_line(fd, rbuf, line, timeout_sec)) { |
| | | ereport(ERROR, (errcode(ERRCODE_QUERY_CANCELED), |
| | |
| | | } |
| | | |
| | | /// @brief Бросает исключение пакета при кодах 4xx/5xx; для 2xx/3xx — ничего не делает. |
| | | static void raise_on_error_code(int code, const vector<string>& lines) { |
| | | static void raise_on_error_code(int code, const std::vector<string>& lines) { |
| | | if (code >= 400 && code <= 499) { |
| | | string all; |
| | | for (auto& s : lines) { all += s; all += "\n"; } |
| | |
| | | } |
| | | |
| | | /// @brief Отправляет SMTP-команду cmd [arg] с CRLF и возвращает все строки ответа (с проверкой кодов). |
| | | static vector<string> smtp_command(int fd, string& rbuf, int timeout_sec, |
| | | static std::vector<string> smtp_command(int fd, string& rbuf, int timeout_sec, |
| | | const string& cmd, const string& arg) { |
| | | string wire = cmd; |
| | | if (!arg.empty()) { wire.push_back(' '); wire += arg; } |