X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/d04e44ac8177fc5b70ae0189bb5e437c2502f910..a6f8c07f83e4e5a8155c04feab543dc0c82ed495:/cmdline/apt-internal-solver.cc diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index ae90c1655..2df1d3bef 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -41,7 +41,7 @@ #include /*}}}*/ -bool ShowHelp(CommandLine &) /*{{{*/ +static bool ShowHelp(CommandLine &) /*{{{*/ { std::cout << _("Usage: apt-internal-solver\n" @@ -58,7 +58,7 @@ APT_NORETURN static void DIE(std::string const &message) { /*{{{*/ exit(EXIT_FAILURE); } /*}}}*/ -std::vector GetCommands() /*{{{*/ +static std::vector GetCommands() /*{{{*/ { return {}; } @@ -71,7 +71,7 @@ int main(int argc,const char *argv[]) /*{{{*/ DropPrivileges(); CommandLine CmdL; - ParseCommandLine(CmdL, APT_CMD::APT_INTERNAL_SOLVER, &_config, NULL, argc, argv); + ParseCommandLine(CmdL, APT_CMD::APT_INTERNAL_SOLVER, &_config, NULL, argc, argv, &ShowHelp, &GetCommands); if (CmdL.FileList[0] != 0 && strcmp(CmdL.FileList[0], "scenario") == 0) { @@ -82,12 +82,14 @@ int main(int argc,const char *argv[]) /*{{{*/ pkgCacheFile CacheFile; CacheFile.Open(NULL, false); APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1); - FILE* output = stdout; + FileFd output; + if (output.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly | FileFd::BufferedWrite, true) == false) + return 2; if (pkgset.empty() == true) EDSP::WriteScenario(CacheFile, output); else EDSP::WriteLimitedScenario(CacheFile, output, pkgset); - fclose(output); + output.Close(); _error->DumpErrors(std::cerr); return 0; } @@ -102,8 +104,10 @@ int main(int argc,const char *argv[]) /*{{{*/ _config->Set("APT::System", "Debian APT solver interface"); _config->Set("APT::Solver", "internal"); _config->Set("edsp::scenario", "/nonexistent/stdin"); - int input = STDIN_FILENO; - FILE* output = stdout; + FileFd output; + if (output.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly | FileFd::BufferedWrite, true) == false) + DIE("stdout couldn't be opened"); + int const input = STDIN_FILENO; SetNonBlock(input, false); EDSP::WriteProgress(0, "Start up solver…", output);