diff options
Diffstat (limited to 'cmdline')
-rw-r--r-- | cmdline/apt-helper.cc | 28 | ||||
-rw-r--r-- | cmdline/makefile | 2 |
2 files changed, 29 insertions, 1 deletions
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index a97fc903f..d235ac315 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -22,6 +22,7 @@ #include <apt-private/private-output.h> #include <apt-private/private-download.h> #include <apt-private/private-cmndline.h> +#include <apt-pkg/srvrec.h> #include <iostream> #include <string> @@ -81,6 +82,31 @@ static bool DoDownloadFile(CommandLine &CmdL) return true; } +static bool DoSrvLookup(CommandLine &CmdL) +{ + if (CmdL.FileSize() < 1) + return _error->Error(_("Must specifc at least one srv record")); + + std::vector<SrvRec> srv_records; + c1out << "# target priority weight port" << std::endl; + for(int i=1; CmdL.FileList[i] != NULL; i++) + { + if(GetSrvRecords(CmdL.FileList[i], srv_records) == false) + _error->Warning(_("GetSrvRec failed for %s"), CmdL.FileList[i]); + for (std::vector<SrvRec>::const_iterator I = srv_records.begin(); + I != srv_records.end(); ++I) + { + c1out << (*I).target.c_str() << " " + << (*I).priority << " " + << (*I).weight << " " + << (*I).port << " " + << std::endl; + } + } + + return true; +} + static bool ShowHelp(CommandLine &) { ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); @@ -96,6 +122,7 @@ static bool ShowHelp(CommandLine &) "\n" "Commands:\n" " download-file - download the given uri to the target-path\n" + " srv-lookup - lookup a SRV record (e.g. _http._tcp.ftp.debian.org)\n" " auto-detect-proxy - detect proxy using apt.conf\n" "\n" " This APT helper has Super Meep Powers.\n"); @@ -107,6 +134,7 @@ int main(int argc,const char *argv[]) /*{{{*/ { CommandLine::Dispatch Cmds[] = {{"help",&ShowHelp}, {"download-file", &DoDownloadFile}, + {"srv-lookup", &DoSrvLookup}, {"auto-detect-proxy", &DoAutoDetectProxy}, {0,0}}; diff --git a/cmdline/makefile b/cmdline/makefile index 816038c3b..6d21b0803 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -49,7 +49,7 @@ include $(PROGRAM_H) # The apt-helper PROGRAM=apt-helper -SLIBS = -lapt-pkg -lapt-private $(INTLLIBS) +SLIBS = -lapt-pkg -lapt-private $(INTLLIBS) -lresolv LIB_MAKES = apt-pkg/makefile apt-private/makefile SOURCE = apt-helper.cc include $(PROGRAM_H) |