X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/df46a87ab6b67019277884f7ae990af26080280d..12b201da7c1d5e2beceae796151e4ebedc5bae97:/cmdline/apt-helper.cc diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index 001b5e5f7..a6f88ad06 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -39,7 +40,8 @@ static bool DoAutoDetectProxy(CommandLine &CmdL) /*{{{*/ if (CmdL.FileSize() != 2) return _error->Error(_("Need one URL as argument")); URI ServerURL(CmdL.FileList[1]); - AutoDetectProxy(ServerURL); + if (AutoDetectProxy(ServerURL) == false) + return false; std::string SpecificProxy = _config->Find("Acquire::"+ServerURL.Access+"::Proxy::" + ServerURL.Host); ioprintf(std::cout, "Using proxy '%s' for URL '%s'\n", SpecificProxy.c_str(), std::string(ServerURL).c_str()); @@ -102,7 +104,7 @@ static bool DoSrvLookup(CommandLine &CmdL) /*{{{*/ _error->Error(_("GetSrvRec failed for %s"), name.c_str()); for (SrvRec const &I : srv_records) - c1out << I.target << "\t" << I.priority << "\t" << I.weight << "\t" << I.port << std::endl; + ioprintf(c1out, "%s\t%d\t%d\t%d\n", I.target.c_str(), I.priority, I.weight, I.port); } return true; } @@ -145,14 +147,28 @@ static bool DoCatFile(CommandLine &CmdL) /*{{{*/ } if (CmdL.FileSize() <= 1) - return _error->Error("Must specify at least one file name"); + { + if (fd.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly) == false) + return false; + if (CopyFile(fd, out) == false) + return false; + return true; + } for(size_t i = 1; CmdL.FileList[i] != NULL; ++i) { std::string const name = CmdL.FileList[i]; - if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == false) - return false; + if (name != "-") + { + if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == false) + return false; + } + else + { + if (fd.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly) == false) + return false; + } if (CopyFile(fd, out) == false) return false; @@ -185,8 +201,6 @@ static std::vector GetCommands() /*{{{*/ /*}}}*/ int main(int argc,const char *argv[]) /*{{{*/ { - InitLocale(); - CommandLine CmdL; auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_HELPER, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);