diff options
| author | Julian Andres Klode <jak@debian.org> | 2024-11-23 15:36:26 +0100 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2024-11-28 10:17:21 +0100 |
| commit | c9530c4773a9d0b50c589098a03a47bcdfc75ea0 (patch) | |
| tree | cd965c5ec3aee6bb2d8a6b9a5e25c7bf59a8681c | |
| parent | 8d66ab29191c59baac04ef89fac30630cf9535e9 (diff) | |
gpgv: Generalize apt_error to apt_msg(), add apt_warning()
This allows printing warnings and errors,
| -rw-r--r-- | apt-pkg/contrib/gpgv.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc index 147f15d9d..aab7851a1 100644 --- a/apt-pkg/contrib/gpgv.cc +++ b/apt-pkg/contrib/gpgv.cc @@ -112,7 +112,9 @@ static bool operator!=(LineBuffer const &buf, std::string_view const exp) noexce And as a cherry on the cake, we use our apt-key wrapper to do part of the lifting in regards to merging keyrings. Fun for the whole family. */ -static void APT_PRINTF(4) apt_error(std::ostream &outterm, int const statusfd, int fd[2], const char *format, ...) +#define apt_error(...) apt_msg("ERROR", __VA_ARGS__) +#define apt_warning(...) apt_msg("WARNING", __VA_ARGS__) +static void APT_PRINTF(5) apt_msg(std::string const &tag, std::ostream &outterm, int const statusfd, int fd[2], const char *format, ...) { std::ostringstream outstr; std::ostream &out = (statusfd == -1) ? outterm : outstr; @@ -128,10 +130,10 @@ static void APT_PRINTF(4) apt_error(std::ostream &outterm, int const statusfd, i } if (statusfd != -1) { - auto const errtag = "[APTKEY:] ERROR "; + auto const errtag = "[APTKEY:] " + tag + " "; outstr << '\n'; auto const errtext = outstr.str(); - if (not FileFd::Write(fd[1], errtag, strlen(errtag)) || + if (not FileFd::Write(fd[1], errtag.data(), errtag.size()) || not FileFd::Write(fd[1], errtext.data(), errtext.size())) outterm << errtext << std::flush; } |
