summaryrefslogtreecommitdiff
path: root/cmdline/apt-helper.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-05-20 13:15:51 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-05-20 13:35:43 +0200
commitf106fecc1d7d0250d1d76c2ba837dc0c870c5fff (patch)
tree1b15821de4a8ad2c43ec92d27e2dc603703238a8 /cmdline/apt-helper.cc
parent98c934f2723d63d00908803ad47ab1359081ec2d (diff)
add GetSrvRecord helper to apt-pkg/contrib/srvrec.{cc,h}
Diffstat (limited to 'cmdline/apt-helper.cc')
-rw-r--r--cmdline/apt-helper.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc
index 2c1107d90..aeeccf06d 100644
--- a/cmdline/apt-helper.cc
+++ b/cmdline/apt-helper.cc
@@ -21,6 +21,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>
@@ -53,6 +54,29 @@ 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;
+ 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 for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
@@ -79,6 +103,7 @@ int main(int argc,const char *argv[]) /*{{{*/
{
CommandLine::Dispatch Cmds[] = {{"help",&ShowHelp},
{"download-file", &DoDownloadFile},
+ {"srv-lookup", &DoSrvLookup},
{0,0}};
std::vector<CommandLine::Args> Args = getCommandArgs(